org.apache.qpid.proton.engine
Interface Transport

All Superinterfaces:
Endpoint

public interface Transport
extends Endpoint

Operates on the entities in the associated Connection by accepting and producing binary AMQP output, potentially layered within SASL and/or SSL.

After a connection is bound with bind(Connection), the methods for accepting and producing output are typically repeatedly called. See the specific methods for details of their legal usage.

Processing the input data received from another AMQP container.

  1. getInputBuffer()
  2. Write data into input buffer
  3. processInput()
  4. Check the result, e.g. by calling TransportResult.checkIsOk()

Getting the output data to send to another AMQP container:

  1. getOutputBuffer()
  2. Read output from output buffer
  3. outputConsumed()

The following methods on the byte buffers returned by getInputBuffer() and getOutputBuffer() must not be called:

  1. Buffer.clear()
  2. ByteBuffer.compact()
  3. Buffer.flip()
  4. Buffer.mark()


Field Summary
static int DEFAULT_MAX_FRAME_SIZE
           
static int END_OF_STREAM
           
static int MIN_MAX_FRAME_SIZE
          the lower bound for the agreed maximum frame size (in bytes).
static int SESSION_WINDOW
           
 
Method Summary
 void bind(Connection connection)
           
 int capacity()
           
 void close_head()
           
 void close_tail()
           
 java.nio.ByteBuffer getInputBuffer()
          Get a buffer that can be used to write input data into the transport.
 int getMaxFrameSize()
          Get the maximum frame size for the transport
 java.nio.ByteBuffer getOutputBuffer()
          Get a read-only byte buffer containing the transport's pending output.
 int getRemoteMaxFrameSize()
           
 java.nio.ByteBuffer head()
           
 int input(byte[] bytes, int offset, int size)
          Deprecated. use getInputBuffer() and processInput() instead.
 int output(byte[] dest, int offset, int size)
          Deprecated. use getOutputBuffer() and outputConsumed() instead
 void outputConsumed()
          Informs the transport that the output buffer returned by getOutputBuffer() is finished with, allowing implementation-dependent steps to be performed such as reclaiming buffer space.
 int pending()
           
 void pop(int bytes)
           
 void process()
           
 TransportResult processInput()
          Tell the transport to process the data written to the input buffer.
 Sasl sasl()
           
 void setMaxFrameSize(int size)
           
 Ssl ssl(SslDomain sslDomain)
          As per ssl(SslDomain, SslPeerDetails) but no attempt is made to resume a previous SSL session.
 Ssl ssl(SslDomain sslDomain, SslPeerDetails sslPeerDetails)
          Wrap this transport's output and input to apply SSL encryption and decryption respectively.
 java.nio.ByteBuffer tail()
           
 
Methods inherited from interface org.apache.qpid.proton.engine.Endpoint
close, free, getCondition, getContext, getLocalState, getRemoteCondition, getRemoteState, open, setCondition, setContext
 

Field Detail

DEFAULT_MAX_FRAME_SIZE

static final int DEFAULT_MAX_FRAME_SIZE
See Also:
Constant Field Values

MIN_MAX_FRAME_SIZE

static final int MIN_MAX_FRAME_SIZE
the lower bound for the agreed maximum frame size (in bytes).

See Also:
Constant Field Values

SESSION_WINDOW

static final int SESSION_WINDOW
See Also:
Constant Field Values

END_OF_STREAM

static final int END_OF_STREAM
See Also:
Constant Field Values
Method Detail

bind

void bind(Connection connection)

capacity

int capacity()

tail

java.nio.ByteBuffer tail()

process

void process()
             throws TransportException
Throws:
TransportException

close_tail

void close_tail()

pending

int pending()

head

java.nio.ByteBuffer head()

pop

void pop(int bytes)

close_head

void close_head()

input

@Deprecated
int input(byte[] bytes,
                     int offset,
                     int size)
Deprecated. use getInputBuffer() and processInput() instead.

Processes the provided input.

Parameters:
bytes - input bytes for consumption
offset - the offset within bytes where input begins
size - the number of bytes available for input
Returns:
the number of bytes consumed
Throws:
TransportException - if the input is invalid, if the transport is already in an error state, or if the input is empty (unless the remote connection is already closed)

getInputBuffer

java.nio.ByteBuffer getInputBuffer()
Get a buffer that can be used to write input data into the transport. Once the client has finished putting into the input buffer, processInput() must be called. Successive calls to this method are not guaranteed to return the same object. Once processInput() is called the buffer must not be used.

Throws:
TransportException - if the transport is already in an invalid state

processInput

TransportResult processInput()
Tell the transport to process the data written to the input buffer. If the returned result indicates failure, the transport will not accept any more input. Specifically, any subsequent processInput() calls on this object will throw an exception.

Returns:
the result of processing the data, which indicates success or failure.
See Also:
getInputBuffer()

output

@Deprecated
int output(byte[] dest,
                      int offset,
                      int size)
Deprecated. use getOutputBuffer() and outputConsumed() instead

Has the transport produce up to size bytes placing the result into dest beginning at position offset.

Parameters:
dest - array for output bytes
offset - the offset within bytes where output begins
size - the maximum number of bytes to be output
Returns:
the number of bytes written

getOutputBuffer

java.nio.ByteBuffer getOutputBuffer()
Get a read-only byte buffer containing the transport's pending output. Once the client has finished getting from the output buffer, outputConsumed() must be called. Successive calls to this method are not guaranteed to return the same object. Once outputConsumed() is called the buffer must not be used. If the transport's state changes AFTER calling this method, this will not be reflected in the output buffer.


outputConsumed

void outputConsumed()
Informs the transport that the output buffer returned by getOutputBuffer() is finished with, allowing implementation-dependent steps to be performed such as reclaiming buffer space.


sasl

Sasl sasl()

ssl

Ssl ssl(SslDomain sslDomain,
        SslPeerDetails sslPeerDetails)
Wrap this transport's output and input to apply SSL encryption and decryption respectively. This method is expected to be called at most once. A subsequent invocation will return the same Ssl object, regardless of the parameters supplied.

Parameters:
sslDomain - the SSL settings to use
sslPeerDetails - may be null, in which case SSL session resume will not be attempted
Returns:
an Ssl object representing the SSL session.

ssl

Ssl ssl(SslDomain sslDomain)
As per ssl(SslDomain, SslPeerDetails) but no attempt is made to resume a previous SSL session.


getMaxFrameSize

int getMaxFrameSize()
Get the maximum frame size for the transport

Returns:
the maximum frame size

setMaxFrameSize

void setMaxFrameSize(int size)

getRemoteMaxFrameSize

int getRemoteMaxFrameSize()