jade.mtp
Interface MTP

All Known Implementing Classes:
MessageTransportProtocol

public abstract interface MTP

Abstract interface for Message Transport Protocols

Author:
Giovanni Rimassa - Universita` di Parma

Inner Class Summary
static interface MTP.Dispatcher
          Callback interface to be notified of message arrivals over this Message Transport Protocol.
static interface MTP.MTPException
          Generic exception class for MTP errors.
 
Method Summary
 TransportAddress activate(MTP.Dispatcher disp)
          Activates an MTP handler for incoming messages on a default address.
 void activate(MTP.Dispatcher disp, TransportAddress ta)
          Activates an MTP handler for incoming messages on a specific address.
 java.lang.String addrToStr(TransportAddress ta)
          Converts a TransportAddress object into a string representation.
 void deactivate()
          Deactivates all the MTP handlers.
 void deactivate(TransportAddress ta)
          Deactivates the MTP handler listening at a given transport address.
 void deliver(TransportAddress ta, Envelope env, byte[] payload)
          Delivers to the specified address an ACL message, encoded in some concrete message representation, using the given envelope as a transmission header.
 java.lang.String getName()
          Reads the name of the message transport protocol managed by this MTP.
 TransportAddress strToAddr(java.lang.String rep)
          Converts a string representing a valid address in this MTP to a TransportAddress object.
 

Method Detail

activate

public TransportAddress activate(MTP.Dispatcher disp)
                          throws MTP.MTPException
Activates an MTP handler for incoming messages on a default address.
Returns:
A TransportAddress, corresponding to the chosen default address.
Throws:
MTP.MTPException - Thrown if some MTP initialization error occurs.

activate

public void activate(MTP.Dispatcher disp,
                     TransportAddress ta)
              throws MTP.MTPException
Activates an MTP handler for incoming messages on a specific address.
Parameters:
ta - A TransportAddress object, representing the transport address to listen to.
Throws:
MTP.MTPException - Thrown if some MTP initialization error occurs.

deactivate

public void deactivate(TransportAddress ta)
                throws MTP.MTPException
Deactivates the MTP handler listening at a given transport address.
Parameters:
ta - The TransportAddress object the handle to close is listening to.
Throws:
MTP.MTPException - Thrown if some MTP cleanup error occurs.

deactivate

public void deactivate()
                throws MTP.MTPException
Deactivates all the MTP handlers.
Throws:
MTP.MTPException - Thrown if some MTP cleanup error occurs.

deliver

public void deliver(TransportAddress ta,
                    Envelope env,
                    byte[] payload)
             throws MTP.MTPException
Delivers to the specified address an ACL message, encoded in some concrete message representation, using the given envelope as a transmission header.
Parameters:
ta - The transport address to deliver the message to. It must be a valid address for this MTP.
env - The message envelope, containing various fields related to message recipients, encoding, and timestamping.
Throws:
MTP.MTPException - Thrown if some MTP delivery error occurs.

strToAddr

public TransportAddress strToAddr(java.lang.String rep)
                           throws MTP.MTPException
Converts a string representing a valid address in this MTP to a TransportAddress object.
Parameters:
rep - The string representation of the address.
Returns:
A TransportAddress object, created from the given string.
Throws:
MTP.MTPException - If the given string is not a valid address according to this MTP.

addrToStr

public java.lang.String addrToStr(TransportAddress ta)
                           throws MTP.MTPException
Converts a TransportAddress object into a string representation.
Parameters:
ta - The TransportAddress object.
Returns:
A string representing the given address.
Throws:
MTP.MTPException - If the given TransportAddress is not a valid address for this MTP.

getName

public java.lang.String getName()
Reads the name of the message transport protocol managed by this MTP. The FIPA standard message transport protocols have a name starting with "fipa.mts.mtp".
Returns:
A string, that is the name of this MTP.