ADK CVS

tryllian.afc.standalone
Class StandaloneAgent

java.lang.Object
  extended bytryllian.afc.agent.AbstractAgent
      extended bytryllian.afc.standalone.StandaloneAgent
All Implemented Interfaces:
AgentContext, MessageDispatcher, java.io.Serializable

public class StandaloneAgent
extends AbstractAgent

Agent that can be run without launching an ARE. Since a StandaloneAgent cannot use an ARE, every StandaloneAgent needs its own Messenger to send messages. Also, all operations that really need ARE support cannot be performed; for example, it cannot move.
Creating a StandaloneAgent with the default constructor will result in a StandaloneMessenger being created.
Not supported by this agent

See Also:
Serialized Form

Constructor Summary
StandaloneAgent()
           
StandaloneAgent(tryllian.are.messenger.Messenger messenger)
          Creates a new agent.
 
Method Summary
 void addMoveListener(MoveListener listener)
          Registers a listener to move events.
protected  void agentStarted()
          Override this method to perform one-time initializations.
protected  tryllian.are.messenger.Messenger createDefaultMessenger()
          Returns a new messenger that is used when this class is created by way of its default constructor, and specifying no (therefore using all default) property values.
 Directory getDirectory()
          Returns the Directory that can be used to get addressing information.
 java.util.Date getDNACreationDate()
          Returns the creation date of the DNA file.
protected  MessageDispatcher getMessageDispatcher()
           
 MessageFactory getMessageFactory()
          Returns the message factory.
 javax.naming.Context getNamingContext()
          Returns the JNDI naming context.
 void removeMoveListener(MoveListener listener)
          Deregisters a listener to move events.
 void requestMove(AddressURI location)
          Requests a move to another location.
 void requestMove(java.lang.String location)
          Requests a move to another location.
 void scheduleRoutine(StoppableRunnable target)
          Schedules a thread for execution.
 void start()
           
 
Methods inherited from class tryllian.afc.agent.AbstractAgent
addCommonMessageHandler, addDeliveryReportListener, addOutgoingMessageListener, addProperties, addPropertyChangeListener, addPropertyChangeListener, addTask, createConversation, getLanguageContext, getMainTask, getMyAddress, getName, getOrCreateConversationFor, getProperties, getProperty, getPropertyKeys, removeCommonMessageHandler, removeDeliveryReportListener, removeOutgoingMessageListener, removePropertyChangeListener, send, setName, setProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StandaloneAgent

public StandaloneAgent()

StandaloneAgent

public StandaloneAgent(tryllian.are.messenger.Messenger messenger)
Creates a new agent.

Method Detail

createDefaultMessenger

protected tryllian.are.messenger.Messenger createDefaultMessenger()
Returns a new messenger that is used when this class is created by way of its default constructor, and specifying no (therefore using all default) property values.


getMessageDispatcher

protected MessageDispatcher getMessageDispatcher()
Specified by:
getMessageDispatcher in class AbstractAgent

start

public void start()

agentStarted

protected void agentStarted()
Override this method to perform one-time initializations. This method called after the agent context has been initialized (which is the main advantage it has over using your constructor). The implementation is empty, so when overriding it, you don't have to call super.agentStarted().


addMoveListener

public void addMoveListener(MoveListener listener)
Description copied from interface: AgentContext
Registers a listener to move events.


getNamingContext

public javax.naming.Context getNamingContext()
                                      throws javax.naming.NamingException
Description copied from interface: AgentContext
Returns the JNDI naming context.

Throws:
javax.naming.NamingException

getMessageFactory

public MessageFactory getMessageFactory()
Description copied from interface: AgentContext
Returns the message factory.


getDirectory

public Directory getDirectory()
Description copied from interface: AgentContext
Returns the Directory that can be used to get addressing information.


removeMoveListener

public void removeMoveListener(MoveListener listener)
Description copied from interface: AgentContext
Deregisters a listener to move events.


requestMove

public void requestMove(AddressURI location)
Description copied from interface: AgentContext
Requests a move to another location. The status of the move (requested, failed, succeeded) is made known through the move event mechanism. request a move, you should register yourself as a MoveListener to know when you've actually moved.

Parameters:
location - the location to move to (only the habitat part is used).

requestMove

public void requestMove(java.lang.String location)
Description copied from interface: AgentContext
Requests a move to another location. The status of the move (requested, failed, succeeded) is made known through the move event mechanism. So if you request a move, you should register yourself as a MoveListener to know when you've actually moved.

Parameters:
location - the name of the habitat to move to.
See Also:
AgentContext.addMoveListener(tryllian.afc.task.MoveListener)

getDNACreationDate

public java.util.Date getDNACreationDate()
Description copied from interface: AgentContext
Returns the creation date of the DNA file.

Returns:
the creation date, or null if unknown.

scheduleRoutine

public void scheduleRoutine(StoppableRunnable target)
Description copied from interface: AgentContext
Schedules a thread for execution.

Parameters:
target - a Runnable with stop() method.

Copyright 2005, Tryllian Solutions B.V.