groovyx.gpars.actor
Class DynamicDispatchActor
java.lang.Object
  
groovyx.gpars.serial.WithSerialId
      
groovyx.gpars.actor.impl.MessageStream
          
groovyx.gpars.actor.Actor
              
groovyx.gpars.actor.AbstractLoopingActor
                  
groovyx.gpars.actor.DynamicDispatchActor
- All Implemented Interfaces: 
 - java.io.Serializable
 
public class DynamicDispatchActor
- extends AbstractLoopingActor
 
A pooled actor allowing for an alternative structure of the message handling code.
 In general DynamicDispatchActor repeatedly scans for messages and dispatches arrived messages to one
 of the onMessage(message) methods defined on the actor.
 
 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 handlers
- Author:
 
  - Vaclav Pech, Alex Tkachman, Dierk Koenig
         Date: Jun 26, 2009
 
- See Also:
 - Serialized Form
 
 
 
 
 
 
 
 
| 
Constructor Summary | 
DynamicDispatchActor()
 
          Creates a new instance without any when handlers registered | 
DynamicDispatchActor(groovy.lang.Closure closure)
 
          Creates an instance, processing all when{} calls in the supplied closure | 
 
| 
Method Summary | 
 void | 
when(groovy.lang.Closure closure)
 
            | 
 
| Methods inherited from class groovyx.gpars.actor.AbstractLoopingActor | 
getCore, getSender, hasBeenStopped, initialize, isActive, isFair, makeFair, reply, replyIfExists, send, setParallelGroup, setTimeout, silentStart, start, stop, sweepNextMessage, terminate | 
 
| Methods inherited from class groovyx.gpars.actor.Actor | 
createActorMessage, createRemoteHandle, deregisterCurrentActorWithThread, getJoinLatch, getParallelGroup, handleException, handleInterrupt, handleStart, handleTermination, handleTimeout, isActorThread, join, join, join, join, onStop, registerCurrentActorWithThread, sendAndContinue, sweepQueue, threadBoundActor | 
 
 
 
| Methods inherited from class java.lang.Object | 
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
 
serialVersionUID
private static final long serialVersionUID
- See Also:
 - Constant Field Values
 
DynamicDispatchActor
public DynamicDispatchActor()
- Creates a new instance without any when handlers registered
 
DynamicDispatchActor
public DynamicDispatchActor(groovy.lang.Closure closure)
- Creates an instance, processing all when{} calls in the supplied closure
- Parameters:
 closure - A closure to run against te actor, typically to register handlers
 
when
public final void when(groovy.lang.Closure closure)