com.caucho.bam.stream
Class AbstractMessageStreamFilter

java.lang.Object
  extended by com.caucho.bam.stream.AbstractMessageStreamFilter
All Implemented Interfaces:
MessageStream

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

Abstract implementation of a BAM filter. The default operation of most methods is to forward the request to the next stream.


Constructor Summary
AbstractMessageStreamFilter()
           
 
Method Summary
 void close()
          Closes the filter, but not the child by default.
 java.lang.String getAddress()
          Returns the address of the final actor
 Broker getBroker()
          Returns the broker of the final actor.
protected abstract  MessageStream getNext()
           
 boolean isClosed()
          Tests if the stream is closed.
 void message(java.lang.String to, java.lang.String from, java.io.Serializable payload)
          Sends a unidirectional message
 void messageError(java.lang.String to, java.lang.String from, java.io.Serializable payload, BamError error)
          Sends a unidirectional message error
 void query(long id, java.lang.String to, java.lang.String from, java.io.Serializable payload)
          Sends a query/RPCinformation call The receiver of a query acts as a service and the caller acts as a client.
 void queryError(long id, java.lang.String to, java.lang.String from, java.io.Serializable payload, BamError error)
          Sends a query error from a failed query.
 void queryResult(long id, java.lang.String to, java.lang.String from, java.io.Serializable payload)
          Sends a query response for a query
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractMessageStreamFilter

public AbstractMessageStreamFilter()
Method Detail

getNext

protected abstract MessageStream getNext()

getAddress

public java.lang.String getAddress()
Returns the address of the final actor

Specified by:
getAddress in interface MessageStream

getBroker

public Broker getBroker()
Returns the broker of the final actor.

Specified by:
getBroker in interface MessageStream

message

public void message(java.lang.String to,
                    java.lang.String from,
                    java.io.Serializable payload)
Sends a unidirectional message

Specified by:
message in interface MessageStream
Parameters:
to - the target address
from - the source address
payload - the message payload

messageError

public void messageError(java.lang.String to,
                         java.lang.String from,
                         java.io.Serializable payload,
                         BamError error)
Sends a unidirectional message error

Specified by:
messageError in interface MessageStream
Parameters:
to - the target address
from - the source 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)
Description copied from interface: MessageStream
Sends a query/RPCinformation call The receiver of a query 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 stream 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 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)
Description copied from interface: MessageStream
Sends a query response for a query

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)
Description copied from interface: MessageStream
Sends a query error from a failed query.

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 query payload
error - additional error information

isClosed

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

Specified by:
isClosed in interface MessageStream

close

public void close()
Closes the filter, but not the child by default.


toString

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