public abstract class AbstractTransportMapping<A extends Address> extends Object implements TransportMapping<A>
AbstractTransportMapping
provides an abstract
implementation for the message dispatcher list and the maximum inbound
message size.Modifier and Type | Field and Description |
---|---|
protected boolean |
asyncMsgProcessingSupported |
protected int |
maxInboundMessageSize |
protected List<TransportListener> |
transportListener |
Constructor and Description |
---|
AbstractTransportMapping() |
Modifier and Type | Method and Description |
---|---|
void |
addTransportListener(TransportListener l)
Adds a transport listener to the transport.
|
abstract void |
close()
Closes the transport an releases all bound resources synchronously.
|
protected void |
fireProcessMessage(Address address,
ByteBuffer buf,
TransportStateReference tmStateReference) |
int |
getMaxInboundMessageSize()
Gets the maximum length of an incoming message that can be successfully
processed by this transport mapping implementation.
|
abstract Class<? extends Address> |
getSupportedAddressClass()
Gets the
Address class that is supported by this transport mapping. |
boolean |
isAsyncMsgProcessingSupported()
Returns
true if asynchronous (multi-threaded) message
processing may be implemented. |
abstract void |
listen()
Listen for incoming messages.
|
void |
removeTransportListener(TransportListener l)
Removes a transport listener.
|
abstract void |
sendMessage(A address,
byte[] message,
TransportStateReference tmStateReference)
Sends a message to the supplied address using this transport.
|
void |
setAsyncMsgProcessingSupported(boolean asyncMsgProcessingSupported)
Specifies whether this transport mapping has to support asynchronous
messages processing or not.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getListenAddress, isListening
protected List<TransportListener> transportListener
protected int maxInboundMessageSize
protected boolean asyncMsgProcessingSupported
public abstract Class<? extends Address> getSupportedAddressClass()
TransportMapping
Address
class that is supported by this transport mapping.getSupportedAddressClass
in interface TransportMapping<A extends Address>
Address
.public abstract void sendMessage(A address, byte[] message, TransportStateReference tmStateReference) throws IOException
TransportMapping
sendMessage
in interface TransportMapping<A extends Address>
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.IOException
- if any underlying IO operation fails.public void addTransportListener(TransportListener l)
TransportMapping
addTransportListener
in interface TransportMapping<A extends Address>
l
- a TransportListener
instance.public void removeTransportListener(TransportListener l)
TransportMapping
TransportListener
.removeTransportListener
in interface TransportMapping<A extends Address>
l
- a TransportListener
instance.protected void fireProcessMessage(Address address, ByteBuffer buf, TransportStateReference tmStateReference)
public abstract void close() throws IOException
TransportMapping
close
in interface TransportMapping<A extends Address>
IOException
- if any IO operation for the close fails.public abstract void listen() throws IOException
TransportMapping
TransportMapping.sendMessage(A, byte[], org.snmp4j.TransportStateReference)
is called for the
first time.listen
in interface TransportMapping<A extends Address>
IOException
- if an IO operation exception occurs while starting the listener.public int getMaxInboundMessageSize()
TransportMapping
getMaxInboundMessageSize
in interface TransportMapping<A extends Address>
public boolean isAsyncMsgProcessingSupported()
true
if asynchronous (multi-threaded) message
processing may be implemented. The default is true
.false
is returned the
MessageDispatcher.processMessage(org.snmp4j.TransportMapping, org.snmp4j.smi.Address, java.nio.ByteBuffer, org.snmp4j.TransportStateReference)
method must not return before the message has been entirely processed.public void setAsyncMsgProcessingSupported(boolean asyncMsgProcessingSupported)
asyncMsgProcessingSupported
- if false
the MessageDispatcher.processMessage(org.snmp4j.TransportMapping, org.snmp4j.smi.Address, java.nio.ByteBuffer, org.snmp4j.TransportStateReference)
method must not return before the message has been entirely processed,
because the incoming message buffer is not copied before the message
is being processed. If true
the message buffer is copied
for each call, so that the message processing can be implemented
asynchronously.Copyright © 2018 SNMP4J.org. All rights reserved.