|
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.ListeningContextPool
This class contains the pool of listening contexts. The usage of this class will prevent more than one ListeningContext trying to listen to the same port.
ListeningContext| Field Summary | |
protected java.lang.String |
bindAddr
|
protected ListeningContext |
context
|
protected static java.util.Hashtable |
contextPool
|
protected int |
hostPort
|
protected java.lang.String |
socketType
|
| Fields inherited from interface uk.co.westhawk.snmp.stack.ListeningContextFace |
DEFAULT_TRAP_PORT, version_id |
| Constructor Summary | |
ListeningContextPool(int port)
Constructor, using the Standard socket type. |
|
ListeningContextPool(int port,
java.lang.String bindAddress)
Constructor, using the Standard socket type. |
|
ListeningContextPool(int port,
java.lang.String bindAddress,
java.lang.String typeSocket)
Constructor. |
|
| Method Summary | |
void |
addRawPduListener(RawPduListener l)
Adds the specified PDU listener to receive the undecoded PDUs. |
void |
addUnhandledRawPduListener(RawPduListener l)
Adds the specified PDU listener to receive the undecoded PDUs when it was not handled (i.e. not consumed) by any of the PDU listeners in addRawPduListener(). |
void |
destroy()
Destroys the current context. |
void |
destroyPool()
Destroys all the contexts in the pool and empties the pool. |
void |
dumpContexts(java.lang.String title)
Dumps the pool of contexts. |
java.lang.String |
getBindAddress()
Returns the local address the server will bind to When the address is null, the socket accepts connections on any/all local addresses. |
java.lang.String |
getHashKey()
Returns the hash key. |
protected ListeningContext |
getMatchingContext()
Returns a context from the pool. |
int |
getMaxRecvSize()
Returns the maximum number of bytes this context will read from the socket. |
int |
getPort()
Returns the port number. |
java.lang.String |
getTypeSocket()
Returns the type of socket. |
void |
removeRawPduListener(RawPduListener l)
Removes the specified PDU listener. |
void |
removeRawPduListenerFromPool(RawPduListener l)
Removes the specified PDU listener from all the contexts in the pool. |
void |
removeUnhandledRawPduListener(RawPduListener l)
Removes the specified unhandled PDU listener. |
void |
setMaxRecvSize(int no)
Sets the maximum number of bytes this context will read from the socket. |
java.lang.String |
toString()
Returns a string representation of the object. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected static java.util.Hashtable contextPool
protected ListeningContext context
protected java.lang.String socketType
protected java.lang.String bindAddr
protected int hostPort
| Constructor Detail |
public ListeningContextPool(int port)
port - The local port where packets are receivedListeningContextPool(int, String),
SnmpContextBasisFace.STANDARD_SOCKET
public ListeningContextPool(int port,
java.lang.String bindAddress)
port - The local port where packets are receivedbindAddress - The local address the server will bind toSnmpContextBasisFace.STANDARD_SOCKET
public ListeningContextPool(int port,
java.lang.String bindAddress,
java.lang.String typeSocket)
Note, the TCP_SOCKET does not provide functionality to send a response back. Listening on such a socket is only useful when listening for traps.
port - The local port where packets are receivedbindAddress - The local address the server will bind toSnmpContextBasisFace.STANDARD_SOCKET,
SnmpContextBasisFace.TCP_SOCKET,
SnmpContextBasisFace.NETSCAPE_SOCKET,
SnmpContextBasisFace.KVM_SOCKET| Method Detail |
public int getPort()
ListeningContextFace
getPort in interface ListeningContextFacepublic java.lang.String getBindAddress()
ListeningContextFace
getBindAddress in interface ListeningContextFacepublic java.lang.String getTypeSocket()
ListeningContextFace
getTypeSocket in interface ListeningContextFaceSnmpContextBasisFace.STANDARD_SOCKET,
SnmpContextBasisFace.TCP_SOCKET,
SnmpContextBasisFace.NETSCAPE_SOCKET,
SnmpContextBasisFace.KVM_SOCKETpublic int getMaxRecvSize()
ListeningContextFaceMSS (i.e. 1300).
getMaxRecvSize in interface ListeningContextFaceSnmpContextBasisFace.MSS,
ListeningContextFace.setMaxRecvSize(int),
AbstractSnmpContext.setMaxRecvSize(int)public void setMaxRecvSize(int no)
MSS (i.e. 1300).
Only the current context will be affected, not to all the
contexts in the pool.
setMaxRecvSize in interface ListeningContextFaceno - The new sizeSnmpContextBasisFace.MSS,
AbstractSnmpContext.getMaxRecvSize()public void destroy()
Note that by calling this method the whole stack will stop listening for packets on the port this context was listening on! The listeners added via the SnmpContext classes are affected as well.
destroy in interface ListeningContextFacedestroyPool(),
destroy()public void destroyPool()
Note that by calling this method the whole stack will stop listening for any packets! The listeners added via the SnmpContext classes are affected as well.
destroy()protected ListeningContext getMatchingContext()
getHashKey()public void dumpContexts(java.lang.String title)
title - The title of the dumppublic java.lang.String getHashKey()
public void addRawPduListener(RawPduListener l)
throws java.io.IOException
ListeningContextFaceAll the SnmpContext objects use this method to listen for PDUs. When a SnmpContext object decodes the PDU succesfully, it will consume it.
Only when a listener is added will this context create a listening socket.
addRawPduListener in interface ListeningContextFacel - The listener object
java.io.IOException - Thrown when creating a listening
socket failsRawPduReceivedSupport.fireRawPduReceived(int, java.lang.String, int, byte[]),
AbstractSnmpContext.addTrapListener(uk.co.westhawk.snmp.event.TrapListener),
AbstractSnmpContext.addRequestPduListener(uk.co.westhawk.snmp.event.RequestPduListener),
ListeningContextFace.addUnhandledRawPduListener(RawPduListener)public void removeRawPduListener(RawPduListener l)
ListeningContextFace
removeRawPduListener in interface ListeningContextFacel - The listener objectpublic void removeRawPduListenerFromPool(RawPduListener l)
ListeningContext.removeRawPduListener(uk.co.westhawk.snmp.event.RawPduListener)
public void addUnhandledRawPduListener(RawPduListener l)
throws java.io.IOException
ListeningContextFaceOnly when a listener is added will this context create a listening socket.
addUnhandledRawPduListener in interface ListeningContextFacejava.io.IOException - Thrown when creating a listening
socket failsListeningContextFace.addRawPduListener(RawPduListener)public void removeUnhandledRawPduListener(RawPduListener l)
ListeningContextFace
removeUnhandledRawPduListener in interface ListeningContextFacepublic java.lang.String toString()
toString in class java.lang.Object
|
SNMP Stack 5_1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||