Akka and I met.
From: Akka 2.3.6 (current) Recommended Actor Practice
This is an example of a DemoActor actor:
class DemoActor(magicNumber: Int) extends Actor {
def receive = {
case x: Int => sender() ! (x + magicNumber)
}
}
In the Recommended Practices section of the document, he reads: βItβs a good idea to provide factory methods at each actorβs companion object that will help keep the ability to create the appropriate details as close as possible to the definition of an actor.β What they do like this:
object DemoActor {
def props(magicNumber: Int): Props = Props(new DemoActor(magicNumber))
}
Question: What is the difference between specifying a factory method for a type attribute:
object DemoActor {
def props(magicNumber: Int): Props = Props(classOf[DemoActor], magicNumber)
}
If you missed it, the difference was the argument of the Props constructor:
new DemoActor(magicNumber)
VS
classOf[DemoActor], magicNumber
akka , Props(classOf[ActorWithArgs], "arg1"):
" " ", IllegalArgumentEception, ".
, ?!?....