uk.org.iscream.cms.server.componentmanager
Class ReferenceManager

java.lang.Object
  extended by uk.org.iscream.cms.server.componentmanager.ReferenceManager

public class ReferenceManager
extends Object

This class returns references for global system objects. This class is used to create and return references to objects that are required throughout the system. Most of which are CORBA based. It also manages the ORB for the component. It is a singleton object with a static method to obtain a reference to it. This removes the need for passing references to all the objects it contains throughout a component.

Version:
$Id: ReferenceManager.java,v 1.21 2004/08/01 10:40:50 tdb Exp $
Author:
$Author: tdb $

Field Summary
private  ConfigurationManager _cm
          The configuration manager
private static ReferenceManager _instance
          A reference to the single instance of this class
private  Logger _logger
          The logger
private  String _name
          This is the friendly identifier of the component this class is running in.
private  NamingContextExt _ns
          The Naming Service
private  ORB _orb
          The ORB
private  POA _rootPOA
          The Root POA
 String REVISION
          The current CVS revision of this class
 
Constructor Summary
private ReferenceManager()
          This is a private constructor This ensures that the system performs according to a Singleton design pattern
 
Method Summary
 void activatePOA()
          Activates the POA Calls the dieWithError() if any exceptions happen!
 void bindToOrb(Servant objRef, String name)
          Binds a given servant with the given name to the naming service.
private  void dieWithError(String message)
          If there are any CORBA errors this method is called with the error message.
 ConfigurationManager getCM()
          Returns a reference to the configuration manager Calls the dieWithError() if any exceptions happen!
 Object getCORBARef(String name)
          Obtains a CORBA reference through the naming service for the named object.
static ReferenceManager getInstance()
          This returns a reference to the single instance of the ReferenceManager.
 Logger getLogger()
          Returns a reference to the logger This will throw a Error if there is an error
 NamingContextExt getNS()
          Returns a reference to the Naming Service Calls the dieWithError() if any exceptions happen!
 ORB getORB()
          Returns a reference to the ORB
 POA getRootPOA()
          Returns a reference to the Root POA Calls the dieWithError() if any exceptions happen!
private  void recoverWithError(String message)
          If there are any CORBA errors this method is called with the error message.
 String toString()
          Overrides the Object.toString() method to provide clean logging (every class should have this).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

REVISION

public final String REVISION
The current CVS revision of this class

See Also:
Constant Field Values

_orb

private ORB _orb
The ORB


_ns

private NamingContextExt _ns
The Naming Service


_rootPOA

private POA _rootPOA
The Root POA


_cm

private ConfigurationManager _cm
The configuration manager


_logger

private Logger _logger
The logger


_name

private String _name
This is the friendly identifier of the component this class is running in. eg, a Filter may be called "filter1", If this class does not have an owning component, a name from the configuration can be placed here. This name could also be changed to null for utility classes.


_instance

private static ReferenceManager _instance
A reference to the single instance of this class

Constructor Detail

ReferenceManager

private ReferenceManager()
This is a private constructor This ensures that the system performs according to a Singleton design pattern

Method Detail

getInstance

public static ReferenceManager getInstance()
This returns a reference to the single instance of the ReferenceManager. This creates the single instance of the ReferenceManager if it does not exist by calling the private constructor.

Returns:
a reference to the ReferenceManager

getCORBARef

public Object getCORBARef(String name)
Obtains a CORBA reference through the naming service for the named object. Calls the dieWithError() if any exceptions happen!

Parameters:
name - the name of the CORBA object to resolve
Returns:
a reference to the object

bindToOrb

public void bindToOrb(Servant objRef,
                      String name)
Binds a given servant with the given name to the naming service. Calls the dieWithError() if any exceptions happen!

Parameters:
objRef - a reverence to the servant object
name - the name to bind to the naming service with

activatePOA

public void activatePOA()
Activates the POA Calls the dieWithError() if any exceptions happen!


toString

public String toString()
Overrides the Object.toString() method to provide clean logging (every class should have this). This uses the uk.org.iscream.cms.util.NameFormat class to format the toString()

Overrides:
toString in class Object
Returns:
the name of this class and its CVS revision

recoverWithError

private void recoverWithError(String message)
                       throws ComponentCORBAException
If there are any CORBA errors this method is called with the error message. The exception this throws is generic to CORBA communication problems, this is a Runtime exception and is typically only explicitly caught in the ComponentManager for the current VM The ComponentManager can then decide what course of action to take. Also, if it can, it will log the message with the logger.

Parameters:
message - the error message to die with
Throws:
ComponentCORBAException

dieWithError

private void dieWithError(String message)
If there are any CORBA errors this method is called with the error message. Currently this prints the error, on the local err stream. Will print to the logger if one is available. ANY CALLS TO THIS METHOD CAUSE THE SYSTEM TO EXIT WITH A NON ZERO CODE!

Parameters:
message - the error message to die with

getORB

public ORB getORB()
Returns a reference to the ORB

Returns:
the reference this class holds

getRootPOA

public POA getRootPOA()
Returns a reference to the Root POA Calls the dieWithError() if any exceptions happen!

Returns:
the reference this class holds

getNS

public NamingContextExt getNS()
Returns a reference to the Naming Service Calls the dieWithError() if any exceptions happen!

Returns:
the reference this class holds

getCM

public ConfigurationManager getCM()
Returns a reference to the configuration manager Calls the dieWithError() if any exceptions happen!

Returns:
the reference this class holds

getLogger

public Logger getLogger()
Returns a reference to the logger This will throw a Error if there is an error

Returns:
the reference this class holds


Copyright © 2000-2003 i-scream. All Rights Reserved.