public class AgentX extends Object implements AgentXCommandListener
AgentX
class implements the AgentX protocol that sends
and receives AgentX PDUs over one or more transport mappings.Constructor and Description |
---|
AgentX(AgentXMessageDispatcher dispatcher) |
Modifier and Type | Method and Description |
---|---|
void |
addCommandResponder(AgentXCommandListener listener)
Adds a
AgentXCommandListener to this AgentX session. |
void |
addTransportMapping(TransportMapping transport) |
protected void |
fireProcessPdu(AgentXCommandEvent event)
Fires a
CommandResponderEvent event to inform listeners about
a received PDU. |
AgentXMessageDispatcher |
getMessageDispatcher() |
void |
processCommand(AgentXCommandEvent event) |
void |
removeCommandResponder(AgentXCommandListener listener)
Removes a
AgentXCommandListener from this AgentX session. |
void |
removeTransportMapping(TransportMapping transport) |
AgentXResponseEvent |
send(AgentXPDU pdu,
AgentXTarget target,
TransportMapping transport)
Sends a
AgentXPDU to the given target and returns the response
synchronously. |
void |
send(AgentXPDU pdu,
AgentXTarget target,
TransportMapping transport,
Object userHandle,
AgentXResponseListener listener)
Sends a
AgentXPDU to the given target and returns the response
asynchronously. |
protected PduHandle |
sendMessage(AgentXPDU pdu,
AgentXTarget target,
TransportMapping transport,
PduHandleCallback<AgentXPDU> pduHandleCallback)
Actually sends a PDU to a target and returns a handle for the sent PDU.
|
public AgentX(AgentXMessageDispatcher dispatcher)
public void addTransportMapping(TransportMapping transport)
public void removeTransportMapping(TransportMapping transport)
public void removeCommandResponder(AgentXCommandListener listener)
AgentXCommandListener
from this AgentX session.listener
- a previously added AgentXCommandListener
instance.public void addCommandResponder(AgentXCommandListener listener)
AgentXCommandListener
to this AgentX session.
The command responder will then be informed about incoming SNMP PDUs of
any kind that are not related to any outstanding requests of this SNMP
session.listener
- the AgentXCommandListener
instance to be added.public AgentXResponseEvent send(AgentXPDU pdu, AgentXTarget target, TransportMapping transport) throws IOException
AgentXPDU
to the given target and returns the response
synchronously.pdu
- a AgentXPDU
instance.target
- the AgentXTarget instance representing the target AgentX entity
where to send the pdu
.transport
- specifies the TransportMapping
to be used when sending
the PDU. If transport
is null
, the associated
message dispatcher will try to determine the transport mapping by the
target
's address.AgentXResponseEvent
instance. To obtain the received response AgentXPDU
call
AgentXResponseEvent.getResponse()
. If the request timed out,
that method will return null
.IOException
- if the message could not be sent.public void send(AgentXPDU pdu, AgentXTarget target, TransportMapping transport, Object userHandle, AgentXResponseListener listener) throws IOException
AgentXPDU
to the given target and returns the response
asynchronously.pdu
- a AgentXPDU
instance.target
- the AgentXTarget instance representing the target AgentX entity
where to send the pdu
.transport
- specifies the TransportMapping
to be used when sending
the PDU. If transport
is null
, the associated
message dispatcher will try to determine the transport mapping by the
target
's address.userHandle
- an arbitrary user handle which is transparently returned to the response
listener.listener
- the listener that should be informed about the reponse or timeout.IOException
- if the message could not be sent.protected PduHandle sendMessage(AgentXPDU pdu, AgentXTarget target, TransportMapping transport, PduHandleCallback<AgentXPDU> pduHandleCallback) throws IOException
pdu
- the PDU
instance to be sent.target
- a AgentXTarget
instance denoting the target AgentX entity.transport
- the (optional) transport mapping to be used to send the request.
If transport
is null
a suitable transport
mapping is determined from the target
address.pduHandleCallback
- an optional callback instance that is informed (if not
null
) about the newly assigned PduHandle just before the
message is sent out.IOException
- if the transport fails to send the PDU or the if the message cannot
be BER encoded.public void processCommand(AgentXCommandEvent event)
processCommand
in interface AgentXCommandListener
protected void fireProcessPdu(AgentXCommandEvent event)
CommandResponderEvent
event to inform listeners about
a received PDU. If a listener has marked the event as processed further
listeners will not be informed about the event.event
- a CommandResponderEvent
.public AgentXMessageDispatcher getMessageDispatcher()
Copyright © 2016 SNMP4J.org. All rights reserved.