springs.context
Class Context_RMIImpl

java.lang.Object
  |
  +--springs.context.Context
        |
        +--springs.context.Context_RMIImpl
All Implemented Interfaces:
java.lang.Cloneable, ConfigurationParameters, ContextInterfaceForAgents, Debug

public class Context_RMIImpl
extends Context
implements java.lang.Cloneable

Note: While the initial RMI specifications clearly defined the client's programming model, they left considerable leeway about the server side. As a result, various RMI implementations export objects differently. For instance, if an object extends UnicastRemoteObject, the RMI runtime in the JDK will automatically export that object. How that exporting occurs, however, is beyond a developer's control and is specific to an RMI implementation. By the same token, how an object is unexported depends on an RMI implementation as well. Source: http://www.javaworld.com/javaworld/jw-12-2003/jw-1219-jiniology_p.html


Field Summary
private static springs.context.ContextManager_RMIImpl _contextManager
          The local Context Manager.
 
Fields inherited from class springs.context.Context
_accessService, _agentInfos, _context, _contextAddress, CONTEXT_ADDRESS_REGION_NAME_SERVER, CONTEXT_LOG_FILENAME, LOCALHOST, LOCALHOST_IP, START_CLASS_SERVER
 
Fields inherited from interface springs.common.ConfigurationParameters
_persistence, ACTIVATE_AUTOMATIC_REFERENCES_UPDATES, ACTIVATE_NAMING_SERVICE, AGENT_REFERENCES_UPDATER_NAME, BACKLOG, BLOCK_UNTIL_REFERENCE_UPDATED_IF_NEEDED, COLLECT_LOGS_CALLS, CONTEXT_MANAGER_NAME, CONTEXT_WATCHING_PERIOD, CRASH_WHEN_NOT_ENOUGH_MEMORY, CREATE_AGENTS_IN_BACKGROUND, DEFAULT_PORT_NUMBER_FOR_CONTEXTS, DELAY_DEPARTURES_IF_NEEDED, DISABLE_LOGGER, EXPORT_RETRIAL, FORCE_REMOVALS, HYBRID_STRATEGY_PROXY_UPDATE, INITIAL_SEPARATOR_URL, LAZY_UPDATE_AGENT_OBJECT, LEASE_VALUE, MAX_MILLIS_TO_WAIT_FOR_ARU, MAX_MILLIS_TO_WAIT_FOR_UPDATE_REFERENCE, MAX_TRIES_ASSIGNING_THREAD_TO_AGENT, MAXIMUM_NUMBER_OF_CONSECUTIVE_FAILED_PINGS, MILLIS_TO_KEEP_MARKED_TO_REMOVE_REFERENCES, MILLIS_TO_KEEP_UNUSED_LOCAL_REFERENCES, MILLIS_TO_WAIT_FOR_CLASS_SERVER_READY, MILLIS_TO_WAIT_FOR_RMI_REGISTRY_CREATION, MINIMUM_MILLIS_STAY_AT_CONTEXT, NUM_STAYS_TO_COMPUTE_AVERAGE_STAY, PERIOD_LARC, REBIND_RETRIAL, REGION_NAME_SERVER_NAME, RETRYING_STRATEGY_FOR_AGENT_SEARCHING, RETRYING_STRATEGY_FOR_CREATIONS, RETRYING_STRATEGY_FOR_INVOKATIONS, RETRYING_STRATEGY_FOR_REMOTE_REFERENCE_UPDATING, RETURN_CALL_RESULTS_WITH_STATISTICS, RMI_PROTOCOL, SECURITY_POLICY, TIME_BETWEEN_TRIES_ASSIGNING_THREAD_TO_AGENT, TIMEOUT_CONNECTION_RMI, TIMEOUT_RMI, TRACE_RMI_SERVERS, TRACKING_FACTOR, UPDATE_REFERENCES_IN_BACKGROUND, UPDATE_REFERENCES_WITH_AUXILIARY_THREAD, USE_CACHE_OF_CLASSES, USE_SOCKETS_COUNTING_BYTES, USE_SPECIFIC_SOCKET_FACTORY, WAIT_UNTIL_REFERENCES_UPDATED, WRITE_CONTEXT_LOGS_IN_STDOUT
 
Fields inherited from interface springs.common.Debug
DEBUG_ACCESS_SERVICE, DEBUG_BASIC, DEBUG_CLASS_LOADING, DEBUG_CONTEXT_MANAGER, DEBUG_CONTEXT_STATUS_WHEN_MEMORY_ERROR, DEBUG_CREATION, DEBUG_DELETING, DEBUG_NAMING_SERVICE, DEBUG_PROBLEMS_WITH_RMI_CLASS_LOADING, DEBUG_REFERENCE_UPDATER, DEBUG_REMOVAL, DEBUG_RMI, DEBUG_RMI_FAILURES, DEBUG_RNS, DEBUG_SEARCHING, DEBUG_SENDING, DEBUG_TIMES, LOG_CONTEXT_INFO, PRINT_EXCEPTION_FAILED_REMOTE_CALLS, PRINT_FAILED_MOVEMENTS, PRINT_FAILED_REMOTE_CALLS, PRINT_FAILED_REMOTE_REFERENCE_UPDATING, PRINT_FAILED_SEARCHINGS, PRINT_RETRYING_TASK_FAILURES, PROXY_QUEUE
 
Constructor Summary
private Context_RMIImpl(java.lang.String name, int port)
          Constructor.
 
Method Summary
 java.lang.Object callAgentMethod(java.lang.String agentName, java.lang.String methodName, boolean cacheRef, java.lang.String caller)
          This method invokes a method of the agent.
 java.lang.Object callAgentMethod(java.lang.String agentName, java.lang.String methodName, java.lang.Object[] args, boolean cacheRef, java.lang.String caller)
          This method invokes a method of the agent.
 java.lang.Object callAgentMethod(java.lang.String agentName, java.lang.String methodName, java.lang.Object[] args, java.lang.String caller)
          This method invokes a method of the agent, and caches the reference.
 java.lang.Object callAgentMethod(java.lang.String agentName, java.lang.String methodName, java.lang.String caller)
          This method invokes a method of the agent, and caches the reference.
 springs.communication.FutureResult callAgentMethodAsynchronously(java.lang.String agentName, java.lang.String methodName, boolean cacheRef, java.lang.String caller)
          This method invokes a method of the agent asynchronously.
 springs.communication.FutureResult callAgentMethodAsynchronously(java.lang.String agentName, java.lang.String methodName, java.lang.Object[] args, boolean cacheRef, java.lang.String caller)
          This method invokes a method of the agent asynchronously.
 springs.communication.FutureResult callAgentMethodAsynchronously(java.lang.String agentName, java.lang.String methodName, java.lang.Object[] args, java.lang.String caller)
          This method invokes a method of the agent asynchronously, and caches the reference.
 springs.communication.FutureResult callAgentMethodAsynchronously(java.lang.String agentName, java.lang.String methodName, java.lang.String caller)
          This method invokes a method of the agent asynchronously, and caches the reference.
 void checkpoint(springs.agent.SpringsAgent agent)
          Checkpoints the agent.
private static void checkRMISpringsAgent(springs.agent.SpringsAgent agent)
          Checks that the agent given is an RMI SpringsAgent.
 java.lang.Object clone()
           
static void create(java.lang.String name, int portNumber, int portClassServer, java.lang.String addressRNS)
          Starts a context.
static void create(java.lang.String name, int portNumber, java.lang.String addressRNS)
          Starts a context.
static void create(java.lang.String name, java.lang.String addressRNS)
          Starts a context.
static void createAgent(springs.context.ContextAddress contextAddress, springs.agent.SpringsAgent agent, java.lang.String agentName)
           
 void createAgent(springs.agent.SpringsAgent agent, java.lang.String agentName)
          Creates an agent.
static void createAgent(springs.agent.SpringsAgent agent, java.lang.String agentName, springs.context.ContextManager cm, boolean isMoving, springs.context.ContextAddress contextAddress)
           
 void createAgent(java.lang.String targetContext, springs.agent.SpringsAgent agent, java.lang.String agentName)
          Creates an agent.
 void deleteAgent(springs.agent.SpringsAgent agent)
          Deletes the given agent from the system.
 springs.context.ContextManager getContextManager(springs.context.ContextAddress contextAddress)
          Obtains the context manager at a certain address.
private static springs.context.ContextManager getContextManagerStatic(springs.context.ContextAddress contextAddress)
          Obtains the context manager at a certain address.
static springs.context.Context instance()
          Gets an instance to the context.
 boolean isSuspended(springs.agent.SpringsAgent agent)
          Obtains if the agent is suspended.
 void moveAgent(springs.agent.SpringsAgent agent, springs.context.ContextAddress contextAddress)
          Moves an agent.
private  void performMovement(springs.context.ContextAddress contextAddress, springs.agent.SpringsAgent agent)
          Performs the movement of the agent.
static void registerAgent(springs.agent.SpringsAgent agent, springs.context.ContextAddress localContextAddress, boolean isMoving)
          Registers an agent.
 void releaseReference(java.lang.String agentName)
          Releases a reference to the given agent, so that it must not be automatically updated anymore
 void removeAgent(springs.agent.SpringsAgent agent, boolean isMoving)
          Removes an agent.
 void sendAgent(springs.agent.SpringsAgent agent, springs.context.ContextAddress contextAddress, boolean isMoving)
          Sends an agent.
 springs.communication.FutureResult sendAsynchronousMessage(java.lang.String agentName, springs.communication.Message message, boolean cacheRef, java.lang.String caller)
          This method sends a message to the agent, asynchronously.
 java.lang.Object sendMessage(java.lang.String agentName, springs.communication.Message message, boolean asynchronous, boolean cacheRef, java.lang.String caller)
          This method sends a message to the agent.
 java.lang.Object sendMessage(java.lang.String agentName, springs.communication.Message message, boolean cacheRef, java.lang.String caller)
          This method sends a message to the agent, synchronously.
protected  void start(java.lang.String addressRNS)
          Starts a context.
private  void start(java.lang.String addressRNS, boolean startClassServer, int portClassServer)
          Starts a context.
protected  void start(java.lang.String addressRNS, int portClassServer)
          Starts a context.
 void suspend(springs.agent.SpringsAgent agent)
          Suspends the agent execution.
private  void unexport(springs.agent.SpringsAgent agent)
          Unexports an agent.
 void updateReferencesTo(springs.agent.SpringsAgent agent, boolean isToRemove)
          Updates the remote references to the given agent.
 void updateReferencesToWithThread(springs.agent.SpringsAgent agent, boolean isToRemove)
          Updates the remote references to the given agent, using an .
 void updateRemoteReferences(java.util.Hashtable contextsToReferences)
          Updates the remote references to local agents.
 
Methods inherited from class springs.context.Context
addAgentInfo, addContext, ensureMinimumStayTime, getAccessService, getAgent, getContextAddress, getContextAddress, getContexts, getContextStatus, getLocationServers, getMillisStay, getName, getNumAgents, getNumContexts, getNumLocationServers, getNumObservers, getNumTrackedAndObservedAgents, getObservers, getPortClassServer, getReferenceToLocalAgent, getStringForReferenceUpdates, initializeLocalIP, isLocalContext, logContextInfo, recordStartStay, referenceUsed, removeAgentInfo, removeContext, setContexts, setPortClassServer, stop
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_contextManager

private static springs.context.ContextManager_RMIImpl _contextManager
The local Context Manager.

See Also:
ContextManager_RMIImpl
Constructor Detail

Context_RMIImpl

private Context_RMIImpl(java.lang.String name,
                        int port)
Constructor. It is private, as required by the singleton pattern.

Parameters:
name - the name of the context.
port - the port number.
Method Detail

instance

public static springs.context.Context instance()
Gets an instance to the context.

Returns:
an instance to the context.
See Also:
Context

create

public static void create(java.lang.String name,
                          int portNumber,
                          java.lang.String addressRNS)
                   throws ContextStartingException
Starts a context.

Parameters:
name - the name of the context.
portNumber - the port number for the context.
addressRNS - the address of the Region Name Server. If any, pass null.
Throws:
ContextStartingException - if error.
See Also:
String, ContextStartingException

create

public static void create(java.lang.String name,
                          java.lang.String addressRNS)
                   throws ContextStartingException
Starts a context.

Parameters:
name - the name of the context.
addressRNS - the address of the Region Name Server. If any, pass null.
Throws:
ContextStartingException - if error.
See Also:
Context, String, ContextStartingException

create

public static void create(java.lang.String name,
                          int portNumber,
                          int portClassServer,
                          java.lang.String addressRNS)
                   throws ContextStartingException
Starts a context.

Parameters:
name - the name of the context.
portNumber - the port number for the context.
portClassServer - the port where to launch the class server.
addressRNS - the address of the Region Name Server. If any, pass null.
Throws:
ContextStartingException - if error.
See Also:
String, ContextStartingException

start

private void start(java.lang.String addressRNS,
                   boolean startClassServer,
                   int portClassServer)
            throws ContextStartingException
Starts a context.

Parameters:
addressRNS - the address of the Region Name Server. If any, pass null.
startClassServer - a boolean indicating whether a class server must be started.
portClassServer - the port where to launch the class server.
Throws:
ContextStartingException - if the context cannot be started.
See Also:
String, ContextStartingException

start

protected void start(java.lang.String addressRNS)
              throws ContextStartingException
Description copied from class: Context
Starts a context.

Specified by:
start in class Context
Parameters:
addressRNS - the address of the Region Name Server. If any, pass null.
Throws:
ContextStartingException - if the context cannot be started.
See Also:
String, ContextStartingException

start

protected void start(java.lang.String addressRNS,
                     int portClassServer)
              throws ContextStartingException
Description copied from class: Context
Starts a context.

Specified by:
start in class Context
Parameters:
addressRNS - the address of the Region Name Server. If any, pass null.
portClassServer - the port where to launch the class server.
Throws:
ContextStartingException - if the context cannot be started.
See Also:
String, ContextStartingException

createAgent

public static void createAgent(springs.agent.SpringsAgent agent,
                               java.lang.String agentName,
                               springs.context.ContextManager cm,
                               boolean isMoving,
                               springs.context.ContextAddress contextAddress)
                        throws CreationException
CreationException

createAgent

public void createAgent(java.lang.String targetContext,
                        springs.agent.SpringsAgent agent,
                        java.lang.String agentName)
                 throws CreationException
Description copied from class: Context
Creates an agent.

Overrides:
createAgent in class Context
Parameters:
targetContext - the name of the target context.
agent - the agent.
agentName - the name of the agent.
Throws:
CreationException - if error.
See Also:
CreationException

createAgent

public static void createAgent(springs.context.ContextAddress contextAddress,
                               springs.agent.SpringsAgent agent,
                               java.lang.String agentName)
                        throws CreationException
CreationException

createAgent

public void createAgent(springs.agent.SpringsAgent agent,
                        java.lang.String agentName)
                 throws CreationException
Description copied from interface: ContextInterfaceForAgents
Creates an agent.

Specified by:
createAgent in interface ContextInterfaceForAgents
Parameters:
agent - the agent.
agentName - the name of the agent.
CreationException
See Also:
SpringsAgent, String, CreationException

removeAgent

public void removeAgent(springs.agent.SpringsAgent agent,
                        boolean isMoving)
                 throws RemovalException
Description copied from class: Context
Removes an agent.

Specified by:
removeAgent in class Context
Parameters:
agent - the agent.
isMoving - a boolean indicating if the agent is sent because of a movement from another context.
RemovalException
See Also:
SpringsAgent, RemovalException

deleteAgent

public void deleteAgent(springs.agent.SpringsAgent agent)
                 throws RemovalException
Deletes the given agent from the system.

Specified by:
deleteAgent in interface ContextInterfaceForAgents
Parameters:
agent - the agent
Throws:
throws - RemovalException if error.
RemovalException
See Also:
SpringsAgent, RemovalException

sendAgent

public void sendAgent(springs.agent.SpringsAgent agent,
                      springs.context.ContextAddress contextAddress,
                      boolean isMoving)
               throws AgentMovementException
Description copied from interface: ContextInterfaceForAgents
Sends an agent.

Specified by:
sendAgent in interface ContextInterfaceForAgents
Parameters:
agent - the agent.
contextAddress - the target context.
isMoving - a boolean indicating if the agent is sent because of a movement from another context.
Throws:
AgentMovementException - if the agent cannot be moved to the target address.
See Also:
SpringsAgent, ContextAddress, AgentMovementException

moveAgent

public void moveAgent(springs.agent.SpringsAgent agent,
                      springs.context.ContextAddress contextAddress)
               throws AgentMovementException
Description copied from interface: ContextInterfaceForAgents
Moves an agent.

Specified by:
moveAgent in interface ContextInterfaceForAgents
Parameters:
agent - the agent.
contextAddress - the target context.
Throws:
AgentMovementException - if the agent cannot be moved to the target address.
See Also:
SpringsAgent, ContextAddress, AgentMovementException

performMovement

private void performMovement(springs.context.ContextAddress contextAddress,
                             springs.agent.SpringsAgent agent)
                      throws AgentMovementException
Performs the movement of the agent.

Parameters:
contextAddress - the context address.
agent - the agent.
Throws:
AgentMovementException - if the agent could not be moved.
See Also:
ContextAddress, SpringsAgent, AgentMovementException

updateRemoteReferences

public void updateRemoteReferences(java.util.Hashtable contextsToReferences)
                            throws CommunicationException
Description copied from class: Context
Updates the remote references to local agents.

Specified by:
updateRemoteReferences in class Context
Parameters:
contextsToReferences - a table that maps from contexts to information about how to update the references.
Throws:
CommunicationException - if error.
See Also:
Hashtable, CommunicationException

releaseReference

public void releaseReference(java.lang.String agentName)
                      throws ContextException
Description copied from class: Context
Releases a reference to the given agent, so that it must not be automatically updated anymore

Specified by:
releaseReference in class Context
Parameters:
agentName - the name of the agent.
Throws:
ContextException - if error.
See Also:
AgentReference, String, ContextException

callAgentMethod

public java.lang.Object callAgentMethod(java.lang.String agentName,
                                        java.lang.String methodName,
                                        java.lang.Object[] args,
                                        java.lang.String caller)
                                 throws MethodCallException,
                                        CommunicationException
Description copied from interface: ContextInterfaceForAgents
This method invokes a method of the agent, and caches the reference.

Specified by:
callAgentMethod in interface ContextInterfaceForAgents
Parameters:
agentName - the name of the target agent.
methodName - the name of the method.
args - the arguments to the method.
caller - the name of the caller agent.
Returns:
the result of the method invocation.
Throws:
CommunicationException - if there is a communication error.
MethodCallException - if the invocation fails.
See Also:
MethodCallException, CommunicationException, String, Object

callAgentMethod

public java.lang.Object callAgentMethod(java.lang.String agentName,
                                        java.lang.String methodName,
                                        java.lang.Object[] args,
                                        boolean cacheRef,
                                        java.lang.String caller)
                                 throws MethodCallException,
                                        CommunicationException
Description copied from interface: ContextInterfaceForAgents
This method invokes a method of the agent.

Specified by:
callAgentMethod in interface ContextInterfaceForAgents
Parameters:
agentName - the name of the target agent.
methodName - the name of the method.
args - the arguments to the method.
cacheRef - a boolean indicating whether the reference to the agent should be cached.
caller - the name of the caller agent.
Returns:
the result of the method invocation.
Throws:
MethodCallException - if the invocation fails.
CommunicationException - if there is a communication error.
See Also:
MethodCallException, CommunicationException, String, Object

callAgentMethod

public java.lang.Object callAgentMethod(java.lang.String agentName,
                                        java.lang.String methodName,
                                        boolean cacheRef,
                                        java.lang.String caller)
                                 throws MethodCallException,
                                        CommunicationException
Description copied from interface: ContextInterfaceForAgents
This method invokes a method of the agent.

Specified by:
callAgentMethod in interface ContextInterfaceForAgents
Parameters:
agentName - the name of the target agent.
methodName - the name of the method.
cacheRef - a boolean indicating whether the reference to the agent should be cached.
caller - the name of the caller agent.
Returns:
the result of the method invocation.
Throws:
CommunicationException - if there is a communication error.
MethodCallException - if the invocation fails.
See Also:
CommunicationException, MethodCallException, String, Object

callAgentMethod

public java.lang.Object callAgentMethod(java.lang.String agentName,
                                        java.lang.String methodName,
                                        java.lang.String caller)
                                 throws MethodCallException,
                                        CommunicationException
Description copied from interface: ContextInterfaceForAgents
This method invokes a method of the agent, and caches the reference.

Specified by:
callAgentMethod in interface ContextInterfaceForAgents
Parameters:
agentName - the name of the target agent.
methodName - the name of the method.
caller - the name of the caller agent.
Returns:
the result of the method invocation.
Throws:
MethodCallException - if the invocation fails.
CommunicationException - if there is a communication error.
See Also:
CommunicationException, MethodCallException, String, Object

callAgentMethodAsynchronously

public springs.communication.FutureResult callAgentMethodAsynchronously(java.lang.String agentName,
                                                                        java.lang.String methodName,
                                                                        java.lang.Object[] args,
                                                                        boolean cacheRef,
                                                                        java.lang.String caller)
                                                                 throws AgentReferenceException
Description copied from interface: ContextInterfaceForAgents
This method invokes a method of the agent asynchronously.

Specified by:
callAgentMethodAsynchronously in interface ContextInterfaceForAgents
Parameters:
agentName - the name of the target agent.
methodName - the name of the method.
args - the arguments to the method.
cacheRef - a boolean indicating whether the reference to the agent should be cached.
caller - the name of the caller agent.
Returns:
a placeholder for the future result of the invocation.
Throws:
AgentReferenceException - if error.
See Also:
FutureResult, AgentReferenceException, String, Object

callAgentMethodAsynchronously

public springs.communication.FutureResult callAgentMethodAsynchronously(java.lang.String agentName,
                                                                        java.lang.String methodName,
                                                                        java.lang.Object[] args,
                                                                        java.lang.String caller)
                                                                 throws AgentReferenceException
Description copied from interface: ContextInterfaceForAgents
This method invokes a method of the agent asynchronously, and caches the reference.

Specified by:
callAgentMethodAsynchronously in interface ContextInterfaceForAgents
Parameters:
agentName - the name of the target agent.
methodName - the name of the method.
args - the arguments to the method.
caller - the name of the caller agent.
Returns:
a placeholder for the future result of the invocation.
Throws:
AgentReferenceException - if error.
See Also:
FutureResult, AgentReferenceException, String, Object

callAgentMethodAsynchronously

public springs.communication.FutureResult callAgentMethodAsynchronously(java.lang.String agentName,
                                                                        java.lang.String methodName,
                                                                        boolean cacheRef,
                                                                        java.lang.String caller)
                                                                 throws AgentReferenceException
Description copied from interface: ContextInterfaceForAgents
This method invokes a method of the agent asynchronously.

Specified by:
callAgentMethodAsynchronously in interface ContextInterfaceForAgents
Parameters:
agentName - the name of the target agent.
methodName - the name of the method.
cacheRef - a boolean indicating whether the reference to the agent should be cached.
caller - the name of the caller agent.
Returns:
a placeholder for the future result of the invocation.
Throws:
AgentReferenceException - if error.
See Also:
FutureResult, AgentReferenceException, String, Object

callAgentMethodAsynchronously

public springs.communication.FutureResult callAgentMethodAsynchronously(java.lang.String agentName,
                                                                        java.lang.String methodName,
                                                                        java.lang.String caller)
                                                                 throws AgentReferenceException
Description copied from interface: ContextInterfaceForAgents
This method invokes a method of the agent asynchronously, and caches the reference.

Specified by:
callAgentMethodAsynchronously in interface ContextInterfaceForAgents
Parameters:
agentName - the name of the target agent.
methodName - the name of the method.
caller - the name of the caller agent.
Returns:
a placeholder for the future result of the invocation.
Throws:
AgentReferenceException - if error.
See Also:
FutureResult, AgentReferenceException, String, Object

sendMessage

public java.lang.Object sendMessage(java.lang.String agentName,
                                    springs.communication.Message message,
                                    boolean cacheRef,
                                    java.lang.String caller)
                             throws CommunicationException
Description copied from interface: ContextInterfaceForAgents
This method sends a message to the agent, synchronously.

Specified by:
sendMessage in interface ContextInterfaceForAgents
Parameters:
agentName - the name of the target agent.
message - the message.
cacheRef - a boolean indicating whether the reference to the agent should be cached.
caller - the name of the caller agent.
Returns:
a possible result from the target agent.
Throws:
CommunicationException - if there is a communication error.
See Also:
Message, if there is a communication error.

sendAsynchronousMessage

public springs.communication.FutureResult sendAsynchronousMessage(java.lang.String agentName,
                                                                  springs.communication.Message message,
                                                                  boolean cacheRef,
                                                                  java.lang.String caller)
                                                           throws CommunicationException
Description copied from interface: ContextInterfaceForAgents
This method sends a message to the agent, asynchronously.

Specified by:
sendAsynchronousMessage in interface ContextInterfaceForAgents
Parameters:
agentName - the name of the target agent.
message - the message.
cacheRef - a boolean indicating whether the reference to the agent should be cached.
caller - the name of the caller agent.
Returns:
a placeholder for the future result from the target agent.
Throws:
CommunicationException - if there is a communication error.
See Also:
FutureResult, Message

sendMessage

public java.lang.Object sendMessage(java.lang.String agentName,
                                    springs.communication.Message message,
                                    boolean asynchronous,
                                    boolean cacheRef,
                                    java.lang.String caller)
                             throws CommunicationException
Description copied from interface: ContextInterfaceForAgents
This method sends a message to the agent.

Specified by:
sendMessage in interface ContextInterfaceForAgents
Parameters:
agentName - the name of the target agent.
message - the message.
asynchronous - a boolean indicating whether the message should be sent asynchronously or not.
cacheRef - a boolean indicating whether the reference to the agent should be cached.
caller - the name of the caller agent.
Returns:
a possible result from the target agent if the message is sent synchronously; a placeholder for the future result if it is sent asynchronously.
Throws:
CommunicationException - if there is a communication error.
See Also:
Message

getContextManager

public springs.context.ContextManager getContextManager(springs.context.ContextAddress contextAddress)
                                                 throws CommunicationException
Description copied from class: Context
Obtains the context manager at a certain address.

Specified by:
getContextManager in class Context
Parameters:
contextAddress - the context address.
Returns:
the context manager.
Throws:
CommunicationException - if error.
See Also:
ContextAddress, ContextManager, CommunicationException

isSuspended

public boolean isSuspended(springs.agent.SpringsAgent agent)
Description copied from interface: ContextInterfaceForAgents
Obtains if the agent is suspended.

Specified by:
isSuspended in interface ContextInterfaceForAgents
Parameters:
agent - the agent.
Returns:
a boolean indicating whether the agent is suspended.
See Also:
SpringsAgent

suspend

public void suspend(springs.agent.SpringsAgent agent)
Description copied from interface: ContextInterfaceForAgents
Suspends the agent execution.

Specified by:
suspend in interface ContextInterfaceForAgents
Parameters:
agent - the agent.
See Also:
SpringsAgent

checkpoint

public void checkpoint(springs.agent.SpringsAgent agent)
Description copied from interface: ContextInterfaceForAgents
Checkpoints the agent.

Specified by:
checkpoint in interface ContextInterfaceForAgents
Parameters:
agent - the agent.
See Also:
SpringsAgent

getContextManagerStatic

private static springs.context.ContextManager getContextManagerStatic(springs.context.ContextAddress contextAddress)
                                                               throws CommunicationException
Obtains the context manager at a certain address.

Parameters:
contextAddress - the context address.
Returns:
the context manager.
Throws:
CommunicationException - if error.
See Also:
ContextAddress, ContextManager, CommunicationException

unexport

private void unexport(springs.agent.SpringsAgent agent)
               throws java.lang.Exception
Unexports an agent.

Parameters:
agent - the agent.
Throws:
java.lang.Exception - if error.
See Also:
SpringsAgent, Exception

checkRMISpringsAgent

private static void checkRMISpringsAgent(springs.agent.SpringsAgent agent)
                                  throws java.lang.IllegalArgumentException
Checks that the agent given is an RMI SpringsAgent.

Parameters:
agent - the agent.
Throws:
java.lang.IllegalArgumentException - if the agent is not an RMI SpringsAgent.
See Also:
SpringsAgent

registerAgent

public static void registerAgent(springs.agent.SpringsAgent agent,
                                 springs.context.ContextAddress localContextAddress,
                                 boolean isMoving)
                          throws CreationException,
                                 AlreadyExistingAgentException
Registers an agent.

Parameters:
agent - the agent.
localContextAddress - the address of the local context.
isMoving - a boolean indicating whether the agent is moving or not.
Throws:
CreationException - if error.
AlreadyExistingAgentException - if the agent cannot be registered because it already exist at the context.
See Also:
SpringsAgent, ContextAddress, CreationException, AlreadyExistingAgentException

updateReferencesToWithThread

public void updateReferencesToWithThread(springs.agent.SpringsAgent agent,
                                         boolean isToRemove)
                                  throws CommunicationException
Updates the remote references to the given agent, using an .

Parameters:
agent - the agent.
isToRemove - a boolean indicating whether the reference should be removed.
Throws:
CommunicationException - if error.
See Also:
SpringsAgent, CommunicationException

updateReferencesTo

public void updateReferencesTo(springs.agent.SpringsAgent agent,
                               boolean isToRemove)
                        throws CommunicationException
Updates the remote references to the given agent.

Parameters:
agent - the agent.
isToRemove - a boolean indicating whether the reference should be removed.
Throws:
CommunicationException - if error.
See Also:
SpringsAgent, CommunicationException

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException - as required by the singleton pattern.