Skip to content

Instantly share code, notes, and snippets.

@viktorklang
Created March 5, 2011 23:13
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save viktorklang/856818 to your computer and use it in GitHub Desktop.
Save viktorklang/856818 to your computer and use it in GitHub Desktop.
PostStart implementation for Akka
trait PostStart { actor: Actor =>
def postStart: Unit
override def preStart {
actor.become {
case "PostStart" => try { postStart } finally { actor.unbecome }
}
actor.self ! "PostStart"
}
}
/*Usage: class MyActor extends Actor with PostStart {
def postStart = {
...
}
def receive = {
... your usual business stuff goes here ...
}
}*/
@raq154
Copy link

raq154 commented Jan 18, 2015

Can you provide java version of this code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment