com.sun.management.snmp.agent
Class SnmpTrapReceiver

java.lang.Object
  extended by com.sun.management.snmp.agent.SnmpTrapReceiver
Direct Known Subclasses:
SnmpTrapForwarder

public class SnmpTrapReceiver
extends Object

This MBean allows you to receive traps of subagents.

This trap receiver listen on a dedicated port and forward traps to some classes.

To enable trap receiving you must start the receiver.

Since:
Java DMK 5.1

Constructor Summary
SnmpTrapReceiver(SnmpEngine engine, int port, InetAddress address)
          Instantiate a SnmpTrapForwarder that will forward received traps according to its configuration.
SnmpTrapReceiver(SnmpEngineParameters parameters, SnmpEngineFactory factory, int port, InetAddress address)
          Instantiate a SnmpTrapForwarder that will forward received traps according to its configuration.
 
Method Summary
protected  TaskServer createCallbackTaskServer()
          Return the TaskServer that will be used to invoke callbacks.
protected  Thread createDispatcherThread(Runnable dispatcher)
          Creates a new Thread to listen for incoming traps.
protected  TaskServer createPacketTaskServer()
          Return the TaskServer that will be used to handle incoming Trap/Inform PDUs.
 void receiveAsGeneric(boolean val)
          Call this method in order to be called by receivedTrap (if true).
protected  void receivedTrap(SnmpTrap trap)
          You must implement this method in order to handle received traps in a generic way.
protected  void receivedV1Trap(SnmpPduTrap trap)
          You must implement this method in order to handle received SNMP V1 traps.
protected  void receivedV2Trap(SnmpPduRequest trap)
          You must implement this method in order to handle received SNMP V2 traps.
protected  void receivedV3Trap(SnmpScopedPduRequest trap)
          You must implement this method in order to handle received SNMP V3 traps.
 void start()
          Start listening for traps.
 void stop()
          Stop listening for traps.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SnmpTrapReceiver

public SnmpTrapReceiver(SnmpEngine engine,
                        int port,
                        InetAddress address)
                 throws IllegalArgumentException
Instantiate a SnmpTrapForwarder that will forward received traps according to its configuration.

Parameters:
engine - The SNMP engine to use.
port - The port the forwarder is listening to.
address - The Ip address the dispatcher will listen for. events on. If null, the dispatcher will listen on localhost.
Throws:
IllegalArgumentException

SnmpTrapReceiver

public SnmpTrapReceiver(SnmpEngineParameters parameters,
                        SnmpEngineFactory factory,
                        int port,
                        InetAddress address)
                 throws IllegalArgumentException
Instantiate a SnmpTrapForwarder that will forward received traps according to its configuration. It instantiates an SnmpEngine.

WARNING : The SnmpEngineId is computed as follow:

Parameters:
parameters - The engine parameters to use.
factory - The factory to use in order to create the engine.
port - The port the forwarder is listening to.
address - The Ip address the dispatcher will listen for.
Throws:
IllegalArgumentException - If one of the specified configuration file doesn't exist.
Method Detail

receiveAsGeneric

public void receiveAsGeneric(boolean val)
Call this method in order to be called by receivedTrap (if true). By default the methods receivedV1Trap or receivedV2Trap or receivedV3Trap are called when the receiver receives a trap (false).

Parameters:
val - True, receive as generic. False, receive a different call for each kind of trap (SNMP V1, V2 or V3).

start

public void start()
           throws SocketException
Start listening for traps.

Throws:
SocketException

stop

public void stop()
          throws SocketException
Stop listening for traps. The socket on which the trap forwarder is listening for traps is closed.

Throws:
SocketException

createPacketTaskServer

protected TaskServer createPacketTaskServer()
Return the TaskServer that will be used to handle incoming Trap/Inform PDUs.

The default implementation of this method is to return a new started DaemonTaskServer.

This method is called from this object constructor.


createCallbackTaskServer

protected TaskServer createCallbackTaskServer()
Return the TaskServer that will be used to invoke callbacks. The default implementation of this method is to return null, which means that callbacks will be directly invoked from the thread of the packetTaskServer.

This method is called from this object constructor.

See Also:
TaskServer

createDispatcherThread

protected Thread createDispatcherThread(Runnable dispatcher)
Creates a new Thread to listen for incoming traps.

The thread returned by this method must be runnable. The default implementation of this method is:

 return new Thread(dispatcher); 

This method is called each time this object is started.

Parameters:
dispatcher - The dispatcher that will listen for incoming traps in the new thread.

receivedTrap

protected void receivedTrap(SnmpTrap trap)
You must implement this method in order to handle received traps in a generic way. The default implementation does nothing.

Parameters:
trap - The received trap pdu.

receivedV1Trap

protected void receivedV1Trap(SnmpPduTrap trap)
You must implement this method in order to handle received SNMP V1 traps. The default implementation does nothing.

Parameters:
trap - The received trap pdu.

receivedV2Trap

protected void receivedV2Trap(SnmpPduRequest trap)
You must implement this method in order to handle received SNMP V2 traps. The default implementation does nothing.

Parameters:
trap - The received trap pdu.

receivedV3Trap

protected void receivedV3Trap(SnmpScopedPduRequest trap)
You must implement this method in order to handle received SNMP V3 traps.

Parameters:
trap - The received trap pdu.

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.