public class DynamicDispatchActor extends AbstractLoopingActor
final class MyActor extends DynamicDispatchActor {* void onMessage(String message) {* println 'Received string'
}* void onMessage(Integer message) {* println 'Received integer'
}* void onMessage(Object message) {* println 'Received object'
}* void onMessage(NullObject nullMessage) {* println 'Received null'
}*}
Method when {...} provides an alternative way to define message handlersMessageStream.RemoteMessageStream, MessageStream.SendTo| Modifier and Type | Field and Description |
|---|---|
private static long |
serialVersionUID |
terminatingFlagACTOR_HAS_ALREADY_BEEN_STARTED, CANNOT_SEND_REPLIES_NO_SENDER_HAS_BEEN_REGISTERED, currentThread, parallelGroup, START_MESSAGE, STOP_MESSAGE, TERMINATE_MESSAGE, TIMEOUT, TIMEOUT_MESSAGE, timerserialHandle| Constructor and Description |
|---|
DynamicDispatchActor()
Creates a new instance without any when handlers registered
|
| Modifier and Type | Method and Description |
|---|---|
DynamicDispatchActor |
become(groovy.lang.Closure closure)
Executes the supplied closure in the context of the actor to set all when() handlers
|
void |
when(groovy.lang.Closure closure) |
getCore, getSender, hasBeenStopped, initialize, isActive, isFair, makeFair, reply, replyIfExists, send, setParallelGroup, setTimeout, silentStart, start, stop, sweepNextMessage, terminatecreateActorMessage, createRemoteHandle, deregisterCurrentActorWithThread, getJoinLatch, getParallelGroup, handleException, handleInterrupt, handleStart, handleTermination, handleTimeout, isActorThread, join, join, join, join, onStop, registerCurrentActorWithThread, sendAndContinue, sendAndPromise, sweepQueue, threadBoundActorcall, getRemoteClass, leftShift, send, send, sendAndWait, sendAndWait, sendAndWaitgetOrCreateSerialHandle, writeReplaceprivate static final long serialVersionUID
public DynamicDispatchActor()
public final DynamicDispatchActor become(groovy.lang.Closure closure)
closure - A sequence of when() handlers to set on the actorpublic final void when(groovy.lang.Closure closure)