java.io.Closeable
, java.lang.AutoCloseable
, TransportMapping<A>
public class DummyTransport<A extends IpAddress> extends AbstractTransportMapping<A>
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
.Modifier and Type | Class | Description |
---|---|---|
class |
DummyTransport.DummyTransportResponder |
asyncMsgProcessingSupported, maxInboundMessageSize, transportListener
Constructor | Description |
---|---|
DummyTransport() |
|
DummyTransport(A senderAddress) |
|
DummyTransport(A senderAddress,
A receiverAddress) |
Modifier and Type | Method | Description |
---|---|---|
void |
close() |
Closes the transport an releases all bound resources synchronously.
|
A |
getListenAddress() |
Returns the address that represents the actual 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,
long timeoutMillis,
int retries) |
Sends a message to the supplied address using this transport.
|
void |
setListenAddress(A listenAddress) |
|
java.lang.String |
toString() |
addTransportListener, fireProcessMessage, getMaxInboundMessageSize, isAsyncMsgProcessingSupported, removeTransportListener, setAsyncMsgProcessingSupported
public DummyTransport()
public DummyTransport(A senderAddress)
public java.lang.Class<? extends Address> getSupportedAddressClass()
TransportMapping
Address
class that is supported by this transport mapping.getSupportedAddressClass
in interface TransportMapping<A extends IpAddress>
getSupportedAddressClass
in class AbstractTransportMapping<A extends IpAddress>
Address
.public A getListenAddress()
TransportMapping
null
this transport
mapping is not configured to listen for incoming packets.public void setListenAddress(A listenAddress)
public void sendMessage(A address, byte[] message, TransportStateReference tmStateReference, long timeoutMillis, int retries) throws java.io.IOException
TransportMapping
sendMessage
in interface TransportMapping<A extends IpAddress>
sendMessage
in class AbstractTransportMapping<A extends IpAddress>
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.timeoutMillis
- maximum number of milli seconds the connection creation might take (if connection based).retries
- maximum retries during connection creation.java.io.IOException
- if any underlying IO operation fails.public void close() throws java.io.IOException
TransportMapping
close
in interface java.lang.AutoCloseable
close
in interface java.io.Closeable
close
in interface TransportMapping<A extends IpAddress>
close
in class AbstractTransportMapping<A extends IpAddress>
java.io.IOException
- if any IO operation for the close fails.public void listen() throws java.io.IOException
TransportMapping
TransportMapping.sendMessage(A, byte[], org.snmp4j.TransportStateReference, long, int)
is called for the
first time.listen
in interface TransportMapping<A extends IpAddress>
listen
in class AbstractTransportMapping<A extends IpAddress>
java.io.IOException
- if an IO operation exception occurs while starting the listener.public boolean isListening()
TransportMapping
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.true
if this transport mapping is listening for messages.public AbstractTransportMapping<A> getResponder(A receiverAddress)
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2018 SNMP4J.org. All rights reserved.