|
HOME | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.ireasoning.protocol.snmp.DefaultAgentConfig com.ireasoning.protocol.snmp.SnmpAgentConfig
This class represents agent's XML configuration data.
Any changes to the state of this object will result in invocation of save()
. So you do not have
to call save()
method explicitly in most cases.
Sample Code:
SnmpAgentConfig config = new SnmpAgentConfig("d:/config/snmpagent.xml"); config.reloadConfig(); ...
Constructor Summary | |
SnmpAgentConfig()
Default config file |
|
SnmpAgentConfig(Object fileName)
Constructs a SnmpAgentConfig object and loads the passed fileName |
|
SnmpAgentConfig(SnmpAgentConfig conf)
Copy constructor |
Method Summary | |
protected boolean |
doAddGroup(Map attrs)
Adds a group, views associated with this group should already exist. |
protected boolean |
doAddProxy(ProxyEntry entry)
Adds a new proxy to the config settings |
protected boolean |
doAddTrapSink(Map attributes)
Adds a trapSink or snmpV3TrapSink element |
protected boolean |
doAddUser(Map attrs)
Adds a user. |
protected boolean |
doAddView(Map attrs)
Adds a view |
protected Map |
doGetPropertiesProps()
Returns a Map object which stores the attributes of properties node |
protected Map[] |
doGetProxyProps()
Return proxies' properties |
protected Map[] |
doGetSnmpV3TrapSinkProps()
Returns trapsinks' properties |
protected Map |
doGetTrapProxyProps()
Returns trap proxy's properties |
protected Map[] |
doGetTrapSinkProps()
Returns non-SNMPv3 trapsinks' properties |
protected void |
doReloadConfig()
Reloads config settings |
protected boolean |
doRemoveGroup(String groupName)
Removes a group. |
protected boolean |
doRemoveProxy(ProxyEntry entry)
Adds a new proxy to the config settings |
protected boolean |
doRemoveTrapSink(String trapSinkHostName,
int trapSinkPort,
int trapSinkVersion)
Removes a trapSink or snmpV3TrapSink element |
protected boolean |
doRemoveUser(String userName)
Removes a user |
protected boolean |
doRemoveView(String viewName)
Removes a view. |
protected void |
doSave()
Saves config file. |
Map[] |
getCommunityViews()
Returns communityView's properties |
String |
getFileName()
Returns the config file name |
Map |
getGroupAttributes(String groupName)
Returns the group's properties |
Map[] |
getGroups()
Returns groups' properties |
InputStream |
getInputStream()
Returns the InputStream of config. |
long |
getSaveDelayTime()
|
Map |
getUserAttributes(String userName)
Returns properties of a user whose name is the passed userName |
Map[] |
getUsers()
Returns users' properties |
Map[] |
getViewAttributes(String viewName)
|
Map[] |
getViews()
Returns views' properties |
protected void |
postReloadConfig()
It's invoked after reloadConfig() method is called |
void |
reloadConfig(InputStream istream)
Reloads config from an InputStream object. |
void |
save(OutputStream ostream)
Saves config file. |
protected boolean |
setAttributeValue(String elementName,
Map keyvals,
String attributeName,
String attributeValue)
Sets element node's attribute's value. |
void |
setSaveDelayTime(long time)
Delays for a while then do save. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public SnmpAgentConfig()
public SnmpAgentConfig(Object fileName) throws IOException
SnmpAgentConfig
object and loads the passed fileName
public SnmpAgentConfig(SnmpAgentConfig conf) throws IOException
Method Detail |
public String getFileName()
It returns null if config was loaded from an InputStream object.
public InputStream getInputStream()
It returns null if config was loaded from a file.
protected boolean setAttributeValue(String elementName, Map keyvals, String attributeName, String attributeValue)
setAttributeValue
in class DefaultAgentConfig
keyvals
- key/value pairs used to distinguish nodes with identical node nameselementName
- element nameattributeName
- attribute's nameattributeValue
- attribute's valueprotected boolean doAddTrapSink(Map attributes)
DefaultAgentConfig
doAddTrapSink
in class DefaultAgentConfig
attributes
- a Map object containing the name/value of attributes, such as "verion" -- "2"protected boolean doRemoveTrapSink(String trapSinkHostName, int trapSinkPort, int trapSinkVersion)
DefaultAgentConfig
doRemoveTrapSink
in class DefaultAgentConfig
trapSinkHostName
- host name or ip address of trap receivertrapSinkPort
- port number of trap receivertrapSinkVersion
- version of trapSink. 1: SNMPv1, 2: SNMPv2c, 3: SNMPv3
public Map[] getViews()
DefaultAgentConfig
getViews
in class DefaultAgentConfig
public Map[] getViewAttributes(String viewName)
protected boolean doAddView(Map attrs)
DefaultAgentConfig
doAddView
in class DefaultAgentConfig
attrs
- a map containing view's attributes
protected boolean doRemoveView(String viewName)
DefaultAgentConfig
doRemoveView
in class DefaultAgentConfig
public Map[] getGroups()
getGroups
in class DefaultAgentConfig
public Map getGroupAttributes(String groupName)
groupName
- group's nameprotected boolean doAddGroup(Map attrs)
DefaultAgentConfig
doAddGroup
in class DefaultAgentConfig
protected boolean doRemoveGroup(String groupName)
doRemoveGroup
in class DefaultAgentConfig
public Map[] getCommunityViews()
getCommunityViews
in class DefaultAgentConfig
public Map[] getUsers()
getUsers
in class DefaultAgentConfig
public Map getUserAttributes(String userName)
userName
userName
- user's nameprotected boolean doAddUser(Map attrs)
doAddUser
in class DefaultAgentConfig
attrs
- user's attributes, such as "name", "authPassword", "privPassword", etc
protected boolean doRemoveUser(String userName)
doRemoveUser
in class DefaultAgentConfig
public void setSaveDelayTime(long time)
time
- delay time, in milliseconds. If it's 0, save() will be invoked right away. If it's a negative number, save() will never occur.DefaultAgentConfig.save()
public long getSaveDelayTime()
public void save(OutputStream ostream) throws IOException
ostream
- OutputStream object for saving config. If it's null
, config can't be saved.
ostream
will be closed when save is finished
IOException
setSaveDelayTime(long)
protected void doSave() throws IOException
doSave
in class DefaultAgentConfig
IOException
setSaveDelayTime(long)
public void reloadConfig(InputStream istream) throws IOException
istream
- an InputStream object from which config is loaded
IOException
DefaultAgentConfig.reloadConfig()
protected void doReloadConfig() throws IOException
DefaultAgentConfig
doReloadConfig
in class DefaultAgentConfig
IOException
protected void postReloadConfig()
DefaultAgentConfig
postReloadConfig
in class DefaultAgentConfig
protected Map doGetPropertiesProps()
DefaultAgentConfig
doGetPropertiesProps
in class DefaultAgentConfig
protected Map[] doGetTrapSinkProps()
doGetTrapSinkProps
in class DefaultAgentConfig
protected Map doGetTrapProxyProps()
DefaultAgentConfig
doGetTrapProxyProps
in class DefaultAgentConfig
protected Map[] doGetProxyProps()
DefaultAgentConfig
doGetProxyProps
in class DefaultAgentConfig
protected Map[] doGetSnmpV3TrapSinkProps()
doGetSnmpV3TrapSinkProps
in class DefaultAgentConfig
protected boolean doAddProxy(ProxyEntry entry)
doAddProxy
in class DefaultAgentConfig
protected boolean doRemoveProxy(ProxyEntry entry)
doRemoveProxy
in class DefaultAgentConfig
|
HOME | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |