com.sun.faban.common
Class RegistryImpl

java.lang.Object
  extended by java.rmi.server.RemoteObject
      extended by java.rmi.server.RemoteServer
          extended by java.rmi.server.UnicastRemoteObject
              extended by com.sun.faban.common.RegistryImpl
All Implemented Interfaces:
Registry, Serializable, Remote

public class RegistryImpl
extends UnicastRemoteObject
implements Registry

This class implements the Registry interface The Registry is the single remote object that runs on the master machine and with which all other instances of remote servers reregister. A remote reference to any remote service is obtained by the GUI as well as the Engine through the registry. There is only one remote server object (the Registry) that is known by rmiregistry running on the master machine. Once a reference to the Registry is obtained by the client, it should use the 'getReference' method to obtain a reference to any type of remote server.

Although the Registry implementation uses rmi underneath, the rmi registry is fully encapsulated inside the Registry and RegistryLocator to avoid any confusion in the agent programs and other programs accessing the registry.

Author:
Shanti Subramanyam
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Method Summary
 int getNumServices(String type)
          Get the number of registered Services of a type.
 Remote getService(String name)
          get reference to service from Registry The registry searches in its list of registered services and returns a remote reference to the requested one.
 Remote getService(String type, String name)
          get reference to service from Registry The registry searches in its list of registered services and returns a remote reference to the requested one.
 Remote[] getServices(String type)
          get all references to a type of services from Registry The registry searches in its list of registered services and returns all remote references to the requested type.
 void kill()
          Kill is called to exit the RMI registry and Registry.
static void main(String[] args)
          Registration for RMI serving.
 boolean register(String name, Remote service)
          Registers service with Registry.
 boolean register(String type, String name, Remote service)
          Registers service with Registry.
 void reregister(String name, Remote service)
          Re-registers service with Registry, replacing old entry if exists.
 void reregister(String type, String name, Remote service)
          Re-registers service with Registry, replacing old entry if exists.
 void unregister(String name)
          unregister service from Registry The registry removes this service from its list and clients can no longer access it.
 void unregister(String type, String name)
          unregister service from Registry The registry removes this service from its list and clients can no longer access it.
 
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
 

Method Detail

register

public boolean register(String name,
                        Remote service)
Registers service with Registry. The service driverName is of the form @ For example, a CmdAgent will reregister itself as CmdAgent@ so all CmdAgents on different machines can be uniquely identified by driverName.

Specified by:
register in interface Registry
Parameters:
name - public driverName of service
service - Remote reference to service
Returns:
true if registration succeeded, false if there is already an object registered by this name.

register

public boolean register(String type,
                        String name,
                        Remote service)
Registers service with Registry. The service driverName is of the form @ For example, a CmdAgent will reregister itself as CmdAgent@ so all CmdAgents on different machines can be uniquely identified by driverName.

Specified by:
register in interface Registry
Parameters:
type - of service
name - of service
service - Remote reference to service
Returns:
true if registration succeeded, false if there is already an object registered by this name.

reregister

public void reregister(String name,
                       Remote service)
Re-registers service with Registry, replacing old entry if exists. The service driverName is of the form <driverName>@<host> For example, a CmdAgent will reregister itself as CmdAgent@<host> so all CmdAgents on different machiens can be uniquely identified by driverName.

Specified by:
reregister in interface Registry
Parameters:
name - public driverName of service
service - Remote reference to service

reregister

public void reregister(String type,
                       String name,
                       Remote service)
Re-registers service with Registry, replacing old entry if exists. The service driverName is of the form <driverName>@<host> For example, a CmdAgent will reregister itself as CmdAgent@<host> so all CmdAgents on different machiens can be uniquely identified by driverName.

Specified by:
reregister in interface Registry
Parameters:
type - of service
name - of service
service - Remote reference to service

unregister

public void unregister(String name)
unregister service from Registry The registry removes this service from its list and clients can no longer access it. This method is typically called when the service exits.

Specified by:
unregister in interface Registry
Parameters:
name - public driverName of service

unregister

public void unregister(String type,
                       String name)
unregister service from Registry The registry removes this service from its list and clients can no longer access it. This method is typically called when the service exits.

Specified by:
unregister in interface Registry
Parameters:
type - of service
name - public driverName of service

getService

public Remote getService(String name)
get reference to service from Registry The registry searches in its list of registered services and returns a remote reference to the requested one. The service driverName is of the form @

Specified by:
getService in interface Registry
Parameters:
name - public driverName of service
Returns:
remote reference

getService

public Remote getService(String type,
                         String name)
get reference to service from Registry The registry searches in its list of registered services and returns a remote reference to the requested one. The service driverName is of the form @

Specified by:
getService in interface Registry
Parameters:
type - of service
name - public driverName of service
Returns:
remote reference

getServices

public Remote[] getServices(String type)
get all references to a type of services from Registry The registry searches in its list of registered services and returns all remote references to the requested type. The service driverName is of the form @

Specified by:
getServices in interface Registry
Parameters:
type - of service
Returns:
remote references

getNumServices

public int getNumServices(String type)
Get the number of registered Services of a type.

Specified by:
getNumServices in interface Registry
Parameters:
type - of service
Returns:
int number of registered services

kill

public void kill()
Kill is called to exit the RMI registry and Registry.

Specified by:
kill in interface Registry

main

public static void main(String[] args)
Registration for RMI serving.

Parameters:
args - Command line arguments, not used