Class NSClientPeerFactory


  • public class NSClientPeerFactory
    extends java.lang.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 Detail

      • NSClientPeerFactory

        public NSClientPeerFactory​(java.io.InputStream stream)
                            throws java.io.IOException

        Constructor for NSClientPeerFactory.

        Parameters:
        stream - a InputStream object.
        Throws:
        java.io.IOException - if any.
    • Method Detail

      • getReadLock

        public java.util.concurrent.locks.Lock getReadLock()
      • getWriteLock

        public java.util.concurrent.locks.Lock getWriteLock()
      • init

        public static void init()
                         throws java.io.IOException
        Load the config from the default config file and create the singleton instance of this factory.
        Throws:
        java.io.IOException - Thrown if the specified config file cannot be read
        java.io.IOException - if any.
      • reload

        public static void reload()
                           throws java.io.IOException
        Reload the config from the default config file
        Throws:
        java.io.IOException - Thrown if the specified config file cannot be read/loaded
        java.io.IOException - if any.
      • saveCurrent

        public void saveCurrent()
                         throws java.io.FileNotFoundException,
                                java.io.IOException
        Saves the current settings to disk
        Throws:
        java.io.IOException
        java.io.FileNotFoundException
        java.lang.Exception - if any.
      • getInstance

        public static NSClientPeerFactory getInstance()
        Return the singleton instance of this factory.
        Returns:
        The current factory instance.
        Throws:
        java.lang.IllegalStateException - Thrown if the factory has not yet been initialized.
      • getAgentConfig

        public NSClientAgentConfig getAgentConfig​(java.net.InetAddress agentInetAddress)

        getAgentConfig

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