juglr
Class DelegatingActor

java.lang.Object
  extended by juglr.Actor
      extended by juglr.DelegatingActor

public class DelegatingActor
extends Actor

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.

See Also:
MulticastActor

Nested Class Summary
static interface DelegatingActor.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()
 
Methods inherited from class juglr.Actor
await, awaitMessage, awaitTimeout, getAddress, getBus, send, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DelegatingActor

public DelegatingActor(Address... delegates)
Create a new DelegatingActor forwarding messages to delegates using a round-robin strategy

Parameters:
delegates - the collection of delegates to forward messages to

DelegatingActor

public DelegatingActor(java.lang.Iterable<Address> delegates)
Create a new DelegatingActor forwarding messages to delegates using a round-robin strategy

Parameters:
delegates - the collection of delegates to forward messages to

DelegatingActor

public DelegatingActor(Actor... delegates)

DelegatingActor

public DelegatingActor(DelegatingActor.Strategy strategy)
Create a new DelegatingActor forwarding messages to delegates selected using the given DelegatingActor.Strategy.

Parameters:
strategy - the Strategy used for selecting the next address to forward an incoming message to
Method Detail

newForActors

public static DelegatingActor newForActors(java.lang.Iterable<Actor> delegates)

newForActors

public static DelegatingActor newForActors(Actor... delegates)

react

public void react(Message msg)
Asynchronously relay the incoming message to the address determined by calling DelegatingActor.Strategy.recipient(Message)

Specified by:
react in class Actor
Parameters:
msg - the incoming message

start

public void start()
Invoke DelegatingActor.Strategy.start()

Overrides:
start in class Actor