Class WmiPeerFactory

  • All Implemented Interfaces:
    org.springframework.beans.factory.InitializingBean

    public class WmiPeerFactory
    extends AbstractWritableJaxbConfigDao<WmiConfig,​WmiConfig>
    This class is the main repository for WMI configuration information used by the capabilities daemon. When this class is loaded it reads the WMI configuration into memory, and uses the configuration to find the WmiAgentConfig 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 , Matt Raykowski
    • Constructor Detail

      • WmiPeerFactory

        public WmiPeerFactory()
      • WmiPeerFactory

        public WmiPeerFactory​(org.springframework.core.io.Resource resource)
    • Method Detail

      • 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 WmiPeerFactory 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​(WmiPeerFactory instance)

        setInstance

      • optimize

        public void optimize()
                      throws java.net.UnknownHostException
        Combine specific and range elements so that WMIPeerFactory has to spend less time iterating all these elements. TODO This really should be pulled up into PeerFactory somehow, but I'm not sure how (given that "Definition" is different for both SNMP and WMI. Maybe some sort of visitor methodology would work. The basic logic should be fine as it's all IP address manipulation Calls should be preceded by a getWriteLock().lock() and wrapped in a try / finally block with getWriteLock().unlock().
        Throws:
        java.net.UnknownHostException
      • getAgentConfig

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

        getAgentConfig

        Parameters:
        agentInetAddress - a InetAddress object.
        Returns:
        a org.opennms.protocols.wmi.WmiAgentConfig object.