Package org.opennms.netmgt.config
Class WmiPeerFactory
- java.lang.Object
-
- org.opennms.core.xml.AbstractJaxbConfigDao<K,V>
-
- org.opennms.core.xml.AbstractWritableJaxbConfigDao<WmiConfig,WmiConfig>
-
- org.opennms.netmgt.config.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 theWmiAgentConfig
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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.opennms.core.xml.AbstractJaxbConfigDao
AbstractJaxbConfigDao.JaxbReloadCallback
-
-
Constructor Summary
Constructors Constructor Description WmiPeerFactory()
WmiPeerFactory(org.springframework.core.io.Resource resource)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description WmiAgentConfig
getAgentConfig(java.net.InetAddress agentInetAddress)
getAgentConfigWmiConfig
getConfig()
static WmiPeerFactory
getInstance()
Return the singleton instance of this factory.static void
init()
Load the config from the default config file and create the singleton instance of this factory.void
optimize()
Combine specific and range elements so that WMIPeerFactory has to spend less time iterating all these elements.static void
reload()
Reload the config from the default config filestatic void
setInstance(WmiPeerFactory instance)
setInstanceWmiConfig
translateConfig(WmiConfig config)
translateConfig-
Methods inherited from class org.opennms.core.xml.AbstractWritableJaxbConfigDao
getObject, getReadLock, getWriteLock, saveCurrent, update
-
Methods inherited from class org.opennms.core.xml.AbstractJaxbConfigDao
addOnReloadedCallback, afterPropertiesSet, getConfigResource, getContainer, getDescription, getReloadCheckInterval, loadConfig, setConfigResource, setReloadCheckInterval
-
-
-
-
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 readjava.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/loadedjava.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
-
translateConfig
public WmiConfig translateConfig(WmiConfig config)
Description copied from class:AbstractJaxbConfigDao
translateConfig
- Specified by:
translateConfig
in classAbstractJaxbConfigDao<WmiConfig,WmiConfig>
- Parameters:
config
- a K object.- Returns:
- a V object.
-
getConfig
public WmiConfig getConfig()
-
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
- aInetAddress
object.- Returns:
- a
org.opennms.protocols.wmi.WmiAgentConfig
object.
-
-