jxl.peermi
Class PeerRegistry

java.lang.Object
  extended by java.rmi.server.RemoteObject
      extended by java.rmi.server.RemoteServer
          extended by java.rmi.server.UnicastRemoteObject
              extended by jxl.peermi.PeerRemoteObject
                  extended by jxl.peermi.PeerRegistry
All Implemented Interfaces:
java.io.Serializable, java.rmi.Remote, PeerRegistryInterface, PeerRemote

public final class PeerRegistry
extends PeerRemoteObject
implements PeerRegistryInterface

PeerRegistry is the universal lookup point for PeerRemote objects. Once activated, PeerRegistries use jxta multicast to locate one another. After that all lookup operations are forwarded to the peer registries and bound remote objects are returned.

Author:
Alex Lynch
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Method Summary
 void addDiscoveryListener(java.lang.String binding, DiscoveryListener listener)
           
 void addRegistry(PeerRegistryInterface reg)
          Remote method.
 boolean bind(PeerRemoteObject p, java.lang.String name)
          If name is not already bound, bind p to name.
static PeerRegistry getLocalInstance()
          Get singleton instance of PeerRegistry.
 PeerRemote lookup(java.lang.String name)
          Remote method.
 void removeDiscoveryListener(java.lang.String binding, DiscoveryListener listener)
           
<T extends PeerRemote>
PeerManager<T>
requestPeerManager(java.lang.String name, java.lang.Class<T> ifaceType)
          Return PeerManager for binding name for interfact type ifaceType.
 
Methods inherited from class jxl.peermi.PeerRemoteObject
checkAlive, isAlive, toStub
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jxl.peermi.PeerRemote
checkAlive
 

Method Detail

getLocalInstance

public static PeerRegistry getLocalInstance()
                                     throws java.rmi.RemoteException
Get singleton instance of PeerRegistry.

Throws:
java.rmi.RemoteException

addDiscoveryListener

public void addDiscoveryListener(java.lang.String binding,
                                 DiscoveryListener listener)

removeDiscoveryListener

public void removeDiscoveryListener(java.lang.String binding,
                                    DiscoveryListener listener)

addRegistry

public void addRegistry(PeerRegistryInterface reg)
                 throws java.rmi.RemoteException
Remote method. Should not be called by clients.

Specified by:
addRegistry in interface PeerRegistryInterface
Throws:
java.rmi.RemoteException

bind

public boolean bind(PeerRemoteObject p,
                    java.lang.String name)
             throws java.rmi.RemoteException
If name is not already bound, bind p to name. If p is an instance of PeerRemoteObject the result of toStub() is bound to this registry, else p is asumed to be a remote stub, and it is bound itself.

If name was bound return false and do not bind p.

Parameters:
p -
name -
Returns:
true if p was bound, false otherwise.
Throws:
java.rmi.RemoteException

lookup

public PeerRemote lookup(java.lang.String name)
                  throws java.rmi.RemoteException
Remote method. This can be used to lookup only the local instance of a PeerRemote object. Most clients will use jxl.peermi.PeerRegistry#lookupAll(String) instead.

Specified by:
lookup in interface PeerRegistryInterface
Throws:
java.rmi.RemoteException

requestPeerManager

public <T extends PeerRemote> PeerManager<T> requestPeerManager(java.lang.String name,
                                                                java.lang.Class<T> ifaceType)
                                                     throws java.rmi.RemoteException
Return PeerManager for binding name for interfact type ifaceType.

Parameters:
name - Binding to lookup.
Returns:
A PeerHashSet containing all of the remote references.
Throws:
java.rmi.RemoteException