com.caucho.bam.broker
Class AbstractBrokerStream

java.lang.Object
  extended by com.caucho.bam.broker.AbstractBrokerStream
All Implemented Interfaces:
MessageStream
Direct Known Subclasses:
AbstractBroker

public abstract class AbstractBrokerStream
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
AbstractBrokerStream()
           
 
Method Summary
 java.lang.String getAddress()
          Returns the address for the broker itself.
protected abstract  Mailbox getMailbox(java.lang.String address)
          Returns the actor stream for the given address.
 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
 
Methods inherited from interface com.caucho.bam.stream.MessageStream
getBroker
 

Constructor Detail

AbstractBrokerStream

public AbstractBrokerStream()
Method Detail

getMailbox

protected abstract Mailbox getMailbox(java.lang.String address)
Returns the actor stream for the given address.


getAddress

public java.lang.String getAddress()
Returns the address for the broker itself.

Specified by:
getAddress 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