com.sun.media.jsdt
Class RegistryFactory

java.lang.Object
  |
  +--com.sun.media.jsdt.impl.JSDTObject
        |
        +--com.sun.media.jsdt.RegistryFactory

public class RegistryFactory
extends com.sun.media.jsdt.impl.JSDTObject

This is a factory class that starts and stops a Registry of the appropriate type. Valid types are "socket", "http", "lrmp" and "rmi".

As with all types of collaborative environments, there needs to be some way for each application to initially rendezvous, so that data can be shared. The JSDT group rendezvous point is a Session object, and a special URL String is used to describe that Session. This Session information needs to be kept somewhere that is easily accessable to all applications. This is where the Registry fits in.

The Registry contains a transient database that maps these URL Strings to JSDT objects. When the Registry is first started, it's database is empty. The names stored in the Registry are pure and are not parsed. A collaborative service storing itself in the Registry may want to prefix the name of the service by a package name (although this is not required), to reduce name collisions.

The Registry can also be used to store special Clients. This Client is capable of being invited to join a JSDT Session.

If the Registry is started by the RegistryFactory.startRegistry method, then it runs in its own thread. This is not a deamon thread, so it should either be stopped with the stopRegistry method, or it will be terminated when the application that started it, exits.

The Registry needs to be started on a "well-known" port. This is defined by the com.sun.media.jsdt.impl.JSDTObject.registryPort variable, which by default, is 4561, irrespective of the implementation type.

Since:
JSDT 1.1
Version:
1.5 - 23rd February 1999
Author:
Rich Burridge
See Also:
Naming, SessionFactory, ClientFactory, Serialized Form

Fields inherited from class com.sun.media.jsdt.impl.JSDTObject
giveTime, httpTunnelPort, maxQueueSize, maxThreadPoolSize, pingPeriod, registryAddress, registryPort, registryTime, showMessage, showStack, socketFactoryClass, SSLCipher, timeoutPeriod, TTL, versionString
 
Constructor Summary
RegistryFactory()
           
 
Method Summary
static boolean registryExists(java.lang.String registryType)
           is a class method that checks if a Registry, of the given registry type, is already running.
static boolean registryExists(java.lang.String registryType, int port)
           is a class method that checks if a Registry, of the given registry type, is already running on the given port.
static void startRegistry(java.lang.String registryType)
           startRegistry is a class method that will start a Registry of the appropriate type, using the current setting of the com.sun.media.jsdt.impl.JSDTObject.registryPort variable as the port number to run it on.
static void startRegistry(java.lang.String registryType, int port)
           startRegistry is a class method that will start a Registry of the appropriate type.
static void stopRegistry(java.lang.String registryType)
           stopRegistry is a class method that will stop a Registry of the appropriate type, using the current setting of the com.sun.media.jsdt.impl.JSDTObject.registryPort variable to determine the port number it is running on.
static void stopRegistry(java.lang.String registryType, int port)
           stopRegistry is a class method that will stop a Registry of the appropriate type.
 
Methods inherited from class com.sun.media.jsdt.impl.JSDTObject
error, getConnectionType, setConnectionType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RegistryFactory

public RegistryFactory()
Method Detail

startRegistry

public static void startRegistry(java.lang.String registryType)
                          throws RegistryExistsException,
                                 NoRegistryException
startRegistry is a class method that will start a Registry of the appropriate type, using the current setting of the com.sun.media.jsdt.impl.JSDTObject.registryPort variable as the port number to run it on.

The Registry is started in a separate thread. It can be stopped with the stopRegistry method. If the process that started it terminates, then the Registry thread is terminated too.

Parameters:
registryType - the type of Registry to start.
Throws:
RegistryExistsException - if a Registry (or some other process) is already running on the port used by the Registry on this machine.
NoRegistryException - if an invalid registry type was given.

startRegistry

public static void startRegistry(java.lang.String registryType,
                                 int port)
                          throws RegistryExistsException,
                                 NoRegistryException
startRegistry is a class method that will start a Registry of the appropriate type. The Registry is started in a separate thread. It can be stopped with the stopRegistry method. If the process that started it terminates, then the Registry thread is terminated too.

The variable com.sun.media.jsdt.impl.JSDTObject.registryPort will be set to the given port number.

Parameters:
registryType - the type of Registry to start.
port - the port number that the Registry should run on.
Throws:
RegistryExistsException - if a Registry (or some other process) is already running on the port used by the Registry on this machine.
NoRegistryException - if an invalid registry type was given.
Since:
JSDT 1.5

stopRegistry

public static void stopRegistry(java.lang.String registryType)
                         throws NoRegistryException
stopRegistry is a class method that will stop a Registry of the appropriate type, using the current setting of the com.sun.media.jsdt.impl.JSDTObject.registryPort variable to determine the port number it is running on.

If the registry was started in this VM with the startRegistry method, then it will just stop the Registry thread, else it will send a message to the running Registry, which will cause the Registry to terminate.

Parameters:
registryType - the type of Registry to start, (ie. "socket").
Throws:
NoRegistryException - if an invalid registry type was given, or the Registry is not running, or wasn't started by the startRegistry method.
Since:
JSDT 1.5

stopRegistry

public static void stopRegistry(java.lang.String registryType,
                                int port)
                         throws NoRegistryException
stopRegistry is a class method that will stop a Registry of the appropriate type. The variable com.sun.media.jsdt.impl.JSDTObject.registryPort will be set to the given port number.

If the registry was started in this VM with the startRegistry method, then it will just stop the Registry thread, else it will send a message to the running Registry, which will cause the Registry to terminate.

Parameters:
registryType - the type of Registry to start, (ie. "socket").
port - the port number that the Registry is running on.
Throws:
NoRegistryException - if an invalid registry type was given, or the Registry is not running, or wasn't started by the startRegistry method.
Since:
JSDT 1.5

registryExists

public static boolean registryExists(java.lang.String registryType)
                              throws NoRegistryException
is a class method that checks if a Registry, of the given registry type, is already running. It uses the current setting of the com.sun.media.jsdt.impl.JSDTObject.registryPort variable to determine the port number it is running on.
Parameters:
registryType - the type of Registry to check on.
Returns:
true if a Registry is already running; false if it isn't.
Throws:
NoRegistryException - if an invalid registry type was given.

registryExists

public static boolean registryExists(java.lang.String registryType,
                                     int port)
                              throws NoRegistryException
is a class method that checks if a Registry, of the given registry type, is already running on the given port.

The variable com.sun.media.jsdt.impl.JSDTObject.registryPort will be set to the given port number.

Parameters:
registryType - the type of Registry to check on.
port - the port number that the Registry is running on.
Returns:
true if a Registry is already running; false if it isn't.
Throws:
NoRegistryException - if an invalid registry type was given.
Since:
JSDT 1.5