org.jboss.jmx.adaptor.snmp.agent
Class RequestHandlerSupport

java.lang.Object
  extended by org.jboss.jmx.adaptor.snmp.agent.RequestHandlerSupport
All Implemented Interfaces:
RequestHandler, SnmpAgentRequestHandler
Direct Known Subclasses:
RequestHandlerImpl

public abstract class RequestHandlerSupport
extends java.lang.Object
implements RequestHandler

Implement RequestHandler with simple tracing of incoming requests. Derived classes are expected to implement actual behaviour.

Version:
$Revision: 110496 $
Author:
Krishnaraj S, Dimitris Andreadis

Field Summary
protected  Clock clock
          the agent clock
protected  org.jboss.logging.Logger log
          Logger object
protected  java.lang.String resourceName
          the file name to get mapping info from
protected  javax.management.MBeanServer server
          the MBeanServer
 
Constructor Summary
RequestHandlerSupport()
          Default CTOR
 
Method Summary
 void initialize(java.lang.String resourceName, javax.management.MBeanServer server, org.jboss.logging.Logger log, Clock uptime)
          Initialize
 void SnmpAgentSessionError(org.snmp4j.Snmp session, int error, java.lang.Object ref)
          This method is invoked if an error occurs in the session.
 org.snmp4j.PDU snmpReceivedGet(org.snmp4j.PDU pdu)
          This method is defined to handle SNMP Get requests that are received by the session.
 org.snmp4j.PDU snmpReceivedGetBulk(org.snmp4j.PDU pdu)
          This method is defined to handle SNMP Get requests that are received by the session.
 void snmpReceivedPdu(org.snmp4j.Snmp session, java.net.InetAddress manager, int port, org.snmp4j.smi.OctetString community, org.snmp4j.PDU pdu)
          This method is defined to handle SNMP requests that are received by the session.
 org.snmp4j.PDU snmpReceivedSet(org.snmp4j.PDU pdu)
          This method is defined to handle SNMP Set requests that are received by the session.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.jmx.adaptor.snmp.agent.RequestHandler
addAttributeMappings, getValueFor, removeAttributeMappings
 

Field Detail

log

protected org.jboss.logging.Logger log
Logger object


server

protected javax.management.MBeanServer server
the MBeanServer


resourceName

protected java.lang.String resourceName
the file name to get mapping info from


clock

protected Clock clock
the agent clock

Constructor Detail

RequestHandlerSupport

public RequestHandlerSupport()
Default CTOR

Method Detail

initialize

public void initialize(java.lang.String resourceName,
                       javax.management.MBeanServer server,
                       org.jboss.logging.Logger log,
                       Clock uptime)
                throws java.lang.Exception
Initialize

Specified by:
initialize in interface RequestHandler
Parameters:
resourceName - file containing mappinginfo
server - the mbean server to forward mapped get/set requests
uptime - the snmp agent uptime
Throws:
java.lang.Exception - in case of initialization problem

snmpReceivedGetBulk

public org.snmp4j.PDU snmpReceivedGetBulk(org.snmp4j.PDU pdu)

This method is defined to handle SNMP Get requests that are received by the session. The request has already been validated by the system. This routine will build a response and pass it back to the caller.

Specified by:
snmpReceivedGetBulk in interface SnmpAgentRequestHandler
Parameters:
pdu - The SNMP pdu
getNext - The agent is requesting the lexically NEXT item after each item in the pdu.
Returns:
SnmpPduRequest filled in with the proper response, or null if cannot process NOTE: this might be changed to throw an exception.

snmpReceivedGet

public org.snmp4j.PDU snmpReceivedGet(org.snmp4j.PDU pdu)
Description copied from interface: SnmpAgentRequestHandler

This method is defined to handle SNMP Get requests that are received by the session. The request has already been validated by the system. This routine will build a response and pass it back to the caller.

Specified by:
snmpReceivedGet in interface SnmpAgentRequestHandler
Parameters:
pdu - The SNMP pdu
Returns:
PDU filled in with the proper response, or null if cannot process. PDU's version is based on the @param pdu. NOTE: this might be changed to throw an exception.

snmpReceivedSet

public org.snmp4j.PDU snmpReceivedSet(org.snmp4j.PDU pdu)

This method is defined to handle SNMP Set requests that are received by the session. The request has already been validated by the system. This routine will build a response and pass it back to the caller.

Specified by:
snmpReceivedSet in interface SnmpAgentRequestHandler
Parameters:
pdu - The SNMP pdu
Returns:
SnmpPduRequest filled in with the proper response, or null if cannot process NOTE: this might be changed to throw an exception.

snmpReceivedPdu

public void snmpReceivedPdu(org.snmp4j.Snmp session,
                            java.net.InetAddress manager,
                            int port,
                            org.snmp4j.smi.OctetString community,
                            org.snmp4j.PDU pdu)

This method is defined to handle SNMP requests that are received by the session. The parameters allow the handler to determine the host, port, and community string of the received PDU

Specified by:
snmpReceivedPdu in interface SnmpAgentRequestHandler
Parameters:
session - The SNMP session
manager - The remote sender
port - The remote senders port
community - The community string
pdu - The SNMP pdu

SnmpAgentSessionError

public void SnmpAgentSessionError(org.snmp4j.Snmp session,
                                  int error,
                                  java.lang.Object ref)

This method is invoked if an error occurs in the session. The error code that represents the failure will be passed in the second parameter, 'error'. The error codes can be found in the class SnmpAgentSession class.

If a particular PDU is part of the error condition it will be passed in the third parameter, 'pdu'. The pdu will be of the type SnmpPduRequest or SnmpPduTrap object. The handler should use the "instanceof" operator to determine which type the object is. Also, the object may be null if the error condition is not associated with a particular PDU.

Parameters:
session - The SNMP Session
error - The error condition value.
ref - The PDU reference, or potentially null. It may also be an exception.


Copyright © 2011. All Rights Reserved.