All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sun.jaw.snmp.manager.SnmpTrapAgent

java.lang.Object
   |
   +----com.sun.jaw.snmp.manager.SnmpTrapAgent

public class SnmpTrapAgent
extends Object
implements Runnable
The SnmpTrapAgent class implements an SNMP trap dispatcher.

Listener objects can be registered in an SnmpTrapAgent. The SnmpTrapAgent listens for any incoming trap: each time it receives a trap, it inform all the listeners. By default the dispatcher listens to the UDP port 162.

The SnmpTrapAgent class implements Runnable: it is expected to be used as a Thread object.

An SnmpTrapAgent object maintains two lists of listener objects:

An object may implement both interfaces and register itself in both lists: like this, it will receive both versions of traps.

See Also:
SnmpTrapListener, SnmpV2TrapListener

Constructor Index

 o SnmpTrapAgent()
Initializes an SnmpTrapAgent which listens on the port 162.
 o SnmpTrapAgent(int)
Initializes an SnmpTrapAgent which listens on the specified port.

Method Index

 o addTrapListener(SnmpTrapListener)
Add an V1 trap listener to this SnmpTrapAgent.
 o addV2TrapListener(SnmpV2TrapListener)
Add an V2 trap listener to this SnmpTrapAgent.
 o containsTrapReceiver(SnmpTrapListener)
Returns true if the specified object is listening to V1 traps.
 o containsV2TrapReceiver(SnmpV2TrapListener)
Returns true if the specified object is listening to V2 traps.
 o getPduFactory()
Get the PDU factory associated to this SnmpTrapAgent.
 o getTrapListeners()
Get all of the V1 trap listeners.
 o getV2TrapListeners()
Get all of the V2 trap listeners.
 o removeTrapListener(SnmpTrapListener)
Remove a V1 trap listener.
 o removeV2TrapListener(SnmpV2TrapListener)
Remove a V2 trap listener.
 o run()
Dispatching loop.
 o setPduFactory(SnmpPduFactoryIf)
Set the PDU factory associated to this SnmpTrapAgent.

Constructors

 o SnmpTrapAgent
 public SnmpTrapAgent() throws SocketException, SnmpStatusException
Initializes an SnmpTrapAgent which listens on the port 162. This constructor invokes SnmpMain.initializeSNMP.

Throws: SocketException
if the object cannot bind of the port 162.
Throws: SnmpStatusException
if initializeSNMP failed.
 o SnmpTrapAgent
 public SnmpTrapAgent(int portNumber) throws SocketException, SnmpStatusException
Initializes an SnmpTrapAgent which listens on the specified port. This constructor invokes SnmpMain.initializeSNMP.

Throws: SocketException
if the object cannot bind of the specified port.
Throws: SnmpStatusException
if initializeSNMP failed.

Methods

 o run
 public void run()
Dispatching loop. This method waits for a trap to be received, select a list of listeners according the version of the trap and activate each listener in the list.

This method is normally called by Thread.start.

 o addTrapListener
 public void addTrapListener(SnmpTrapListener handler)
Add an V1 trap listener to this SnmpTrapAgent.

Parameters:
handler - the listener.
 o addV2TrapListener
 public void addV2TrapListener(SnmpV2TrapListener handler)
Add an V2 trap listener to this SnmpTrapAgent.

Parameters:
handler - the listener.
 o containsTrapReceiver
 public boolean containsTrapReceiver(SnmpTrapListener handler)
Returns true if the specified object is listening to V1 traps.

Parameters:
handler - a listener.
 o containsV2TrapReceiver
 public boolean containsV2TrapReceiver(SnmpV2TrapListener handler)
Returns true if the specified object is listening to V2 traps.

Parameters:
handler - a listener.
 o removeTrapListener
 public void removeTrapListener(SnmpTrapListener handler)
Remove a V1 trap listener.

Parameters:
the - listener to be removed.
 o removeV2TrapListener
 public void removeV2TrapListener(SnmpV2TrapListener handler)
Remove a V2 trap listener.

Parameters:
the - listener to be removed.
 o getTrapListeners
 public Enumeration getTrapListeners()
Get all of the V1 trap listeners.

Returns:
an Enumeration of SnmpTrapListener objects
 o getV2TrapListeners
 public Enumeration getV2TrapListeners()
Get all of the V2 trap listeners.

Returns:
an Enumeration of SnmpV2TrapListener objects
 o getPduFactory
 public SnmpPduFactoryIf getPduFactory()
Get the PDU factory associated to this SnmpTrapAgent.

Returns:
the PDU factory (always non-null)
 o setPduFactory
 public void setPduFactory(SnmpPduFactoryIf factory)
Set the PDU factory associated to this SnmpTrapAgent.

Parameters:
factory - the PDU factory (if null, the default factory is set)

All Packages  Class Hierarchy  This Package  Previous  Next  Index