com.adventnet.snmp.snmp2.agent
Class SimpleRequestHandler

java.lang.Object
  extended by com.adventnet.snmp.snmp2.agent.SimpleRequestHandler
All Implemented Interfaces:
VarBindRequestListener, AgentEventListener
Direct Known Subclasses:
BaseSysORTableRequestHandler, BaseTableRequestHandler, BaseTrapForwardingTable, DynamicRegistration, DynamicRegistrationWithCommunity, DynamicRegistrationWithInstance, SnmpAgentInfoRequestHandler, SnmpCommunityTableRequestHandler, SnmpDBAdaptor, SnmpEngineRequestHandler, SnmpMPDStatsRequestHandler, SnmpRequestHandler, SnmpSetRequestHandler, SnmpTargetAddrExtTableRequestHandler, SnmpTargetAddrTableRequestHandler, SnmpTargetObjectsRequestHandler, SystemGroupHandler, TrapTableRequestHandler, UsmStatsRequestHandler, UsmUserRequestHandler, UsmUserTableRequestHandler, VacmAccessTableRequestHandler, VacmContextTableRequestHandler, VacmMIBViewsRequestHandler, VacmSecurityToGroupTableRequestHandler, VacmViewTreeFamilyTableRequestHandler

public class SimpleRequestHandler
extends java.lang.Object
implements VarBindRequestListener

Implements the VarBindRequestListener interface.

See Also:
VarBindRequestListener, PduRequestHandler

Field Summary
protected  InstrumentHandlerInterface instrumentHandler
           
protected  UpdateListener listener
          The UpdateListener for persistence storage.
protected  TableModelListenerExt tableListener
           
(package private)  boolean writeEachTime
           
 
Constructor Summary
SimpleRequestHandler()
          Default Constructor - currently does nothing.
 
Method Summary
 void addInstrumentHandler(InstrumentHandlerInterface listener)
          Setting of InstrumentHandler,which will be used for getting/setting attributes in Instrument files of Scalar Group
 void addRegistrationListener(RegistrationListener rl)
          This method is called by BeanInfo for adding Registration Listener with PduRequestHandler
 void addTableListener(TableModelListenerExt listener)
          Setting of TableModelListenerExt,which will be used if StorageType is "User Storage Model"
 void addUpdateListener(UpdateListener l)
          Addition of UpdateListener for persistence storage of Table values.
 InstrumentHandlerInterface getInstrument()
          Used for getting the InstrumentHandler interface reference
static java.util.Hashtable getMibVarHash()
          Deprecated. - use getObjectHash() for getting the details of Sub-Ids This method will be overridden in the generated handler files to return the Hashtable which has the details of the Subid List.
 void getNextRequest(VarBindRequestEvent pe)
          This method is same as the getNextRequest(VarBindRequestEvent,AgentResource) method.
 void getNextRequest(VarBindRequestEvent pe, AgentResource agentSource)
          This method is called by AdventNet Extensible Agent for SNMP Get Next Requests
 java.util.Hashtable getObjectHash()
          This method is same as getMibVarHash(),but non-static This is duplicated for backward compatibility.
 java.util.Hashtable getObjectTypeHash()
          This method will be overridden in the generated handler files to return the Hashtable which has the details of the syntax type of each obkect in that Scalar/Table group
 int[] getOidRep()
          Retrives the integer representation of OID
 void getRequest(VarBindRequestEvent pe)
          This method is called by AdventNet Extensible Agent for SNMP Get Requests
protected  int[] getSubidList()
          Gets the subid list of the oid.
 TableModelListenerExt getTableListener()
          Used for getting the TableModelListenerExt interface reference This will be used if StorageType is "User Storage Model"
 UpdateListener getUpdateListener()
          Getting the UpdateListener to Add/Update/Delete the entries in the persistence storage Table values.
 boolean isWriteEachTime()
          This method gets whether the file needs to be updated on every SET request or for the whole table
protected  void processGetNextRequest(SnmpVarBind varb, AgentNode node, VarBindRequestEvent pe)
          Process the GetNext Request message which is received from PduRequestHandler.
protected  void processGetNextRequest(java.util.Vector list, java.util.Vector leafNodes, VarBindRequestEvent pe)
          Process the GetNext Request message which is received from PduRequestHandler.
protected  void processGetRequest(SnmpVarBind varb, AgentNode node, VarBindRequestEvent pe)
          Process the Get Request message which is received from PduRequestHandler.
protected  void processGetRequest(java.util.Vector list, java.util.Vector leafNodes, VarBindRequestEvent pe)
          Process the Get Request message which is received from PduRequestHandler.
protected  void processSetRequest(SnmpVarBind varb, AgentNode node, VarBindRequestEvent pe)
          Process the Set Request message which is received from PduRequestHandler.
protected  void processSetRequest(java.util.Vector list, java.util.Vector leafNodes, VarBindRequestEvent pe)
          Process the Set Request message which is received from PduRequestHandler.
 void removeRegistrationListener(RegistrationListener rl)
          This method is called by BeanInfo for removing Registration Listener from PduRequestHandler
 void removeUpdateListener()
          Removal of UpdateListener for persistence storage of Table values.
 void setRequest(VarBindRequestEvent pe)
          This method is called by AdventNet Extensible Agent for SNMP Set Requests
 void setWriteEachTime(boolean val)
          This method can be called to set whether the file needs to be updated on every SET request or after proceesing all the SET requests ( in mult-var SET )
protected  void writeIntoFile()
          Writes the entry into the file if Persistence option is selected.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

writeEachTime

boolean writeEachTime

listener

protected UpdateListener listener
The UpdateListener for persistence storage.


instrumentHandler

protected InstrumentHandlerInterface instrumentHandler

tableListener

protected TableModelListenerExt tableListener
Constructor Detail

SimpleRequestHandler

public SimpleRequestHandler()
Default Constructor - currently does nothing.

Method Detail

setWriteEachTime

public void setWriteEachTime(boolean val)
This method can be called to set whether the file needs to be updated on every SET request or after proceesing all the SET requests ( in mult-var SET )

Parameters:
val - the boolean value

isWriteEachTime

public boolean isWriteEachTime()
This method gets whether the file needs to be updated on every SET request or for the whole table

Returns:
the value of writeEachTime

getMibVarHash

public static java.util.Hashtable getMibVarHash()
Deprecated. - use getObjectHash() for getting the details of Sub-Ids This method will be overridden in the generated handler files to return the Hashtable which has the details of the Subid List.

Returns:
The Hashtable of MibVars.

getObjectHash

public java.util.Hashtable getObjectHash()
This method is same as getMibVarHash(),but non-static This is duplicated for backward compatibility. This method will be overridden in the generated handler files to return the Hashtable which has the details of the Subid List.


getObjectTypeHash

public java.util.Hashtable getObjectTypeHash()
This method will be overridden in the generated handler files to return the Hashtable which has the details of the syntax type of each obkect in that Scalar/Table group

Returns:
The Hashtable of Objects Types.

getRequest

public void getRequest(VarBindRequestEvent pe)
                throws AgentSnmpException
This method is called by AdventNet Extensible Agent for SNMP Get Requests

Specified by:
getRequest in interface VarBindRequestListener
Parameters:
pe - the VarBindRequestEvent contains information about varbinds and sender
Throws:
AgentSnmpException - AgentSnmpException this wraps all the exceptions occured while processing this Request.

getNextRequest

public void getNextRequest(VarBindRequestEvent pe)
                    throws AgentSnmpException
This method is same as the getNextRequest(VarBindRequestEvent,AgentResource) method. Having this to have backward compatibility with older versions

Parameters:
pe - the VarBindRequestEvent contains information about varbinds and sender
agentSource - The AgentResource created for this Request.
Throws:
AgentSnmpException - this wraps all the exceptions occured while processing this Request.

getNextRequest

public void getNextRequest(VarBindRequestEvent pe,
                           AgentResource agentSource)
                    throws AgentSnmpException
This method is called by AdventNet Extensible Agent for SNMP Get Next Requests

Specified by:
getNextRequest in interface VarBindRequestListener
Parameters:
pe - the VarBindRequestEvent contains information about varbinds and sender
agentSource - The AgentResource created for this Request.
Throws:
AgentSnmpException - this wraps all the exceptions occured while processing this Request.

setRequest

public void setRequest(VarBindRequestEvent pe)
                throws AgentSnmpException
This method is called by AdventNet Extensible Agent for SNMP Set Requests

Specified by:
setRequest in interface VarBindRequestListener
Parameters:
pe - the VarBindRequestEvent contains information about varbinds and sender
Throws:
AgentSnmpException - this wraps all the exceptions occured while processing this Request.

addRegistrationListener

public void addRegistrationListener(RegistrationListener rl)
This method is called by BeanInfo for adding Registration Listener with PduRequestHandler

Parameters:
rl - the registration listener for an OID.

removeRegistrationListener

public void removeRegistrationListener(RegistrationListener rl)
This method is called by BeanInfo for removing Registration Listener from PduRequestHandler

Parameters:
rl - the registration listener for an OID.

processGetRequest

protected void processGetRequest(SnmpVarBind varb,
                                 AgentNode node,
                                 VarBindRequestEvent pe)
                          throws AgentSnmpException
Process the Get Request message which is received from PduRequestHandler.

Parameters:
varb - The received varbind .
node - The node for which Get Request is to be done.
pe - The VarBind Request Event created by this Get request.
Throws:
AgentSnmpException - This wraps all the Exceptions thrown while Processing the Event.

processGetRequest

protected void processGetRequest(java.util.Vector list,
                                 java.util.Vector leafNodes,
                                 VarBindRequestEvent pe)
Process the Get Request message which is received from PduRequestHandler.

Parameters:
list - List of SnmpVarbinds received for which SET is to be performed
leafNodes - List of AgentNodes for which GET Request is to be performed
pe - The VarBind Request Event created by this Get request.

processSetRequest

protected void processSetRequest(SnmpVarBind varb,
                                 AgentNode node,
                                 VarBindRequestEvent pe)
                          throws AgentSnmpException
Process the Set Request message which is received from PduRequestHandler.

Parameters:
varb - The received varbind.
node - The node for which Get Next Request is to be done.
pe - The VarBind Request Event created by this GetNext request.
Throws:
AgentSnmpException - This wraps all the Exceptions thrown while Processing the Event.

processSetRequest

protected void processSetRequest(java.util.Vector list,
                                 java.util.Vector leafNodes,
                                 VarBindRequestEvent pe)
Process the Set Request message which is received from PduRequestHandler.

Parameters:
list - List of SnmpVarbinds received for which SET is to be performed
leafNodes - List of AgentNodes for which SET Request is to be performed
pe - The VarBind Request Event created by this Set request.

writeIntoFile

protected void writeIntoFile()
Writes the entry into the file if Persistence option is selected. Derived classes can override this method to handle writing into the file. This method will be called according to the value of writeEachTime boolean. By default the file will be updated after completing all the requests for a table ( If multi-var SET is made ). Generated code can override this method to enable writing into file after each SET is made.

See Also:
setWriteEachTime(boolean val)

processGetNextRequest

protected void processGetNextRequest(SnmpVarBind varb,
                                     AgentNode node,
                                     VarBindRequestEvent pe)
                              throws AgentSnmpException
Process the GetNext Request message which is received from PduRequestHandler.

Parameters:
varb - The received varbind.
node - The node for which Get Next Request is to be done.
pe - The VarBind Request Event created by this GetNext request.
Throws:
AgentSnmpException - This wraps all the Exceptions thrown while Processing the Event.

processGetNextRequest

protected void processGetNextRequest(java.util.Vector list,
                                     java.util.Vector leafNodes,
                                     VarBindRequestEvent pe)
Process the GetNext Request message which is received from PduRequestHandler.

Parameters:
list - List of SnmpVarbinds received for which GETNEXT is to be performed
leafNodes - List of AgentNodes for which GETNEXT Request is to be performed
pe - The VarBind Request Event created by this GetNext request.

getOidRep

public int[] getOidRep()
Retrives the integer representation of OID

Returns:
the integer array of OID

getSubidList

protected int[] getSubidList()
Gets the subid list of the oid.

Returns:
the integer array of subid list

addUpdateListener

public void addUpdateListener(UpdateListener l)
Addition of UpdateListener for persistence storage of Table values.

Parameters:
l - The updateListener which implements the writeIntoFile method.

getUpdateListener

public UpdateListener getUpdateListener()
Getting the UpdateListener to Add/Update/Delete the entries in the persistence storage Table values.

Parameters:
l - The updateListener which implements the writeIntoFile method.

removeUpdateListener

public void removeUpdateListener()
Removal of UpdateListener for persistence storage of Table values. Makes the UpdateListener to null.


getInstrument

public InstrumentHandlerInterface getInstrument()
Used for getting the InstrumentHandler interface reference

Returns:
InstrumentHandler reference

getTableListener

public TableModelListenerExt getTableListener()
Used for getting the TableModelListenerExt interface reference This will be used if StorageType is "User Storage Model"

Returns:
TableModelListenerExt reference

addInstrumentHandler

public void addInstrumentHandler(InstrumentHandlerInterface listener)
Setting of InstrumentHandler,which will be used for getting/setting attributes in Instrument files of Scalar Group

Parameters:
listener - Listener which implements InstrumentHandler Interface

addTableListener

public void addTableListener(TableModelListenerExt listener)
Setting of TableModelListenerExt,which will be used if StorageType is "User Storage Model"

Parameters:
listener - Listener which implements TableModelListenerExt Interface