org.snmp4j.transport
Class AbstractTransportMapping

java.lang.Object
  extended by org.snmp4j.transport.AbstractTransportMapping
All Implemented Interfaces:
TransportMapping
Direct Known Subclasses:
TcpTransportMapping, UdpTransportMapping

public abstract class AbstractTransportMapping
extends java.lang.Object
implements TransportMapping

The AbstractTransportMapping provides an abstract implementation for the message dispatcher list and the maximum inbound message size.

Version:
1.6
Author:
Frank Fock

Field Summary
protected  boolean asyncMsgProcessingSupported
           
protected  int maxInboundMessageSize
           
protected  java.util.Vector transportListener
           
 
Constructor Summary
AbstractTransportMapping()
           
 
Method Summary
 void addMessageDispatcher(MessageDispatcher dispatcher)
          Adds a message dispatcher to the transport.
 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, java.nio.ByteBuffer buf)
           
 int getMaxInboundMessageSize()
          Gets the maximum length of an incoming message that can be successfully processed by this transport mapping implementation.
abstract  java.lang.Class getSupportedAddressClass()
          Gets the Address class that is this transport mapping supports.
 boolean isAsyncMsgProcessingSupported()
          Returns true if asynchronous (multi-threaded) message processing may be implemented.
abstract  void listen()
          Listen for incoming messages.
 void removeMessageDispatcher(MessageDispatcher dispatcher)
          Removes a message dispatcher.
 void removeTransportListener(TransportListener l)
          Removes a transport listener.
abstract  void sendMessage(Address address, byte[] message)
          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.
 
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
getListenAddress, isListening
 

Field Detail

transportListener

protected java.util.Vector transportListener

maxInboundMessageSize

protected int maxInboundMessageSize

asyncMsgProcessingSupported

protected boolean asyncMsgProcessingSupported
Constructor Detail

AbstractTransportMapping

public AbstractTransportMapping()
Method Detail

getSupportedAddressClass

public abstract java.lang.Class getSupportedAddressClass()
Description copied from interface: TransportMapping
Gets the Address class that is this transport mapping supports.

Specified by:
getSupportedAddressClass in interface TransportMapping
Returns:
a subclass of Address.

sendMessage

public abstract void sendMessage(Address address,
                                 byte[] message)
                          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
Parameters:
address - an Address instance denoting the target address.
message - the whole message as an array of bytes.
Throws:
java.io.IOException

addMessageDispatcher

public void addMessageDispatcher(MessageDispatcher dispatcher)
Description copied from interface: TransportMapping
Adds a message dispatcher to the transport. Normally, at least one message dispatcher needs to be added to process responses (or requests).

Specified by:
addMessageDispatcher in interface TransportMapping
Parameters:
dispatcher - a MessageDispatcher instance.
See Also:
MessageDispatcherImpl

removeMessageDispatcher

public void removeMessageDispatcher(MessageDispatcher dispatcher)
Description copied from interface: TransportMapping
Removes a message dispatcher. Incoming messages will no longer be propagated to the supplied message dispatcher.

Specified by:
removeMessageDispatcher in interface TransportMapping
Parameters:
dispatcher - a previously added MessageDispatcher instance.
See Also:
TransportMapping.addMessageDispatcher(org.snmp4j.MessageDispatcher)

addTransportListener

public void addTransportListener(TransportListener l)
Description copied from interface: TransportMapping
Adds a transport listener to the transport. Normally, at least one transport listener needs to be added to process incoming messages.

Specified by:
addTransportListener in interface TransportMapping
Parameters:
l - a TransportListener instance.

removeTransportListener

public void removeTransportListener(TransportListener l)
Description copied from interface: TransportMapping
Removes a transport listener. Incoming messages will no longer be propagated to the supplied TransportListener.

Specified by:
removeTransportListener in interface TransportMapping
Parameters:
l - a TransportListener instance.

fireProcessMessage

protected void fireProcessMessage(Address address,
                                  java.nio.ByteBuffer buf)

close

public abstract 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
Throws:
java.io.IOException

listen

public abstract 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(org.snmp4j.smi.Address, byte[]) is called for the first time.

Specified by:
listen in interface TransportMapping
Throws:
java.io.IOException

getMaxInboundMessageSize

public int getMaxInboundMessageSize()
Description copied from interface: TransportMapping
Gets the maximum length of an incoming message that can be successfully processed by this transport mapping implementation.

Specified by:
getMaxInboundMessageSize in interface TransportMapping
Returns:
an integer > 484.

isAsyncMsgProcessingSupported

public boolean isAsyncMsgProcessingSupported()
Returns true if asynchronous (multi-threaded) message processing may be implemented. The default is true.

Returns:
if false is returned the MessageDispatcher.processMessage(org.snmp4j.TransportMapping, org.snmp4j.smi.Address, org.snmp4j.asn1.BERInputStream) method must not return before the message has been entirely processed.

setAsyncMsgProcessingSupported

public void setAsyncMsgProcessingSupported(boolean asyncMsgProcessingSupported)
Specifies whether this transport mapping has to support asynchronous messages processing or not.

Parameters:
asyncMsgProcessingSupported - if false the MessageDispatcher.processMessage(org.snmp4j.TransportMapping, org.snmp4j.smi.Address, org.snmp4j.asn1.BERInputStream) 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 2005-2010 Frank Fock (SNMP4J.org)

Copyright © 2011 SNMP4J.org. All Rights Reserved.