com.adventnet.snmp.beans
Class NotificationAdaptor

java.lang.Object
  |
  +--com.adventnet.snmp.beans.NotificationAdaptor
All Implemented Interfaces:
java.util.EventListener, TrapListener

public class NotificationAdaptor
extends java.lang.Object
implements TrapListener

v2c and v3 only This class is an SNMP NotificationAdaptor for use with SnmpTrapReceiver. It supports event generation per the JDK 1.1 event model.

To use in an application, simply instantiate an SnmpTrapReceiver, specify the port, and register instance of this to receive traps. The purpose of this adaptor is to convert a v2 trap pdu to v1 trap pdu. For example,

    SnmpTrapReceiver receiver = new SnmpTrapReceiver();
    receiver.setPort(162);

    NotificationAdaptor filter = new NotificationAdaptor();
    receiver.addTrapListener(filter);
    TrapListener listener = new TrapListener() {
        public void receivedTrap(TrapEvent trap) {
            System.err.println("Got a trap from: "+trap.getRemoteHost());
        }
    };
    
filter.addTrapListener(listener);

Supply the applet in the constructor if using applets and may need to use SAS.


Constructor Summary
NotificationAdaptor()
          Default constructor.
 
Method Summary
 void addTrapListener(TrapListener l)
          Add a listener for events from this target.
protected  TrapEvent convertTrap(TrapEvent trp)
          Attempts to convert v2c notification pdu parameters to v1 trap pdu parameters.
 void receivedTrap(TrapEvent evt)
          Fires the received trap event after applying this filter to the registered listeners.
 void removeTrapListener(TrapListener l)
          Remove a listener for events from this target.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NotificationAdaptor

public NotificationAdaptor()
Default constructor.

Method Detail

receivedTrap

public void receivedTrap(TrapEvent evt)
Fires the received trap event after applying this filter to the registered listeners.

Specified by:
receivedTrap in interface TrapListener

addTrapListener

public void addTrapListener(TrapListener l)
Add a listener for events from this target. The listener listens for events from any or all SNMP requests.


removeTrapListener

public void removeTrapListener(TrapListener l)
Remove a listener for events from this target.


convertTrap

protected TrapEvent convertTrap(TrapEvent trp)
Attempts to convert v2c notification pdu parameters to v1 trap pdu parameters. Returns new pdu if successful. Otherwise returns the old pdu.



Copyright (c)ZOHO Corp. 1996-2012