Revision 7816b56e
b/src/main/scala/gr/grnet/aquarium/actor/ReflectiveActor.scala | ||
---|---|---|
39 | 39 |
import java.lang.reflect.InvocationTargetException |
40 | 40 |
import com.ckkloverdos.maybe.{Failed, Just, MaybeEither} |
41 | 41 |
import akka.actor.Actor |
42 |
import gr.grnet.aquarium.util.{Loggable, shortNameOfClass}
|
|
42 |
import gr.grnet.aquarium.util.{Loggable, simpleNameOfClass}
|
|
43 | 43 |
|
44 | 44 |
/** |
45 | 45 |
* An actor who dispatches to particular methods based on the type of the received message. |
46 | 46 |
* |
47 |
* Do not overload message class names in different packages or else it will not recognize them! |
|
48 |
* |
|
47 | 49 |
* @author Christos KK Loverdos <loverdos@gmail.com>. |
48 | 50 |
*/ |
49 | 51 |
trait ReflectiveActor extends Actor with Loggable { |
... | ... | |
51 | 53 |
val classMethodPairs = for(knownMessageClass <- knownMessageTypes) yield { |
52 | 54 |
require(knownMessageClass ne null, "Null in knownMessageTypes of %s".format(this.getClass)) |
53 | 55 |
|
54 |
val methodName = "on%s".format(shortNameOfClass(knownMessageClass))
|
|
56 |
val methodName = "on%s".format(simpleNameOfClass(knownMessageClass))
|
|
55 | 57 |
// For each class MethodClass we expect a method with the following signature: |
56 | 58 |
// def onMethodClass(message: MethodClass): Unit |
57 | 59 |
MaybeEither(this.getClass.getMethod(methodName, knownMessageClass)) match { |
Also available in: Unified diff