|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--fipaos.agent.task.Task
This class is an abstract representation of an agent task. It contains message dispatchers and dummy handling methods. To implement tasks in your agent, subclass this class and override the methods for the message types that you need to handle. For example, if your agent handles two conversations - one of type request and the other of contract net, then you would create two task classes that subclass this class. One that handles fipa-request protocol messages only, and on the handles fipa-contract-net messages only.
The Task-lifecycle is as follows:
Field Summary | |
protected java.util.Set |
_children
List of children of this task. |
protected java.lang.Object |
_lock
Lock - ensures mutual exclusion between threads modifying this Task |
protected FIPAOSAgent |
_owner
The agent that owns this task - should only be used for the purpose of updating/retreiving parent-Agent state information |
protected TaskManager |
_tm
The task manager that manages this task object - useful for registering new tasks based on incoming conversations |
Constructor Summary | |
Task()
Constructs a Task object - to fully initialise a Task object, use the Task or TaskManager newTask() method |
|
Task(FIPAOSAgent owner,
TaskManager taskman)
Deprecated. This constructor is no longer supported. Use the no-argument constructor from sub-classes, and initialise using the newTask() method of the parent Task or TaskManager. |
|
Task(FIPAOSAgent owner,
TaskManager taskman,
java.lang.String id)
Deprecated. This constructor is no longer supported. Use the no-argument constructor from sub-classes, and initialise using the newTask() method of the parent Task or TaskManager. |
Method Summary | |
protected void |
DFSearchResults(DFAgentDescription[] df_descs)
Callback method that is used to signal to the task that the previously requestes DF search has now finished. |
protected void |
done()
When invoked, parent task will have the appropriate doneX() method invoked |
protected void |
done(java.lang.Object result)
When invoked, parent task will have the appropriate doneX(Object) method invoked |
void |
doneDFSearchTask(java.lang.Object result)
Callback method to indicate that a DFSearchTask has completed. |
void |
errorDFSearchTask(Task t,
java.lang.Throwable exception)
Callback method to indicate that a DFSearchTask has failed. |
protected void |
forward(ACL acl)
Sends an ACL message. |
protected void |
forward(Message msg)
Sends a Message. |
java.lang.Object |
getContext()
Gets a context object for this Task - allows a parent-Task to associate some arbritary "context" with a child-Task which it can pickup when the child completes/fails |
protected ACL |
getNewConversation(java.lang.String protocol)
Returns a new ACL message object that is pre-filled for the specified protocol. |
TaskState |
getState()
Returns the TaskState associated with this Task |
void |
handleAcceptProposal(Conversation c)
Dummy method - please override implementation and DO NOT invoke |
void |
handleAgree(Conversation c)
Dummy method - please override implementation and DO NOT invoke |
void |
handleCfp(Conversation c)
Dummy method - please override implementation and DO NOT invoke |
void |
handleConfirm(Conversation c)
Dummy method - please override implementation and DO NOT invoke |
void |
handleDisconfirm(Conversation c)
Dummy method - please override implementation and DO NOT invoke |
void |
handleFailure(Conversation c)
Dummy method - please override implementation and DO NOT invoke |
void |
handleInform(Conversation c)
Dummy method - please override implementation and DO NOT invoke |
void |
handleInformIf(Conversation c)
Dummy method - please override implementation and DO NOT invoke |
void |
handleInformRef(Conversation c)
Dummy method - please override implementation and DO NOT invoke |
void |
handleLateMessage(Message msg)
Please override implementation - by default sends a not-understood |
void |
handleNotUnderstood(Conversation c)
Dummy method - please override implementation and DO NOT invoke |
protected void |
handleOther(Conversation conv)
This method can be implemented to provide a mechanism for dealing with incoming messages for which there is no performative handler available in the task subclass. |
void |
handlePropagate(Conversation c)
Dummy method - please override implementation and DO NOT invoke |
void |
handlePropose(Conversation c)
Dummy method - please override implementation and DO NOT invoke |
void |
handleProxy(Conversation c)
Dummy method - please override implementation and DO NOT invoke |
void |
handleQueryIf(Conversation c)
Dummy method - please override implementation and DO NOT invoke |
void |
handleQueryRef(Conversation c)
Dummy method - please override implementation and DO NOT invoke |
void |
handleRefuse(Conversation c)
Dummy method - please override implementation and DO NOT invoke |
void |
handleRejectProposal(Conversation c)
Dummy method - please override implementation and DO NOT invoke |
void |
handleRequest(Conversation c)
Dummy method - please override implementation and DO NOT invoke |
void |
handleRequestWhen(Conversation c)
Dummy method - please override implementation and DO NOT invoke |
void |
handleRequestWhenever(Conversation c)
Dummy method - please override implementation and DO NOT invoke |
void |
handleSubscribe(Conversation c)
Dummy method - please override implementation and DO NOT invoke |
void |
handleUndeliverableMessage(Message msg)
Please override implementation to deal with undeliverable messages |
protected void |
newTask(java.lang.String name,
Task task)
Initialises the given task, and invokes its start() method |
protected void |
newTask(java.lang.String name,
Task task,
Conversation conv)
Initialises the given task, and invokes its start() method |
protected void |
newTask(java.lang.String name,
Task task,
Conversation conv,
long timeout)
Initialises the given task, and invokes its start() method. |
protected void |
newTask(java.lang.String name,
Task task,
long timeout)
Initialises the given task, and invokes its start() method. |
protected void |
newTask(Task task)
Initialises the given task, and invokes its start() method. |
protected void |
newTask(Task task,
Conversation conv)
Initialises the given task, and invokes its start() method. |
protected void |
newTask(Task task,
Conversation conv,
long timeout)
Initialises the given task, and invokes its start() method. |
protected void |
newTask(Task task,
long timeout)
Initialises the given task, and invokes its start() method. |
void |
notify(Conversation conv)
Dispatches incoming messages to the correct message handling method. |
protected 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 :) |
protected 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 |
notifyMessageFailure(Message msg)
Dispatches incoming messages that have bounced for some reason. |
void |
notifyMessageForEndedConversation(Message msg)
Dispatches incoming message for ended conversation to the correct method. |
protected 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 |
searchDF(DFAgentDescription df_desc)
Searches the local platform DF for any agents matching the specified DF description. |
protected boolean |
searchDF(DFAgentDescription df_desc,
boolean federated)
Searches the local platform DF for any agents matching the specified DF description. |
protected boolean |
searchDF(DFAgentDescription df_desc,
SearchConstraints constraint)
Searches the local platform DF for any agents matching the specified DF description using the specified search constraint. |
protected boolean |
searchDF(java.lang.String df,
DFAgentDescription df_desc,
boolean federated)
Searches the specified DF for any agents matching the specified DF description. |
protected boolean |
searchDF(java.lang.String df,
DFAgentDescription df_desc,
SearchConstraints constraint,
boolean federated)
Searches the specified DF for any agents matching the specified DF description using the specified search contraint. |
protected boolean |
sendNotUnderstood(ACL orig_acl)
Send a not-understood in response to the given ACL |
void |
setContext(java.lang.Object o)
Sets a context object for this Task - allows a parent-Task to associate some arbritary "context" with a child-Task which it can pickup when the child completes/fails |
protected void |
startTask()
Invoked immediately after the task has been initialised by newTask() |
void |
timeoutDFSearchTask(Task t)
Callback method to indicate that a DFSearchTask has failed. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected FIPAOSAgent _owner
protected TaskManager _tm
protected java.util.Set _children
protected java.lang.Object _lock
Constructor Detail |
public Task()
public Task(FIPAOSAgent owner, TaskManager taskman)
owner
- The agent that owns this tasktaskman
- Reference to parent TaskManagerpublic Task(FIPAOSAgent owner, TaskManager taskman, java.lang.String id)
owner
- The agent that owns this tasktaskman
- The task manager managing this taskid
- The unique id of the taskMethod Detail |
public void setContext(java.lang.Object o)
public java.lang.Object getContext()
public TaskState getState()
public void notifyMessageForEndedConversation(Message msg)
msg
- Message that has arrived after end of conversationpublic void notifyMessageFailure(Message msg)
conv
- Conversation containing incoming messagepublic void notify(Conversation conv)
conv
- Conversation containing incoming messagepublic void handleInform(Conversation c)
public void handleRequest(Conversation c)
public void handleFailure(Conversation c)
public void handleNotUnderstood(Conversation c)
public void handleRefuse(Conversation c)
public void handleSubscribe(Conversation c)
public void handleAgree(Conversation c)
public void handleAcceptProposal(Conversation c)
public void handleCfp(Conversation c)
public void handleConfirm(Conversation c)
public void handleDisconfirm(Conversation c)
public void handleInformIf(Conversation c)
public void handleInformRef(Conversation c)
public void handlePropagate(Conversation c)
public void handlePropose(Conversation c)
public void handleProxy(Conversation c)
public void handleQueryIf(Conversation c)
public void handleQueryRef(Conversation c)
public void handleRejectProposal(Conversation c)
public void handleRequestWhen(Conversation c)
public void handleRequestWhenever(Conversation c)
public void handleUndeliverableMessage(Message msg)
NOTE: Not yet implemented
public void handleLateMessage(Message msg)
protected boolean searchDF(DFAgentDescription df_desc)
df_desc
- The DF description to search forprotected boolean searchDF(DFAgentDescription df_desc, SearchConstraints constraint)
df_desc
- The DF description to search forconstraint
- The search constraintprotected boolean searchDF(DFAgentDescription df_desc, boolean federated)
df_desc
- The DF description to search forfederated
- Flag to signal whether this search should be federated or notprotected boolean searchDF(java.lang.String df, DFAgentDescription df_desc, boolean federated)
df
- The DF to searchdf_desc
- The DF description to search forfederated
- Flag to signal whether this search should be federated or notprotected boolean searchDF(java.lang.String df, DFAgentDescription df_desc, SearchConstraints constraint, boolean federated)
df
- The DF to searchdf_desc
- The DF description to search forconstraint
- The search constraintfederated
- Flag to signal whether this search should be federated or notprotected void DFSearchResults(DFAgentDescription[] df_descs)
df_descs
- An array of search resultspublic void doneDFSearchTask(java.lang.Object result)
result
- The result of the DF-searchpublic void errorDFSearchTask(Task t, java.lang.Throwable exception)
public void timeoutDFSearchTask(Task t)
t
- The DFSearchTask that has timed-outexception
- protected void forward(ACL acl)
acl
- The ACL message to sendMessageSenderException
- if the message could not be sentprotected void forward(Message msg)
msg
- The Message to sendMessageSenderException
- if the message could not be sentprotected boolean sendNotUnderstood(ACL orig_acl)
protected ACL getNewConversation(java.lang.String protocol)
protocol
- The agent interaction protocol to useprotected void newTask(Task task)
task
- The new Task to be initialised and added to the systemprotected void newTask(Task task, Conversation conv)
task
- The new Task to be initialised and added to the systemconv
- Conversation to be associated with this Taskprotected void newTask(java.lang.String name, Task task)
task
- The new Task to be initialised and added to the systemname
- The name to be used for this taskprotected void newTask(java.lang.String name, Task task, Conversation conv)
task
- The new Task to be initialised and added to the systemconv
- Conversation to be associated with this Taskname
- The name to be associated with this taskprotected void newTask(Task task, long timeout)
timeout
- The time in milliseconds to wait before timing outtask
- The new Task to be initialised and added to the systemprotected void newTask(Task task, Conversation conv, long timeout)
timeout
- The time in milliseconds to wait before timing outtask
- The new Task to be initialised and added to the systemconv
- Conversation to be associated with this Taskprotected void newTask(java.lang.String name, Task task, long timeout)
timeout
- The time in milliseconds to wait before timing outtask
- The new Task to be initialised and added to the systemname
- The name to be used for this taskprotected void newTask(java.lang.String name, Task task, Conversation conv, long timeout)
timeout
- The time in milliseconds to wait before timing outtask
- The new Task to be initialised and added to the systemconv
- Conversation to be associated with this Taskname
- The name to be associated with this taskprotected void done()
protected void done(java.lang.Object result)
result
- The Object to pass to parent taskprotected void startTask()
protected void notifyError(Task child, java.lang.String method, java.lang.Throwable error)
child
- Child-Task that has failedmethod
- Name of the method to invokeprotected 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)protected void notifyTimeout(Task child, java.lang.String method)
child
- Child-Task that has timed-outmethod
- Name of the method to invokeprotected void handleOther(Conversation conv)
conv
- The conversation containing the message to handle
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |