-
Notifications
You must be signed in to change notification settings - Fork 1
Interop
laforge49 edited this page Aug 31, 2011
·
8 revisions
A Scala Reactor can send messages to an AsyncFP Actor for synchronous, asynchronous or transactional processing through the use of an Interop object. The only restriction is that messages whose classes are bound to a Safe object can not be sent. Here then is a sample AsyncFP actor.
case class SimpleEcho(value: String) case class QueryEcho(value: String) case class Ex()
class SimpleActor extends Actor {
bind(classOf[SimpleEcho], simpleEcho)
bindSafe(classOf[QueryEcho], new Query(queryEcho))
bind(classOf[Ex], ex)
private def simpleEcho(msg: AnyRef, rf: Any => Unit) {
rf(msg.asInstanceOf[SimpleEcho].value)
}
private def queryEcho(msg: AnyRef, rf: Any => Unit) {
rf(msg.asInstanceOf[QueryEcho].value)
}
private def ex(msg: AnyRef, rf: Any => Unit) {
throw new IllegalArgumentException
}
}