com.caucho.hemp.broker
Class HempBroker

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.hemp.broker.HempBroker
All Implemented Interfaces:
Broker, ManagedBroker, MessageStream

public class HempBroker
extends AbstractManagedBroker

Broker


Nested Class Summary
 class HempBroker.ActorClose
           
 class HempBroker.ActorStartup
           
 
Constructor Summary
HempBroker(HempBrokerManager manager)
           
HempBroker(HempBrokerManager manager, java.lang.String domain)
           
 
Method Summary
 void addAlias(java.lang.String domain)
          Adds a domain alias
 void addMailbox(Mailbox mailbox)
          Registers a actor
 void addStartupActor(Bean bean, java.lang.String name, int threadMax)
           
 void afterStart()
           
 void close()
          Close the Broker
protected  java.lang.String generateAddress(java.lang.String uid, java.lang.String resource)
           
 java.lang.String getAddress()
          getAddress() returns null for the broker
static HempBroker getCurrent()
           
protected  java.lang.String getDomain()
          Returns the domain
 Mailbox getMailbox(java.lang.String address)
          Returns the mailbox for the given address
protected  java.lang.String getManagerAddress()
          Returns the manager's own id.
 boolean isClosed()
          Returns true if the broker is closed
 void message(java.lang.String to, java.lang.String from, java.io.Serializable payload)
          Sends a message to the desination mailbox.
 void messageError(java.lang.String to, java.lang.String from, java.io.Serializable payload, BamError error)
          Sends a messageError to the desination mailbox.
 void query(long id, java.lang.String to, java.lang.String from, java.io.Serializable payload)
          Sends a query to the destination mailbox.
 void queryError(long id, java.lang.String to, java.lang.String from, java.io.Serializable payload, BamError error)
          Sends a query to the destination mailbox.
 void queryResult(long id, java.lang.String to, java.lang.String from, java.io.Serializable payload)
          Sends a query to the destination mailbox.
 void removeMailbox(Mailbox mailbox)
          Removes a actor
 void setDomainManager(DomainManager domainManager)
           
protected  boolean startActorFromManager(java.lang.String address)
           
 java.lang.String toString()
           
 
Methods inherited from class com.caucho.bam.broker.AbstractManagedBroker
createAgent, createAgent, createClient, createMailbox, createMailbox
 
Methods inherited from class com.caucho.bam.broker.AbstractBroker
getBroker, getBrokerMailbox
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.caucho.bam.broker.Broker
getBrokerMailbox
 
Methods inherited from interface com.caucho.bam.stream.MessageStream
getBroker
 

Constructor Detail

HempBroker

public HempBroker(HempBrokerManager manager)

HempBroker

public HempBroker(HempBrokerManager manager,
                  java.lang.String domain)
Method Detail

getCurrent

public static HempBroker getCurrent()

setDomainManager

public void setDomainManager(DomainManager domainManager)

isClosed

public boolean isClosed()
Returns true if the broker is closed

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

addAlias

public void addAlias(java.lang.String domain)
Adds a domain alias


afterStart

public void afterStart()

generateAddress

protected java.lang.String generateAddress(java.lang.String uid,
                                           java.lang.String resource)

addMailbox

public void addMailbox(Mailbox mailbox)
Registers a actor

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

removeMailbox

public void removeMailbox(Mailbox mailbox)
Removes a actor

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

getManagerAddress

protected java.lang.String getManagerAddress()
Returns the manager's own id.


getDomain

protected java.lang.String getDomain()
Returns the domain


getAddress

public java.lang.String getAddress()
getAddress() returns null for the broker

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

message

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

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)
Sends a messageError to the desination mailbox.

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)
Sends a query to the destination mailbox.

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)
Sends a query to the destination mailbox.

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)
Sends a query to the destination mailbox.

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

getMailbox

public Mailbox getMailbox(java.lang.String address)
Returns the mailbox 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

startActorFromManager

protected boolean startActorFromManager(java.lang.String address)

addStartupActor

public void addStartupActor(Bean bean,
                            java.lang.String name,
                            int threadMax)

close

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

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

toString

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