springs.tests
Class MovingSpringsHelloAgent

java.lang.Object
  |
  +--java.rmi.server.RemoteObject
        |
        +--java.rmi.server.RemoteServer
              |
              +--java.rmi.server.UnicastRemoteObject
                    |
                    +--springs.agent.SpringsAgent_RMIImpl
                          |
                          +--springs.tests.MovingSpringsHelloAgent
All Implemented Interfaces:
IMovingSpringsHelloAgent, ISpringsAgent_RMIImpl, java.rmi.Remote, java.io.Serializable, SpringsAgent

public class MovingSpringsHelloAgent
extends SpringsAgent_RMIImpl
implements IMovingSpringsHelloAgent

A Springs agent that moves around and writes "hello world" in the standard output.

Author:
Sergio Ilarri Artigas
See Also:
Serialized Form

Field Summary
private  int _numTravelsPerformed
           
static int NUM_TRAVELS_TO_PERFORM
           
static boolean RETURN_HOME
           
static int[] TARGET_PORTS
           
static java.lang.String[] TARGET_URLS
           
 
Fields inherited from class springs.agent.SpringsAgent_RMIImpl
_numberOfJumps
 
Fields inherited from class java.rmi.server.UnicastRemoteObject
 
Fields inherited from class java.rmi.server.RemoteServer
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Fields inherited from interface springs.agent.SpringsAgent
METHOD_MESSAGE_RECEPTION
 
Fields inherited from interface springs.agent.ISpringsAgent_RMIImpl
ADD_OBSERVER_METHOD, REMOVE_OBSERVER_METHOD
 
Constructor Summary
MovingSpringsHelloAgent()
           
 
Method Summary
 void afterCreation()
          Method called just after creating the agent on a certain context.
 void afterRemoval()
          Method called just after removing the agent from a certain context.
 void beforeCreation()
          Method called just before creating the agent on a certain context.
 void beforeRemoval()
          Method called just before removing the agent from a certain context.
 void endTravels()
          End of travels.
 void endTravelsWithWill(java.lang.String willReceiver)
          End of travels.
 void main()
          Main method of the agent.
 void main1()
          All the agent's task in a single method and using a status variable to keep track of the number of trips performed.
 void postArrival()
          It executes after the agent has arrived at the destination.
 void postDeparture()
          It executes on the original stale object at the source, and is typically defined to perform activities such as removing the stale object from persistence.
 void preArrival()
          This method is executed on the copy of the object at the destination.
 void preDeparture(java.lang.String originContext, java.lang.String targetContext)
          This method is executed on the original object at the source.
 void travel1()
          The first travel.
 void travel2()
          The second travel.
 void travel3()
          The third travel.
 
Methods inherited from class springs.agent.SpringsAgent_RMIImpl
addObserver, addTaskToSchedule, addTaskToSchedule, addTaskToSchedule, addTaskToSchedule, addTaskToSchedule, atHome, callAgentMethod, callAgentMethod, callAgentMethodAsynchronously, callAgentMethodAsynchronously, callback, checkpoint, getAddress, getAgentInitializationTime, getAgentMoving, getArgsCallbackMethod, getCallbackMethod, getCodebase, getContextInterfaceForAgents, getContextName, getHomeAddress, getHostname, getLocationServers, getMillisStay, getMillisWhenCreated, getName, getNameWithContext, getNumObservers, getObservers, getObserversAddresses, getPort, getSchedule, getSequenceNumberForAddressUpdateMessages, getURL, goHome, goHome, goHome, handleMessage, hasCallbackMethod, increaseSequenceNumberForAddressUpdateMessages, initialization, initializationAfterMovement, isSuspended, justCreatedForTheFirstTime, moreTasksInSchedule, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveToURL, moveToURL, moveToURL, moveToURL, receiveMethodCall, recordEndStay, recordStartStay, remove, removeObserver, sendAsynchronousMessage, sendMessage, sendMessage, setAgentInitializationTime, setAgentMoving, setCacheReferences, setCallbackMethod, setCodebase, setContextInterfaceForAgents, setHomeAddress, setLocationServers, setName, start, suspend, takeNextTask
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

RETURN_HOME

public static boolean RETURN_HOME

NUM_TRAVELS_TO_PERFORM

public static int NUM_TRAVELS_TO_PERFORM

TARGET_URLS

public static java.lang.String[] TARGET_URLS

TARGET_PORTS

public static int[] TARGET_PORTS

_numTravelsPerformed

private int _numTravelsPerformed
Constructor Detail

MovingSpringsHelloAgent

public MovingSpringsHelloAgent()
                        throws java.rmi.RemoteException
Method Detail

main

public void main()
Main method of the agent.

Specified by:
main in interface SpringsAgent
Overrides:
main in class SpringsAgent_RMIImpl

main1

public void main1()
All the agent's task in a single method and using a status variable to keep track of the number of trips performed.


travel1

public void travel1()
The first travel.


travel2

public void travel2()
The second travel.


travel3

public void travel3()
The third travel.


endTravels

public void endTravels()
End of travels.


endTravelsWithWill

public void endTravelsWithWill(java.lang.String willReceiver)
End of travels.

Parameters:
willReceiver - the name of the person that will get the possessions of the agent (nothing!) after it dies.
See Also:
String

beforeCreation

public void beforeCreation()
Description copied from interface: SpringsAgent
Method called just before creating the agent on a certain context.

Specified by:
beforeCreation in interface SpringsAgent
Overrides:
beforeCreation in class SpringsAgent_RMIImpl

afterCreation

public void afterCreation()
Description copied from interface: SpringsAgent
Method called just after creating the agent on a certain context.

Specified by:
afterCreation in interface SpringsAgent
Overrides:
afterCreation in class SpringsAgent_RMIImpl

beforeRemoval

public void beforeRemoval()
Description copied from interface: SpringsAgent
Method called just before removing the agent from a certain context.

Specified by:
beforeRemoval in interface SpringsAgent
Overrides:
beforeRemoval in class SpringsAgent_RMIImpl

afterRemoval

public void afterRemoval()
Description copied from interface: SpringsAgent
Method called just after removing the agent from a certain context.

Specified by:
afterRemoval in interface SpringsAgent
Overrides:
afterRemoval in class SpringsAgent_RMIImpl

postArrival

public void postArrival()
Description copied from interface: SpringsAgent
It executes after the agent has arrived at the destination. At this point the movement is deemed successful.

Specified by:
postArrival in interface SpringsAgent
Overrides:
postArrival in class SpringsAgent_RMIImpl

postDeparture

public void postDeparture()
Description copied from interface: SpringsAgent
It executes on the original stale object at the source, and is typically defined to perform activities such as removing the stale object from persistence.

Specified by:
postDeparture in interface SpringsAgent
Overrides:
postDeparture in class SpringsAgent_RMIImpl

preArrival

public void preArrival()
Description copied from interface: SpringsAgent
This method is executed on the copy of the object at the destination.

Specified by:
preArrival in interface SpringsAgent
Overrides:
preArrival in class SpringsAgent_RMIImpl

preDeparture

public void preDeparture(java.lang.String originContext,
                         java.lang.String targetContext)
Description copied from interface: SpringsAgent
This method is executed on the original object at the source.

Specified by:
preDeparture in interface SpringsAgent
Overrides:
preDeparture in class SpringsAgent_RMIImpl
Parameters:
originContext - the origin context.
targetContext - the target context.
See Also:
String