org.opennms.netmgt.config
Class ServiceConfigFactory

java.lang.Object
  extended by org.opennms.netmgt.config.ServiceConfigFactory

public final class ServiceConfigFactory
extends 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

Constructor Summary
ServiceConfigFactory(Reader rdr)
           
 
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
static void setInstance(ServiceConfigFactory instance)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServiceConfigFactory

public ServiceConfigFactory(Reader rdr)
                     throws org.exolab.castor.xml.MarshalException,
                            org.exolab.castor.xml.ValidationException
Throws:
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException
Method Detail

init

public static void init()
                 throws 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:
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 IOException,
                          org.exolab.castor.xml.MarshalException,
                          org.exolab.castor.xml.ValidationException
Reload the config from the default config file

Throws:
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:
IllegalStateException - Thrown if the factory has not yet been initialized.

setInstance

public static void setInstance(ServiceConfigFactory instance)

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.


Copyright © 2009. All Rights Reserved.