OpenNMS API 1.2.3

org.opennms.netmgt.config
Class ServiceConfigFactory

java.lang.Object
  extended byorg.opennms.netmgt.config.ServiceConfigFactory

public final class ServiceConfigFactory
extends java.lang.Object

This factory class is designed to be the main interface between the service configuration information and the users of the information. When initialized the factory loads the configuration from the file system, allowing access to the information by others. The init method may be called by more than one thread, but MUST be called by at least one thread before the factory can be used.

The factory supports the singleton design pattern, and thus the configuration is loaded only once. All callers get the same reference unless a call to reload is made. After than any saved instances of the factory can still be referenced. Old references will not reflect any changes in the file if the factory is reloaded.

Author:
Weave, OpenNMS

Field Summary
private  ServiceConfiguration m_config
          The loaded configuration after is has been unmarhsalled by castor.
private static boolean m_loaded
          This member is set to true if the configuration file has been loaded.
private static ServiceConfigFactory m_singleton
          The singleton instance of this factory
 
Constructor Summary
private ServiceConfigFactory(java.lang.String configFile)
          Private constructor.
 
Method Summary
static ServiceConfigFactory getInstance()
          Returns the currently defined singleton instance of the factory.
 Service[] getServices()
          Returns an array of all the defined configuration information for the Services.
static void init()
          Load the config from the default config file and create the singleton instance of this factory.
static void reload()
          Reload the config from the default config file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_singleton

private static ServiceConfigFactory m_singleton
The singleton instance of this factory


m_loaded

private static boolean m_loaded
This member is set to true if the configuration file has been loaded.


m_config

private ServiceConfiguration m_config
The loaded configuration after is has been unmarhsalled by castor.

Constructor Detail

ServiceConfigFactory

private ServiceConfigFactory(java.lang.String configFile)
                      throws java.io.IOException,
                             org.exolab.castor.xml.MarshalException,
                             org.exolab.castor.xml.ValidationException
Private constructor. This constructor used to load the specified configuration file and initialized an instance of the class.

Parameters:
configFile - The name of the configuration file.
Throws:
java.io.IOException - Thrown if the specified config file cannot be read
org.exolab.castor.xml.MarshalException - Thrown if the file does not conform to the schema.
org.exolab.castor.xml.ValidationException - Thrown if the contents do not match the required schema.
Method Detail

init

public static void init()
                 throws java.io.IOException,
                        org.exolab.castor.xml.MarshalException,
                        org.exolab.castor.xml.ValidationException
Load the config from the default config file and create the singleton instance of this factory.

Throws:
java.io.IOException - Thrown if the specified config file cannot be read
org.exolab.castor.xml.MarshalException - Thrown if the file does not conform to the schema.
org.exolab.castor.xml.ValidationException - Thrown if the contents do not match the required schema.

reload

public static void reload()
                   throws java.io.IOException,
                          org.exolab.castor.xml.MarshalException,
                          org.exolab.castor.xml.ValidationException
Reload the config from the default config file

Throws:
java.io.IOException - Thrown if the specified config file cannot be read/loaded
org.exolab.castor.xml.MarshalException - Thrown if the file does not conform to the schema.
org.exolab.castor.xml.ValidationException - Thrown if the contents do not match the required schema.

getInstance

public static ServiceConfigFactory getInstance()
Returns the currently defined singleton instance of the factory. There is only one instance of the configuration information, and it will not change unless the reload method is called.

Returns:
The singular instance of the factory class.
Throws:
java.lang.IllegalStateException - Thrown if the factory has not yet been initialized.

getServices

public Service[] getServices()
Returns an array of all the defined configuration information for the Services. If there are no defined services an array of length zero is returned to the caller.

Returns:
An array holding a reference to all the Service configuration instances.

OpenNMS API 1.2.3

Generated by eevans on May 29 2005 2015.