de.uniba.wiai.lspi.chord.com.local
Class Registry

java.lang.Object
  extended by de.uniba.wiai.lspi.chord.com.local.Registry

public final class Registry
extends java.lang.Object

This class represents a registry for endpointsthat can be used to build up a chord network within the same JVM with help of Java Threads. This Registry is a singleton so that there is only one instance of this in the JVM. A reference to the singleton can be obtained by invocation of getRegistryInstance().

Version:
1.0.5
Author:
sven

Method Summary
 void addProxyUsedBy(URL url, ThreadProxy proxy)
          Add the given proxy used by the node with nodeName.
 void bind(ThreadEndpoint endpoint)
          Register the given endpointso that it can be looked up via #lookup(String).
 java.util.List<ThreadProxy> getProxiesInUseBy(URL nodeName)
          Get a reference to the Listof proxies used by the node with nodeName.
static Registry getRegistryInstance()
          Get a reference to the registry singleton.
 ThreadEndpoint lookup(URL url)
          This method looks up the endpointfor the node with the given name.
 java.util.Map<URL,ThreadEndpoint> lookupAll()
          Returns an array of all registered endpoints.
 void removeProxiesInUseBy(URL nodeName)
          Removes the proxies used by the node with nodeName.
 void shutdown()
          Shutdown this registry.
 java.lang.String toString()
          Overwritten from Object.
 void unbind(ThreadEndpoint endpoint)
          Remove the given endpointfrom the registry.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

addProxyUsedBy

public void addProxyUsedBy(URL url,
                           ThreadProxy proxy)
Add the given proxy used by the node with nodeName.

Parameters:
url - The url of the node that uses the proxy.
proxy - The proxyto add.

getProxiesInUseBy

public java.util.List<ThreadProxy> getProxiesInUseBy(URL nodeName)
Get a reference to the Listof proxies used by the node with nodeName.

Parameters:
url - The url of the node.
Returns:
Listof proxiesthat are used by the node with nodeName. May return null if there are no proxies in use by the node.

removeProxiesInUseBy

public void removeProxiesInUseBy(URL nodeName)
Removes the proxies used by the node with nodeName.

Parameters:
url - The url of the node, for that the proxies should be removed.

bind

public void bind(ThreadEndpoint endpoint)
Register the given endpointso that it can be looked up via #lookup(String).

Parameters:
endpoint - The ThreadEndpointto register.

unbind

public void unbind(ThreadEndpoint endpoint)
Remove the given endpointfrom the registry.

Parameters:
endpoint - ThreadEndpointto remove.

lookup

public ThreadEndpoint lookup(URL url)
This method looks up the endpointfor the node with the given name. If no endpoint is found null is returned.

Parameters:
url - The url of the node, for which the endpointis looked up.
Returns:
Reference to the endpointof node with name "name". May be null if no such reference exists.

lookupAll

public java.util.Map<URL,ThreadEndpoint> lookupAll()
Returns an array of all registered endpoints.

Returns:
Array of all registered endpoints. If no endpoint is registered an array of length 0 is returned.

getRegistryInstance

public static Registry getRegistryInstance()
Get a reference to the registry singleton. This method is not thread-safe!

Returns:
Reference to the registry singleton.

toString

public java.lang.String toString()
Overwritten from Object.

Overrides:
toString in class java.lang.Object
Returns:
String representation of this.

shutdown

public void shutdown()
Shutdown this registry.