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 theNSClientAgentConfigobjects 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 SummaryConstructors Constructor Description NSClientPeerFactory(InputStream stream)Constructor for NSClientPeerFactory.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description NSClientAgentConfiggetAgentConfig(InetAddress agentInetAddress)getAgentConfigstatic NSClientPeerFactorygetInstance()Return the singleton instance of this factory.LockgetReadLock()LockgetWriteLock()static voidinit()Load the config from the default config file and create the singleton instance of this factory.static voidreload()Reload the config from the default config filevoidsaveCurrent()Saves the current settings to diskstatic voidsetInstance(NSClientPeerFactory singleton)setInstance
 
- 
- 
- 
Constructor Detail- 
NSClientPeerFactorypublic NSClientPeerFactory(InputStream stream) throws IOException Constructor for NSClientPeerFactory. - Parameters:
- stream- a- InputStreamobject.
- Throws:
- IOException- if any.
 
 
- 
 - 
Method Detail- 
getReadLockpublic Lock getReadLock() 
 - 
getWriteLockpublic Lock getWriteLock() 
 - 
initpublic static void init() throws IOExceptionLoad 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
- IOException- if any.
 
 - 
reloadpublic static void reload() throws IOExceptionReload the config from the default config file- Throws:
- IOException- Thrown if the specified config file cannot be read/loaded
- IOException- if any.
 
 - 
saveCurrentpublic void saveCurrent() throws FileNotFoundException, IOExceptionSaves the current settings to disk- Throws:
- IOException
- FileNotFoundException
- Exception- if any.
 
 - 
getInstancepublic 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.
 
 - 
setInstancepublic static void setInstance(NSClientPeerFactory singleton) setInstance - Parameters:
- singleton- a- NSClientPeerFactoryobject.
 
 - 
getAgentConfigpublic NSClientAgentConfig getAgentConfig(InetAddress agentInetAddress) getAgentConfig - Parameters:
- agentInetAddress- a- InetAddressobject.
- Returns:
- a NSClientAgentConfigobject.
 
 
- 
 
-