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 ... | |
} | |
}*/ |
Alaz: Care to write that in code?
The pleasure is all mine
Hi,
trait PostStart { actor: Actor =>
def postStart: Unit
override def preStart {
context.become {
case "PostStart" => try { postStart } finally { context.unbecome }
}
actor.self ! "PostStart"
}
}
with Akka 2.1 (I didn't see this version)
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
?