org.opennms.netmgt.config
Class XmlrpcdConfigFactory

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

public final class XmlrpcdConfigFactory
extends Object

This is the singleton class used to load the configuration for the OpenNMS xmlrpcd service from the xmlrpcd-configuration xml file. Note: Users of this class should make sure the init() is called before calling any other method to ensure the config is loaded before accessing other convenience methods.

Author:
James Zuo , OpenNMS

Constructor Summary
XmlrpcdConfigFactory(Reader rdr)
          Constructor for testing
 
Method Summary
 XmlrpcdConfiguration getConfiguration()
          Return the xmlrpcd configuration object.
 List<SubscribedEvent> getEventList(ExternalServers server)
          Retrieves configured list of subscribed event uei for the given subscribing server.
 Collection<ExternalServers> getExternalServerCollection()
          Retrieves configured list of xmlrpc servers and the events to which they subscribe.
 Enumeration<ExternalServers> getExternalServerEnumeration()
          Retrieves configured list of xmlrpc servers and the events to which they subscribe.
static XmlrpcdConfigFactory getInstance()
          Return the singleton instance of this factory.
 int getMaxQueueSize()
          Retrieves the max event queue size from configuration.
 Collection<Subscription> getSubscriptionCollection()
          Retrieves configured list of server subscriptions and the UEIs they are associated with.
 Enumeration<Subscription> getSubscriptionEnumeration()
          Retrieves configured list of server subscriptions and the UEIs they are associated with.
static void init()
          Load the config from the default config file and create the singleton instance of this factory.
static void init(File cfgFile)
          Load the specified config file and create the singleton instance of this factory.
static void reload()
          Reload the config from the default config file
static void setInstance(XmlrpcdConfigFactory instance)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlrpcdConfigFactory

public XmlrpcdConfigFactory(Reader rdr)
                     throws IOException,
                            org.exolab.castor.xml.MarshalException,
                            org.exolab.castor.xml.ValidationException
Constructor for testing

Throws:
IOException - Thrown if the specified reader 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 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.

init

public static void init(File cfgFile)
                 throws IOException,
                        org.exolab.castor.xml.MarshalException,
                        org.exolab.castor.xml.ValidationException
Load the specified 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 XmlrpcdConfigFactory getInstance()
Return the singleton instance of this factory.

Returns:
The current factory instance.
Throws:
IllegalStateException - Thrown if the factory has not yet been initialized.

setInstance

public static void setInstance(XmlrpcdConfigFactory instance)

getConfiguration

public XmlrpcdConfiguration getConfiguration()
Return the xmlrpcd configuration object.


getEventList

public List<SubscribedEvent> getEventList(ExternalServers server)
                                   throws org.exolab.castor.xml.ValidationException
Retrieves configured list of subscribed event uei for the given subscribing server.

Returns:
an enumeration of subscribed event ueis.
Throws:
org.exolab.castor.xml.ValidationException - if a serverSubscription element references a subscription name that doesn't exist

getExternalServerEnumeration

public Enumeration<ExternalServers> getExternalServerEnumeration()
Retrieves configured list of xmlrpc servers and the events to which they subscribe.

Returns:
an enumeration of xmlrpc servers.

getSubscriptionEnumeration

public Enumeration<Subscription> getSubscriptionEnumeration()
Retrieves configured list of server subscriptions and the UEIs they are associated with.

Returns:
an enumeration of subscriptions.

getExternalServerCollection

public Collection<ExternalServers> getExternalServerCollection()
Retrieves configured list of xmlrpc servers and the events to which they subscribe.

Returns:
a collection of xmlrpc servers.

getSubscriptionCollection

public Collection<Subscription> getSubscriptionCollection()
Retrieves configured list of server subscriptions and the UEIs they are associated with.

Returns:
a collection of subscriptions.

getMaxQueueSize

public int getMaxQueueSize()
Retrieves the max event queue size from configuration.

Returns:
the max size of the xmlrpcd event queue.


Copyright © 2009. All Rights Reserved.