Package org.opennms.netmgt.config
Class AmiPeerFactory
- java.lang.Object
-
- org.opennms.netmgt.config.AmiPeerFactory
-
public class AmiPeerFactory extends java.lang.Object
This class is the main repository for AMI configuration information used by the capabilities daemon. When this class is loaded it reads the AMI configuration into memory, and uses the configuration to find theAmiAgentConfig
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:
- Jeff Gehlbach, OpenNMS
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AmiAgentConfig
getAgentConfig(java.net.InetAddress agentInetAddress)
getAgentConfigstatic AmiConfig
getAmiConfig()
getAmiConfigstatic AmiPeerFactory
getInstance()
Return the singleton instance of this factory.java.util.concurrent.locks.Lock
getReadLock()
java.util.concurrent.locks.Lock
getWriteLock()
static void
init()
Load the config from the default config file and create the singleton instance of this factory.static void
reload()
Reload the config from the default config filevoid
saveCurrent()
Saves the current settings to diskstatic void
setAmiConfig(AmiConfig m_config)
setAmiConfigstatic void
setInstance(AmiPeerFactory singleton)
setInstance
-
-
-
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 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 AmiPeerFactory 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(AmiPeerFactory singleton)
setInstance
- Parameters:
singleton
- aAmiPeerFactory
object.
-
setAmiConfig
public static void setAmiConfig(AmiConfig m_config)
setAmiConfig
- Parameters:
m_config
- aAmiConfig
object.
-
saveCurrent
public void saveCurrent() throws java.lang.Exception
Saves the current settings to disk- Throws:
java.lang.Exception
- if saving settings to disk fails.
-
getAgentConfig
public AmiAgentConfig getAgentConfig(java.net.InetAddress agentInetAddress)
getAgentConfig
- Parameters:
agentInetAddress
- aInetAddress
object.- Returns:
- a
org.opennms.protocols.ami.AmiAgentConfig
object.
-
-