Class PollerConfigFactory

  • All Implemented Interfaces:
    PathOutageConfig, PollerConfig

    public final class PollerConfigFactory
    extends PollerConfigManager
    This is the singleton class used to load the configuration for the OpenNMS Poller service from the poller-configuration XML file. A mapping of the configured URLs to the iplist they contain is built at init() time so as to avoid numerous file reads. 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 , Mike Davidson , Sowmya Nataraj , OpenNMS
    • Constructor Detail

      • PollerConfigFactory

        public PollerConfigFactory​(long currentVersion,
                                   java.io.InputStream stream)

        Constructor for PollerConfigFactory.

        Parameters:
        currentVersion - a long.
        stream - a InputStream object.
    • Method Detail

      • setPollerConfigFile

        public static void setPollerConfigFile​(java.io.File pollerConfigFile)
                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • 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.
      • getInstance

        public static PollerConfig 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.
      • setInstance

        public static void setInstance​(PollerConfig instance)

        setInstance

        Parameters:
        instance - a PollerConfig object.
      • saveXml

        protected void saveXml​(java.lang.String xml)
                        throws java.io.IOException

        saveXml

        Specified by:
        saveXml in class PollerConfigManager
        Parameters:
        xml - a String object.
        Throws:
        java.io.IOException - if any.