Top Description Fields Constructors Methods
org.xnio.channels

public Class FramedMessageChannel

extends TranslatingSuspendableChannel<ConnectedMessageChannel, ConnectedStreamChannel>
implements ConnectedMessageChannel
Class Inheritance
All Implemented Interfaces
org.xnio.channels.ConnectedMessageChannel, org.xnio.channels.ConnectedChannel, org.xnio.channels.BoundChannel, org.xnio.channels.CloseableChannel, org.xnio.channels.Configurable, java.nio.channels.InterruptibleChannel, java.nio.channels.Channel, java.io.Closeable, java.lang.AutoCloseable, org.xnio.channels.MessageChannel, org.xnio.channels.SuspendableChannel, org.xnio.channels.SuspendableWriteChannel, org.xnio.channels.SuspendableReadChannel, org.xnio.channels.WritableMessageChannel, org.xnio.channels.ReadableMessageChannel
Annotations
@SuppressWarnings:unused
@Deprecated
Static Imports
org.xnio._private.Messages.msg

Deprecated

This class is deprecated; use conduits instead.

A connected message channel providing a SASL-style framing layer over a stream channel where each message is prepended by a four-byte length field.
Author
David M. Lloyd

Field Summary

Modifier and TypeField and Description
private static final Logger
private final Object
private final Pooled<ByteBuffer>
receiveBuffer

References Deprecated Pooled is deprecated or references (maybe indirectly) at least one deprecated element.
private final Pooled<ByteBuffer>
transmitBuffer

References Deprecated Pooled is deprecated or references (maybe indirectly) at least one deprecated element.
private final Object
Inherited from org.xnio.channels.TranslatingSuspendableChannel:
channel

Constructor Summary

AccessConstructor and Description
public
FramedMessageChannel(final ConnectedStreamChannel
the channel to wrap
channel
,
final ByteBuffer
the receive buffer (should be direct)
receiveBuffer
,
final ByteBuffer
the send buffer (should be direct)
transmitBuffer
)

Construct a new instance.

public
FramedMessageChannel(final ConnectedStreamChannel
the channel to wrap
channel
,
final Pooled<ByteBuffer>
the receive buffer (should be direct)
receiveBuffer
,
final Pooled<ByteBuffer>
the send buffer (should be direct)
transmitBuffer
)
References Deprecated Pooled is deprecated or references (maybe indirectly) at least one deprecated element.

Construct a new instance.

Method Summary

Modifier and TypeMethod and Description
protected void
closeAction(final boolean
if reads were previously shut down
readShutDown
,
final boolean
if writes were previously shut down
writeShutDown
)

Overrides org.xnio.channels.TranslatingSuspendableChannel.closeAction.

The action to perform when the channel is closed via the close() method.

private boolean
private boolean
protected boolean
flushAction(final boolean
true if the channel's write side has been shut down, false otherwise
shutDown
)

Overrides org.xnio.channels.TranslatingSuspendableChannel.flushAction.

The action to perform when the channel is flushed.

public ConnectedStreamChannel

Returns:

the underlying channel
getChannel
()

Overrides org.xnio.channels.TranslatingSuspendableChannel.getChannel.

Implements org.xnio.channels.WrappedChannel.getChannel.

Get the underlying channel.

public SocketAddress
getLocalAddress()

Implements org.xnio.channels.BoundChannel.getLocalAddress.

Get the local address that this channel is bound to.

public <A extends SocketAddress> A
getLocalAddress(final Class<A>
the address type class
type
)

Implements org.xnio.channels.BoundChannel.getLocalAddress.

Get the local address of a given type, or null if the address is not of that type.

public SocketAddress
getPeerAddress()

Implements org.xnio.channels.ConnectedChannel.getPeerAddress.

Get the peer address of this channel.

public <A extends SocketAddress> A
getPeerAddress(final Class<A>
the address type class
type
)

Implements org.xnio.channels.ConnectedChannel.getPeerAddress.

Get the peer address of a given type, or null if the address is not of that type.

public int
receive(final ByteBuffer
the buffer that will hold the message
buffer
)

Implements org.xnio.channels.ReadableMessageChannel.receive.

Receive a message.

public long
receive(final ByteBuffer[]
the buffers that will hold the message
buffers
)

Implements org.xnio.channels.ReadableMessageChannel.receive.

Receive a message.

public long
receive(final ByteBuffer[]
the buffers that will hold the message
buffers
,
final int
the offset into the array of buffers of the first buffer to read into
offs
,
final int
the number of buffers to fill
len
)

Implements org.xnio.channels.ReadableMessageChannel.receive.

Receive a message.

public boolean
send(final ByteBuffer
the message to send
buffer
)

Implements org.xnio.channels.WritableMessageChannel.send.

Send a complete message.

public boolean
send(final ByteBuffer[]
the buffers holding the message to send
buffers
)

Implements org.xnio.channels.WritableMessageChannel.send.

Send a complete message.

public boolean
send(final ByteBuffer[]
the buffers holding the message to send
buffers
,
final int
the offset into the buffer array of the first buffer
offs
,
final int
the number of buffers that contain data to send
len
)

Implements org.xnio.channels.WritableMessageChannel.send.

Send a complete message.

public boolean
sendFinal(ByteBuffer
the message to send
buffer
)

Implements org.xnio.channels.WritableMessageChannel.sendFinal.

Send a complete message.

public boolean
sendFinal(ByteBuffer[]
the buffers holding the message to send
buffers
)

Implements org.xnio.channels.WritableMessageChannel.sendFinal.

Send a complete message.

public boolean
sendFinal(ByteBuffer[]
the buffers holding the message to send
buffers
,
int
the offset into the buffer array of the first buffer
offs
,
int
the number of buffers that contain data to send
len
)

Implements org.xnio.channels.WritableMessageChannel.sendFinal.

Send a complete message.

protected void
shutdownReadsAction(final boolean writeComplete)

Overrides org.xnio.channels.TranslatingSuspendableChannel.shutdownReadsAction.

The action to perform when reads are shut down.

protected void
shutdownWritesComplete(final boolean
true if the read side was already shut down, false otherwise
readShutDown
)

Overrides org.xnio.channels.TranslatingSuspendableChannel.shutdownWritesComplete.

Notification that the channel has successfully flushed after having shut down writes.

Inherited from org.xnio.channels.TranslatingSuspendableChannel:
awaitReadableawaitReadableawaitWritableawaitWritableclearReadReadyclearReadRequiresWriteclearWriteReadyclearWriteRequiresReadcloseflushgetCloseListenergetCloseSettergetIoThreadgetOptiongetReadListenergetReadSettergetReadThreadgetWorkergetWriteListenergetWriteSettergetWriteThreadhandleClosedhandleReadablehandleWritableisOpenisReadResumedisReadShutDownisWriteCompleteisWriteResumedisWriteShutDownreadRequiresWriteremoveReadRequiresExternalremoveWriteRequiresExternalresumeReadsresumeWritessetClosedsetCloseListenersetOptionsetReadListenersetReadReadysetReadRequiresWritesetReadShutDownsetWriteListenersetWriteReadysetWriteRequiresReadsetWriteShutDownshutdownReadsshutdownWritesshutdownWritesActionsupportsOptionsuspendReadssuspendWritesthisTypedtoStringtryAddReadRequiresExternaltryAddWriteRequiresExternalwakeupReadswakeupWriteswriteRequiresRead

Field Detail

logback to summary
private static final Logger log
readLockback to summary
private final Object readLock
receiveBufferback to summary
private final Pooled<ByteBuffer> receiveBuffer

References Deprecated

Pooled is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

transmitBufferback to summary
private final Pooled<ByteBuffer> transmitBuffer

References Deprecated

Pooled is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

writeLockback to summary
private final Object writeLock

Constructor Detail

FramedMessageChannelback to summary
public FramedMessageChannel(final ConnectedStreamChannel channel, final ByteBuffer receiveBuffer, final ByteBuffer transmitBuffer)

Construct a new instance.

Parameters
channel:ConnectedStreamChannel

the channel to wrap

receiveBuffer:ByteBuffer

the receive buffer (should be direct)

transmitBuffer:ByteBuffer

the send buffer (should be direct)

FramedMessageChannelback to summary
public FramedMessageChannel(final ConnectedStreamChannel channel, final Pooled<ByteBuffer> receiveBuffer, final Pooled<ByteBuffer> transmitBuffer)

References Deprecated

Pooled is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Construct a new instance.

Parameters
channel:ConnectedStreamChannel

the channel to wrap

receiveBuffer:Pooled<ByteBuffer>

the receive buffer (should be direct)

transmitBuffer:Pooled<ByteBuffer>

the send buffer (should be direct)

Method Detail

closeActionback to summary
protected void closeAction(final boolean readShutDown, final boolean writeShutDown) throws IOException

Overrides org.xnio.channels.TranslatingSuspendableChannel.closeAction.

Doc from org.xnio.channels.TranslatingSuspendableChannel.closeAction.

The action to perform when the channel is closed via the close() method. By default, the underlying channel is closed.

Parameters
readShutDown:boolean

if reads were previously shut down

writeShutDown:boolean

if writes were previously shut down

Exceptions
IOException:
if an error occurs
doFlushback to summary
private boolean doFlush() throws IOException
doFlushBufferback to summary
private boolean doFlushBuffer() throws IOException
flushActionback to summary
protected boolean flushAction(final boolean shutDown) throws IOException

Overrides org.xnio.channels.TranslatingSuspendableChannel.flushAction.

Doc from org.xnio.channels.TranslatingSuspendableChannel.flushAction.

The action to perform when the channel is flushed. By default, this method delegates to the underlying channel. If the shutDown parameter is set, and this method returns true, the underlying channel will be shut down and this method will never be called again (future calls to flush() will flush the underlying channel until it returns true).

Parameters
shutDown:boolean

true if the channel's write side has been shut down, false otherwise

Returns:boolean

true if the flush succeeded, false if it would block

Exceptions
IOException:
if an error occurs
getChannelback to summary
public ConnectedStreamChannel getChannel()

Overrides org.xnio.channels.TranslatingSuspendableChannel.getChannel.

Implements org.xnio.channels.WrappedChannel.getChannel.

Get the underlying channel.

Returns:ConnectedStreamChannel

the underlying channel

getLocalAddressback to summary
public SocketAddress getLocalAddress()

Implements org.xnio.channels.BoundChannel.getLocalAddress.

Doc from org.xnio.channels.BoundChannel.getLocalAddress.

Get the local address that this channel is bound to.

Returns:SocketAddress

the local address

getLocalAddressback to summary
public <A extends SocketAddress> A getLocalAddress(final Class<A> type)

Implements org.xnio.channels.BoundChannel.getLocalAddress.

Doc from org.xnio.channels.BoundChannel.getLocalAddress.

Get the local address of a given type, or null if the address is not of that type.

Parameters
<A>
the address type
type:Class<A>

the address type class

Returns:A

the local address, or null if unknown

getPeerAddressback to summary
public SocketAddress getPeerAddress()

Implements org.xnio.channels.ConnectedChannel.getPeerAddress.

Doc from org.xnio.channels.ConnectedChannel.getPeerAddress.

Get the peer address of this channel.

Returns:SocketAddress

the peer address

getPeerAddressback to summary
public <A extends SocketAddress> A getPeerAddress(final Class<A> type)

Implements org.xnio.channels.ConnectedChannel.getPeerAddress.

Doc from org.xnio.channels.ConnectedChannel.getPeerAddress.

Get the peer address of a given type, or null if the address is not of that type.

Parameters
type:Class<A>

the address type class

Returns:A

the peer address, or null if unknown

receiveback to summary
public int receive(final ByteBuffer buffer) throws IOException

Implements org.xnio.channels.ReadableMessageChannel.receive.

Doc from org.xnio.channels.ReadableMessageChannel.receive.

Receive a message.

Parameters
buffer:ByteBuffer

the buffer that will hold the message

Returns:int

the size of the received message, 0 if no message is available, and -1 if the message channel has reached an end-of-file condition

Exceptions
IOException:
if an I/O error occurs
receiveback to summary
public long receive(final ByteBuffer[] buffers) throws IOException

Implements org.xnio.channels.ReadableMessageChannel.receive.

Doc from org.xnio.channels.ReadableMessageChannel.receive.

Receive a message.

Parameters
buffers:ByteBuffer[]

the buffers that will hold the message

Returns:long

the size of the received message, 0 if no message is available, and -1 if the message channel has reached an end-of-file condition

Exceptions
IOException:
if an I/O error occurs
receiveback to summary
public long receive(final ByteBuffer[] buffers, final int offs, final int len) throws IOException

Implements org.xnio.channels.ReadableMessageChannel.receive.

Doc from org.xnio.channels.ReadableMessageChannel.receive.

Receive a message.

Parameters
buffers:ByteBuffer[]

the buffers that will hold the message

offs:int

the offset into the array of buffers of the first buffer to read into

len:int

the number of buffers to fill

Returns:long

the size of the received message, 0 if no message is available, and -1 if the message channel has reached an end-of-file condition

Exceptions
IOException:
if an I/O error occurs
sendback to summary
public boolean send(final ByteBuffer buffer) throws IOException

Implements org.xnio.channels.WritableMessageChannel.send.

Doc from org.xnio.channels.WritableMessageChannel.send.

Send a complete message.

Parameters
buffer:ByteBuffer

the message to send

Returns:boolean

the result of the send operation; true if the message was sent, or false if it would block

Exceptions
IOException:
if an I/O error occurs
sendback to summary
public boolean send(final ByteBuffer[] buffers) throws IOException

Implements org.xnio.channels.WritableMessageChannel.send.

Doc from org.xnio.channels.WritableMessageChannel.send.

Send a complete message.

Parameters
buffers:ByteBuffer[]

the buffers holding the message to send

Returns:boolean

the result of the send operation; true if the message was sent, or false if it would block

Exceptions
IOException:
if an I/O error occurs
sendback to summary
public boolean send(final ByteBuffer[] buffers, final int offs, final int len) throws IOException

Implements org.xnio.channels.WritableMessageChannel.send.

Doc from org.xnio.channels.WritableMessageChannel.send.

Send a complete message.

Parameters
buffers:ByteBuffer[]

the buffers holding the message to send

offs:int

the offset into the buffer array of the first buffer

len:int

the number of buffers that contain data to send

Returns:boolean

the result of the send operation; true if the message was sent, or false if it would block

Exceptions
IOException:
if an I/O error occurs
sendFinalback to summary
public boolean sendFinal(ByteBuffer buffer) throws IOException

Implements org.xnio.channels.WritableMessageChannel.sendFinal.

Doc from org.xnio.channels.WritableMessageChannel.sendFinal.

Send a complete message. If the message was successfully sent the channel with have its writes shutdown.

Parameters
buffer:ByteBuffer

the message to send

Returns:boolean

the result of the send operation; true if the message was sent, or false if it would block

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
sendFinalback to summary
public boolean sendFinal(ByteBuffer[] buffers) throws IOException

Implements org.xnio.channels.WritableMessageChannel.sendFinal.

Doc from org.xnio.channels.WritableMessageChannel.sendFinal.

Send a complete message. If the message was successfully sent the channel with have its writes shutdown.

Parameters
buffers:ByteBuffer[]

the buffers holding the message to send

Returns:boolean

the result of the send operation; true if the message was sent, or false if it would block

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
sendFinalback to summary
public boolean sendFinal(ByteBuffer[] buffers, int offs, int len) throws IOException

Implements org.xnio.channels.WritableMessageChannel.sendFinal.

Doc from org.xnio.channels.WritableMessageChannel.sendFinal.

Send a complete message. If the message was successfully sent the channel with have its writes shutdown.

Parameters
buffers:ByteBuffer[]

the buffers holding the message to send

offs:int

the offset into the buffer array of the first buffer

len:int

the number of buffers that contain data to send

Returns:boolean

the result of the send operation; true if the message was sent, or false if it would block

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
shutdownReadsActionback to summary
protected void shutdownReadsAction(final boolean writeComplete) throws IOException

Overrides org.xnio.channels.TranslatingSuspendableChannel.shutdownReadsAction.

Doc from org.xnio.channels.TranslatingSuspendableChannel.shutdownReadsAction.

The action to perform when reads are shut down. By default, this method delegates to the underlying channel.

Exceptions
IOException:
if an error occurs
shutdownWritesCompleteback to summary
protected void shutdownWritesComplete(final boolean readShutDown) throws IOException

Overrides org.xnio.channels.TranslatingSuspendableChannel.shutdownWritesComplete.

Doc from org.xnio.channels.TranslatingSuspendableChannel.shutdownWritesComplete.

Notification that the channel has successfully flushed after having shut down writes. The underlying channel may not yet be fully flushed at this time.

Parameters
readShutDown:boolean

true if the read side was already shut down, false otherwise

Exceptions
IOException:
if an error occurs