thanks *Björn,*

*exactly what I was looking for.*


On Saturday, 16 August 2014 16:24:40 UTC+10, workingdog wrote:
>
> With Akka I would like to do something like this:
>
>     class MyTestClass ... {
>       ....
>       def register[A <: Handler](handler: A) = channel ! 
> Register(context.actorOf(Props(classOf[handler])))
>     }
>
> so that in my code I can do:
>     myTestObj.register(MyHandler)
>
> I have tried the following test code without success:
>
>     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(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(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)
>       }
>     }
>
> How can I make the register() work?
>

-- 
>>>>>>>>>>      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