org.opennms.protocols.nsclient.config
Class NSClientPeerFactory

java.lang.Object
  extended by org.opennms.protocols.nsclient.config.NSClientPeerFactory

public final class NSClientPeerFactory
extends Object

This class is the main repository for NSCLient configuration information used by the capabilities daemon. When this class is loaded it reads the nsclient configuration into memory, and uses the configuration to find the NSClientAgentConfig objects for specific addresses. If an address cannot be located in the configuration then a default peer instance is returned to the caller. 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:
David Hustace , Weave , Gerald Turner , OpenNMS

Constructor Summary
NSClientPeerFactory(InputStream stream)
          Constructor for NSClientPeerFactory.
 
Method Summary
 NSClientAgentConfig getAgentConfig(InetAddress agentInetAddress)
          getAgentConfig
static NSClientPeerFactory getInstance()
          Return the singleton instance of this factory.
 Lock getReadLock()
           
 Lock getWriteLock()
           
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
 void saveCurrent()
          Saves the current settings to disk
static void setInstance(NSClientPeerFactory singleton)
          setInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NSClientPeerFactory

public NSClientPeerFactory(InputStream stream)
                    throws IOException,
                           org.exolab.castor.xml.MarshalException,
                           org.exolab.castor.xml.ValidationException

Constructor for NSClientPeerFactory.

Parameters:
stream - a InputStream object.
Throws:
IOException - if any.
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.
Method Detail

getReadLock

public Lock getReadLock()

getWriteLock

public Lock getWriteLock()

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.
IOException - if any.
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.

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.
IOException - if any.
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.

saveCurrent

public void saveCurrent()
                 throws Exception
Saves the current settings to disk

Throws:
Exception - if any.

getInstance

public static NSClientPeerFactory 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(NSClientPeerFactory singleton)

setInstance

Parameters:
singleton - a NSClientPeerFactory object.

getAgentConfig

public NSClientAgentConfig getAgentConfig(InetAddress agentInetAddress)

getAgentConfig

Parameters:
agentInetAddress - a InetAddress object.
Returns:
a NSClientAgentConfig object.


Copyright © 2011. All Rights Reserved.