|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--fipaos.agent.task.TaskManager
The TaskManager class stores task objects with their associated conversation IDs for
an agent. The agent must add it's tasks during initialisation.
Each task can be used to handle the messages for a particular conversation that an
agent participates in. For example. if an agent registers with a DF on startup, one task
object can be used to handle this conversation without having to store any state for
other conversations - even if they have the same protocol.
Inner Class Summary | |
static class |
TaskManager.DefaultTaskManagerListener
Default implementation of the TM Listener - just adds events back to TM in the order they arrive |
Field Summary | |
protected java.util.Set |
_conversation_ids
A List of all conversation ids' for which a Task has been assigned, but the Conversation hasn't ended - allows Tasks to terminate before the end of a Conversation without worrying about carrying out the rest of the Conversation (i.e. |
Constructor Summary | |
TaskManager(FIPAOSAgent owner,
MessageSender ms,
Task top_level_parent,
TaskManagerProfile tmp)
Constructs an empty task manager. |
Method Summary | |
void |
appendToExecutionOrder(Task t)
Append a Task to the execution order (Tasks are executed in the order they are added to the execution order). |
protected void |
checkConversationEnded(Conversation conv)
Check if Conversation is finished - if so we should remove it from _conversation_ids |
java.util.Set |
getActiveTasks()
List the active Tasks |
int |
getPendingTaskEvents()
Get info. |
int |
getTaskCount()
Get info. |
int |
getTimeoutCount()
Get info. |
static java.util.Set |
getVMTaskManagers()
Get set of all TM's in VM |
void |
newTask(java.lang.String name,
Task task)
Creates a new Task with the top level handler task as parent and the given alternate Task name |
void |
newTask(java.lang.String name,
Task task,
Conversation conv,
Task parent)
Initializes a new child-task and adds it to the TaskManager. |
void |
newTask(Task task)
Initializes a new "top-level" task and adds it to the TaskManager. |
void |
newTask(Task t,
Conversation conv)
Initializes a new "top-level" task and adds it to the TaskManager. |
void |
newTask(Task task,
Conversation conv,
long timeout)
Initialises the given task, and invokes its start() method. |
void |
newTask(Task task,
Conversation conv,
long timeout,
Task parent)
Initializes a new "top-level" task and adds it to the TaskManager. |
void |
newTask(Task task,
Conversation conv,
Task parent)
Initializes a new child-task and adds it to the TaskManager. |
void |
newTask(Task task,
long timeout)
Initialises the given task, and invokes its start() method. |
void |
newTask(Task t,
java.lang.String id)
Initializes a new "top-level" task and adds it to the TaskManager. |
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 |
notifyMessageInEndedConversation(Message msg)
Indicates that the given Message arrived for a completed Conversation - pass it to IDLE task |
void |
notifyMessageUndeliverable(Message msg)
Indicates that the given Message was not deliverable |
boolean |
removeTask(java.lang.String key)
Removes a task object associated with the specified conversation id from the manager. |
boolean |
removeTask(Task task)
Removes a task object from the manager. |
void |
setMessageSender(MessageSender ms)
Sets the MessageSender that this should use |
void |
setTaskManagerListener(TaskManagerListener tml)
Setup the TaskManageristener |
void |
shutdown()
Shuts-down this TaskManager - prevents any new Tasks from starting |
java.lang.String |
toString()
Get the name of the owning Agent |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected java.util.Set _conversation_ids
Constructor Detail |
public TaskManager(FIPAOSAgent owner, MessageSender ms, Task top_level_parent, TaskManagerProfile tmp)
owner
- Reference to parent Agentms
- MessageSender to send messages - this may be null (can be set
later via the setMessageSender() method).Method Detail |
public void shutdown()
public void newTask(Task task)
public void newTask(java.lang.String name, Task task)
public void newTask(Task t, java.lang.String id)
public void newTask(Task t, Conversation conv)
public void newTask(Task task, Conversation conv, Task parent)
public void newTask(java.lang.String name, Task task, Conversation conv, Task parent)
public 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 systemconv
- Conversation to be associated with this Taskpublic 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 Taskpublic void newTask(Task task, Conversation conv, long timeout, Task parent)
public boolean removeTask(java.lang.String key)
key
- The conversation id of the task to be removed.public boolean removeTask(Task task)
task
- Task to be removedpublic int getTaskCount()
public int getTimeoutCount()
public int getPendingTaskEvents()
public java.lang.String toString()
toString
in class java.lang.Object
public static java.util.Set getVMTaskManagers()
public void appendToExecutionOrder(Task t)
public java.util.Set getActiveTasks()
public void setTaskManagerListener(TaskManagerListener tml)
protected void checkConversationEnded(Conversation conv)
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 setMessageSender(MessageSender ms)
setMessageSender
in interface ConversationListener
public void notifyMessageInEndedConversation(Message msg)
notifyMessageInEndedConversation
in interface ConversationListener
public void notifyMessageUndeliverable(Message msg)
NOTE: This is a new feature which hasn't been fully tested
notifyMessageUndeliverable
in interface ConversationListener
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |