|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjuglr.Actor
juglr.DelegatingActor
public class DelegatingActor
Asynchronously forward messages to a delegate according to
a given strategy. The DelegatingActor will always forward a message to
exactly one delegate. If you need to forward the same message to multiple
delegates use a MulticastActor
.
MulticastActor
Nested Class Summary | |
---|---|
static interface |
DelegatingActor.Strategy
|
Field Summary | |
---|---|
protected DelegatingActor.Strategy |
strategy
|
Constructor Summary | |
---|---|
DelegatingActor(Actor... delegates)
|
|
DelegatingActor(Address... delegates)
Create a new DelegatingActor forwarding messages to delegates
using a round-robin strategy |
|
DelegatingActor(DelegatingActor.Strategy strategy)
Create a new DelegatingActor forwarding messages to delegates
selected using the given DelegatingActor.Strategy . |
|
DelegatingActor(java.lang.Iterable<Address> delegates)
Create a new DelegatingActor forwarding messages to delegates
using a round-robin strategy |
Method Summary | |
---|---|
static DelegatingActor |
newForActors(Actor... delegates)
|
static DelegatingActor |
newForActors(java.lang.Iterable<Actor> delegates)
|
void |
react(Message msg)
Asynchronously relay the incoming message to the address determined by calling DelegatingActor.Strategy.recipient(Message) . |
void |
start()
Invoke DelegatingActor.Strategy.start() |
boolean |
validate(Message msg)
If this method returns false msg will not be sent
along to the delegates. |
Methods inherited from class juglr.Actor |
---|
await, awaitTimeout, getAddress, getBus, send, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected DelegatingActor.Strategy strategy
Constructor Detail |
---|
public DelegatingActor(Address... delegates)
delegates
using a round-robin strategy
delegates
- the collection of delegates to forward messages topublic DelegatingActor(java.lang.Iterable<Address> delegates)
delegates
using a round-robin strategy
delegates
- the collection of delegates to forward messages topublic DelegatingActor(Actor... delegates)
public DelegatingActor(DelegatingActor.Strategy strategy)
delegates
selected using the given DelegatingActor.Strategy
.
strategy
- the Strategy used for selecting the next address to
forward an incoming message toMethod Detail |
---|
public static DelegatingActor newForActors(java.lang.Iterable<Actor> delegates)
public static DelegatingActor newForActors(Actor... delegates)
public void react(Message msg)
DelegatingActor.Strategy.recipient(Message)
. The delegate can
obtain the address of the original sender by calling
Message.getReplyTo()
.
react
in class Actor
msg
- the incoming messagepublic void start()
DelegatingActor.Strategy.start()
start
in class Actor
public boolean validate(Message msg)
false
msg
will not be sent
along to the delegates. The default implementation always return
true
- subclasses should override this method with their own
validation logic.
msg
- the message to validate
true
if the message is good and should be forwarded to
the delegates and false
if the message should be blocked
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |