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:
- listeners which implement the
SnmpTrapListener
interface will be activated each time an SNMP V1 trap
is received.
- listeners which implement the
SnmpV2TrapListener
interface will be activated each time an SNMP V2 trap
is received.
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
-
SnmpTrapAgent()
- Initializes an
SnmpTrapAgent which listens on the port 162.
-
SnmpTrapAgent(int)
- Initializes an
SnmpTrapAgent which listens on the specified port.
-
addTrapListener(SnmpTrapListener)
- Add an V1 trap listener to this
SnmpTrapAgent.
-
addV2TrapListener(SnmpV2TrapListener)
- Add an V2 trap listener to this
SnmpTrapAgent.
-
containsTrapReceiver(SnmpTrapListener)
- Returns true if the specified object is listening to V1 traps.
-
containsV2TrapReceiver(SnmpV2TrapListener)
- Returns true if the specified object is listening to V2 traps.
-
getPduFactory()
- Get the PDU factory associated to this
SnmpTrapAgent.
-
getTrapListeners()
- Get all of the V1 trap listeners.
-
getV2TrapListeners()
- Get all of the V2 trap listeners.
-
removeTrapListener(SnmpTrapListener)
- Remove a V1 trap listener.
-
removeV2TrapListener(SnmpV2TrapListener)
- Remove a V2 trap listener.
-
run()
- Dispatching loop.
-
setPduFactory(SnmpPduFactoryIf)
- Set the PDU factory associated to this
SnmpTrapAgent.
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.
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.
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.
addTrapListener
public void addTrapListener(SnmpTrapListener handler)
- Add an V1 trap listener to this
SnmpTrapAgent.
- Parameters:
- handler - the listener.
addV2TrapListener
public void addV2TrapListener(SnmpV2TrapListener handler)
- Add an V2 trap listener to this
SnmpTrapAgent.
- Parameters:
- handler - the listener.
containsTrapReceiver
public boolean containsTrapReceiver(SnmpTrapListener handler)
- Returns true if the specified object is listening to V1 traps.
- Parameters:
- handler - a listener.
containsV2TrapReceiver
public boolean containsV2TrapReceiver(SnmpV2TrapListener handler)
- Returns true if the specified object is listening to V2 traps.
- Parameters:
- handler - a listener.
removeTrapListener
public void removeTrapListener(SnmpTrapListener handler)
- Remove a V1 trap listener.
- Parameters:
- the - listener to be removed.
removeV2TrapListener
public void removeV2TrapListener(SnmpV2TrapListener handler)
- Remove a V2 trap listener.
- Parameters:
- the - listener to be removed.
getTrapListeners
public Enumeration getTrapListeners()
- Get all of the V1 trap listeners.
- Returns:
- an Enumeration of
SnmpTrapListener objects
getV2TrapListeners
public Enumeration getV2TrapListeners()
- Get all of the V2 trap listeners.
- Returns:
- an Enumeration of
SnmpV2TrapListener objects
getPduFactory
public SnmpPduFactoryIf getPduFactory()
- Get the PDU factory associated to this
SnmpTrapAgent.
- Returns:
- the PDU factory (always non-null)
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