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(org.springframework.core.io.Resource resource)
Constructor for SnmpPeerFactory.
|
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) |
SnmpAgentConfig |
getAgentConfig(InetAddress agentInetAddress,
int requestedSnmpVersion) |
SnmpAgentConfig |
getAgentConfig(InetAddress agentAddress,
String location)
getAgentConfig
|
SnmpAgentConfig |
getAgentConfig(InetAddress agentInetAddress,
String location,
int requestedSnmpVersion) |
static File |
getFile() |
static SnmpPeerFactory |
getInstance()
Load the config from the default config file and create the singleton instance of this factory.
|
protected Lock |
getReadLock() |
SnmpConfig |
getSnmpConfig()
getSnmpConfig
|
String |
getSnmpConfigAsString()
Creates a string containing the XML of the current SnmpConfig
|
int |
getVersionCode(Definition def,
SnmpConfig config,
int requestedSnmpVersion) |
protected Lock |
getWriteLock() |
static void |
init() |
void |
saveCurrent()
Saves the current settings to disk
|
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.protected Lock getReadLock()
protected Lock getWriteLock()
public static void init() throws IOException
IOException
public static SnmpPeerFactory getInstance()
IOException
- Thrown if the specified config file cannot be readpublic static void setInstance(SnmpPeerFactory singleton)
setInstance
singleton
- a SnmpPeerFactory
object.public static File getFile() throws IOException
IOException
public void saveCurrent() throws IOException
IOException
- if any.public void saveToFile(File file) throws UnsupportedEncodingException, FileNotFoundException, IOException
public SnmpAgentConfig getAgentConfig(InetAddress agentAddress)
public SnmpAgentConfig getAgentConfig(InetAddress agentAddress, String location)
SnmpAgentConfigFactory
getAgentConfig
getAgentConfig
in interface SnmpAgentConfigFactory
agentAddress
- a InetAddress
object.location
- a String
object.SnmpAgentConfig
object.public SnmpAgentConfig getAgentConfig(InetAddress agentInetAddress, int requestedSnmpVersion)
public SnmpAgentConfig getAgentConfig(InetAddress agentInetAddress, String location, int requestedSnmpVersion)
public int getVersionCode(Definition def, SnmpConfig config, int requestedSnmpVersion)
public SnmpConfig getSnmpConfig()
getSnmpConfig
SnmpConfig
object.public void define(SnmpEventInfo info)
info
- a SnmpEventInfo
object.public String getSnmpConfigAsString()
Copyright © 2019. All rights reserved.