Akka and I are getting to know each other.
From : Akka 2.3.6 (current) Actor Recommended Practice
These is an example actor called DemoActor :
class DemoActor(magicNumber: Int) extends Actor {
def receive = {
case x: Int => sender() ! (x + magicNumber)
}
}
In Recommended Practices section of the doc it states : "It is a good idea to provide factory methods on the companion object of each Actor which help keeping the creation of suitable Props as close to the actor definition as possible." Which they do like this :
object DemoActor {
def props(magicNumber: Int): Props = Props(new DemoActor(magicNumber))
}
Question : What is the difference between specifying the factory for props method like :
object DemoActor {
def props(magicNumber: Int): Props = Props(classOf[DemoActor], magicNumber)
}
In case you missed it, the difference was the argument to the Props constructor :
new DemoActor(magicNumber)
VS
classOf[DemoActor], magicNumber
From the same akka documentation page a bit further up in the Props section, it also mentions when using Props(classOf[ActorWithArgs], "arg1"):
"The presence of a matching constructor is verified during construction of the Props object, resulting in an IllegalArgumentEception if no or multiple matching constructors are found."
That's good, isn't it?!?....