org.snmp4j.agent.agentx
Class AgentX

java.lang.Object
  extended by org.snmp4j.agent.agentx.AgentX
All Implemented Interfaces:
java.util.EventListener, AgentXCommandListener

public class AgentX
extends java.lang.Object
implements AgentXCommandListener

The AgentX class implements the AgentX protocol that sends and receives AgentX PDUs over one or more transport mappings.

Version:
1.0
Author:
Frank Fock

Constructor Summary
AgentX(AgentXMessageDispatcher dispatcher)
           
 
Method Summary
 void addCommandResponder(AgentXCommandListener listener)
          Adds a AgentXCommandListener to this AgentX session.
 void addTransportMapping(org.snmp4j.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(org.snmp4j.TransportMapping transport)
           
 AgentXResponseEvent send(AgentXPDU pdu, AgentXTarget target, org.snmp4j.TransportMapping transport)
          Sends a AgentXPDU to the given target and returns the response synchronously.
 void send(AgentXPDU pdu, AgentXTarget target, org.snmp4j.TransportMapping transport, java.lang.Object userHandle, AgentXResponseListener listener)
          Sends a AgentXPDU to the given target and returns the response asynchronously.
protected  org.snmp4j.mp.PduHandle sendMessage(AgentXPDU pdu, AgentXTarget target, org.snmp4j.TransportMapping transport, org.snmp4j.mp.PduHandleCallback pduHandleCallback)
          Actually sends a PDU to a target and returns a handle for the sent PDU.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AgentX

public AgentX(AgentXMessageDispatcher dispatcher)
Method Detail

addTransportMapping

public void addTransportMapping(org.snmp4j.TransportMapping transport)

removeTransportMapping

public void removeTransportMapping(org.snmp4j.TransportMapping transport)

removeCommandResponder

public void removeCommandResponder(AgentXCommandListener listener)
Removes a AgentXCommandListener from this AgentX session.

Parameters:
listener - a previously added AgentXCommandListener instance.

addCommandResponder

public void addCommandResponder(AgentXCommandListener listener)
Adds a 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.

Parameters:
listener - the AgentXCommandListener instance to be added.

send

public AgentXResponseEvent send(AgentXPDU pdu,
                                AgentXTarget target,
                                org.snmp4j.TransportMapping transport)
                         throws java.io.IOException
Sends a AgentXPDU to the given target and returns the response synchronously.

Parameters:
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.
Returns:
the received response encapsulated in a AgentXResponseEvent instance. To obtain the received response AgentXPDU call AgentXResponseEvent.getResponse(). If the request timed out, that method will return null.
Throws:
java.io.IOException - if the message could not be sent.

send

public void send(AgentXPDU pdu,
                 AgentXTarget target,
                 org.snmp4j.TransportMapping transport,
                 java.lang.Object userHandle,
                 AgentXResponseListener listener)
          throws java.io.IOException
Sends a AgentXPDU to the given target and returns the response asynchronously.

Parameters:
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.
Throws:
java.io.IOException - if the message could not be sent.

sendMessage

protected org.snmp4j.mp.PduHandle sendMessage(AgentXPDU pdu,
                                              AgentXTarget target,
                                              org.snmp4j.TransportMapping transport,
                                              org.snmp4j.mp.PduHandleCallback pduHandleCallback)
                                       throws java.io.IOException
Actually sends a PDU to a target and returns a handle for the sent PDU.

Parameters:
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.
Returns:
PduHandle that uniquely identifies the sent PDU for further reference.
Throws:
java.io.IOException - if the transport fails to send the PDU or the if the message cannot be BER encoded.

processCommand

public void processCommand(AgentXCommandEvent event)
Specified by:
processCommand in interface AgentXCommandListener

fireProcessPdu

protected void fireProcessPdu(AgentXCommandEvent event)
Fires a 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.

Parameters:
event - a CommandResponderEvent.

getMessageDispatcher

public AgentXMessageDispatcher getMessageDispatcher()

Copyright 2005-2011 Frank Fock (SNMP4J.org)

Copyright © 2011 SNMP4J.org. All Rights Reserved.