Created
March 5, 2011 23:13
-
-
Save viktorklang/856818 to your computer and use it in GitHub Desktop.
PostStart implementation for Akka
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ... | |
} | |
}*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can you provide java version of this code?