|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgroovyx.gpars.actor.impl.SequentialProcessingActor
gpars.actor.AbstractPooledActor
gpars.actor.DynamicDispatchActor
@SuppressWarnings("GroovyAssignmentToMethodParameter") class DynamicDispatchActor extends AbstractPooledActor
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
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
|
act()
Loops reading messages using the react() method and dispatches to the corresponding onMessage() method. |
void
|
when(groovy.lang.Closure closure)
|
Methods inherited from class AbstractPooledActor | |
---|---|
act, doOnException, doOnInterrupt, doOnStart, doOnTermination, doOnTimeout, onStop, receive, receive, receive, receiveImpl, receiveImpl, sweepQueue |
Constructor Detail |
---|
public DynamicDispatchActor()
public DynamicDispatchActor(groovy.lang.Closure closure)
Method Detail |
---|
public final void act()
void when(groovy.lang.Closure closure)
Groovy Documentation