springs.access
Class AccessService

java.lang.Object
  |
  +--springs.access.AccessService

public class AccessService
extends java.lang.Object

The access service.

Author:
Sergio Ilarri Artigas

Nested Class Summary
(package private)  class AccessService.RetryingGettingReference
          Note: it seems that the searching could be improved by looking if it is among the local references outside the thread (in a way that we can avoid creating a thread every time): however, the reference could disappeared from the list of local references causing a fail that cannot be captured unless it is within the boundaries of a retrying task.
 
Field Summary
protected  springs.access.AgentReferencesUpdater _agentReferencesUpdater
          The updater of remote references to agents.
protected  springs.access.LocalAgentReferencesCollector _larc
          The collector of unused local references to agents.
protected  springs.access.LocalAgentReferences _localReferencesToAgents
          Stores information about local references to agents.
private  java.lang.String _lockForSeach
           
protected  java.util.Hashtable _referenceGetters
           
 
Constructor Summary
AccessService()
          Constructor.
 
Method Summary
 void deleteAllReferencesTo(springs.agent.SpringsAgent agent, java.lang.String localContextName)
          Records the need of deleting the remote references to the given agent.
 springs.access.LocalAgentReferences getLocalReferencesToAgent()
          Obtains the local references to the agents.
 int getNumberOfReferences()
          Obtains the number of references.
 springs.access.AgentReference getReference(java.lang.String agentName)
          Obtains a reference to an agent.
 springs.access.AgentReference getReference(java.lang.String agentName, boolean registerAsObserver)
          Obtains a reference to an agent by searching it remotely.
 springs.access.AgentReference getReferenceFromLocalAgents(java.lang.String agentName, boolean mustBeAutomaticUpdate)
          Gets a reference to a locally-executing agent.
 springs.access.AgentReference getReferenceFromTable(java.lang.String agentName)
          Gets a reference searching only locally.
 void referenceUsed(java.lang.String agentName)
          Notifies the context that a reference to the given agent has been used.
 void removeNeedToUpdateReferenceTo(java.lang.String agentName)
          Removes the need to update the remote references to the given agent (e.g., because the agent has moved to another context).
 void removeReference(java.lang.String agentName)
          Removes a reference to an agent.
 void terminate()
          Shuts the access service down.
 void updateAllReferencesTo(springs.agent.SpringsAgent agent, java.lang.String localContextName)
          Records the need of updating the remote references to the given agent.
 void updateReference(java.lang.String agentName, java.lang.String context, int seqNum, boolean youAreLocationServer, long millisWhenCreated)
          Updates the reference to the given agent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_localReferencesToAgents

protected springs.access.LocalAgentReferences _localReferencesToAgents
Stores information about local references to agents.

See Also:
LocalAgentReferences

_larc

protected springs.access.LocalAgentReferencesCollector _larc
The collector of unused local references to agents.

See Also:
LocalAgentReferencesCollector

_agentReferencesUpdater

protected springs.access.AgentReferencesUpdater _agentReferencesUpdater
The updater of remote references to agents.

See Also:
AgentReferencesUpdater

_referenceGetters

protected java.util.Hashtable _referenceGetters

_lockForSeach

private java.lang.String _lockForSeach
Constructor Detail

AccessService

public AccessService()
Constructor.

Method Detail

getReference

public springs.access.AgentReference getReference(java.lang.String agentName)
                                           throws AgentReferenceException
Obtains a reference to an agent.

Parameters:
agentName - the name of the agent.
Returns:
a reference.
Throws:
AgentReferenceException - if error.
See Also:
AgentReference, AgentReferenceException

getReference

public springs.access.AgentReference getReference(java.lang.String agentName,
                                                  boolean registerAsObserver)
                                           throws AgentReferenceException
Obtains a reference to an agent by searching it remotely.

Parameters:
agentName - the name of the agent.
registerAsObserver - a boolean indicating whether the context should register itself as an observer for the agent.
Returns:
a reference.
Throws:
AgentReferenceException - if the agent cannot be found.
See Also:
AgentReference, AgentReferenceException

getNumberOfReferences

public int getNumberOfReferences()
Obtains the number of references.

Returns:
the number of references.

updateReference

public void updateReference(java.lang.String agentName,
                            java.lang.String context,
                            int seqNum,
                            boolean youAreLocationServer,
                            long millisWhenCreated)
Updates the reference to the given agent.

Parameters:
agentName - the agent name.
context - the context.
seqNum - a number to identify the sequence number for the current address of the agent.
youAreLocationServer - a boolean indicating whether this agent is a location server.
millisWhenCreated - the millis when the agent was created.
See Also:
String

removeReference

public void removeReference(java.lang.String agentName)
Removes a reference to an agent.

Parameters:
agentName - the name of the agent.
See Also:
String

getLocalReferencesToAgent

public springs.access.LocalAgentReferences getLocalReferencesToAgent()
Obtains the local references to the agents.

Returns:
the local references.
See Also:
LocalAgentReferences

referenceUsed

public void referenceUsed(java.lang.String agentName)
Notifies the context that a reference to the given agent has been used.

Parameters:
agentName - the name of the agent.
See Also:
String

updateAllReferencesTo

public void updateAllReferencesTo(springs.agent.SpringsAgent agent,
                                  java.lang.String localContextName)
Records the need of updating the remote references to the given agent.

Parameters:
agent - the agent.
localContextName - the local context name.
See Also:
SpringsAgent, Vector, String

removeNeedToUpdateReferenceTo

public void removeNeedToUpdateReferenceTo(java.lang.String agentName)
Removes the need to update the remote references to the given agent (e.g., because the agent has moved to another context).

Parameters:
agentName - the name of the agent.
See Also:
String

deleteAllReferencesTo

public void deleteAllReferencesTo(springs.agent.SpringsAgent agent,
                                  java.lang.String localContextName)
Records the need of deleting the remote references to the given agent.

Parameters:
agent - the agent.
localContextName - the local context name.
See Also:
SpringsAgent, Vector

terminate

public void terminate()
Shuts the access service down.


getReferenceFromLocalAgents

public springs.access.AgentReference getReferenceFromLocalAgents(java.lang.String agentName,
                                                                 boolean mustBeAutomaticUpdate)
Gets a reference to a locally-executing agent.

Parameters:
agentName - the name of the agent.
mustBeAutomaticUpdate - a boolean indicating whether the reference is required to be updated automatically.
Returns:
the reference.
See Also:
AgentReference

getReferenceFromTable

public springs.access.AgentReference getReferenceFromTable(java.lang.String agentName)
Gets a reference searching only locally.

Parameters:
agentName - the name of the agent.
Returns:
the reference.
See Also:
AgentReference