jgroup.core.registry
Class BootstrapRegistry

java.lang.Object
  extended by jgroup.core.registry.BootstrapRegistry

public class BootstrapRegistry
extends java.lang.Object

Provides static methods for binding bootstrap references to a local RMI registry. It will create local registry if no such registry exists and bind the given name-remote object pair. Currently, used by ExecDaemon, RegistryImpl (DependableRegistry), the Jgroup Daemon and the partition simulator to bootstraping their references.

Since:
Jgroup 1.2
Author:
Hein Meling

Constructor Summary
BootstrapRegistry()
           
 
Method Summary
static void bind(java.lang.String name, java.rmi.Remote obj)
          Binds the specified name to a new remote object.
static java.rmi.registry.Registry createRegistry()
          Create a local RMI registry on the default bootstrap port and socket factories.
static java.rmi.registry.Registry createRegistry(java.rmi.server.RMIClientSocketFactory csf, java.rmi.server.RMIServerSocketFactory ssf)
          Create a local RMI registry on the specified bootstrap port and socket factories.
static java.rmi.registry.Registry getLocalRegistry(java.rmi.server.RMIClientSocketFactory csf, java.rmi.server.RMIServerSocketFactory ssf)
          Get a reference to a local RMI registry associated with the bootstrap port specified in the configuration files.
static java.rmi.registry.Registry getRegistry()
          Get a reference to a local RMI registry associated with the bootstrap port specified in the configuration files.
static java.rmi.registry.Registry getRemoteRegistry(java.lang.String hostname, java.rmi.server.RMIClientSocketFactory csf, boolean checkCache)
          Get a reference to a local RMI registry associated with the specified bootstrap port and socket factories.
static java.lang.String[] list()
          Returns an array of the names bound in the bootstrap registry.
static java.rmi.Remote lookup(java.lang.String name)
          Obtains a remote object reference for the specified object name, from the local bootstrap registry.
static java.rmi.Remote lookup(java.lang.String hostname, java.lang.String name)
          Obtains a remote object reference for the specified object name, from the bootstrap registry located on the given hostname.
static void rebind(java.lang.String name, java.rmi.Remote obj)
          Rebinds the specified name to a new remote object.
static void refreshRegistryStub()
          Update the bootstrap registry reference.
static void refreshRemoteRegistries()
          Update the bootstrap registry references to the remote registries.
static void unbind(java.lang.String name)
          Removes the binding for the specified name in the bootstrap registry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BootstrapRegistry

public BootstrapRegistry()
Method Detail

refreshRegistryStub

public static void refreshRegistryStub()
                                throws java.rmi.RemoteException
Update the bootstrap registry reference. This should be used in the case when the JVM hosting the bootstrap registry has crashed, and the bootstrap registry should be recreated within a new JVM.

Throws:
java.rmi.RemoteException

refreshRemoteRegistries

public static void refreshRemoteRegistries()
                                    throws java.rmi.RemoteException
Update the bootstrap registry references to the remote registries.

Throws:
java.rmi.RemoteException

list

public static java.lang.String[] list()
                               throws java.rmi.AccessException,
                                      java.rmi.RemoteException
Returns an array of the names bound in the bootstrap registry. The array will contain a snapshot of the names bound in this registry at the time of the given invocation of this method.

Returns:
an array of the names bound in this registry
Throws:
java.rmi.AccessException - if this operation is not permitted (if originating from a non-local host, for example)
java.rmi.RemoteException - if registry could not be contacted

lookup

public static java.rmi.Remote lookup(java.lang.String name)
                              throws java.rmi.AccessException,
                                     java.rmi.RemoteException,
                                     java.rmi.NotBoundException
Obtains a remote object reference for the specified object name, from the local bootstrap registry.

Parameters:
name - Name of remote object to be retreived.
Throws:
java.rmi.AccessException - if this operation is not permitted (if originating from a non-local host, for example)
java.rmi.RemoteException - if registry could not be contacted
java.rmi.NotBoundException - if name is not bound in the registry

lookup

public static java.rmi.Remote lookup(java.lang.String hostname,
                                     java.lang.String name)
                              throws java.rmi.AccessException,
                                     java.net.UnknownHostException,
                                     java.rmi.RemoteException,
                                     java.rmi.NotBoundException
Obtains a remote object reference for the specified object name, from the bootstrap registry located on the given hostname.

Parameters:
hostname - name of remote host from which the object reference is obtained
name - name of remote object to be retreived
Throws:
java.rmi.AccessException - if this operation is not permitted (if originating from a non-local host, for example)
java.rmi.RemoteException - if registry could not be contacted
java.rmi.NotBoundException - if name is not bound in the registry
java.net.UnknownHostException

bind

public static void bind(java.lang.String name,
                        java.rmi.Remote obj)
                 throws java.rmi.AccessException,
                        java.rmi.RemoteException,
                        java.rmi.AlreadyBoundException
Binds the specified name to a new remote object. This bind operation works on the existing local BootstrapRegistry instance.

Parameters:
name - Name to be associated with the remote object
obj - Remote object to associate with the name
Throws:
java.rmi.AccessException - if this operation is not permitted (if originating from a non-local host, for example)
java.rmi.RemoteException - if registry could not be contacted
java.rmi.AlreadyBoundException - if name is already bound

rebind

public static void rebind(java.lang.String name,
                          java.rmi.Remote obj)
                   throws java.rmi.AccessException,
                          java.rmi.RemoteException
Rebinds the specified name to a new remote object. Any existing binding for the name is replaced. This rebind operation works on the existing local BootstrapRegistry instance.

Parameters:
name - name to be associated with the remote object
obj - new remote object to associate with the name
Throws:
java.rmi.AccessException - if this operation is not permitted (if originating from a non-local host, for example)
java.rmi.RemoteException - if registry could not be contacted

unbind

public static void unbind(java.lang.String name)
                   throws java.rmi.AccessException,
                          java.rmi.RemoteException,
                          java.rmi.NotBoundException
Removes the binding for the specified name in the bootstrap registry.

Parameters:
name - The name of the binding to remove
Throws:
java.rmi.AccessException - if this operation is not permitted (if originating from a non-local host, for example)
java.rmi.RemoteException - if registry could not be contacted
java.rmi.NotBoundException - if name is not bound in the registry

getRegistry

public static java.rmi.registry.Registry getRegistry()
                                              throws java.rmi.RemoteException
Get a reference to a local RMI registry associated with the bootstrap port specified in the configuration files. The socket factories used by the registry will be the default once.

Returns:
a Registry object
Throws:
java.rmi.AccessException - if this operation is not permitted (if originating from a non-local host, for example)
java.rmi.RemoteException - if registry could not be contacted

getLocalRegistry

public static java.rmi.registry.Registry getLocalRegistry(java.rmi.server.RMIClientSocketFactory csf,
                                                          java.rmi.server.RMIServerSocketFactory ssf)
                                                   throws java.rmi.AccessException,
                                                          java.rmi.RemoteException
Get a reference to a local RMI registry associated with the bootstrap port specified in the configuration files. The socket factories may be specified.

Parameters:
csf - client-side Socket factory used to make connections to the registry
ssf - server-side ServerSocket factory used to accept connections to the registry
Returns:
a Registry object
Throws:
java.rmi.AccessException - if this operation is not permitted (if originating from a non-local host, for example)
java.rmi.RemoteException - if registry could not be contacted

getRemoteRegistry

public static java.rmi.registry.Registry getRemoteRegistry(java.lang.String hostname,
                                                           java.rmi.server.RMIClientSocketFactory csf,
                                                           boolean checkCache)
                                                    throws java.net.UnknownHostException,
                                                           java.rmi.RemoteException
Get a reference to a local RMI registry associated with the specified bootstrap port and socket factories. Note that for non-local RMI registries, the returned reference (stub) may not work since we cannot create a registry on the remote host. This case may be used to determine if the host is running a registry.

Parameters:
hostname - the hostname to query for bootstrap registry
csf - client-side Socket factory used to make connections to the registry
checkCache - use true to check the cache for the registry reference; false will not query the cache, but will update it.
Returns:
a Registry object
Throws:
java.rmi.AccessException - if this operation is not permitted (if originating from a non-local host, for example)
java.rmi.RemoteException - if registry could not be contacted
java.net.UnknownHostException

createRegistry

public static java.rmi.registry.Registry createRegistry()
                                                 throws java.rmi.AccessException,
                                                        java.rmi.RemoteException
Create a local RMI registry on the default bootstrap port and socket factories.

Returns:
a Registry object
Throws:
java.rmi.AccessException - if this operation is not permitted (if originating from a non-local host, for example)
java.rmi.RemoteException - if registry could not be contacted

createRegistry

public static java.rmi.registry.Registry createRegistry(java.rmi.server.RMIClientSocketFactory csf,
                                                        java.rmi.server.RMIServerSocketFactory ssf)
                                                 throws java.rmi.AccessException,
                                                        java.rmi.RemoteException
Create a local RMI registry on the specified bootstrap port and socket factories.

Parameters:
csf - client-side Socket factory used to make connections to the registry
ssf - server-side ServerSocket factory used to accept connections to the registry
Returns:
a Registry object
Throws:
java.rmi.AccessException - if this operation is not permitted (if originating from a non-local host, for example)
java.rmi.RemoteException - if registry could not be contacted


Copyright © 1998-2006 The Jgroup/ARM development team. All Rights Reserved.