|
||||||||||
| 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
public class BaseAgent
Base class to inherit when implementing a basic Magentix agent. This class provides mechanisms to enable communication between agents. A good alternative is to inherit from SingleAgent, which provides methods (callbacks) when a message arrives, etc. If this class is too basic, consider to inherit from one of the two possibilities given by the QueueAgent and the CAgent.
SingleAgent,
QueueAgent,
CAgent| Field Summary | |
|---|---|
protected org.apache.log4j.Logger |
logger
The logger variable considers to print any event that occurs by the agent |
protected org.apache.qpid.transport.Session |
session
QPid session used for communication. |
protected org.apache.qpid.transport.Session |
traceSession
Qpid session used for tracing. |
| Constructor Summary | |
|---|---|
BaseAgent(AgentID aid)
Creates a new agent in an open broker connection |
|
| Method Summary | |
|---|---|
void |
activateTraceService()
|
void |
changeIdentity(AgentID _aid)
Changes the name of the agent to acquire a new identity. |
void |
deactivateTraceService()
|
protected void |
execute()
Method that defines all the logic and behavior of the agent. |
void |
finalize()
The trace system is notified when the agent is about to disappear, in this method. |
AgentID |
getAid()
Returns a structure as the Agent Identificator formed by the name, protocol, host and port Agent. |
String |
getName()
Returns the agent name |
protected void |
init()
Define activities such as initialization resources, and every task necessary before execution of execute procedure. |
protected void |
onMessage(ACLMessage msg)
Function that will be executed when the agent gets a message The user has to write his/her code here |
protected void |
onTraceEvent(TraceEvent tEvent)
Function that will be executed when the agent gets a trace event. |
void |
run()
Runs Agent's thread |
void |
send(ACLMessage msg)
Sends a ACLMessage to all specified recipients agents. |
void |
sendTraceEvent(TraceEvent tEvent)
Sends a trace event to the mgx.trace exchange |
void |
start()
Starts the agent |
protected void |
terminate()
Function that will be executed when the agent terminates |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected org.apache.log4j.Logger logger
protected org.apache.qpid.transport.Session session
protected org.apache.qpid.transport.Session traceSession
TracingService| Constructor Detail |
|---|
public BaseAgent(AgentID aid)
throws Exception
aid - Agent identification for the new agent, it has to be unique on the platform
Exception - If Agent ID already exists on the platform| Method Detail |
|---|
public void changeIdentity(AgentID _aid)
throws Exception
_aid - the new agent id
Exceptionpublic void send(ACLMessage msg)
msg - public void sendTraceEvent(TraceEvent tEvent)
tEvent - Trace event which is to be sentpublic String getName()
protected void init()
protected void execute()
public void finalize()
finalize in class Object
protected void onMessage(ACLMessage msg)
throws Exception
msg - Message received
Exceptionprotected void onTraceEvent(TraceEvent tEvent)
protected void terminate()
public void run()
run in interface Runnablepublic void start()
public AgentID getAid()
public void activateTraceService()
public void deactivateTraceService()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||