|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectes.upv.dsic.gti_ia.core.BaseAgent
es.upv.dsic.gti_ia.cAgents.CAgent
public abstract class CAgent
An agent has to extend this class in order to use the conversation support.
| Field Summary | |
|---|---|
protected CFactory |
defaultFactory
|
ExecutorService |
exec
|
protected CProcessor |
welcomeProcessor
|
| Fields inherited from class es.upv.dsic.gti_ia.core.BaseAgent |
|---|
logger, session, traceSession |
| Constructor Summary | |
|---|---|
CAgent(AgentID aid)
Creates a new CAgent |
|
| Method Summary | |
|---|---|
void |
addFactoryAsInitiator(CFactory factory)
Add a new factory that will create conversations where this agent will play the initiator role |
void |
addFactoryAsParticipant(CFactory factory)
Add a new factory that will create conversations where this agent will play the participant role |
protected void |
addProcessor(String conversationID,
CProcessor processor)
Adds a CProcessor to the agent |
protected boolean |
addTimer(String conversationId,
String stateName,
long period,
int waitType)
Adds a timer in a CProcessor, this is called from a wait state |
protected void |
createDefaultFactory(CAgent me)
This method creates the default factory that will manage the messages that no other factory can |
protected void |
endConversation(CFactory theFactory)
Ends a conversation |
protected void |
execute()
This is the main method of the agent. |
protected abstract void |
execution(CProcessor firstProcessor,
ACLMessage welcomeMessage)
This is the main method of the agent |
protected abstract void |
finalize(CProcessor firstProcessor,
ACLMessage finalizeMessage)
This method is executed just before the agent ends its execution |
int |
getMutexHoldCount()
Gets the hold count of the agent's mutex |
void |
lock()
Locks the agent's mutex |
String |
newConversationID()
Gets a new conversation identifier |
protected void |
notifyAgentEnd()
This method signals the end of the agent in order to unlock the main conversation thread |
void |
onMessage(ACLMessage msg)
This method should not be modified. |
void |
removeFactory(String name)
Removes the specified factory |
protected void |
removeProcessor(String conversationID)
Removes a processor identified by its conversation id |
void |
send(ACLMessage msg)
Sends a ACLMessage to all specified recipients agents. |
void |
Shutdown()
Terminates the agent's execution |
protected void |
startConversation(ACLMessage msg,
CProcessor parent,
Boolean sync)
Starts a conversation |
void |
startSyncConversation(String factoryName)
Starts a new conversation asynchronously |
void |
unlock()
Unlocks the agent's mutex |
| Methods inherited from class es.upv.dsic.gti_ia.core.BaseAgent |
|---|
activateTraceService, changeIdentity, deactivateTraceService, finalize, getAid, getName, init, onTraceEvent, run, sendTraceEvent, start, terminate |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected CProcessor welcomeProcessor
protected CFactory defaultFactory
public ExecutorService exec
| Constructor Detail |
|---|
public CAgent(AgentID aid)
throws Exception
aid -
Exception| Method Detail |
|---|
public void lock()
public void unlock()
public void addFactoryAsInitiator(CFactory factory)
factory - to be added as a initiator onepublic void addFactoryAsParticipant(CFactory factory)
factory - to be added as a participant onepublic void onMessage(ACLMessage msg)
onMessage in class BaseAgentmsg - message received by the agentpublic void removeFactory(String name)
name - of the factory to removepublic void Shutdown()
public void send(ACLMessage msg)
BaseAgent
send in class BaseAgentprotected void createDefaultFactory(CAgent me)
me - The agent owner of this factoryprotected void notifyAgentEnd()
protected final void execute()
execute in class BaseAgent
protected abstract void finalize(CProcessor firstProcessor,
ACLMessage finalizeMessage)
firstProcessor - The CProcessor managing the welcome conversationfinalizeMessage - The final message produced by this conversation
protected abstract void execution(CProcessor firstProcessor,
ACLMessage welcomeMessage)
firstProcessor - The CProcessor managing the welcome conversationwelcomeMessage - The message sent by the platform to the agent
protected void addProcessor(String conversationID,
CProcessor processor)
conversationID - of the conversation that the CProcessor will manageprocessor - The CProcessor to add
protected boolean addTimer(String conversationId,
String stateName,
long period,
int waitType)
conversationId - stateName - period - Time to waitwaitType - Wait type (oneshot, absolut or periodic)
protected void endConversation(CFactory theFactory)
theFactory - managing the conversation that is going to be finishedpublic String newConversationID()
protected void removeProcessor(String conversationID)
conversationID - of the conversation that the CProcessor that is going to be removed is managing
protected void startConversation(ACLMessage msg,
CProcessor parent,
Boolean sync)
msg - Initial messageparent - CProcessorsync - true if it is a synchronous conversation or false it is asynchronouspublic void startSyncConversation(String factoryName)
factoryName - Name of the initiator factory that will create the conversationpublic int getMutexHoldCount()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||