org.opennms.netmgt.config
Class SnmpPeerFactory

java.lang.Object
  extended by org.opennms.netmgt.config.PeerFactory
      extended by org.opennms.netmgt.config.SnmpPeerFactory
All Implemented Interfaces:
SnmpAgentConfigFactory

public final class SnmpPeerFactory
extends PeerFactory
implements SnmpAgentConfigFactory

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)
           
SnmpPeerFactory(org.springframework.core.io.Resource resource)
           
 
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 File getFile()
           
static SnmpPeerFactory getInstance()
          Return the singleton instance of this factory.
static 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 setFile(File configFile)
           
static void setInstance(SnmpPeerFactory singleton)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SnmpPeerFactory

public SnmpPeerFactory(org.springframework.core.io.Resource resource)

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 IOException,
                               org.exolab.castor.xml.MarshalException,
                               org.exolab.castor.xml.ValidationException
Saves the current settings to disk

Throws:
IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException

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.

setFile

public static void setFile(File configFile)

getFile

public static File getFile()
                    throws IOException
Throws:
IOException

setInstance

public static void setInstance(SnmpPeerFactory singleton)

getAgentConfig

public org.opennms.netmgt.snmp.SnmpAgentConfig getAgentConfig(InetAddress agentAddress)
Specified by:
getAgentConfig in interface SnmpAgentConfigFactory

getSnmpConfig

public static SnmpConfig getSnmpConfig()

define

public void define(SnmpEventInfo info)
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.


marshallConfig

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

Returns:
Marshalled SnmpConfig


Copyright © 2009. All Rights Reserved.