org.snmp4j.transport
Class DummyTransport<A extends IpAddress>

java.lang.Object
  extended by org.snmp4j.transport.AbstractTransportMapping<A>
      extended by org.snmp4j.transport.DummyTransport<A>
All Implemented Interfaces:
TransportMapping<A>

public class DummyTransport<A extends IpAddress>
extends AbstractTransportMapping<A>

The DummyTransport is a test TransportMapping for Command Generators which actually does not sent messages over the network. Instead it provides the message transparently as incoming message over the DummyTransport.DummyTransportResponder on a virtual listen address, regardless to which outbound address the message was sent. The messages are returned even if the listenAddress is left null.

Since:
2.0
Author:
Frank Fock

Nested Class Summary
 class DummyTransport.DummyTransportResponder
           
 
Field Summary
 
Fields inherited from class org.snmp4j.transport.AbstractTransportMapping
asyncMsgProcessingSupported, maxInboundMessageSize, transportListener
 
Constructor Summary
DummyTransport()
           
DummyTransport(A senderAddress)
           
DummyTransport(A senderAddress, A receiverAddress)
           
 
Method Summary
 void close()
          Closes the transport an releases all bound resources synchronously.
 A getListenAddress()
          Returns the address that represents the incoming address this transport mapping uses to listen for incoming packets.
 AbstractTransportMapping<A> getResponder(A receiverAddress)
           
 java.lang.Class<? extends Address> getSupportedAddressClass()
          Gets the Address class that is supported by this transport mapping.
 boolean isListening()
          Returns true if the transport mapping is listening for incoming messages.
 void listen()
          Listen for incoming messages.
 void sendMessage(A address, byte[] message, TransportStateReference tmStateReference)
          Sends a message to the supplied address using this transport.
 void setListenAddress(A listenAddress)
           
 java.lang.String toString()
           
 
Methods inherited from class org.snmp4j.transport.AbstractTransportMapping
addTransportListener, fireProcessMessage, getMaxInboundMessageSize, isAsyncMsgProcessingSupported, removeTransportListener, setAsyncMsgProcessingSupported
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DummyTransport

public DummyTransport()

DummyTransport

public DummyTransport(A senderAddress)

DummyTransport

public DummyTransport(A senderAddress,
                      A receiverAddress)
Method Detail

getSupportedAddressClass

public java.lang.Class<? extends Address> getSupportedAddressClass()
Description copied from interface: TransportMapping
Gets the Address class that is supported by this transport mapping.

Specified by:
getSupportedAddressClass in interface TransportMapping<A extends IpAddress>
Specified by:
getSupportedAddressClass in class AbstractTransportMapping<A extends IpAddress>
Returns:
a subclass of Address.

getListenAddress

public A getListenAddress()
Description copied from interface: TransportMapping
Returns the address that represents the incoming address this transport mapping uses to listen for incoming packets.

Returns:
the address for incoming packets or null this transport mapping is not configured to listen for incoming packets.

setListenAddress

public void setListenAddress(A listenAddress)

sendMessage

public void sendMessage(A address,
                        byte[] message,
                        TransportStateReference tmStateReference)
                 throws java.io.IOException
Description copied from interface: TransportMapping
Sends a message to the supplied address using this transport.

Specified by:
sendMessage in interface TransportMapping<A extends IpAddress>
Specified by:
sendMessage in class AbstractTransportMapping<A extends IpAddress>
Parameters:
address - an Address instance denoting the target address.
message - the whole message as an array of bytes.
tmStateReference - the (optional) transport model state reference as defined by RFC 5590 section 6.1.
Throws:
java.io.IOException - if any underlying IO operation fails.

close

public void close()
           throws java.io.IOException
Description copied from interface: TransportMapping
Closes the transport an releases all bound resources synchronously.

Specified by:
close in interface TransportMapping<A extends IpAddress>
Specified by:
close in class AbstractTransportMapping<A extends IpAddress>
Throws:
java.io.IOException - if any IO operation for the close fails.

listen

public void listen()
            throws java.io.IOException
Description copied from interface: TransportMapping
Listen for incoming messages. For connection oriented transports, this method needs to be called before TransportMapping.sendMessage(A, byte[], org.snmp4j.TransportStateReference) is called for the first time.

Specified by:
listen in interface TransportMapping<A extends IpAddress>
Specified by:
listen in class AbstractTransportMapping<A extends IpAddress>
Throws:
java.io.IOException - if an IO operation exception occurs while starting the listener.

isListening

public boolean isListening()
Description copied from interface: TransportMapping
Returns true if the transport mapping is listening for incoming messages. For connection oriented transport mappings this is a prerequisite to be able to send SNMP messages. For connectionless transport mappings it is a prerequisite to be able to receive responses.

Returns:
true if this transport mapping is listening for messages.

getResponder

public AbstractTransportMapping<A> getResponder(A receiverAddress)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

Copyright 2005-2011 Frank Fock (SNMP4J.org)

Copyright © 2011 SNMP4J.org. All Rights Reserved.