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(Reader rdr)
           
 
Method Summary
 void define(SnmpEventInfo info)
          Enhancement: Allows specific or ranges to be merged into snmp configuration with many other attributes.
 org.opennms.netmgt.snmp.SnmpAgentConfig getAgentConfig(InetAddress agentAddress)
           
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 String marshallConfig()
          Creates a string containing the XML of the current SnmpConfig
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 String toIpAddr(long ip)
          display an IP as a dotted quad xxx.xxx.xxx.xxx
 
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(Reader rdr)
                throws IOException,
                       org.exolab.castor.xml.MarshalException,
                       org.exolab.castor.xml.ValidationException
Throws:
IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException
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.

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.

saveCurrent

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

Throws:
Exception

getInstance

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

getAgentConfig

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

getSnmpConfig

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

toIpAddr

public static String toIpAddr(long ip)
display an IP as a dotted quad xxx.xxx.xxx.xxx


define

public void define(SnmpEventInfo info)
            throws UnknownHostException
Enhancement: Allows specific or ranges to be merged into snmp configuration with many other attributes. Uses new classes the wrap Castor generated code to help with merging, comparing, and optimizing definitions. Thanks for your initial work on this Gerald. Puts a specific IP address with associated read-community string into the currently loaded snmp-config.xml.

Throws:
UnknownHostException

marshallConfig

public static String marshallConfig()
Creates a string containing the XML of the current SnmpConfig

Returns:
Marshalled SnmpConfig


Copyright ? 2008. All Rights Reserved.