com.ibm.able.platform
Class AbleJasMessageListener
java.lang.Object
|
+--com.ibm.able.platform.AbleJasMessageListener
- All Implemented Interfaces:
- javax.agent.service.transport.MessageListener
- public class AbleJasMessageListener
- extends java.lang.Object
- implements javax.agent.service.transport.MessageListener
This class provides a simple JAS message listener, or message
"inbox", for all AblePlatformDefaultAgent objects; each
AblePlatformDefaultAgent has at least one of these listeners,
which, by default, is setup by the agent to call back to the
containing agent's receiveMessage(TransportMessage)
method. Each AbleJasMessageListener created by an agent should be
coupled with a JAS Locator which is advertised in the agent's
registered AgentDescription. This allows other agents to examine
the number and kind of inboxes an agent has and then send certain
types of messages to specific inboxes.
By extending this class, a listener can be made to deal with
incoming messages itself rather than calling back to the containing
agent; or, a derived listener can be made to route messages of
different types to different entry points within the containing
agent, thus providing an agent with the ability to have multiple
inboxes instead of just one, as seems to be the norm in JAS.
Field Summary |
protected AblePlatformDefaultAgent |
myParent
The AblePlatformDefaultAgent that owns this JAS message listener,
or "inbox". |
protected AbleUserDefinedFunction |
myParentsMessageReceiveMethod
The method in the containing agent that is called by this
listener when an incoming JAS message is received. |
protected java.lang.String |
myProtocol
The message protocol that is used by this inbox; by default, this
is an empty string as message protocols have no meaning for base
AblePlatformDefaultAgent objects. |
Method Summary |
java.lang.String |
getProtocol()
Gets the message protocol used by this message listener. |
void |
receiveMessage(javax.agent.TransportMessage theTransportMessage)
When a JAS message receiver receives a transport message on a
Locator associated with this inbox, the JAS message receiver
calls this method; in this default implementation, the transport
message is simply forwarded on to the specified method in this
message listener's containing agent. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface javax.agent.service.transport.MessageListener |
equals, hashCode |
myParent
protected AblePlatformDefaultAgent myParent
- The AblePlatformDefaultAgent that owns this JAS message listener,
or "inbox". This field is set from a constructor parameter and
must not be null.
myProtocol
protected java.lang.String myProtocol
- The message protocol that is used by this inbox; by default, this
is an empty string as message protocols have no meaning for base
AblePlatformDefaultAgent objects. This field is provided to give
message listeners the ability to handle a specific type or format
of message. This field is set from a constructor parameter and
must not be null.
myParentsMessageReceiveMethod
protected AbleUserDefinedFunction myParentsMessageReceiveMethod
- The method in the containing agent that is called by this
listener when an incoming JAS message is received. This field is
set from a constructor parameter and must not be null.
AbleJasMessageListener
public AbleJasMessageListener(AblePlatformDefaultAgent theParent,
java.lang.String theProtocol,
AbleUserDefinedFunction theParentsMessageReceiveMethod)
- Creates a new Able JAS MessageListener, or "inbox", for an
AblePlatformDefaultAgent. A JAS Locator should be coupled to
this listener.
- Parameters:
theParent
- the AblePlatformDefaultAgent that owns this "inbox".
theProtocol
- the message protocol that this inbox is to use. The
empty string means no specific protocol. This base
message listener simply saves this parameter, but does
not use it.
theParentsMessageReceiveMethod
- the method within the containing agent that this inbox
is to call when a JAS message is received.
receiveMessage
public void receiveMessage(javax.agent.TransportMessage theTransportMessage)
- When a JAS message receiver receives a transport message on a
Locator associated with this inbox, the JAS message receiver
calls this method; in this default implementation, the transport
message is simply forwarded on to the specified method in this
message listener's containing agent.
- Specified by:
receiveMessage
in interface javax.agent.service.transport.MessageListener
- Parameters:
theTransportMessage
- the incoming message.
getProtocol
public java.lang.String getProtocol()
- Gets the message protocol used by this message listener.
- Returns:
- the protocol used by this inbox. The empty string
("") is the default and means no special type of
message is expected by this inbox.
(C) Copyright IBM Corporation 1999, 2003