de.tu_darmstadt.sp.rmi
Class RegistryImpl

java.lang.Object
  |
  +--java.rmi.server.RemoteObject
        |
        +--java.rmi.server.RemoteServer
              |
              +--java.rmi.server.UnicastRemoteObject
                    |
                    +--de.tu_darmstadt.sp.rmi.RegistryImpl

public class RegistryImpl
extends java.rmi.server.UnicastRemoteObject
implements java.rmi.registry.Registry, java.rmi.Remote

Class RegistryImpl implements the Registry interface using an implementation object obtained from LocateRegistry.

It is intended for use with secure sockets. The 'traditional' rmiregistry in jdk has the advantage of using one well defined port and always the same type of sockets. Additionally, the Naming class facilitates the access to the standard registry. In Java 2, a comunity of RMI objects may use their own custom sockets and therefore need their private 'custom' rmiregistry.

Simply replacing sun's rmiregistry doesn't work, since the Naming has hardcoded informations to what kind of registry it is speaking.. On the other hand, creating a new 'MyNaming' class wouln't solve the problem, since it will work until somebody needs yet another type of rmiregistry. The 'rmiregistry' provided with JDK 1.2 can communicate using custom sockets. HOwever, if the factories need additional classes, the normal rmiregistry does not work well..

This registry simply can register itself on a specified (or anonymous) port on the local registry under a given name like any other remote server. Objects interested in getting a reference to such a secure registry, should use the name to lookup the registry object. Therefore, a local rmiregistry has to run on the local host before starting this registry implementation.

At the present moment, the LocateRegistry.createRegistry doens't seem to work. This is the main motivation in using this registry..

Version:
$Revision: 1.3 $
Author:
Andrei Popovici
See Also:
Serialized Form

Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
RegistryImpl(int port)
          Create a remote object being a registry, using normal sockets.
RegistryImpl(int port, java.rmi.server.RMIClientSocketFactory csf, java.rmi.server.RMIServerSocketFactory ssf)
          Create a remote object being a registry, using custom sockets.
 
Method Summary
 void bind(java.lang.String name, java.rmi.Remote obj)
          Binds the specified name to a remote object.
 java.lang.String[] list()
          Returns an array of the names bound in the registry.
 java.rmi.Remote lookup(java.lang.String name)
          Returns a reference, a stub, for the remote object associated with the specified name.
 void rebind(java.lang.String name, java.rmi.Remote obj)
          Rebinds the specified name to a new remote object.
 void unbind(java.lang.String name)
          Destroys the binding for the specified name that is associated with a remote object.
 
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, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RegistryImpl

public RegistryImpl(int port)
             throws java.rmi.RemoteException,
                    java.net.MalformedURLException
Create a remote object being a registry, using normal sockets.
Parameters:
port - the port to listen to
Throws:
java.net.MalformedURLException - if the name is not a correct URL-like rmi string.

RegistryImpl

public RegistryImpl(int port,
                    java.rmi.server.RMIClientSocketFactory csf,
                    java.rmi.server.RMIServerSocketFactory ssf)
             throws java.rmi.RemoteException,
                    java.net.MalformedURLException
Create a remote object being a registry, using custom sockets.
Parameters:
port - the port to listen to
csf - client socket factory
ssf - server socket factory
Throws:
java.net.MalformedURLException - name is not a correct URL-like RMI string.
Method Detail

lookup

public java.rmi.Remote lookup(java.lang.String name)
                       throws java.rmi.RemoteException,
                              java.rmi.NotBoundException,
                              java.rmi.AccessException
Returns a reference, a stub, for the remote object associated with the specified name.
Specified by:
lookup in interface java.rmi.registry.Registry

bind

public void bind(java.lang.String name,
                 java.rmi.Remote obj)
          throws java.rmi.RemoteException,
                 java.rmi.AlreadyBoundException,
                 java.rmi.AccessException
Binds the specified name to a remote object.
Specified by:
bind in interface java.rmi.registry.Registry

unbind

public void unbind(java.lang.String name)
            throws java.rmi.RemoteException,
                   java.rmi.NotBoundException,
                   java.rmi.AccessException
Destroys the binding for the specified name that is associated with a remote object.
Specified by:
unbind in interface java.rmi.registry.Registry

rebind

public void rebind(java.lang.String name,
                   java.rmi.Remote obj)
            throws java.rmi.RemoteException,
                   java.rmi.AccessException
Rebinds the specified name to a new remote object. Any existing binding for the name is replaced.
Specified by:
rebind in interface java.rmi.registry.Registry

list

public java.lang.String[] list()
                        throws java.rmi.RemoteException,
                               java.rmi.AccessException
Returns an array of the names bound in the registry. The names are URL-formatted strings. The array contains a snapshot of the names present in the registry at the time of the call.
Specified by:
list in interface java.rmi.registry.Registry