Hi,the code blow cause the StackOverFlow error,but if I want to do 
something useful in an trait and let the actor who want to use mixin it,and 
that trait need to do some initialize witch need to hook the actor's 
lifecycle ,then what the best practice?
The problem of the code blow is that it will cause the StackOverFlow,that's 
really definite wrong.


trait UsefulTrait {actor:Actor =>
  @throws[Exception](classOf[Exception])
  override def preStart(): Unit = {
    //do some thing here
    actor.preStart()
  }
  
}

class UsefulActor extends Actor with UsefulTrait{
  override def receive: Receive = {
    case msg => //handle it
  }

  @throws[Exception](classOf[Exception]) override
  def preStart(): Unit = {
    //do some thing here too
    super.preStart()
  }
}

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