|
SNMP Stack 5_1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--uk.co.westhawk.snmp.stack.ListeningContext | +--uk.co.westhawk.snmp.stack.DefaultTrapContext
ListeningContext
and
ListeningContextPool
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.
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 |
protected DefaultTrapContext(int port) throws java.io.IOException
port
- The local port where traps are receivedSnmpContextBasisFace.STANDARD_SOCKET
protected DefaultTrapContext(int port, java.lang.String typeSocketA) throws java.io.IOException
port
- The local port where traps are receivedtypeSocketA
- The type of socket to use.SnmpContextBasisFace.STANDARD_SOCKET
,
SnmpContextBasisFace.TCP_SOCKET
,
SnmpContextBasisFace.NETSCAPE_SOCKET
,
SnmpContextBasisFace.KVM_SOCKET
Method Detail |
public static DefaultTrapContext getInstance(int port) throws java.io.IOException
java.io.IOException
public static DefaultTrapContext getInstance(int port, java.lang.String typeSocketA) throws java.io.IOException
java.io.IOException
|
SNMP Stack 5_1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |