com.sun.management.snmp
Class SnmpEventReportDispatcher

java.lang.Object
  extended by com.sun.management.snmp.manager.SnmpEventReportDispatcher
      extended by com.sun.management.snmp.SnmpEventReportDispatcher
All Implemented Interfaces:
Runnable

public class SnmpEventReportDispatcher
extends SnmpEventReportDispatcher

Implements an SNMP event report dispatcher.

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

The SnmpEventReportDispatcher class implements Runnable: it is expected to be used as a Thread object. The run method never returns.

An SnmpEventReportDispatcher object maintains 2 lists of listener objects. The listener objects implement the SnmpTrapListener or SnmpInformListener interface and will be activated each time an SNMP event report (trap or inform PDU) is received.

By default, the SnmpEventReportDispatcher will create one Task per incoming message (inform or trap) and triggered listener, and will execute this task in a new thread. This default threading policy can be overridden by providing a specific TaskServer in the constructor of this object.

Since:
Java DMK 5.1
See Also:
SnmpTrapListener, SnmpInformListener, TaskServer

Constructor Summary
SnmpEventReportDispatcher()
          Initializes an SnmpEventReportDispatcher which listens on the port 162.
SnmpEventReportDispatcher(int portNumber)
          Initializes an SnmpEventReportDispatcher which listens on the specified port.
SnmpEventReportDispatcher(int portNumber, InetAddress address, TaskServer packetTaskServer, TaskServer callbackTaskServer)
          Initializes an SnmpEventReportDispatcher which listens on the specified port.
SnmpEventReportDispatcher(SnmpEngine engine, int portNumber, InetAddress address, TaskServer packetTaskServer, TaskServer callbackTaskServer)
          Initializes an SnmpEventReportDispatcher which listens on the specified port.
SnmpEventReportDispatcher(SnmpEngine engine, int portNumber, TaskServer packetTaskServer, TaskServer callbackTaskServer)
          Initializes an SnmpEventReportDispatcher which listens on the specified port.
SnmpEventReportDispatcher(SnmpEngineParameters parameters, SnmpEngineFactory factory, int portNumber, InetAddress address, TaskServer packetTaskServer, TaskServer callbackTaskServer)
          Initializes an SnmpEventReportDispatcher which listens on the specified port.
SnmpEventReportDispatcher(SnmpEngineParameters parameters, SnmpEngineFactory factory, int portNumber, TaskServer packetTaskServer, TaskServer callbackTaskServer)
          Initializes an SnmpEventReportDispatcher which listens on the specified port.
 
Method Summary
protected  void handleCallback(Runnable callbackHandler)
          This method invokes a listener callback.
protected  void handlePacket(Runnable packetHandler)
          This method handles a received SNMP DatagramPacket.
 
Methods inherited from class com.sun.management.snmp.manager.SnmpEventReportDispatcher
addInformListener, addTrapListener, close, containsInformListener, containsTrapListener, getEngine, getEngineId, getInformListeners, getPduFactory, getSnmpInASNParseErrs, getSnmpInBadVersions, getSnmpInInforms, getSnmpInPkts, getSnmpInTraps, getSnmpInvalidMsgs, getSnmpUnknownSecurityModels, getTrapListeners, removeInformListener, removeTrapListener, run, setPduFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SnmpEventReportDispatcher

public SnmpEventReportDispatcher()
                          throws SocketException,
                                 IllegalArgumentException
Initializes an SnmpEventReportDispatcher which listens on the port 162. It instantiates an SnmpEngine.

WARNING : The SnmpEngineId is computed as follows:

Throws:
IllegalArgumentException - If one of the specified configuration files do not exist.
SocketException - If the object cannot bind to the port 162.

SnmpEventReportDispatcher

public SnmpEventReportDispatcher(int portNumber)
                          throws SocketException,
                                 IllegalArgumentException
Initializes an SnmpEventReportDispatcher which listens on the specified port. It instantiates an SnmpEngine.

WARNING : The SnmpEngineId is computed as follows:

Parameters:
portNumber - The port number.
Throws:
IllegalArgumentException - If one of the specified configuration files don't exist.
SocketException - If the object cannot bind to the specified port.

SnmpEventReportDispatcher

public SnmpEventReportDispatcher(int portNumber,
                                 InetAddress address,
                                 TaskServer packetTaskServer,
                                 TaskServer callbackTaskServer)
                          throws SocketException,
                                 IllegalArgumentException
Initializes an SnmpEventReportDispatcher which listens on the specified port. It instantiates an SnmpEngine.

WARNING : The SnmpEngineId is computed as follows:

Parameters:
portNumber - The port number.
address - The Ip address the dispatcher will listen for events on. If null, the dispatcher will listen on localhost.
packetTaskServer - The task server to use when a trap or inform PDU is received.
callbackTaskServer - The task server to use when invoking a callback. This can be the same object as packetTaskServer
Throws:
IllegalArgumentException - If one of the specified configuration files don't exist.
SocketException - If the object cannot bind to the specified port.

SnmpEventReportDispatcher

public SnmpEventReportDispatcher(SnmpEngineParameters parameters,
                                 SnmpEngineFactory factory,
                                 int portNumber,
                                 TaskServer packetTaskServer,
                                 TaskServer callbackTaskServer)
                          throws SocketException,
                                 IllegalArgumentException
Initializes an SnmpEventReportDispatcher which listens on the specified port. It instantiates an SnmpEngine.

WARNING : The SnmpEngineId is computed as follows:

Parameters:
parameters - The engine parameters to use.
factory - The factory to use in order to create the engine.
portNumber - The port number.
packetTaskServer - The task server to use when a trap or inform PDU is received.
callbackTaskServer - The task server to use when invoking a callback. This can be the same object as packetTaskServer
Throws:
IllegalArgumentException - If one of the specified configuration files don't exist.
SocketException - If the object cannot bind to the specified port.

SnmpEventReportDispatcher

public SnmpEventReportDispatcher(SnmpEngine engine,
                                 int portNumber,
                                 TaskServer packetTaskServer,
                                 TaskServer callbackTaskServer)
                          throws SocketException,
                                 IllegalArgumentException
Initializes an SnmpEventReportDispatcher which listens on the specified port.

Parameters:
engine - The SnmpEngine to use.
portNumber - The port number.
packetTaskServer - The task server to use when a trap or inform PDU is received.
callbackTaskServer - The task server to use when invoking a callback. This can be the same object as packetTaskServer
Throws:
IllegalArgumentException - if the passed engine is null.
SocketException - If the object cannot bind to the specified port.

SnmpEventReportDispatcher

public SnmpEventReportDispatcher(SnmpEngineParameters parameters,
                                 SnmpEngineFactory factory,
                                 int portNumber,
                                 InetAddress address,
                                 TaskServer packetTaskServer,
                                 TaskServer callbackTaskServer)
                          throws SocketException,
                                 IllegalArgumentException
Initializes an SnmpEventReportDispatcher which listens on the specified port. It instantiates an SnmpEngine.

WARNING : The SnmpEngineId is computed as follows:

Parameters:
parameters - The engine parameters to use.
factory - The factory to use in order to create the engine.
portNumber - The port number.
address - The Ip address the dispatcher will listen for events on. If null, the dispatcher will listen on localhost.
packetTaskServer - The task server to use when a trap or inform PDU is received.
callbackTaskServer - The task server to use when invoking a callback. This can be the same object as packetTaskServer
Throws:
IllegalArgumentException - If one of the specified configuration files don't exist.
SocketException - If the object cannot bind to the specified port.

SnmpEventReportDispatcher

public SnmpEventReportDispatcher(SnmpEngine engine,
                                 int portNumber,
                                 InetAddress address,
                                 TaskServer packetTaskServer,
                                 TaskServer callbackTaskServer)
                          throws SocketException,
                                 IllegalArgumentException
Initializes an SnmpEventReportDispatcher which listens on the specified port.

Parameters:
engine - The SnmpEngine to use.
portNumber - The port number.
address - The Ip address the dispatcher will listen for events on. If null, the dispatcher will listen on localhost.
packetTaskServer - The task server to use when a trap or inform PDU is received.
callbackTaskServer - The task server to use when invoking a callback. This can be the same object as packetTaskServer
Throws:
IllegalArgumentException - if the passed engine is null.
SocketException - If the object cannot bind to the specified port.
Method Detail

handleCallback

protected final void handleCallback(Runnable callbackHandler)
This method invokes a listener callback. Do not call this method directly. It is called by the super class when a callback needs to be invoked.

This method uses the callbackTaskServer in order to execute the given callbackHandler.

Overrides:
handleCallback in class SnmpEventReportDispatcher
Parameters:
callbackHandler - A Runnable object wrapping the listener callback to be invoked.

handlePacket

protected final void handlePacket(Runnable packetHandler)
This method handles a received SNMP DatagramPacket. Do not call this method directly. It is called by the super class when an SNMP DatagrapPacket is received.

This method uses the packetTaskServer in order to execute the given packetHandler.

Overrides:
handlePacket in class SnmpEventReportDispatcher
Parameters:
packetHandler - A Runnable object wrapping the packet to be handled.

Open Source build 02
opendmk-1.0-b02 2007.10.01_19:17:46_MEST

Copyright 1998-2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.