SNMP Stack 5_1

uk.co.westhawk.snmp.stack
Class DefaultTrapContext

java.lang.Object
  |
  +--uk.co.westhawk.snmp.stack.ListeningContext
        |
        +--uk.co.westhawk.snmp.stack.DefaultTrapContext
All Implemented Interfaces:
ListeningContextFace, java.lang.Runnable

Deprecated. As of 4_14, replaced by ListeningContext and ListeningContextPool

public class DefaultTrapContext
extends ListeningContext

The DefaultTrapContext class will enable this stack to receive traps. Only one (1) instance of the DefaultTrapContext can exist. The context will only start receiving (or listen for) traps when there is at least one listener registered. Two kind of listeners can be added; the normal and unhandled trap listeners. The normal trap listeners are added via the addTrapListener() method, the unhandled trap listeners are added via the addUnhandledTrapListener().

Use one of the getInstance() methods to get the instance and add a trap listener. This class will fire undecoded trap events, i.e. the raw data is sent and no attempt is made to decode the data into a pdu.

The SnmpContext classes provide functionality for decoded trap events. These classes will register themselves to the DefaultTrapContext object and only pass the event on if it matches their configuration.

Note that because only one instance of this class can exist, the first call of getInstance() will define the settings (i.e. port number and socket type) for the lifetime of the stack. All the subsequent calls of getInstance() will return the existing instance, irrespective of the arguments.

On UNIX and Linux operating systems the default port where trap are sent (i.e. 162) can only be opened as root.

Note, this class is now deprecated. We are (very) slowly trying to move to a more general way of receiving packets and adding agent functionality. ListeningContext and ListeningContextPool allow the stack to listen to more than one port.

Version:
$Revision: 3.10 $ $Date: 2006/01/17 17:43:54 $
Author:
Birgit Arkesteijn
See Also:
AbstractSnmpContext.addTrapListener(uk.co.westhawk.snmp.event.TrapListener), ListeningContext, ListeningContextPool

Field Summary
 
Fields inherited from class uk.co.westhawk.snmp.stack.ListeningContext
bindAddr, hostPort, maxRecvSize, typeSocket
 
Fields inherited from interface uk.co.westhawk.snmp.stack.ListeningContextFace
DEFAULT_TRAP_PORT, version_id
 
Constructor Summary
protected DefaultTrapContext(int port)
          Deprecated. Constructor.
protected DefaultTrapContext(int port, java.lang.String typeSocketA)
          Deprecated. Constructor.
 
Method Summary
static DefaultTrapContext getInstance(int port)
          Deprecated. Returns the instance of DefaultTrapContext.
static DefaultTrapContext getInstance(int port, java.lang.String typeSocketA)
          Deprecated. Returns the instance of DefaultTrapContext.
 
Methods inherited from class uk.co.westhawk.snmp.stack.ListeningContext
addRawPduListener, addUnhandledRawPduListener, destroy, getBindAddress, getMaxRecvSize, getPort, getTypeSocket, processIncomingMessage, removeRawPduListener, removeUnhandledRawPduListener, run, setMaxRecvSize, startListening, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultTrapContext

protected DefaultTrapContext(int port)
                      throws java.io.IOException
Deprecated. 
Constructor. The Standard socket type will be used.

Parameters:
port - The local port where traps are received
See Also:
SnmpContextBasisFace.STANDARD_SOCKET

DefaultTrapContext

protected DefaultTrapContext(int port,
                             java.lang.String typeSocketA)
                      throws java.io.IOException
Deprecated. 
Constructor. The typeSocket will indicate which type of socket to use. This way different handlers can be provided for Netscape or Standard JVM. The Netscape implementation will make the necessary security calls to access connections that are not the applet's webserver. The KVM version will be for small device support (e.g. Palm Pilot).

Parameters:
port - The local port where traps are received
typeSocketA - The type of socket to use.
See Also:
SnmpContextBasisFace.STANDARD_SOCKET, SnmpContextBasisFace.TCP_SOCKET, SnmpContextBasisFace.NETSCAPE_SOCKET, SnmpContextBasisFace.KVM_SOCKET
Method Detail

getInstance

public static DefaultTrapContext getInstance(int port)
                                      throws java.io.IOException
Deprecated. 
Returns the instance of DefaultTrapContext. It will create the instance if it didn't exists. See the note above.

java.io.IOException

getInstance

public static DefaultTrapContext getInstance(int port,
                                             java.lang.String typeSocketA)
                                      throws java.io.IOException
Deprecated. 
Returns the instance of DefaultTrapContext. It will create the instance if it didn't exists. See the note above.

java.io.IOException

SNMP Stack 5_1