com.caucho.bam.actor
Class SkeletonActorFilter<T>

java.lang.Object
  extended by com.caucho.bam.actor.SkeletonActorFilter<T>
All Implemented Interfaces:
Actor, MessageStream

public class SkeletonActorFilter<T>
extends java.lang.Object
implements Actor

Base ActorStream implementation using introspection and @Message annotations to simplify Actor development.

Message Handling

To handle a message, create a method with the proper signature for the expected payload type and annotate it with @Message. To send a response message or query, use getBrokerStream() or getClient().


Constructor Summary
SkeletonActorFilter(Actor next, T actor)
           
 
Method Summary
protected  BamSkeleton<T> createSkeleton(T actor)
           
 java.lang.String getAddress()
          Returns the Actor's address so the Broker can register it.
 Broker getBroker()
          Returns the stream to the broker for query results or errors, or low-level messaging.
 boolean isClosed()
          Tests if the stream is closed.
 void message(java.lang.String to, java.lang.String from, java.io.Serializable payload)
          Dispatches a unidirectional message to a matching method on the SimpleActorStream.
 void messageError(java.lang.String to, java.lang.String from, java.io.Serializable payload, BamError error)
          Dispatches a messageError to a matching method on the SimpleActorStream.
 void query(long id, java.lang.String to, java.lang.String from, java.io.Serializable payload)
          Dispatches a queryGet to a matching method on the SimpleActorStream.
 void queryError(long id, java.lang.String to, java.lang.String from, java.io.Serializable payload, BamError error)
          Dispatches a queryError to a matching method on the SimpleActorStream.
 void queryResult(long id, java.lang.String to, java.lang.String from, java.io.Serializable payload)
          Dispatches a queryResult to a matching method on the SimpleActorStream.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SkeletonActorFilter

public SkeletonActorFilter(Actor next,
                           T actor)
Method Detail

createSkeleton

protected BamSkeleton<T> createSkeleton(T actor)

getAddress

public java.lang.String getAddress()
Returns the Actor's address so the Broker can register it.

Specified by:
getAddress in interface MessageStream

isClosed

public boolean isClosed()
Description copied from interface: MessageStream
Tests if the stream is closed.

Specified by:
isClosed in interface MessageStream

getBroker

public Broker getBroker()
Returns the stream to the broker for query results or errors, or low-level messaging.

Specified by:
getBroker in interface MessageStream

message

public void message(java.lang.String to,
                    java.lang.String from,
                    java.io.Serializable payload)
Dispatches a unidirectional message to a matching method on the SimpleActorStream. By default, message invokes a method annotated by @Message with a payload class matching the message payload. If no method is found, the message is ignored.

Specified by:
message in interface MessageStream
Parameters:
to - the SimpleActorStream's address
from - the sending actor's address
payload - the message payload

messageError

public void messageError(java.lang.String to,
                         java.lang.String from,
                         java.io.Serializable payload,
                         BamError error)
Dispatches a messageError to a matching method on the SimpleActorStream. By default, messageError invokes a method annotated by @MessageError with a payload class matching the messageError payload. If no method is found, the messageError is ignored.

Specified by:
messageError in interface MessageStream
Parameters:
to - the SimpleActorStream's address
from - the sending actor's address
payload - the message payload
error - the message error

query

public void query(long id,
                  java.lang.String to,
                  java.lang.String from,
                  java.io.Serializable payload)
Dispatches a queryGet to a matching method on the SimpleActorStream. By default, queryGet invokes a method annotated by @QueryGet with a payload class matching the queryGet payload. The @QueryGet method MUST send either a queryResult or queryError as a response. If no method is found, queryGet sends a queryError response with a feature-not-implemented error.

Specified by:
query in interface MessageStream
Parameters:
id - a correlation id to match the result or error
to - the SimpleActorStream's address
from - the client actor's address
payload - the query payload

queryResult

public void queryResult(long id,
                        java.lang.String to,
                        java.lang.String from,
                        java.io.Serializable payload)
Dispatches a queryResult to a matching method on the SimpleActorStream. By default, queryResult invokes a method annotated by @QueryResult with a payload class matching the queryResult payload. If no method is found, queryResult ignores the packet.

Specified by:
queryResult in interface MessageStream
Parameters:
id - the correlation id from the original query
to - the SimpleActorStream's address
from - the client actor's address
payload - the query payload

queryError

public void queryError(long id,
                       java.lang.String to,
                       java.lang.String from,
                       java.io.Serializable payload,
                       BamError error)
Dispatches a queryError to a matching method on the SimpleActorStream. By default, queryError invokes a method annotated by @QueryError with a payload class matching the queryError payload. If no method is found, queryError ignores the packet.

Specified by:
queryError in interface MessageStream
Parameters:
id - the correlation id from the original query
to - the SimpleActorStream's address
from - the client actor's address
payload - the query payload
error - the error information

toString

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