com.caucho.bam.actor
Class SimpleActorSender

java.lang.Object
  extended by com.caucho.bam.actor.SimpleActorSender
All Implemented Interfaces:
ActorSender, QuerySender
Direct Known Subclasses:
LocalActorSender

public class SimpleActorSender
extends java.lang.Object
implements ActorSender

ActorClient is a convenience API for sending messages to other Actors, which always using the actor's address as the "from" parameter.


Constructor Summary
SimpleActorSender(Actor next)
           
SimpleActorSender(Actor next, Broker broker)
           
SimpleActorSender(Actor next, ManagedBroker broker, java.lang.String uid, java.lang.String resource)
           
SimpleActorSender(ManagedBroker broker, java.lang.String uid)
           
SimpleActorSender(ManagedBroker broker, java.lang.String uid, java.lang.String resource)
           
SimpleActorSender(java.lang.String address, Broker broker)
           
 
Method Summary
 void close()
          Closes the client
 Actor getActor()
           
 java.lang.String getAddress()
          Returns the Actor's address used for all "from" parameters.
 Broker getBroker()
          The underlying, low-level stream to the link
protected  ManagedBroker getManagedBroker()
           
 QueryManager getQueryManager()
           
 boolean isClosed()
          Returns true if the client is closed
 void message(java.lang.String to, java.io.Serializable payload)
          Sends a unidirectional message to an ActorHolder, addressed by the Actor's address.
 long nextQueryId()
          Returns the next query identifier.
 java.io.Serializable query(java.lang.String to, java.io.Serializable payload)
          Sends a query information call (get) to an actor, blocking until the actor responds with a result or an error.
 java.io.Serializable query(java.lang.String to, java.io.Serializable payload, long timeout)
          Sends a query information call (get) to an actor, blocking until the actor responds with a result or an error.
 void query(java.lang.String to, java.io.Serializable payload, QueryCallback callback)
          Sends a query information call (get) to an actor, providing a callback to receive the result or error.
 void query(java.lang.String to, java.io.Serializable payload, QueryCallback callback, long timeout)
          Sends a query information call (get) to an actor, providing a callback to receive the result or error.
 void setBroker(Broker broker)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleActorSender

public SimpleActorSender(java.lang.String address,
                         Broker broker)

SimpleActorSender

public SimpleActorSender(Actor next)

SimpleActorSender

public SimpleActorSender(Actor next,
                         Broker broker)

SimpleActorSender

public SimpleActorSender(Actor next,
                         ManagedBroker broker,
                         java.lang.String uid,
                         java.lang.String resource)

SimpleActorSender

public SimpleActorSender(ManagedBroker broker,
                         java.lang.String uid)

SimpleActorSender

public SimpleActorSender(ManagedBroker broker,
                         java.lang.String uid,
                         java.lang.String resource)
Method Detail

getAddress

public java.lang.String getAddress()
Returns the Actor's address used for all "from" parameters.

Specified by:
getAddress in interface QuerySender

getActor

public Actor getActor()

getBroker

public Broker getBroker()
The underlying, low-level stream to the link

Specified by:
getBroker in interface ActorSender
Specified by:
getBroker in interface QuerySender

setBroker

public void setBroker(Broker broker)

getManagedBroker

protected ManagedBroker getManagedBroker()

message

public void message(java.lang.String to,
                    java.io.Serializable payload)
Sends a unidirectional message to an ActorHolder, addressed by the Actor's address.

Specified by:
message in interface ActorSender
Specified by:
message in interface QuerySender
Parameters:
to - the target actor's address
payload - the message payload

nextQueryId

public long nextQueryId()
Description copied from interface: ActorSender
Returns the next query identifier.

Specified by:
nextQueryId in interface ActorSender

getQueryManager

public QueryManager getQueryManager()
Specified by:
getQueryManager in interface QuerySender

query

public java.io.Serializable query(java.lang.String to,
                                  java.io.Serializable payload)
Sends a query information call (get) to an actor, blocking until the actor responds with a result or an error. The target actor of a queryGet acts as a service and the caller acts as a client. Because BAM Actors are symmetrical, all Actors can act as services and clients for different RPC calls. The target actor MUST send a queryResult or queryError to the client using the same id, because RPC clients rely on a response.

Specified by:
query in interface ActorSender
Specified by:
query in interface QuerySender
Parameters:
to - the target actor's address
payload - the query payload

query

public java.io.Serializable query(java.lang.String to,
                                  java.io.Serializable payload,
                                  long timeout)
Sends a query information call (get) to an actor, blocking until the actor responds with a result or an error. The target actor of a queryGet acts as a service and the caller acts as a client. Because BAM Actors are symmetrical, all Actors can act as services and clients for different RPC calls. The target actor MUST send a queryResult or queryError to the client using the same id, because RPC clients rely on a response.

Specified by:
query in interface ActorSender
Specified by:
query in interface QuerySender
Parameters:
to - the target actor's address
payload - the query payload
timeout - time spent waiting for the query to return

query

public void query(java.lang.String to,
                  java.io.Serializable payload,
                  QueryCallback callback)
Sends a query information call (get) to an actor, providing a callback to receive the result or error. The target actor of a queryGet acts as a service and the caller acts as a client. Because BAM Actors are symmetrical, all Actors can act as services and clients for different RPC calls. The target actor MUST send a queryResult or queryError to the client using the same id, because RPC clients rely on a response.

Specified by:
query in interface ActorSender
Specified by:
query in interface QuerySender
Parameters:
to - the target actor's address
payload - the query payload
callback - the application's callback for the result

query

public void query(java.lang.String to,
                  java.io.Serializable payload,
                  QueryCallback callback,
                  long timeout)
Sends a query information call (get) to an actor, providing a callback to receive the result or error. The target actor of a queryGet acts as a service and the caller acts as a client. Because BAM Actors are symmetrical, all Actors can act as services and clients for different RPC calls. The target actor MUST send a queryResult or queryError to the client using the same id, because RPC clients rely on a response.

Parameters:
to - the target actor's address
payload - the query payload
callback - the application's callback for the result

isClosed

public boolean isClosed()
Returns true if the client is closed

Specified by:
isClosed in interface ActorSender

close

public void close()
Closes the client

Specified by:
close in interface ActorSender

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object