com.adventnet.snmp.beans
Class NotificationAdaptor
java.lang.Object
|
+--com.adventnet.snmp.beans.NotificationAdaptor
- public class NotificationAdaptor
- extends java.lang.Object
- implements TrapListener
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.
|
Field Summary |
(package private) java.util.Vector |
listeners
|
| Methods inherited from class java.lang.Object |
,
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
listeners
java.util.Vector listeners
NotificationAdaptor
public NotificationAdaptor()
- Default constructor.
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.
compare
boolean compare(int[] a,
int[] b,
int len)