kaos.core.service.transport.cougaar
Class CougaarMessageReceiver

java.lang.Object
  extended by kaos.core.service.transport.cougaar.CougaarMessageReceiver

public class CougaarMessageReceiver
extends java.lang.Object


Field Summary
static java.lang.String RESPONSE
           
 
Constructor Summary
CougaarMessageReceiver(CougaarServiceRoot sr)
          Constructor
CougaarMessageReceiver(CougaarServiceRoot sr, JasBean env)
           
 
Method Summary
 void addMessageListener(MessageListener ml)
          Adds a MessageListener to the MessageReceiver for asynchronous message delivery.
static void addMessageReceivedRunnable(java.lang.Runnable runnable)
          Add a runnable to be executed inside the transaction that the message is marked as received.
 void bindToLocalLocator(Locator l)
          The method which binds the MessageReceiver to a local locator.
 long currentTimeMillis()
           
 void execute()
           
 java.lang.String getBlackboardClientName()
          Cougaar BlackboardClient implementation
 Locator getLocalLocator()
          Returns a local locator depending upon binding status.
 TransportMessage getMessage()
          A blocking read operation.
 TransportMessage getMessage(long wait_millis)
          A timed blocking read operation.
 MessageTransportService getMessageTransportService()
           
 int getNumberOfMessages()
          The the number returned does not guarantee the actual number of messages available instantaneously.
static boolean isReceiveThread(java.lang.Thread t)
           
 void removeMessageListener(MessageListener ml)
          Removes a MessageListener from the MessageReceiver.
 boolean triggerEvent(java.lang.Object event)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESPONSE

public static final java.lang.String RESPONSE
See Also:
Constant Field Values
Constructor Detail

CougaarMessageReceiver

public CougaarMessageReceiver(CougaarServiceRoot sr)
Constructor


CougaarMessageReceiver

public CougaarMessageReceiver(CougaarServiceRoot sr,
                              JasBean env)
Method Detail

bindToLocalLocator

public void bindToLocalLocator(Locator l)
                        throws NotLocatableException,
                               TransportFailure
The method which binds the MessageReceiver to a local locator.

Parameters:
l - the local Locator.
Throws:
NotLocatableException - if l is not a local locator.
TransportFailure - if the binding process fails.

getLocalLocator

public Locator getLocalLocator()
                        throws TransportFailure
Returns a local locator depending upon binding status. If the MessageReceiver is not bound, then the local locator is randomly created and returned. Otherwise, the locator used for binding is returned.

Returns:
Locator a local locator.
Throws:
TransportFailure - if any transport related failure occurs.

addMessageListener

public void addMessageListener(MessageListener ml)
                        throws TransportFailure
Adds a MessageListener to the MessageReceiver for asynchronous message delivery.

Parameters:
ml - the MessageListener to callback with the incoming message.
Throws:
TransportFailure - if any transport related failure occurs.

removeMessageListener

public void removeMessageListener(MessageListener ml)
                           throws TransportFailure
Removes a MessageListener from the MessageReceiver.

Parameters:
ml - the MessageListener to remove from the MessageReceiver.
Throws:
TransportFailure - if any transport related failure occurs.

getNumberOfMessages

public int getNumberOfMessages()
                        throws TransportFailure
The the number returned does not guarantee the actual number of messages available instantaneously.

Returns:
the number of messages destined for the agent.
Throws:
TransportFailure - if any transport related failure occurs.

getMessage

public TransportMessage getMessage()
                            throws java.lang.InterruptedException,
                                   TransportFailure
A blocking read operation. This method will block awaiting the arrival of a transport message.

Returns:
TransportMessage the message destined for the agent.
Throws:
java.lang.InterruptedException - if the waiting thread is interrupted.
TransportFailure - if any transport related failure occurs.

getMessage

public TransportMessage getMessage(long wait_millis)
                            throws java.lang.InterruptedException,
                                   TransportFailure
A timed blocking read operation. This method will block for the amount of time (in milliseconds) specified awaiting the arrival of a transport message.

Parameters:
wait_millis - the most the current thread should block for a message.
Returns:
TransportMessage the message destined for the agent, or null if the wait times out.
Throws:
java.lang.InterruptedException - if the waiting thread is interrupted.
TransportFailure - if any transport related failure occurs.

getMessageTransportService

public MessageTransportService getMessageTransportService()

getBlackboardClientName

public java.lang.String getBlackboardClientName()
Cougaar BlackboardClient implementation


currentTimeMillis

public long currentTimeMillis()

triggerEvent

public boolean triggerEvent(java.lang.Object event)

execute

public void execute()

isReceiveThread

public static boolean isReceiveThread(java.lang.Thread t)

addMessageReceivedRunnable

public static void addMessageReceivedRunnable(java.lang.Runnable runnable)
Add a runnable to be executed inside the transaction that the message is marked as received. Note that the blackboard transaction will be open when running these runnables, and they should NOT close the transaction, it will be closed for them