gr.demokritos.iit.jinsect.distributed
Class MobileAgent

java.lang.Object
  extended by jade.core.Agent
      extended by gr.demokritos.iit.jinsect.distributed.MobileAgent
All Implemented Interfaces:
jade.core.TimerListener, java.io.Serializable, java.lang.Runnable
Direct Known Subclasses:
NGramDocumentComparatorAgent

public class MobileAgent
extends jade.core.Agent

This is an example of mobile agent. This class contains the resources used by the agent behaviours: the counter, the flag cntEnabled, and the list of visited locations. At the setup it creates a gui and adds behaviours to: get the list of available locations from AMS, serve the incoming messages, and to increment the counter. In particular, notice the usage of the two methods beforeMove() and afterMove() to execute some application-specific tasks just before and just after the agent migration takes effect. Because this agent has a GUI, it extends the class GuiAgent that, in turn, extends the class Agent. Being the GUI a different thread, the communication between the agent and its GUI is based on event passing.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class jade.core.Agent
jade.core.Agent.Interrupted
 
Field Summary
static int CLONE_EVENT
           
static int CONTINUE_EVENT
           
static int EXIT
           
protected  java.util.ArrayList Locations
           
static int MOVE_EVENT
           
static int REFRESH_EVENT
           
static int STOP_EVENT
           
 
Fields inherited from class jade.core.Agent
AP_ACTIVE, AP_DELETED, AP_IDLE, AP_INITIATED, AP_MAX, AP_MIN, AP_SUSPENDED, AP_WAITING, D_ACTIVE, D_MAX, D_MIN, D_RETIRED, D_SUSPENDED, D_UNKNOWN
 
Constructor Summary
MobileAgent()
           
 
Method Summary
 void afterLoad()
           
protected  void afterMove()
          This method is executed as soon as the agent arrives to the new destination.
 void afterReload()
           
 void afterThaw()
           
 void beforeFreeze()
           
protected  void beforeMove()
          This method is executed just before moving the agent to another location.
 void beforeReload()
           
 void setup()
           
 void updateLocations(java.util.Iterator iLocationIterator)
           
 
Methods inherited from class jade.core.Agent
addBehaviour, afterClone, beforeClone, blockingReceive, blockingReceive, blockingReceive, blockingReceive, changeStateTo, clean, doActivate, doClone, doDelete, doMove, doSuspend, doTimeOut, doWait, doWait, doWake, getAgentState, getAID, getAMS, getArguments, getContainerController, getContentManager, getCurQueueSize, getDefaultDF, getHap, getHelper, getLocalName, getName, getO2AObject, getProperty, getQueueSize, getState, here, join, notifyChangeBehaviourState, notifyRestarted, postMessage, putBack, putO2AObject, receive, receive, removeBehaviour, restartLater, restore, restoreBufferedState, run, send, setArguments, setEnabledO2ACommunication, setGenerateBehaviourEvents, setQueueSize, takeDown, waitUntilStarted, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Locations

protected transient java.util.ArrayList Locations

EXIT

public static final int EXIT
See Also:
Constant Field Values

MOVE_EVENT

public static final int MOVE_EVENT
See Also:
Constant Field Values

STOP_EVENT

public static final int STOP_EVENT
See Also:
Constant Field Values

CONTINUE_EVENT

public static final int CONTINUE_EVENT
See Also:
Constant Field Values

REFRESH_EVENT

public static final int REFRESH_EVENT
See Also:
Constant Field Values

CLONE_EVENT

public static final int CLONE_EVENT
See Also:
Constant Field Values
Constructor Detail

MobileAgent

public MobileAgent()
Method Detail

setup

public void setup()
Overrides:
setup in class jade.core.Agent

beforeMove

protected void beforeMove()
This method is executed just before moving the agent to another location. It is automatically called by the JADE framework. It disposes the GUI and prints a bye message on the standard output.

Overrides:
beforeMove in class jade.core.Agent

afterMove

protected void afterMove()
This method is executed as soon as the agent arrives to the new destination. It registers the communication prerequisites.

Overrides:
afterMove in class jade.core.Agent

afterLoad

public void afterLoad()

beforeFreeze

public void beforeFreeze()

afterThaw

public void afterThaw()

beforeReload

public void beforeReload()

afterReload

public void afterReload()

updateLocations

public void updateLocations(java.util.Iterator iLocationIterator)