Package org.snmp4j.agent.agentx
Class AgentXMessageDispatcherImpl
java.lang.Object
org.snmp4j.agent.agentx.AgentXMessageDispatcherImpl
- All Implemented Interfaces:
AgentXMessageDispatcher
,org.snmp4j.transport.TransportListener
The
AgentXMessageDispatcherImpl
implements an AgentX AgentXMessageDispatcher
.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds aAgentXCommandListener
to this message dispatcher.void
addTransportMapping
(org.snmp4j.TransportMapping<?> transport) Adds aTransportMapping
to the dispatcher.protected org.snmp4j.mp.PduHandle
Creates a new PDU handle.protected void
fireCommandEvent
(AgentXCommandEvent<?> event) Fires aAgentXCommandEvent
int
Increments the internal packet ID counter and returns the next ID.Collection
<org.snmp4j.TransportMapping<?>> Gets theCollection
of transport mappings in this message dispatcher.<A extends org.snmp4j.smi.Address>
voidprocessMessage
(org.snmp4j.TransportMapping<? super A> sourceTransport, A incomingAddress, ByteBuffer wholeMessage, org.snmp4j.TransportStateReference tmStateReference) void
Removes aAgentXCommandListener
from this message dispatcher.org.snmp4j.TransportMapping
<?> removeTransportMapping
(org.snmp4j.TransportMapping<?> transport) Removes a previously addedTransportMapping
from the dispatcher.<A extends org.snmp4j.smi.Address>
voidsend
(A address, org.snmp4j.TransportMapping<? super A> transport, ByteBuffer message, org.snmp4j.TransportStateReference tmStateReference) Sends aAgentXPDU
encoded in aByteBuffer
to a target.<A extends org.snmp4j.smi.Address>
org.snmp4j.mp.PduHandlesend
(org.snmp4j.TransportMapping<? super A> transport, A address, AgentXPDU message, org.snmp4j.mp.PduHandleCallback<AgentXPDU> callback) Sends aAgentXPDU
to a target.
-
Constructor Details
-
AgentXMessageDispatcherImpl
public AgentXMessageDispatcherImpl()Creates aAgentXMessageDispatcherImpl
.
-
-
Method Details
-
getNextPacketID
public int getNextPacketID()Increments the internal packet ID counter and returns the next ID.- Returns:
- a new (positive) packet ID. If there is an overrun, 1 is returned.
-
createPduHandle
protected org.snmp4j.mp.PduHandle createPduHandle()Creates a new PDU handle.- Returns:
- a new
PduHandle
.
-
addTransportMapping
public void addTransportMapping(org.snmp4j.TransportMapping<?> transport) Description copied from interface:AgentXMessageDispatcher
Adds aTransportMapping
to the dispatcher. The transport mapping is used to send and receive messages to/from the network.- Specified by:
addTransportMapping
in interfaceAgentXMessageDispatcher
- Parameters:
transport
- aTransportMapping
instance.
-
getTransportMappings
Description copied from interface:AgentXMessageDispatcher
Gets theCollection
of transport mappings in this message dispatcher.- Specified by:
getTransportMappings
in interfaceAgentXMessageDispatcher
- Returns:
- Collection
-
processMessage
public <A extends org.snmp4j.smi.Address> void processMessage(org.snmp4j.TransportMapping<? super A> sourceTransport, A incomingAddress, ByteBuffer wholeMessage, org.snmp4j.TransportStateReference tmStateReference) - Specified by:
processMessage
in interfaceorg.snmp4j.transport.TransportListener
-
removeTransportMapping
public org.snmp4j.TransportMapping<?> removeTransportMapping(org.snmp4j.TransportMapping<?> transport) Description copied from interface:AgentXMessageDispatcher
Removes a previously addedTransportMapping
from the dispatcher.- Specified by:
removeTransportMapping
in interfaceAgentXMessageDispatcher
- Parameters:
transport
- aTransportMapping
instance.- Returns:
- the
TransportMapping
instance supplied if it could be successfully removed,null
otherwise.
-
send
public <A extends org.snmp4j.smi.Address> org.snmp4j.mp.PduHandle send(org.snmp4j.TransportMapping<? super A> transport, A address, AgentXPDU message, org.snmp4j.mp.PduHandleCallback<AgentXPDU> callback) throws IOException Sends aAgentXPDU
to a target.- Specified by:
send
in interfaceAgentXMessageDispatcher
- Type Parameters:
A
- the address type.- Parameters:
transport
- theTransportMapping
.address
- the target address.message
- theAgentXPDU
to be sent.callback
- thePduHandleCallback
to generate aPduHandle
whe required.- Returns:
- the PduHandle associated with the PDU.
- Throws:
IOException
- if sending fails because of anIOException
.
-
send
public <A extends org.snmp4j.smi.Address> void send(A address, org.snmp4j.TransportMapping<? super A> transport, ByteBuffer message, org.snmp4j.TransportStateReference tmStateReference) throws IOException Sends aAgentXPDU
encoded in aByteBuffer
to a target.- Type Parameters:
A
- the address type.- Parameters:
address
- the target address.transport
- theTransportMapping
.message
- the message to be sent.tmStateReference
- theTransportStateReference
to hold SNMPv3 state reference.- Throws:
IOException
- if sending fails because of anIOException
.
-
fireCommandEvent
Fires aAgentXCommandEvent
- Parameters:
event
- theAgentXCommandEvent
to be fired.
-
addCommandListener
Description copied from interface:AgentXMessageDispatcher
Adds aAgentXCommandListener
to this message dispatcher.- Specified by:
addCommandListener
in interfaceAgentXMessageDispatcher
- Parameters:
l
- the command listener to add.
-
removeCommandListener
Description copied from interface:AgentXMessageDispatcher
Removes aAgentXCommandListener
from this message dispatcher.- Specified by:
removeCommandListener
in interfaceAgentXMessageDispatcher
- Parameters:
l
- the listener to be removed.
-