com.caucho.hemp.servlet
Class ServerGatewayBroker

java.lang.Object
  extended by com.caucho.bam.broker.AbstractBrokerStream
      extended by com.caucho.bam.broker.AbstractBroker
          extended by com.caucho.hemp.servlet.ServerGatewayBroker
All Implemented Interfaces:
Broker, MessageStream

public class ServerGatewayBroker
extends AbstractBroker

Handles the requests to the server from the link, dispatching requests to the link service and the broker. The "from" is passed through unchanged because the caller is another server.


Constructor Summary
ServerGatewayBroker(Broker broker, ClientStubManager clientManager, MessageStream linkActor)
           
 
Method Summary
 void close()
          Close the Broker
 java.lang.String getAddress()
          Returns the broker's address, i.e.
 java.lang.String getClientAddress()
           
 boolean isClosed()
          Returns true if the broker has been closed
 void message(java.lang.String to, java.lang.String from, java.io.Serializable payload)
          Sends a message to the link service if 'to' is null, else send it to the broker.
 void messageError(java.lang.String to, java.lang.String from, java.io.Serializable payload, BamError error)
          Handles a message
 void query(long id, java.lang.String to, java.lang.String from, java.io.Serializable payload)
          Handles a query.
 void queryError(long id, java.lang.String to, java.lang.String from, java.io.Serializable payload, BamError error)
          Handles a query error.
 void queryResult(long id, java.lang.String to, java.lang.String from, java.io.Serializable payload)
          Handles a query result.
 java.lang.String toString()
           
 
Methods inherited from class com.caucho.bam.broker.AbstractBroker
addMailbox, getBroker, getBrokerMailbox, getMailbox, removeMailbox
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ServerGatewayBroker

public ServerGatewayBroker(Broker broker,
                           ClientStubManager clientManager,
                           MessageStream linkActor)
Method Detail

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

getClientAddress

public java.lang.String getClientAddress()

message

public void message(java.lang.String to,
                    java.lang.String from,
                    java.io.Serializable payload)
Sends a message to the link service if 'to' is null, else send it to the broker.

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)
Handles a 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)
Handles a query. The query handler must respond with either a QueryResult or a QueryError

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)
Handles a query result. The result id will match a pending get or set.

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)
Handles a query error. The result id will match a pending get or set.

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

isClosed

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

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

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