Class NSClientPeerFactory
- java.lang.Object
-
- org.opennms.protocols.nsclient.config.NSClientPeerFactory
-
public 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 theNSClientAgentConfig
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
Constructors Constructor Description NSClientPeerFactory(InputStream stream)
Constructor for NSClientPeerFactory.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description NSClientAgentConfig
getAgentConfig(InetAddress agentInetAddress)
getAgentConfigstatic 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 filevoid
saveCurrent()
Saves the current settings to diskstatic void
setInstance(NSClientPeerFactory singleton)
setInstance
-
-
-
Constructor Detail
-
NSClientPeerFactory
public NSClientPeerFactory(InputStream stream) throws IOException
Constructor for NSClientPeerFactory.
- Parameters:
stream
- aInputStream
object.- Throws:
IOException
- if any.
-
-
Method Detail
-
getReadLock
public Lock getReadLock()
-
getWriteLock
public Lock getWriteLock()
-
init
public static void init() throws IOException
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 readIOException
- if any.
-
reload
public static void reload() throws IOException
Reload the config from the default config file- Throws:
IOException
- Thrown if the specified config file cannot be read/loadedIOException
- if any.
-
saveCurrent
public void saveCurrent() throws FileNotFoundException, IOException
Saves the current settings to disk- Throws:
IOException
FileNotFoundException
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
- aNSClientPeerFactory
object.
-
getAgentConfig
public NSClientAgentConfig getAgentConfig(InetAddress agentInetAddress)
getAgentConfig
- Parameters:
agentInetAddress
- aInetAddress
object.- Returns:
- a
NSClientAgentConfig
object.
-
-