org.opennms.netmgt.config
Class AmiPeerFactory

java.lang.Object
  extended by org.opennms.netmgt.config.PeerFactory
      extended by org.opennms.netmgt.config.AmiPeerFactory

public class AmiPeerFactory
extends PeerFactory

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 the AmiAgentConfig 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.

Version:
$Id: $
Author:
Jeff Gehlbach, OpenNMS , Jeff Gehlbach, OpenNMS

Method Summary
 void define(InetAddress ip, String username, String password)
          Puts a specific IP address with associated password into the currently loaded ami-config.xml.
 AmiAgentConfig getAgentConfig(InetAddress agentInetAddress)
          getAgentConfig
static AmiConfig getAmiConfig()
          getAmiConfig
static AmiPeerFactory 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.
static void reload()
          Reload the config from the default config file
static void saveCurrent()
          Saves the current settings to disk
static void setAmiConfig(AmiConfig m_config)
          setAmiConfig
static void setInstance(AmiPeerFactory singleton)
          setInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

init

public static void init()
                 throws IOException,
                        org.exolab.castor.xml.MarshalException,
                        org.exolab.castor.xml.ValidationException
Load 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 read
org.exolab.castor.xml.MarshalException - Thrown if the file does not conform to the schema.
org.exolab.castor.xml.ValidationException - Thrown if the contents do not match the required schema.
IOException - if any.
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.

reload

public static void reload()
                   throws IOException,
                          org.exolab.castor.xml.MarshalException,
                          org.exolab.castor.xml.ValidationException
Reload the config from the default config file

Throws:
IOException - Thrown if the specified config file cannot be read/loaded
org.exolab.castor.xml.MarshalException - Thrown if the file does not conform to the schema.
org.exolab.castor.xml.ValidationException - Thrown if the contents do not match the required schema.
IOException - if any.
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.

saveCurrent

public static void saveCurrent()
                        throws Exception
Saves the current settings to disk

Throws:
Exception - if saving settings to disk fails.

getInstance

public static AmiPeerFactory 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(AmiPeerFactory singleton)

setInstance

Parameters:
singleton - a AmiPeerFactory object.

define

public void define(InetAddress ip,
                   String username,
                   String password)
            throws UnknownHostException
Puts a specific IP address with associated password into the currently loaded ami-config.xml. Perhaps with a bit of jiggery pokery this could be pulled up into PeerFactory

Parameters:
ip - the IP address of a definition
password - the password for a definition
username - a String object.
Throws:
UnknownHostException - if any.

getAgentConfig

public AmiAgentConfig getAgentConfig(InetAddress agentInetAddress)

getAgentConfig

Parameters:
agentInetAddress - a InetAddress object.
Returns:
a AmiAgentConfig object.

getAmiConfig

public static AmiConfig getAmiConfig()

getAmiConfig

Returns:
a AmiConfig object.

setAmiConfig

public static void setAmiConfig(AmiConfig m_config)

setAmiConfig

Parameters:
m_config - a AmiConfig object.


Copyright © 2011. All Rights Reserved.