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 theWmiAgentConfigobjects 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 WmiAgentConfiggetAgentConfig(InetAddress agentInetAddress)getAgentConfigWmiConfiggetConfig()static WmiPeerFactorygetInstance()Return the singleton instance of this factory.static voidinit()Load the config from the default config file and create the singleton instance of this factory.voidoptimize()Combine specific and range elements so that WMIPeerFactory has to spend less time iterating all these elements.static voidreload()Reload the config from the default config filestatic voidsetInstance(WmiPeerFactory instance)setInstanceWmiConfigtranslateConfig(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 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 readIOException- if any.
-
reload
public static void reload() throws IOExceptionReload the config from the default config file- Throws:
IOException- Thrown if the specified config file cannot be read/loadedIOException- if any.
-
getInstance
public static WmiPeerFactory getInstance()
Return the singleton instance of this factory.- Returns:
- The current factory instance.
- Throws:
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:AbstractJaxbConfigDaotranslateConfig
- Specified by:
translateConfigin classAbstractJaxbConfigDao<WmiConfig,WmiConfig>- Parameters:
config- a K object.- Returns:
- a V object.
-
getConfig
public WmiConfig getConfig()
-
optimize
public void optimize() throws UnknownHostExceptionCombine 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:
UnknownHostException
-
getAgentConfig
public WmiAgentConfig getAgentConfig(InetAddress agentInetAddress)
getAgentConfig
- Parameters:
agentInetAddress- aInetAddressobject.- Returns:
- a
org.opennms.protocols.wmi.WmiAgentConfigobject.
-
-