I\'m confused how to ensure that my Actors have the appropriate dependencies using the cake pattern. I\'m still getting to grips with this, and I can\'t find any examples anywhe
One additional gotcha, as pointed out by Owen, is that creating actors using actorOf(Props[MyClass])
won't work for inner classes. Ie: the following will fail:
trait MyComponent {
class MyActor {
def receive = ...
}
}
new MyComponent {
val myActorRef = system.actorOf( Props[MyActor] )
}
According to the documentation at http://doc.akka.io/docs/akka/snapshot/scala/actors.html,
if they are not declared within a top-level object then the enclosing instance’s this reference needs to be passed as the first argument
However, this does not seem to be supported by the scaladoc Props method signatures. The only way around this I found was to use the Props(actor: Actor) constructor, instantiating the actor mysql and passing it to Props.
val myActorRef = system.actorOf( Props( new MyActor(arg1, arg2) ) )
Would be interested to know if there's a better way..