org.opennms.netmgt.config
Class SnmpPeerFactory

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

public final class SnmpPeerFactory
extends PeerFactory

This class is the main respository for SNMP configuration information used by the capabilities daemon. When this class is loaded it reads the snmp configuration into memory, and uses the configuration to find the SnmpAgentConfig 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 , OpenNMS

Constructor Summary
SnmpPeerFactory(java.io.Reader rdr)
           
 
Method Summary
 void define(java.net.InetAddress ip, java.lang.String community)
          Puts a specific IP address with associated read-community string into the currently loaded snmp-config.xml.
 org.opennms.netmgt.snmp.SnmpAgentConfig getAgentConfig(java.net.InetAddress agentAddress)
           
 org.opennms.netmgt.snmp.SnmpAgentConfig getAgentConfig(java.net.InetAddress agentInetAddress, int requestedSnmpVersion)
           
static SnmpPeerFactory getInstance()
          Return the singleton instance of this factory.
static org.opennms.netmgt.config.snmp.SnmpConfig getSnmpConfig()
           
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 setInstance(SnmpPeerFactory singleton)
           
static void setSnmpConfig(org.opennms.netmgt.config.snmp.SnmpConfig m_config)
           
 
Methods inherited from class org.opennms.netmgt.config.PeerFactory
countChar, matchNumericListOrRange, matchRange, toLong, verifyIpMatch
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SnmpPeerFactory

public SnmpPeerFactory(java.io.Reader rdr)
                throws java.io.IOException,
                       org.exolab.castor.xml.MarshalException,
                       org.exolab.castor.xml.ValidationException
Throws:
java.io.IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException
Method Detail

init

public static void init()
                 throws java.io.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:
java.io.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.

reload

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

Throws:
java.io.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.

saveCurrent

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

Throws:
java.lang.Exception

getInstance

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

define

public void define(java.net.InetAddress ip,
                   java.lang.String community)
            throws java.net.UnknownHostException
Puts a specific IP address with associated read-community string into the currently loaded snmp-config.xml.

Throws:
java.net.UnknownHostException

getAgentConfig

public org.opennms.netmgt.snmp.SnmpAgentConfig getAgentConfig(java.net.InetAddress agentAddress)

getAgentConfig

public org.opennms.netmgt.snmp.SnmpAgentConfig getAgentConfig(java.net.InetAddress agentInetAddress,
                                                              int requestedSnmpVersion)

getSnmpConfig

public static org.opennms.netmgt.config.snmp.SnmpConfig getSnmpConfig()

setSnmpConfig

public static void setSnmpConfig(org.opennms.netmgt.config.snmp.SnmpConfig m_config)


Copyright © 2007. All Rights Reserved.