org.jboss.remoting.transporter
Class InternalTransporterServices

java.lang.Object
  extended by org.jboss.remoting.transporter.InternalTransporterServices

public class InternalTransporterServices
extends java.lang.Object

This is a singleton that maintains internal services required for all transporter servers and clients. The transporter server and client use these services to perform their functions. These "services" include an MBeanServer, a Detector to detect other servers on the network and a Network Registry used to maintain a list of known servers that have been detected.

End-users do not have to interface with this singleton unless they want to customize the services used by the transporter framework. Call setup(MBeanServer) to setup this singleton with an MBeanServer that is to be used to house all the internal services. You can then assign a detector and/or assign a network registry to this singleton. You can setup and assign those services all in one call via setup(MBeanServer, Detector, ObjectName, NetworkRegistry, ObjectName, boolean, boolean).

The Network Registry and Detector objects are only needed if you want the transporter server/client to use their clustering feature.

Note that once this singleton is setup, it cannot be setup again. You must first reset() it in order to re-setup the singleton.

Version:
$Revision: 876 $
Author:
John Mazzitelli

Field Summary
static javax.management.ObjectName DEFAULT_DETECTOR_OBJECTNAME
          The default detector name if one is not provided.
static javax.management.ObjectName DEFAULT_NETWORKREGISTRY_OBJECTNAME
          The default network registry name if one is not provided.
 
Method Summary
 void assignDetector(Detector detector, javax.management.ObjectName detectorName, boolean registerDetector)
          This will assign a detector to this singleton if one has not yet been setup.
 void assignNetworkRegistry(NetworkRegistry registry, javax.management.ObjectName registryName, boolean registerRegistry)
          This will assign a network registry to this singleton if one has not yet been setup.
 Detector getDetector()
          Returns the detector used to auto-detect other servers on the network.
 javax.management.ObjectName getDetectorName()
          Returns the name of the detector used to auto-detect other servers on the network.
static InternalTransporterServices getInstance()
          Returns the singleton instance containing the services used by all TransporterServer and TransporterClient instances.
 javax.management.MBeanServer getMBeanServer()
          Returns the MBeanServer that will house all the internal services.
 NetworkRegistry getNetworkRegistry()
          Returns the network registry used to maintain the list of known servers.
 javax.management.ObjectName getNetworkRegistryName()
          Returns the name of the network registry used to maintain the list of known servers.
 boolean isSetup()
          Returns true if the internal transporter services singleton has been setup.
 void reset()
          If the caller wants to reset this singleton (e.g.
 void setup(javax.management.MBeanServer mbs)
          Sets the MBeanServer used to house the transporter services.
 void setup(javax.management.MBeanServer mbs, Detector detector, javax.management.ObjectName detectorName, NetworkRegistry registry, javax.management.ObjectName registryName, boolean registerDetector, boolean registerRegistry)
          Sets the MBeanServer used to house the transporter services, assigns the detector used to auto-detect other servers on the network and assigns the network registry that maintains the list of known servers on the network.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_DETECTOR_OBJECTNAME

public static final javax.management.ObjectName DEFAULT_DETECTOR_OBJECTNAME
The default detector name if one is not provided.


DEFAULT_NETWORKREGISTRY_OBJECTNAME

public static final javax.management.ObjectName DEFAULT_NETWORKREGISTRY_OBJECTNAME
The default network registry name if one is not provided.

Method Detail

getInstance

public static InternalTransporterServices getInstance()
Returns the singleton instance containing the services used by all TransporterServer and TransporterClient instances.

Returns:
the singleton

getMBeanServer

public javax.management.MBeanServer getMBeanServer()
Returns the MBeanServer that will house all the internal services.

Returns:
mBeanServer

getDetector

public Detector getDetector()
Returns the detector used to auto-detect other servers on the network.

Returns:
detector

getDetectorName

public javax.management.ObjectName getDetectorName()
Returns the name of the detector used to auto-detect other servers on the network.

Returns:
detector name

getNetworkRegistry

public NetworkRegistry getNetworkRegistry()
Returns the network registry used to maintain the list of known servers.

Returns:
network registry

getNetworkRegistryName

public javax.management.ObjectName getNetworkRegistryName()
Returns the name of the network registry used to maintain the list of known servers.

Returns:
network registry name

isSetup

public boolean isSetup()
Returns true if the internal transporter services singleton has been setup. When this returns true, you can be guaranteed that a non-null MBeanServer has been given to this singleton. A detector and/or network registry may or may not be registered - it all depends on how the singleton was set up and if those services were assigned to this singleton.

Returns:
true if this singleton has already been setup; false if it has not been setup yet

reset

public void reset()
If the caller wants to reset this singleton (e.g. a new MBeanServer is to be installed), this method must be called before calling one of the setup methods again. Calling this method wipes the original MBeanServer and unassigns any detector or network registry references this singleton has.


assignDetector

public void assignDetector(Detector detector,
                           javax.management.ObjectName detectorName,
                           boolean registerDetector)
                    throws java.lang.IllegalArgumentException,
                           java.lang.IllegalStateException,
                           java.lang.Exception
This will assign a detector to this singleton if one has not yet been setup. If there is no MBean Server yet, this will throw an exception. If a detector has already been assigned, this will throw an exception. If registerDetector is true, the given detector will be registered on the MBeanServer under the given name; if it is false, it will be assumed the detector is already registered under that name and does not have to be registered here.

Parameters:
detector - the detector to assign to this singleton (must not be null)
detectorName - the name the detector will be registered as (if null, a default name is used)
registerDetector - if true, will register the detector with the given name in the MBeanServer
Throws:
java.lang.IllegalStateException - if the MBeanServer is not setup yet or there is already a detector assigned
java.lang.IllegalArgumentException - if detector is null
java.lang.Exception - any other exception means the detector failed to get registered in the MBeanServer

assignNetworkRegistry

public void assignNetworkRegistry(NetworkRegistry registry,
                                  javax.management.ObjectName registryName,
                                  boolean registerRegistry)
                           throws java.lang.IllegalArgumentException,
                                  java.lang.IllegalStateException,
                                  java.lang.Exception
This will assign a network registry to this singleton if one has not yet been setup. If there is no MBean Server yet, this will throw an exception. If a registry has already been assigned, this will throw an exception. If registerRegistry is true, the given registry will be registered on the MBeanServer with the given name; if it is false, it will be assumed the registry is already registered under that name and does not have to be registered here.

Parameters:
registry - the network registry to assign to this singleton (must not be null)
registryName - the name the registry will be registered as (if null a default name is used)
registerRegistry - if true, will register the network registry with the given name in the MBeanServer
Throws:
java.lang.IllegalStateException - if the MBeanServer is not setup yet or there is already a registry assigned
java.lang.IllegalArgumentException - if registry is null
java.lang.Exception - any other exception means the registry failed to get registered in the MBeanServer

setup

public void setup(javax.management.MBeanServer mbs)
           throws java.lang.IllegalArgumentException,
                  java.lang.IllegalStateException
Sets the MBeanServer used to house the transporter services. Use this method if the transporter servers/clients do not need clustering and therefore do not need to assign a detector service or the network registry.

Parameters:
mbs - the MBeanServer that will house the internal services
Throws:
java.lang.IllegalArgumentException - if mbs is null
java.lang.IllegalStateException - if the singleton was already setup

setup

public void setup(javax.management.MBeanServer mbs,
                  Detector detector,
                  javax.management.ObjectName detectorName,
                  NetworkRegistry registry,
                  javax.management.ObjectName registryName,
                  boolean registerDetector,
                  boolean registerRegistry)
           throws java.lang.Exception
Sets the MBeanServer used to house the transporter services, assigns the detector used to auto-detect other servers on the network and assigns the network registry that maintains the list of known servers on the network. If the detector or registry already exist in the MBeanServer and their respective registerXXX parameter is true, an exception is thrown.

Parameters:
mbs - the MBeanServer that will house the internal services (must not be null)
detector - the detector that will listen for other servers on the network
detectorName - the name of the detector as it is or will be registered in the MBeanServer (if null, a default name will be used)
registry - the network registry that will maintain the list of known servers on the network
registryName - the name of the network registry as it is or will be registered in the MBeanServer (if null, a default name will be used)
registerDetector - if true, will register the detector with the given name
registerRegistry - if true, will register the network registry with the given name
Throws:
java.lang.IllegalStateException - if the singleton was already setup
java.lang.IllegalArgumentException - if the MBeanServer is null or detector is null but its name is not or registry is null but its name is not
java.lang.Exception - if this method failed to register the detector or registry
See Also:
assignDetector(Detector, ObjectName, boolean), assignNetworkRegistry(NetworkRegistry, ObjectName, boolean)


Copyright © 1998-2005 JBoss Inc . All Rights Reserved.