com.caucho.bam.mailbox
Class MultiworkerMailbox

java.lang.Object
  extended by com.caucho.bam.mailbox.MultiworkerMailbox
All Implemented Interfaces:
Mailbox, MessageStream, java.io.Closeable
Direct Known Subclasses:
HmuxQueue

public class MultiworkerMailbox
extends java.lang.Object
implements Mailbox, java.io.Closeable

mailbox for BAM messages waiting to be sent to the Actor.


Constructor Summary
MultiworkerMailbox(MessageStream actorStream, Broker broker, int threadMax)
           
MultiworkerMailbox(java.lang.String address, MessageStream actorStream, Broker broker, int threadMax)
           
 
Method Summary
 void close()
          Closes the mailbox
protected  MailboxWorker createWorker()
           
protected  Packet dequeue()
           
protected  void dispatch(Packet packet)
          Dispatches the packet to the stream
protected  void enqueue(Packet packet)
           
 MessageStream getActorStream()
          Returns the actor stream for the actor itself.
 java.lang.String getAddress()
          Returns the actor's address
 Broker getBroker()
          Returns the stream back to the link for error packets
protected  long getCurrentTimeActual()
           
 int getThreadMax()
           
 boolean isClosed()
          Tests if the stream is closed.
 boolean isPacketAvailable()
          Returns true if a message is available.
 void message(java.lang.String to, java.lang.String from, java.io.Serializable value)
          Sends a message
 void messageError(java.lang.String to, java.lang.String from, java.io.Serializable value, BamError error)
          Sends a message
 void query(long id, java.lang.String to, java.lang.String from, java.io.Serializable query)
          Query an entity
 void queryError(long id, java.lang.String to, java.lang.String from, java.io.Serializable query, BamError error)
          Query an entity
 void queryResult(long id, java.lang.String to, java.lang.String from, java.io.Serializable value)
          Query an entity
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MultiworkerMailbox

public MultiworkerMailbox(MessageStream actorStream,
                          Broker broker,
                          int threadMax)

MultiworkerMailbox

public MultiworkerMailbox(java.lang.String address,
                          MessageStream actorStream,
                          Broker broker,
                          int threadMax)
Method Detail

createWorker

protected MailboxWorker createWorker()

getThreadMax

public int getThreadMax()

getAddress

public java.lang.String getAddress()
Returns the actor's address

Specified by:
getAddress in interface MessageStream

isPacketAvailable

public boolean isPacketAvailable()
Returns true if a message is available.


getBroker

public Broker getBroker()
Returns the stream back to the link for error packets

Specified by:
getBroker in interface MessageStream

getActorStream

public MessageStream getActorStream()
Description copied from interface: Mailbox
Returns the actor stream for the actor itself.

Specified by:
getActorStream in interface Mailbox

message

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

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

messageError

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

Specified by:
messageError in interface MessageStream
Parameters:
to - the target actor's address
from - the source actor's address
value - the message payload
error - the message error

query

public void query(long id,
                  java.lang.String to,
                  java.lang.String from,
                  java.io.Serializable query)
Query an entity

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
query - the query payload

queryResult

public void queryResult(long id,
                        java.lang.String to,
                        java.lang.String from,
                        java.io.Serializable value)
Query an entity

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
value - the result payload

queryError

public void queryError(long id,
                       java.lang.String to,
                       java.lang.String from,
                       java.io.Serializable query,
                       BamError error)
Query an entity

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

enqueue

protected final void enqueue(Packet packet)

dispatch

protected void dispatch(Packet packet)
Dispatches the packet to the stream


dequeue

protected Packet dequeue()

close

public void close()
Description copied from interface: Mailbox
Closes the mailbox

Specified by:
close in interface Mailbox
Specified by:
close in interface java.io.Closeable

getCurrentTimeActual

protected long getCurrentTimeActual()

isClosed

public boolean isClosed()
Description copied from interface: MessageStream
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