springs.context
Interface ContextInterfaceForAgents

All Known Implementing Classes:
Context

public interface ContextInterfaceForAgents

The interface for a proxy to a context.

Author:
Sergio Ilarri Artigas

Method Summary
 java.lang.Object callAgentMethod(java.lang.String targetAgent, 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 targetAgent, 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 targetAgent, 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 targetAgent, 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 targetAgent, 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 targetAgent, 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 targetAgent, 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 targetAgent, 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.
 void createAgent(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.ContextAddress getContextAddress()
          Gets the context address.
 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.
 void sendAgent(springs.agent.SpringsAgent agent, springs.context.ContextAddress contextAddress, boolean isMoving)
          Sends an agent.
 springs.communication.FutureResult sendAsynchronousMessage(java.lang.String targetAgent, 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 targetAgent, 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 targetAgent, springs.communication.Message message, boolean cacheRef, java.lang.String caller)
          This method sends a message to the agent, synchronously.
 void suspend(springs.agent.SpringsAgent agent)
          Suspends the agent execution.
 

Method Detail

createAgent

public void createAgent(springs.agent.SpringsAgent agent,
                        java.lang.String agentName)
                 throws CreationException
Creates an agent.

Parameters:
agent - the agent.
agentName - the name of the agent.
Throws:
throws - CreationException if error.
CreationException
See Also:
SpringsAgent, String, CreationException

deleteAgent

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

Parameters:
agent - the agent
Throws:
throws - RemovalException if error.
RemovalException
See Also:
SpringsAgent, RemovalException

getContextAddress

public springs.context.ContextAddress getContextAddress()
Gets the context address.

Returns:
the context address.
See Also:
ContextAddress

sendAgent

public void sendAgent(springs.agent.SpringsAgent agent,
                      springs.context.ContextAddress contextAddress,
                      boolean isMoving)
               throws AgentMovementException
Sends an agent.

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
Moves an agent.

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

isSuspended

public boolean isSuspended(springs.agent.SpringsAgent agent)
Obtains if the agent is suspended.

Parameters:
agent - the agent.
Returns:
a boolean indicating whether the agent is suspended.
See Also:
SpringsAgent

suspend

public void suspend(springs.agent.SpringsAgent agent)
Suspends the agent execution.

Parameters:
agent - the agent.
See Also:
SpringsAgent

checkpoint

public void checkpoint(springs.agent.SpringsAgent agent)
Checkpoints the agent.

Parameters:
agent - the agent.
See Also:
SpringsAgent

callAgentMethod

public java.lang.Object callAgentMethod(java.lang.String targetAgent,
                                        java.lang.String methodName,
                                        java.lang.Object[] args,
                                        boolean cacheRef,
                                        java.lang.String caller)
                                 throws MethodCallException,
                                        CommunicationException
This method invokes a method of the agent.

Parameters:
targetAgent - 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 targetAgent,
                                        java.lang.String methodName,
                                        java.lang.Object[] args,
                                        java.lang.String caller)
                                 throws MethodCallException,
                                        CommunicationException
This method invokes a method of the agent, and caches the reference.

Parameters:
targetAgent - 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:
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 targetAgent,
                                        java.lang.String methodName,
                                        boolean cacheRef,
                                        java.lang.String caller)
                                 throws MethodCallException,
                                        CommunicationException
This method invokes a method of the agent.

Parameters:
targetAgent - 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:
MethodCallException - if the invocation fails.
CommunicationException - if there is a communication error.
See Also:
CommunicationException, MethodCallException, String, Object

callAgentMethod

public java.lang.Object callAgentMethod(java.lang.String targetAgent,
                                        java.lang.String methodName,
                                        java.lang.String caller)
                                 throws MethodCallException,
                                        CommunicationException
This method invokes a method of the agent, and caches the reference.

Parameters:
targetAgent - 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 targetAgent,
                                                                        java.lang.String methodName,
                                                                        java.lang.Object[] args,
                                                                        boolean cacheRef,
                                                                        java.lang.String caller)
                                                                 throws AgentReferenceException
This method invokes a method of the agent asynchronously.

Parameters:
targetAgent - 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 targetAgent,
                                                                        java.lang.String methodName,
                                                                        java.lang.Object[] args,
                                                                        java.lang.String caller)
                                                                 throws AgentReferenceException
This method invokes a method of the agent asynchronously, and caches the reference.

Parameters:
targetAgent - 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 targetAgent,
                                                                        java.lang.String methodName,
                                                                        boolean cacheRef,
                                                                        java.lang.String caller)
                                                                 throws AgentReferenceException
This method invokes a method of the agent asynchronously.

Parameters:
targetAgent - 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 targetAgent,
                                                                        java.lang.String methodName,
                                                                        java.lang.String caller)
                                                                 throws AgentReferenceException
This method invokes a method of the agent asynchronously, and caches the reference.

Parameters:
targetAgent - 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 targetAgent,
                                    springs.communication.Message message,
                                    boolean cacheRef,
                                    java.lang.String caller)
                             throws CommunicationException
This method sends a message to the agent, synchronously.

Parameters:
targetAgent - 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 targetAgent,
                                                                  springs.communication.Message message,
                                                                  boolean cacheRef,
                                                                  java.lang.String caller)
                                                           throws CommunicationException
This method sends a message to the agent, asynchronously.

Parameters:
targetAgent - 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 targetAgent,
                                    springs.communication.Message message,
                                    boolean asynchronous,
                                    boolean cacheRef,
                                    java.lang.String caller)
                             throws CommunicationException
This method sends a message to the agent.

Parameters:
targetAgent - 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