com.caucho.bam.broker
Class ManagedBrokerAdapter

java.lang.Object
  extended by com.caucho.bam.broker.AbstractBrokerStream
      extended by com.caucho.bam.broker.AbstractBroker
          extended by com.caucho.bam.broker.AbstractManagedBroker
              extended by com.caucho.bam.broker.ManagedBrokerAdapter
All Implemented Interfaces:
Broker, ManagedBroker, MessageStream

public class ManagedBrokerAdapter
extends AbstractManagedBroker

Broker is the hub which routes messages to actors.


Constructor Summary
ManagedBrokerAdapter(Broker broker)
           
 
Method Summary
 void addMailbox(java.lang.String address, Mailbox mailbox)
          Adds a mailbox.
 void close()
          Close the Broker
static ManagedBroker create(Broker broker)
           
 java.lang.String getAddress()
          Returns the broker's address, i.e.
 Broker getBroker()
          The broker returns itself for the broker.
 Mailbox getBrokerMailbox()
          Returns a mailbox to the broker itself
 Mailbox getMailbox(java.lang.String address)
          Returns the actor stream for the given address.
 boolean isClosed()
          Returns true if the broker has been 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.
 void removeMailbox(Mailbox mailbox)
          Removes a mailbox.
 
Methods inherited from class com.caucho.bam.broker.AbstractManagedBroker
createAgent, createAgent, createClient, createMailbox, createMailbox
 
Methods inherited from class com.caucho.bam.broker.AbstractBrokerStream
getQueryErrorStream, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ManagedBrokerAdapter

public ManagedBrokerAdapter(Broker broker)
Method Detail

create

public static ManagedBroker create(Broker broker)

getAddress

public java.lang.String getAddress()
Description copied from class: AbstractBroker
Returns the broker's address, i.e. the virtual host domain name.

Specified by:
getAddress in interface MessageStream
Overrides:
getAddress in class AbstractBroker

isClosed

public boolean isClosed()
Description copied from class: AbstractManagedBroker
Returns true if the broker has been closed

Specified by:
isClosed in interface MessageStream
Overrides:
isClosed in class AbstractManagedBroker

getBroker

public Broker getBroker()
Description copied from class: AbstractBroker
The broker returns itself for the broker.

Specified by:
getBroker in interface MessageStream
Overrides:
getBroker in class AbstractBroker

message

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

Specified by:
message in interface MessageStream
Overrides:
message in class AbstractBrokerStream
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)
Description copied from class: AbstractBrokerStream
Receives a message error. The abstract implementation ignores the message.

Specified by:
messageError in interface MessageStream
Overrides:
messageError in class AbstractBrokerStream
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)
Description copied from class: AbstractBrokerStream
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
Overrides:
query in class AbstractBrokerStream
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 class: AbstractBrokerStream
Handles a query response from a service Actor. The default implementation ignores the packet.

Specified by:
queryResult in interface MessageStream
Overrides:
queryResult in class AbstractBrokerStream
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 class: AbstractBrokerStream
Handles a query error from a service Actor. The default implementation ignores the packet.

Specified by:
queryError in interface MessageStream
Overrides:
queryError in class AbstractBrokerStream
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

getBrokerMailbox

public Mailbox getBrokerMailbox()
Description copied from class: AbstractBroker
Returns a mailbox to the broker itself

Specified by:
getBrokerMailbox in interface Broker
Overrides:
getBrokerMailbox in class AbstractBroker

getMailbox

public Mailbox getMailbox(java.lang.String address)
Description copied from class: AbstractBrokerStream
Returns the actor stream for the given address.

Specified by:
getMailbox in interface Broker
Overrides:
getMailbox in class AbstractBroker
Parameters:
address - the address of the mailbox
Returns:
the mailbox with the given address or null

addMailbox

public void addMailbox(java.lang.String address,
                       Mailbox mailbox)
Description copied from class: AbstractManagedBroker
Adds a mailbox.

Specified by:
addMailbox in interface Broker
Specified by:
addMailbox in interface ManagedBroker
Overrides:
addMailbox in class AbstractManagedBroker

removeMailbox

public void removeMailbox(Mailbox mailbox)
Description copied from class: AbstractManagedBroker
Removes a mailbox.

Specified by:
removeMailbox in interface Broker
Specified by:
removeMailbox in interface ManagedBroker
Overrides:
removeMailbox in class AbstractManagedBroker

close

public void close()
Description copied from interface: Broker
Close the Broker

Specified by:
close in interface Broker
Overrides:
close in class AbstractBroker