com.caucho.bam.stream
Class AbstractMessageStream

java.lang.Object
  extended by com.caucho.bam.stream.AbstractMessageStream
All Implemented Interfaces:
MessageStream
Direct Known Subclasses:
AbstractActor, NullMessageStream, SimpleActor, XmppAgentStream, XmppBindCallback

public abstract class AbstractMessageStream
extends java.lang.Object
implements MessageStream

The abstract implementation of an MessageStream returns query errors for RPC packets, and ignores unknown packets for messages and presence announcement. Most developers will use SkeletonActorFilter or SimpleActor because those classes use introspection with @Message annotations to simplify Actor development.


Constructor Summary
AbstractMessageStream()
           
 
Method Summary
 java.lang.String getAddress()
          Returns the address at the end of the stream.
 Broker getBroker()
          Returns the owning broker
 boolean isClosed()
          Tests if the stream is closed.
 void message(java.lang.String to, java.lang.String from, java.io.Serializable payload)
          Receives a unidirectional message.
 void messageError(java.lang.String to, java.lang.String from, java.io.Serializable payload, BamError error)
          Receives a message error.
 void query(long id, java.lang.String to, java.lang.String from, java.io.Serializable payload)
          Receives a query call, acting as a service for the query.
 void queryError(long id, java.lang.String to, java.lang.String from, java.io.Serializable payload, BamError error)
          Handles a query error from a service Actor.
 void queryResult(long id, java.lang.String to, java.lang.String from, java.io.Serializable payload)
          Handles a query response from a service Actor.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractMessageStream

public AbstractMessageStream()
Method Detail

getAddress

public java.lang.String getAddress()
Returns the address at the end of the stream.

Specified by:
getAddress in interface MessageStream

getBroker

public Broker getBroker()
Description copied from interface: MessageStream
Returns the owning broker

Specified by:
getBroker in interface MessageStream

message

public void message(java.lang.String to,
                    java.lang.String from,
                    java.io.Serializable payload)
Receives a unidirectional message. The abstract implementation ignores the message.

Specified by:
message in interface MessageStream
Parameters:
to - the target actor's address
from - the source 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)
Receives a message error. The abstract implementation ignores the message.

Specified by:
messageError in interface MessageStream
Parameters:
to - the target actor's address
from - the source actor's address
payload - the original message payload
error - the message error

query

public void query(long id,
                  java.lang.String to,
                  java.lang.String from,
                  java.io.Serializable payload)
Receives a query call, acting as a service for the query. The default implementation returns a feature-not-implemented QueryError message to the client.

Specified by:
query in interface MessageStream
Parameters:
id - the query identifier used to match requests with responses
to - the service actor'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)
Handles a query response from a service Actor. The default implementation ignores the packet.

Specified by:
queryResult in interface MessageStream
Parameters:
id - the query identifier used to match requests with responses
to - the client actor's address
from - the service actor's address
payload - the result payload

queryError

public void queryError(long id,
                       java.lang.String to,
                       java.lang.String from,
                       java.io.Serializable payload,
                       BamError error)
Handles a query error from a service Actor. The default implementation ignores the packet.

Specified by:
queryError in interface MessageStream
Parameters:
id - the query identifier used to match requests with responses
to - the client actor's address
from - the service actor's address
payload - the result payload
error - additional error information

isClosed

public boolean isClosed()
Tests if the stream is closed.

Specified by:
isClosed in interface MessageStream

toString

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