Hi,

I'm not exactly sure what you are trying to achieve, but you need to use 
classes and not instances. See inline comments.

B/

On 16 August 2014 at 08:24:43, workingdog ([email protected]) wrote:

import akka.actor.{Actor, ActorRef, ActorSystem, Props}

    case class Register(handler: ActorRef)

    class MyTestClass(context: ActorSystem) {
      val channel = context.actorOf(Props(classOf[MyChannel]))
      def register[A <: MyHandler](handler: A) = channel ! 
Register(context.actorOf(Props(classOf[handler])))


def register[A <: MyHandler](hc: Class[A]) = channel ! 
Register(context.actorOf(Props(hc)))




     // def register(handle: ActorRef) = channel ! Register(handle)
    }
    object MyTestClass {
      def main(args: Array[String]) {
        implicit val context = ActorSystem("test")
        val myTestObj = new MyTestClass(context)
        myTestObj.register(new MyHandler)


myTestObj.register(classOf[MyHandler])




      //  myTestObj.register(context.actorOf(Props(classOf[MyHandler])))
      }
    }
    class MyChannel extends Actor {
      def receive = {
        case Register(handle) => println("MyChannel handle: " + handle)
        case x => println("MyChannel x: " + x)
      }
    }
    class MyHandler extends Actor {
      def receive = {
        case x => println("MyHandler x: " + x)
      }
    }


-- 
Björn Antonsson
Typesafe – Reactive Apps on the JVM
twitter: @bantonsson

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to