fipaos.mts.rmi.internal
Class RMIComms

java.lang.Object
  |
  +--fipaos.mts.MTPBase
        |
        +--fipaos.mts.InternalMTPBase
              |
              +--fipaos.mts.rmi.internal.RMIComms
All Implemented Interfaces:
InternalMTP, PreParserService, Service
Direct Known Subclasses:
SSLRMIComms

public class RMIComms
extends InternalMTPBase

This class is a Comms implementation which offers support for RMI.


Inner Class Summary
 class RMIComms.MTSListener
          Class that is actually bound to the NS
 
Fields inherited from class fipaos.mts.MTPBase
_hap, _name, _ns_url, _shutdown, ACC_NAME
 
Fields inherited from interface fipaos.mts.service.Service
ACL_LANGUAGE_UNKNOWN, CONTENT_LANGUAGE_UNKNOWN, ERROR_STRING, ERROR_UNKNOWN, FIPAOS_DEBUG, FIPAOS_MSG_ID_SLOT, MALFORMED_ENVELOPE, MSG_DELIVERY_FAILURE_REASON, NONE, PROTOCOL_UNKNOWN, TARGET_UNKNOWN
 
Constructor Summary
RMIComms(java.lang.String name, URL ns)
          Comms initialiser
 
Method Summary
protected  void bind()
          Bind the MTP to the NS (if it exists) and perform other start-up operations
static void bindToRegistry(java.lang.String name, java.rmi.Remote r, int port)
          This method will (re)bind the given entry into the local Registry NOTE: RMIRegistry's only allow local objects to be bound to them, hence the need for an additional (lightweight) Naming-Service.
 java.util.List getAddresses()
          Method to retreive the protocol dependant address of an object that can be used to receive messages.
protected  RMIComms.MTSListener getMTSListener(RMIComms parent)
          Method to get an instance of MTSListener
 java.util.List getProtocols()
          Retreives the protocols known by this comms implementation
 void handleMessage(Message msg)
           
protected  java.lang.Object lookup(java.lang.String name)
          Attempt to lookup a reference to the MTS belonging to the given Agent
protected  java.lang.Object lookup(URL name)
          Lookup a reference to the MTS at the given URL
static void main(java.lang.String[] args)
          Test harness for transport
protected  void send(java.lang.Object target, Message msg)
          Invoked to send the given Message to the given target
 void shutdown()
          This should be invoked when the transport should be safely shutdown
static void startupRegistry(int port)
          This method will create a new Registry locally if there isn't already one running
protected  void unbind()
          Un-bind the MTP to the NS (if it exists)
 
Methods inherited from class fipaos.mts.InternalMTPBase
handleIncoming, incoming, initialise, outgoing
 
Methods inherited from class fipaos.mts.MTPBase
handleIncoming, handleOutgoing, shutdownMTPBase
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RMIComms

public RMIComms(java.lang.String name,
                URL ns)
         throws InitialisationException,
                java.rmi.RemoteException
Comms initialiser
Parameters:
our_name - The name to use when binding to the transport layers naming service - should include HAP address, i.e. "agentA@hap"
Method Detail

bind

protected void bind()
             throws InitialisationException
Bind the MTP to the NS (if it exists) and perform other start-up operations
Overrides:
bind in class MTPBase

unbind

protected void unbind()
Un-bind the MTP to the NS (if it exists)
Overrides:
unbind in class MTPBase

lookup

protected java.lang.Object lookup(URL name)
                           throws UnknownTargetException
Lookup a reference to the MTS at the given URL
Overrides:
lookup in class MTPBase

lookup

protected java.lang.Object lookup(java.lang.String name)
                           throws UnknownTargetException
Attempt to lookup a reference to the MTS belonging to the given Agent
Overrides:
lookup in class MTPBase

send

protected void send(java.lang.Object target,
                    Message msg)
             throws UnableToSendException
Invoked to send the given Message to the given target
Overrides:
send in class InternalMTPBase

getAddresses

public java.util.List getAddresses()
Method to retreive the protocol dependant address of an object that can be used to receive messages.
Overrides:
getAddresses in class InternalMTPBase
Returns:
A URL containing the required address, or null if this Comms doesn't publish such an object

getProtocols

public java.util.List getProtocols()
Retreives the protocols known by this comms implementation
Overrides:
getProtocols in class InternalMTPBase
Returns:
A List of String's

shutdown

public void shutdown()
This should be invoked when the transport should be safely shutdown
Overrides:
shutdown in class InternalMTPBase

handleMessage

public void handleMessage(Message msg)

startupRegistry

public static void startupRegistry(int port)
                            throws InitialisationException
This method will create a new Registry locally if there isn't already one running

bindToRegistry

public static void bindToRegistry(java.lang.String name,
                                  java.rmi.Remote r,
                                  int port)
                           throws InitialisationException
This method will (re)bind the given entry into the local Registry NOTE: RMIRegistry's only allow local objects to be bound to them, hence the need for an additional (lightweight) Naming-Service.
Parameters:
name - Name to bind the object into the Registry using
r - The Remote object reference to bind

getMTSListener

protected RMIComms.MTSListener getMTSListener(RMIComms parent)
                                       throws java.rmi.RemoteException
Method to get an instance of MTSListener

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Test harness for transport