Remember that the the type of receive method is alias for 
PartialFunction[Any, Unit] and you can compose partial functions using 
orElse[1]
You can defined several message handling function in your base class, and 
them mix & match them in derived classes:

scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive() {
  return behaviorOne.orElse(behaviorTwo).orElse(behaviorThree);
}

Of course ordering matters, unless the domains of your functions (handled 
message sets) are fully disjoint.

Cheers,
Rafał

[1] 
http://www.scala-lang.org/api/current/index.html#scala.PartialFunction@orElse[A1<:A,B1>:B](that:PartialFunction[A1,B1]):PartialFunction[A1,B1]

W dniu poniedziałek, 20 października 2014 21:34:44 UTC+2 użytkownik Chanan 
Braunstein napisał:
>
> Hello,
>
> Is it possible to define a base class for actors that will provide some 
> default behaviors? For example I create a MyAbstractActor that handles 
> MyMessage type. Someone on my team can then extend that class and handle 
> some other types as well. Somewhat like AbstractPersistentActor handles 
> Persistent messages, but in Java and hopefully without implementing all of 
> Actor which at a glance seems like AbstractPersistentActor is doing.
>
> Thanks,
> Chanan
>

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