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

java.lang.Object
  extended by org.jboss.jmx.adaptor.snmp.agent.RequestHandlerSupport
      extended by org.jboss.jmx.adaptor.snmp.agent.RequestHandlerImpl
All Implemented Interfaces:
Reconfigurable, RequestHandler, org.opennms.protocols.snmp.SnmpAgentHandler

public class RequestHandlerImpl
extends RequestHandlerSupport
implements Reconfigurable

Implement RequestHandler with mapping of snmp get/set requests to JMX mbean attribute gets/sets

Version:
$Revision: 57210 $
Author:
Heiko W. Rupp, Dimitris Andreadis

Field Summary
protected  SortedMap bindings
          Bindings from oid to mbean
 
Fields inherited from class org.jboss.jmx.adaptor.snmp.agent.RequestHandlerSupport
clock, log, resourceName, server
 
Constructor Summary
RequestHandlerImpl()
          Default CTOR
 
Method Summary
 void initialize(String resourceName, javax.management.MBeanServer server, org.jboss.logging.Logger log, Clock uptime)
          Initialize
 void reconfigure(String resName)
          Reconfigures the RequestHandler
 void SnmpAgentSessionError(org.opennms.protocols.snmp.SnmpAgentSession session, int error, Object ref)
           This method is invoked if an error occurs in the session.
 org.opennms.protocols.snmp.SnmpPduRequest snmpReceivedGet(org.opennms.protocols.snmp.SnmpPduPacket pdu, boolean getNext)
           This method is defined to handle SNMP Get requests that are received by the session.
 void snmpReceivedPdu(org.opennms.protocols.snmp.SnmpAgentSession session, InetAddress manager, int port, org.opennms.protocols.snmp.SnmpOctetString community, org.opennms.protocols.snmp.SnmpPduPacket pdu)
           This method is defined to handle SNMP requests that are received by the session.
 org.opennms.protocols.snmp.SnmpPduRequest snmpReceivedSet(org.opennms.protocols.snmp.SnmpPduPacket 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
 

Field Detail

bindings

protected SortedMap bindings
Bindings from oid to mbean

Constructor Detail

RequestHandlerImpl

public RequestHandlerImpl()
Default CTOR

Method Detail

initialize

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

Specified by:
initialize in interface RequestHandler
Overrides:
initialize in class RequestHandlerSupport
Parameters:
resourceName - A file containing get/set mappings
server - Our MBean-Server
log - The logger we use
uptime - The uptime of the snmp-agent subsystem.
Throws:
Exception - in case of initialization problem

reconfigure

public void reconfigure(String resName)
                 throws Exception
Reconfigures the RequestHandler

Specified by:
reconfigure in interface Reconfigurable
Parameters:
resName - the file to configure from, usually the same used at initialization time.
Throws:
Exception - in case of failure

snmpReceivedGet

public org.opennms.protocols.snmp.SnmpPduRequest snmpReceivedGet(org.opennms.protocols.snmp.SnmpPduPacket pdu,
                                                                 boolean getNext)

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 org.opennms.protocols.snmp.SnmpAgentHandler
Overrides:
snmpReceivedGet in class RequestHandlerSupport
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.

snmpReceivedSet

public org.opennms.protocols.snmp.SnmpPduRequest snmpReceivedSet(org.opennms.protocols.snmp.SnmpPduPacket 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 org.opennms.protocols.snmp.SnmpAgentHandler
Overrides:
snmpReceivedSet in class RequestHandlerSupport
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.opennms.protocols.snmp.SnmpAgentSession session,
                            InetAddress manager,
                            int port,
                            org.opennms.protocols.snmp.SnmpOctetString community,
                            org.opennms.protocols.snmp.SnmpPduPacket 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 org.opennms.protocols.snmp.SnmpAgentHandler
Overrides:
snmpReceivedPdu in class RequestHandlerSupport
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.opennms.protocols.snmp.SnmpAgentSession session,
                                  int error,
                                  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.

Specified by:
SnmpAgentSessionError in interface org.opennms.protocols.snmp.SnmpAgentHandler
Overrides:
SnmpAgentSessionError in class RequestHandlerSupport
Parameters:
session - The SNMP Session
error - The error condition value.
ref - The PDU reference, or potentially null. It may also be an exception.


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.