java.lang.Object
org.snmp4j.transport.AbstractTransportMapping<A>
org.snmp4j.transport.DummyTransport.DummyTransportResponder
- All Implemented Interfaces:
Closeable
,AutoCloseable
,TransportMapping<A>
- Enclosing class:
DummyTransport<A extends IpAddress>
-
Field Summary
Fields inherited from class org.snmp4j.transport.AbstractTransportMapping
asyncMsgProcessingSupported, connectionTimeout, listenWorkerTask, maxInboundMessageSize, socketCleaner, suspendedAddresses, transportListener, transportStateListeners
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the transport an releases all bound resources synchronously.Returns the address that represents the actual incoming address this transport mapping uses to listen for incoming packets.Gets theWorkerTask
that is responsible for receiving new messages.Gets the primaryAddress
class that is supported by this transport mapping.boolean
Returnstrue
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.Methods inherited from class org.snmp4j.transport.AbstractTransportMapping
addTransportListener, addTransportStateListener, fireConnectionStateChanged, fireProcessMessage, getMaxInboundMessageSize, getPriority, getSocketCleaner, getSuspendedAddresses, getThreadName, handleDroppedMessageToSend, isAsyncMsgProcessingSupported, removeAllTransportListeners, removeTransportListener, removeTransportStateListener, resumeAddress, setAsyncMsgProcessingSupported, setPriority, setThreadName, suspendAddress
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.snmp4j.TransportMapping
getMaxOutboundMessageSize, getSupportedAddressClasses, getSupportedTransportType, isAddressSupported, isAddressSupported
-
Constructor Details
-
DummyTransportResponder
public DummyTransportResponder()
-
-
Method Details
-
getSupportedAddressClass
Description copied from interface:TransportMapping
Gets the primaryAddress
class that is supported by this transport mapping.- Specified by:
getSupportedAddressClass
in interfaceTransportMapping<A extends IpAddress>
- Specified by:
getSupportedAddressClass
in classAbstractTransportMapping<A extends IpAddress>
- Returns:
- a subclass of
Address
.
-
getListenAddress
Description copied from interface:TransportMapping
Returns the address that represents the actual incoming address this transport mapping uses to listen for incoming packets.- Specified by:
getListenAddress
in interfaceTransportMapping<A extends IpAddress>
- Specified by:
getListenAddress
in classAbstractTransportMapping<A extends IpAddress>
- Returns:
- the address for incoming packets or
null
this transport mapping is not configured to listen for incoming packets.
-
sendMessage
public void sendMessage(A address, byte[] message, TransportStateReference tmStateReference, long timeoutMillis, int retries) throws IOException Description copied from class:AbstractTransportMapping
Sends a message to the supplied address using this transport. If the target address has been suspended, then instead actually sending the message on the wire, the methodAbstractTransportMapping.handleDroppedMessageToSend(Address, byte[], TransportStateReference, long, int)
will be called. To stop suspending of a target address, callAbstractTransportMapping.resumeAddress(Address)
for that address.- Specified by:
sendMessage
in interfaceTransportMapping<A extends IpAddress>
- Specified by:
sendMessage
in classAbstractTransportMapping<A extends IpAddress>
- Parameters:
address
- anAddress
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 milliseconds the connection creation might take (if connection based).retries
- maximum retries during connection creation.- Throws:
IOException
- if any underlying IO operation fails.
-
close
Description copied from interface:TransportMapping
Closes the transport an releases all bound resources synchronously.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceTransportMapping<A extends IpAddress>
- Specified by:
close
in classAbstractTransportMapping<A extends IpAddress>
- Throws:
IOException
- if any IO operation for the close fails.
-
listen
Description copied from interface:TransportMapping
Listen for incoming messages. For connection oriented transports, this method needs to be called beforeTransportMapping.sendMessage(A, byte[], org.snmp4j.TransportStateReference, long, int)
is called for the first time.- Specified by:
listen
in interfaceTransportMapping<A extends IpAddress>
- Specified by:
listen
in classAbstractTransportMapping<A extends IpAddress>
- Throws:
IOException
- if an IO operation exception occurs while starting the listener.
-
getListenWorkerTask
Description copied from class:AbstractTransportMapping
Gets theWorkerTask
that is responsible for receiving new messages.- Overrides:
getListenWorkerTask
in classAbstractTransportMapping<A extends IpAddress>
- Returns:
- a
WorkerTask
instance which is most likely aDefaultThreadFactory.WorkerThread
.
-
isListening
public boolean isListening()Description copied from interface:TransportMapping
Returnstrue
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.- Specified by:
isListening
in interfaceTransportMapping<A extends IpAddress>
- Overrides:
isListening
in classAbstractTransportMapping<A extends IpAddress>
- Returns:
true
if this transport mapping is listening for messages.
-