ABLE, Version 1.1b

com.ibm.able.platform.agents
Class FipaAmsAgentAppl

java.lang.Object
  |
  +--java.rmi.server.RemoteObject
        |
        +--java.rmi.server.RemoteServer
              |
              +--java.rmi.server.UnicastRemoteObject
                    |
                    +--com.ibm.able.AbleObject
                          |
                          +--com.ibm.able.agents.AbleDefaultAgent
                                |
                                +--com.ibm.able.platform.agents.FipaAgentDefaultAgent
                                      |
                                      +--com.ibm.able.platform.agents.FipaAmsAgentAppl

public class FipaAmsAgentAppl
extends FipaAgentDefaultAgent
implements FipaAmsAgent

This class provides an implementation of a FIPA Agent Management System (AMS) agent.

This implementation of an AMS agent will

This agent will also register itself with itself and the DF.

Version:
$Revision: 1.4 $, $Date: 2000/02/22 19:23:13 $
See Also:
Serialized Form

Fields inherited from class com.ibm.able.platform.agents.FipaAgentDefaultAgent
myAmsAd, myDfAd, myDfServices
 
Fields inherited from class com.ibm.able.agents.AbleDefaultAgent
activeDataSource, agentAddr, agentHost, agentName, beans, effectors, eventConnections, numEpochs, processList, processListOK, sensors
 
Fields inherited from class com.ibm.able.AbleObject
changed, chgSupport, comment, dataFlowEnabled, destBufferConnections, eventQueue, fileName, inputBuffer, listeners, logger, name, outputBuffer, parent, propertyConnectionMgr, sourceBufferConnections, state, stateChgSupport
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
FipaAmsAgentAppl()
          Create a new Able Platform FIPA AMS agent.
 
Method Summary
 void authenticate(FipaAmsAgentDescription theDescription)
          Authenticate a registered agent.
static java.lang.String Copyright()
          Determine the copyright of this class.
 java.lang.Object createAgent(FipaAmsAgentDescription theDescription)
          Create an agent on this or another host as specified in the description, and then register it with this AMS.
 FipaAmsAgentDescription deregisterAgent(FipaAmsAgentDescription theDescription)
          Deregister an agent from this AMS.
 java.util.Hashtable getRegisteredAgents()
          Get all the registered agents from this AMS.
 void init()
          Initialize and configure the agent.
 void invokeAgent(java.lang.String theAgentName)
          Invoke a registered agent.
static void main(java.lang.String[] args)
          Create a FIPA AMS agent and register it with RMI so that it is available over the network.
 void modifyAgent(FipaAmsAgentDescription theDescription)
          Modify a registered agent.
 FipaApDescription queryPlatformProfile()
          Retrieve the platform profile for this distributed agent platform.
 void quitAgent()
          Terminate this agent.
 FipaAmsAgentDescription registerAgent(FipaAmsAgentDescription theDescription)
          Register an agent with this AMS.
 FipaAmsAgentDescription searchAgent(FipaAmsAgentDescription theDescription)
          Search the agent registry for an agent with specific attributes.
 void terminateAgent(java.lang.String theAgentName)
          Terminate a registered agent.
 java.lang.String toString()
          Retrieve a string describing (the contents of) the object.
 
Methods inherited from class com.ibm.able.platform.agents.FipaAgentDefaultAgent
deregisterWithAms, deregisterWithDf, destroyAgent, executeAgent, invokeAgent, moveAgent, msgAcceptProposal, msgAgree, msgCancel, msgCfp, msgConfirm, msgDisconfirm, msgFailure, msgInform, msgInformIf, msgInformRef, msgNotUnderstood, msgPropose, msgQueryIf, msgQueryRef, msgRefuse, msgRejectProposal, msgRequest, msgRequestWhen, msgRequestWhenever, msgSubscribe, registerWithAms, registerWithDf, resumeAgent, suspendAgent, waitAgent, wakeUpAgent
 
Methods inherited from class com.ibm.able.agents.AbleDefaultAgent
addBean, addEffector, addEventConnection, addSensor, buildProcessList, clsNm, containsBean, containsBean, debugTrace, getAgentAddr, getAgentHost, getAgentName, getBean, getBeans, getDataSource, getEffectors, getNumEpochs, getProcessList, getSensors, handleAbleEvent, init, invokeEffector, invokeSensor, isActiveDataSource, process, propertyChange, quitAll, quitEnabledEventProcessing, removeAllBeans, removeBean, removeEffector, removeEventConnection, removeSensor, reset, resumeAll, rmiRebind, rmiUnbind, setActiveDataSource, setEffectors, setProcessList, setSensors, suspendAll
 
Methods inherited from class com.ibm.able.AbleObject
addAbleEventListener, addDestBufferConnection, addPropertyChangeListener, addPropertyConnection, addSourceBufferConnection, addStateChangeListener, dataChanged, firePropertyChange, flushAbleEventQueue, getAbleEventListeners, getAbleEventProcessingEnabled, getAbleEventQueueSize, getBuffer, getBufferContents, getComment, getDestBufferConnections, getFileName, getInputBuffer, getInputBuffer, getInputBufferAsStringArray, getInputBufferContents, getLogger, getName, getOutputBuffer, getOutputBuffer, getOutputBufferAsStringArray, getOutputBufferContents, getParent, getPropertyConnectionManager, getSleepTime, getSourceBufferConnections, getState, hasInputBuffer, hasOutputBuffer, isAbleEventPostingEnabled, isAbleEventProcessingEnabled, isChanged, isConnectable, isDataFlowEnabled, isTimerEventProcessingEnabled, notifyAbleEventListeners, processAbleEvent, processBufferConnections, processNoEventProcessingEnabledSituation, processTimerEvent, removeAbleEventListener, removeAllAbleEventListeners, removeAllBufferConnections, removeAllPropertyConnections, removeDestBufferConnection, removePropertyChangeListener, removePropertyConnection, removeSourceBufferConnection, removeStateChangeListener, restartEnabledEventProcessing, restoreFromFile, restoreFromFile, restoreFromSerializedFile, restoreFromStream, resumeEnabledEventProcessing, saveToFile, saveToFile, setAbleEventProcessingEnabled, setChanged, setComment, setDataFlowEnabled, setFileName, setInputBuffer, setInputBuffer, setLogger, setName, setOutputBuffer, setOutputBuffer, setParent, setSleepTime, setState, setTimerEventProcessingEnabled, sourceConnectionsOK, startEnabledEventProcessing, suspendEnabledEventProcessing
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FipaAmsAgentAppl

public FipaAmsAgentAppl()
                 throws java.rmi.RemoteException
Create a new Able Platform FIPA AMS agent.

The name and comment are set to pre-defined values, but the agent does not otherwise initialise itself or begin running until init() is called.

Throws:
java.rmi.RemoteException - On any error.
Method Detail

registerAgent

public FipaAmsAgentDescription registerAgent(FipaAmsAgentDescription theDescription)
                                      throws java.rmi.RemoteException
Register an agent with this AMS.
Specified by:
registerAgent in interface FipaAmsAgent
Parameters:
theDescription - A FIPA AMS agent description identifying the agent to be registered.

Returns:
The FIPA AMS agent description of the registered agent.
Throws:
java.rmi.RemoteException - On any error.

deregisterAgent

public FipaAmsAgentDescription deregisterAgent(FipaAmsAgentDescription theDescription)
                                        throws java.rmi.RemoteException
Deregister an agent from this AMS.
Specified by:
deregisterAgent in interface FipaAmsAgent
Parameters:
theDescription - A FIPA AMS agent description identifying the agent to be deregistered. The agent must, of course, already be registered with this AMS.

Returns:
The FIPA AMS agent description of the deregistered agent, or null if the agent was not found in the registry.
Throws:
java.rmi.RemoteException - On any error.

searchAgent

public FipaAmsAgentDescription searchAgent(FipaAmsAgentDescription theDescription)
                                    throws java.rmi.RemoteException
Search the agent registry for an agent with specific attributes.

NOTE that this method currently searches only by name!

Specified by:
searchAgent in interface FipaAmsAgent
Parameters:
theDescription - A FIPA AMS agent description containing search attributes.

Returns:
The FIPA AMS agent description of the single agent that matches the search attributes, or null if no matching agent was found.
Throws:
java.rmi.RemoteException - On any error.

modifyAgent

public void modifyAgent(FipaAmsAgentDescription theDescription)
                 throws java.rmi.RemoteException
Modify a registered agent.

NOTE that this method currently does nothing!

Specified by:
modifyAgent in interface FipaAmsAgent
Parameters:
theDescription - A FIPA AMS agent description identifying the agent to be modified, and how it is to be modified. The agent must, of course, be registered with this AMS.

Throws:
java.rmi.RemoteException - On any error.

authenticate

public void authenticate(FipaAmsAgentDescription theDescription)
                  throws java.rmi.RemoteException
Authenticate a registered agent.

NOTE that this method currently does nothing!

Specified by:
authenticate in interface FipaAmsAgent
Parameters:
theDescription - A FIPA AMS agent description identifying the agent to be authenticated. The agent must, of course, be registered with this AMS.

Throws:
java.rmi.RemoteException - On any error.

queryPlatformProfile

public FipaApDescription queryPlatformProfile()
                                       throws java.rmi.RemoteException
Retrieve the platform profile for this distributed agent platform.
Specified by:
queryPlatformProfile in interface FipaAmsAgent
Returns:
A FIPA Agent Platform Profile
Throws:
java.rmi.RemoteException - On any error.

createAgent

public java.lang.Object createAgent(FipaAmsAgentDescription theDescription)
                             throws java.rmi.RemoteException
Create an agent on this or another host as specified in the description, and then register it with this AMS.

Note that this method does not init() the agent! It is up to the caller to initialise the agent by calling its init() method when ready to do so.

Specified by:
createAgent in interface FipaAmsAgent
Parameters:
theDescription - A FIPA AMS agent description identifying the agent to be created, and where it is to be created. Note that an AblePlatformSupport object must be running on the host where the agent is to be created.

Returns:
An interface that can be used to access the agent directly. NOTE that depending on what the agent implements, this could be one of many different things, for example a PlatformAgent. It is up to the caller to determine how the return object is to be cast.
Throws:
java.rmi.RemoteException - On any error.

invokeAgent

public void invokeAgent(java.lang.String theAgentName)
                 throws java.rmi.RemoteException
Invoke a registered agent.

This implementation simply calls the specified agent's startEnabledEventProcesing() method (which is also available through direct invocation).

Specified by:
invokeAgent in interface FipaAmsAgent
Parameters:
theAgentName - A String containing the name of the agent to invoke. The agent must, of course, be registered with this AMS. If the agent is not registered, this method does nothing.

Throws:
java.rmi.RemoteException - On any error.

terminateAgent

public void terminateAgent(java.lang.String theAgentName)
                    throws java.rmi.RemoteException
Terminate a registered agent.

This implementation simply calls the specified agent's quitEnabledEventProcessing() method (which is also available through direct invocation). It is up to the caller to also deregister the agent, if necessary, from any services with which the specified agent is registered.

Specified by:
terminateAgent in interface FipaAmsAgent
Parameters:
theAgentName - A String containing the name of the agent to invoke. The agent must, of course, be registered with this AMS. If the agent is not registered, this method does nothing.

Throws:
java.rmi.RemoteException - On any error.

getRegisteredAgents

public java.util.Hashtable getRegisteredAgents()
                                        throws java.rmi.RemoteException
Get all the registered agents from this AMS.
Specified by:
getRegisteredAgents in interface FipaAmsAgent
Returns:
A copy of the hashtable of that contains all registered FIPA AMS agent names and descriptions (FipaAmsAgentDescription objects).
Throws:
java.rmi.RemoteException - On any error.

quitAgent

public void quitAgent()
               throws java.rmi.RemoteException
Terminate this agent.
Throws:
java.rmi.RemoteException - On any error.
Overrides:
quitAgent in class FipaAgentDefaultAgent

init

public void init()
          throws java.rmi.RemoteException
Initialize and configure the agent.

In this implementation the bean's state changes from AbleState.Uninitiated to AbleState.Initiated; timer event processing is disabled; both Able event posting and processing are enabled; and the asynchronous thread is started.

Furthermore, the Agent Platform Description is set up; the AMS Agent Description is filled in; the AMS registers with itself; the DF and ACC agents are started, if necessary; and a tuple space is set up on the server specified in the user's platform.preferences file.

Overrides:
init in class AbleDefaultAgent

main

public static void main(java.lang.String[] args)
Create a FIPA AMS agent and register it with RMI so that it is available over the network.

toString

public java.lang.String toString()
Retrieve a string describing (the contents of) the object.
Returns:
A String containing the current contents of the object.
Overrides:
toString in class FipaAgentDefaultAgent

Copyright

public static java.lang.String Copyright()
Determine the copyright of this class.
Returns:
A String containing this class's copyright statement.

ABLE, Version 1.1b

ABLE: Produced by Joe, Don, and Jeff who say, 'Thanks for your support.'