|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--fipaos.agent.FIPAOSAgent
Base FIPA-OS agent class implementing FIPA-OS specifics for agent to agent communication. Override
notify()deal with updated Conversations directly in the underlying Agent implementation, or use the
setListenerTask()to set a default Task if you wish to use the TaskManager to implement the Agent.
Inner Class Summary | |
class |
FIPAOSAgent.TopLevelHandlerTask
|
Field Summary | |
protected DatabaseProfile |
_database_profile
Database Profile |
java.util.List |
_registered_with
List of Agents that this Agent is registered with |
java.lang.String |
_state
Agent states: unknown, waiting, suspended, transit, initiated, active |
protected TaskManager |
_tm
Task manager. |
Constructor Summary | |
FIPAOSAgent(PlatformProfile platform_profile,
AgentProfile agent_profile,
java.lang.String agent_name,
java.lang.String ownership,
boolean using_task_manager)
Constructor method to initialise an Agent. |
|
FIPAOSAgent(PlatformProfile platform_profile,
AgentProfile agent_profile,
java.lang.String agent_name,
java.lang.String ownership,
boolean using_task_manager,
FIPAOSAgentComponentFactory factory)
Constructor method to initialise an Agent. |
|
FIPAOSAgent(java.lang.String platform_profile_location,
java.lang.String agent_name,
java.lang.String ownership)
Constructor method to initialise an Agent. |
|
FIPAOSAgent(java.lang.String platform_profile_location,
java.lang.String agent_name,
java.lang.String ownership,
boolean using_task_manager)
Constructor method to initialise an Agent. |
Method Summary | |
void |
activate()
This method should be overriden by the FIPAOSAgent - it is invoked when the user of the local machine wishes it to do something (usually display a GUI) |
protected boolean |
addNewProtocol(java.lang.String protocol_name,
java.lang.String protocol_defn)
Adds a newly downloaded protocol definition to the conversation manager to make it available for use. |
protected void |
deregisterWithAMS()
Deregisters this agent with the DF. |
protected void |
deregisterWithDF()
Deregisters this agent with the DF. |
void |
forward(ACL acl)
Forward an acl message out via the ConversationManagerImpl |
void |
forward(Message msg)
Forward an message out via the ConversationManager |
AgentID |
getAID()
Gets the AgentID of this Agent |
protected ConversationManager |
getCM()
Provides a reference to this Agent's ConversationManager implementation |
Conversation |
getCurrentConversation(java.lang.String conv)
Method to retreive a conversation from the active list |
java.lang.String |
getHAP()
Gets the local HAP name |
java.lang.String |
getLocalAMS()
Returns the agent AID of the local platform AMS. |
AgentID |
getLocalAMSAID()
Returns the agent AID of the local platform AMS. |
java.lang.String |
getLocalDF()
Returns the agent AID of the local platform DF. |
AgentID |
getLocalDFAID()
Returns the agent AID of the local platform DF. |
Conversation |
getNewConversation(java.lang.String protocol)
Method to get a new Conversation object from the conversation manager given the protocol specified |
java.lang.String |
getOwnership()
Returns the ownership id of the agent. |
PlatformProfile |
getPlatformProfile()
Gets the platform profile for this Agent |
AgentProfile |
getProfile()
Gets the profile for this Agent |
java.lang.String |
getState()
Returns the state of the agent Currently, only 2 states might be returned: "unknown" and "active" |
boolean |
isShutdown()
Indicates if this Agent has been shutdown |
protected boolean |
knowsProtocol(java.lang.String protocol_name)
Indicates if the agent is aware of the protocol specified. |
void |
notify(Conversation conv)
Conversation listener method to deal with conversations being sent by the planner scheduler. |
void |
notify(java.util.Enumeration enum)
Deals with multiple conversations at once - just calls notify( Conversation ) for each one. |
void |
notifyDone(Task child,
java.lang.String method,
java.lang.Object result)
Default method invoked to dispatch done callbacks - override this with a method to dispatch the callback statically to improve efficiency :) |
void |
notifyError(Task child,
java.lang.String method,
java.lang.Throwable error)
Default method invoked to dispatch error callbacks - override this with a method to dispatch the callback statically to improve efficiency :) |
void |
notifyMessageInEndedConversation(Message msg)
Indicates that the given Message arrived for a completed Conversation - override to deal with this if a TaskManager is not in use |
void |
notifyMessageUndeliverable(Message msg)
Indicates that the given Message was not deliverable - override to deal with this if a TaskManager is not in use |
void |
notifyTimeout(Task child,
java.lang.String method)
Default method invoked to dispatch timeout callbacks - override this with a method to dispatch the callback statically to improve efficiency :) |
protected boolean |
registeredWith(AgentID agent)
Indicates if this agent is registered with the platform agent specified. |
protected boolean |
registeredWithAMS()
Indicates if this agent is registered with the local AMS. |
protected boolean |
registeredWithDF()
Indicates if this agent is registered with the local DF. |
protected void |
registerWithAMS()
Registers this agent with the local platform AMS. |
protected void |
registerWithAMS(AgentID ams)
Registers this agent with the AMS specified. |
protected void |
registerWithAMS(AgentID ams,
java.lang.String state)
Registers this agent with the AMS specified. |
protected void |
registerWithAMS(AMSRegistrationTask ams_task)
Registers this agent using the AMS registration task specified. |
protected void |
registerWithDF(AgentID df,
DFAgentDescription df_desc)
Registers this agent with the DF specified. |
protected void |
registerWithDF(AgentID df,
java.lang.String agent_type)
Registers this agent with the DF specified. |
protected void |
registerWithDF(DFRegistrationTask df_task)
Registers this agent using the DF registration task specified. |
protected void |
registerWithDF(java.lang.String agent_type)
Registers this agent with the local platform DF. |
boolean |
sendNotUnderstood(ACL orig_acl)
Send a not understood message in response to the given ACL message |
boolean |
sendNotUnderstood(ACL orig_acl,
java.lang.String reason)
Send a not understood message in response to the given ACL message |
protected boolean |
setListenerTask(Task idle_task)
Sets the agent's idle task - this method MUST be used if you are using the task manager as it defines which task object should handle incoming messages that we have not previously seen. |
void |
setMessageSender(MessageSender ms)
Sets the MessageSender for this |
void |
shutdown()
Shutdown the Agent safely |
protected void |
startPushing()
When using the push model or ConversationManagement, this method should be invoked in order to allow pushing to start |
void |
waitForPushLock()
Blocks until the Agent is ready to receive messages/conversations |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected TaskManager _tm
protected DatabaseProfile _database_profile
public java.lang.String _state
public java.util.List _registered_with
Constructor Detail |
public FIPAOSAgent(java.lang.String platform_profile_location, java.lang.String agent_name, java.lang.String ownership)
platform_profile_location
- The location of the platform.profile (a fully qualified file name)agent_name
- globally unique identifier for the agentownership
- the ownership of the agentpublic FIPAOSAgent(java.lang.String platform_profile_location, java.lang.String agent_name, java.lang.String ownership, boolean using_task_manager)
platform_profile_location
- The location of the platform.profile (a fully qualified file name)agent_name
- unique name of the Agent within its platformownership
- the ownership of the agentusing_task_manager
- Selected if a task manager is to be usedpublic FIPAOSAgent(PlatformProfile platform_profile, AgentProfile agent_profile, java.lang.String agent_name, java.lang.String ownership, boolean using_task_manager)
platform_profile
- Representation of the Platform's profileagent_profile
- Representation of the Agent's profileagent_name
- unique name of the Agent within its platformownership
- the ownership of the agentusing_task_manager
- Selected if a task manager is to be usedpublic FIPAOSAgent(PlatformProfile platform_profile, AgentProfile agent_profile, java.lang.String agent_name, java.lang.String ownership, boolean using_task_manager, FIPAOSAgentComponentFactory factory)
platform_profile
- Representation of the Platform's profileagent_profile
- Representation of the Agent's profileagent_name
- unique name of the Agent within its platformownership
- the ownership of the agentusing_task_manager
- Selected if a task manager is to be usedfactory
- Factory to be used to generate Agent componentsMethod Detail |
public void forward(ACL acl)
acl
- ACL containing an agent communication language
(acl) messagepublic void forward(Message msg)
msg
- Message containing an agent communication language
(acl) message and its associated envelopepublic void waitForPushLock()
public void shutdown()
public boolean isShutdown()
public java.lang.String getOwnership()
public AgentProfile getProfile()
public PlatformProfile getPlatformProfile()
public AgentID getAID()
public java.lang.String getHAP()
public void activate()
By default it does nothing
public Conversation getCurrentConversation(java.lang.String conv) throws InvalidConversationIDException
conv
- The conversation id of the Conversation object to retreivepublic java.lang.String getLocalAMS()
public AgentID getLocalAMSAID()
public java.lang.String getLocalDF()
public AgentID getLocalDFAID()
public java.lang.String getState()
protected boolean setListenerTask(Task idle_task)
idle_task
- The task object that should be used when the agent is idling
e.g. the task object that handles incoming messages that are not repliesprotected void startPushing()
protected boolean addNewProtocol(java.lang.String protocol_name, java.lang.String protocol_defn)
protocol_name
- The name of the protocol to add (e.g. fipa-new-protocol)protocol_defn
- The RDF definition of the protocolprotected boolean knowsProtocol(java.lang.String protocol_name)
protocol_name
- The name of the protocol (e.g. fipa-new-protocol)public Conversation getNewConversation(java.lang.String protocol) throws UnknownProtocolException
protected ConversationManager getCM()
public void notify(Conversation conv)
notify
in interface ConversationListener
conv
- The updated conversation to deal withpublic void notify(java.util.Enumeration enum)
notify
in interface ConversationListener
enum
- An enumeration of updated conversations to deal withpublic void notifyMessageInEndedConversation(Message msg)
notifyMessageInEndedConversation
in interface ConversationListener
public void notifyMessageUndeliverable(Message msg)
notifyMessageUndeliverable
in interface ConversationListener
public void setMessageSender(MessageSender ms)
setMessageSender
in interface ConversationListener
public boolean sendNotUnderstood(ACL orig_acl)
acl
- The ACL object to reply topublic boolean sendNotUnderstood(ACL orig_acl, java.lang.String reason)
acl
- The ACL object to reply toreason
- The reason for not-understandingprotected boolean registeredWith(AgentID agent)
registeredWithX()
methods of this class.protected boolean registeredWithAMS()
protected boolean registeredWithDF()
protected void registerWithAMS() throws AMSRegistrationException
protected void registerWithAMS(AgentID ams) throws AMSRegistrationException
ams
- The AID of the AMS to register withprotected void registerWithAMS(AgentID ams, java.lang.String state) throws AMSRegistrationException
ams
- The AID of the AMS to register withstate
- The platform state of the agent (e.g. ACTIVE - see FIPA spec for details)protected void registerWithAMS(AMSRegistrationTask ams_task) throws AMSRegistrationException
ams_task
- The AMSRegistrationTask to register withprotected void registerWithDF(java.lang.String agent_type) throws DFRegistrationException
agent_type
- The type of this agent, e.g. fipa-agent, fipa-arb etcprotected void registerWithDF(AgentID df, DFAgentDescription df_desc) throws DFRegistrationException
df
- The AID of the AMS to register withdf_desc
- A DF description that describes this agentprotected void registerWithDF(AgentID df, java.lang.String agent_type) throws DFRegistrationException
df
- The GUID/AID of the DF to register withagent_type
- The type of this agent, e.g. fipa-agent, fipa-arb etcprotected void registerWithDF(DFRegistrationTask df_task) throws DFRegistrationException
df_task
- The ADFRegistrationTask to register withprotected void deregisterWithDF() throws DFRegistrationException
protected void deregisterWithAMS() throws AMSRegistrationException
public void notifyDone(Task child, java.lang.String method, java.lang.Object result)
child
- Child-Task that has completedmethod
- Name of the method to invokeresult
- Result associated with the completion (null if no result given)public void notifyTimeout(Task child, java.lang.String method)
child
- Child-Task that has timed-outmethod
- Name of the method to invokepublic void notifyError(Task child, java.lang.String method, java.lang.Throwable error)
child
- Child-Task that has failedmethod
- Name of the method to invoke
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |