public class SnmpPeerFactory extends Object implements SnmpAgentConfigFactory
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.Constructor and Description |
---|
SnmpPeerFactory(InputStream stream)
Constructor for SnmpPeerFactory.
|
SnmpPeerFactory(Reader rdr)
Deprecated.
Use code for InputStream instead to avoid character set issues
|
SnmpPeerFactory(org.springframework.core.io.Resource resource)
Constructor for SnmpPeerFactory.
|
SnmpPeerFactory(String configString)
A constructor that takes a config string for use mostly in tests
|
Modifier and Type | Method and Description |
---|---|
void |
define(SnmpEventInfo info)
Enhancement: Allows specific or ranges to be merged into SNMP configuration
with many other attributes.
|
SnmpAgentConfig |
getAgentConfig(InetAddress agentAddress)
getAgentConfig
|
static File |
getFile()
getFile
|
static SnmpPeerFactory |
getInstance()
Return the singleton instance of this factory.
|
static Lock |
getReadLock() |
static SnmpConfig |
getSnmpConfig()
getSnmpConfig
|
static Lock |
getWriteLock() |
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 |
saveCurrent()
Saves the current settings to disk
|
static void |
saveToFile(File file) |
static void |
setFile(File configFile)
setFile
|
static void |
setInstance(SnmpPeerFactory singleton)
setInstance
|
public SnmpPeerFactory(org.springframework.core.io.Resource resource)
Constructor for SnmpPeerFactory.
resource
- a Resource
object.public SnmpPeerFactory(Reader rdr) throws IOException
Constructor for SnmpPeerFactory.
rdr
- a Reader
object.IOException
- if any.org.exolab.castor.xml.MarshalException
- if any.org.exolab.castor.xml.ValidationException
- if any.public SnmpPeerFactory(String configString) throws IOException
IOException
public SnmpPeerFactory(InputStream stream)
Constructor for SnmpPeerFactory.
stream
- a InputStream
object.public static Lock getReadLock()
public static Lock getWriteLock()
public static void init() throws IOException
IOException
- Thrown if the specified config file cannot be readorg.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.public static void saveCurrent() throws IOException
IOException
- if any.org.exolab.castor.xml.MarshalException
- if any.org.exolab.castor.xml.ValidationException
- if any.public static void saveToFile(File file) throws UnsupportedEncodingException, FileNotFoundException, IOException
public static SnmpPeerFactory getInstance()
IllegalStateException
- Thrown if the factory has not yet been initialized.public static File getFile() throws IOException
getFile
File
object.IOException
- if any.public static void setInstance(SnmpPeerFactory singleton)
setInstance
singleton
- a SnmpPeerFactory
object.public SnmpAgentConfig getAgentConfig(InetAddress agentAddress)
getAgentConfig
getAgentConfig
in interface SnmpAgentConfigFactory
agentAddress
- a InetAddress
object.SnmpAgentConfig
object.public static SnmpConfig getSnmpConfig()
getSnmpConfig
SnmpConfig
object.public void define(SnmpEventInfo info)
info
- a SnmpEventInfo
object.public static String marshallConfig()
Copyright © 2015. All Rights Reserved.