- java.lang.Object
-
- org.xnio.channels.TranslatingSuspendableChannel<ConnectedMessageChannel,ConnectedStreamChannel>
-
- org.xnio.channels.FramedMessageChannel
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.nio.channels.Channel
,java.nio.channels.InterruptibleChannel
,BoundChannel
,CloseableChannel
,CloseListenerSettable<ConnectedMessageChannel>
,Configurable
,ConnectedChannel
,ConnectedMessageChannel
,MessageChannel
,ReadableMessageChannel
,ReadListenerSettable<ConnectedMessageChannel>
,SuspendableChannel
,SuspendableReadChannel
,SuspendableWriteChannel
,WrappedChannel<ConnectedStreamChannel>
,WritableMessageChannel
,WriteListenerSettable<ConnectedMessageChannel>
@Deprecated public class FramedMessageChannel extends TranslatingSuspendableChannel<ConnectedMessageChannel,ConnectedStreamChannel> implements ConnectedMessageChannel
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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.xnio.channels.CloseListenerSettable
CloseListenerSettable.Setter<C extends java.nio.channels.Channel>
-
Nested classes/interfaces inherited from interface org.xnio.channels.ReadListenerSettable
ReadListenerSettable.Setter<C extends java.nio.channels.Channel>
-
Nested classes/interfaces inherited from interface org.xnio.channels.WriteListenerSettable
WriteListenerSettable.Setter<C extends java.nio.channels.Channel>
-
-
Field Summary
-
Fields inherited from class org.xnio.channels.TranslatingSuspendableChannel
channel
-
Fields inherited from interface org.xnio.channels.Configurable
EMPTY
-
-
Constructor Summary
Constructors Constructor Description FramedMessageChannel(ConnectedStreamChannel channel, java.nio.ByteBuffer receiveBuffer, java.nio.ByteBuffer transmitBuffer)
Deprecated.Construct a new instance.FramedMessageChannel(ConnectedStreamChannel channel, Pooled<java.nio.ByteBuffer> receiveBuffer, Pooled<java.nio.ByteBuffer> transmitBuffer)
Deprecated.Construct a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
closeAction(boolean readShutDown, boolean writeShutDown)
Deprecated.The action to perform when the channel is closed via theTranslatingSuspendableChannel.close()
method.protected boolean
flushAction(boolean shutDown)
Deprecated.The action to perform when the channel is flushed.ConnectedStreamChannel
getChannel()
Deprecated.Get the underlying channel.java.net.SocketAddress
getLocalAddress()
Deprecated.Get the local address that this channel is bound to.<A extends java.net.SocketAddress>
AgetLocalAddress(java.lang.Class<A> type)
Deprecated.Get the local address of a given type, ornull
if the address is not of that type.java.net.SocketAddress
getPeerAddress()
Deprecated.Get the peer address of this channel.<A extends java.net.SocketAddress>
AgetPeerAddress(java.lang.Class<A> type)
Deprecated.Get the peer address of a given type, ornull
if the address is not of that type.int
receive(java.nio.ByteBuffer buffer)
Deprecated.Receive a message.long
receive(java.nio.ByteBuffer[] buffers)
Deprecated.Receive a message.long
receive(java.nio.ByteBuffer[] buffers, int offs, int len)
Deprecated.Receive a message.boolean
send(java.nio.ByteBuffer buffer)
Deprecated.Send a complete message.boolean
send(java.nio.ByteBuffer[] buffers)
Deprecated.Send a complete message.boolean
send(java.nio.ByteBuffer[] buffers, int offs, int len)
Deprecated.Send a complete message.boolean
sendFinal(java.nio.ByteBuffer buffer)
Deprecated.Send a complete message.boolean
sendFinal(java.nio.ByteBuffer[] buffers)
Deprecated.Send a complete message.boolean
sendFinal(java.nio.ByteBuffer[] buffers, int offs, int len)
Deprecated.Send a complete message.protected void
shutdownReadsAction(boolean writeComplete)
Deprecated.The action to perform when reads are shut down.protected void
shutdownWritesComplete(boolean readShutDown)
Deprecated.Notification that the channel has successfully flushed after having shut down writes.-
Methods inherited from class org.xnio.channels.TranslatingSuspendableChannel
awaitReadable, awaitReadable, awaitWritable, awaitWritable, clearReadReady, clearReadRequiresWrite, clearWriteReady, clearWriteRequiresRead, close, flush, getCloseListener, getCloseSetter, getIoThread, getOption, getReadListener, getReadSetter, getReadThread, getWorker, getWriteListener, getWriteSetter, getWriteThread, handleClosed, handleReadable, handleWritable, isOpen, isReadResumed, isReadShutDown, isWriteComplete, isWriteResumed, isWriteShutDown, readRequiresWrite, removeReadRequiresExternal, removeWriteRequiresExternal, resumeReads, resumeWrites, setClosed, setCloseListener, setOption, setReadListener, setReadReady, setReadRequiresWrite, setReadShutDown, setWriteListener, setWriteReady, setWriteRequiresRead, setWriteShutDown, shutdownReads, shutdownWrites, shutdownWritesAction, supportsOption, suspendReads, suspendWrites, thisTyped, toString, tryAddReadRequiresExternal, tryAddWriteRequiresExternal, wakeupReads, wakeupWrites, writeRequiresRead
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.xnio.channels.CloseableChannel
getIoThread, getWorker
-
Methods inherited from interface org.xnio.channels.Configurable
getOption, setOption, supportsOption
-
Methods inherited from interface org.xnio.channels.ConnectedMessageChannel
getCloseSetter, getReadSetter, getWriteSetter
-
Methods inherited from interface org.xnio.channels.SuspendableReadChannel
awaitReadable, awaitReadable, getReadThread, isReadResumed, resumeReads, shutdownReads, suspendReads, wakeupReads
-
Methods inherited from interface org.xnio.channels.SuspendableWriteChannel
awaitWritable, awaitWritable, close, flush, getWriteThread, isOpen, isWriteResumed, resumeWrites, shutdownWrites, suspendWrites, wakeupWrites
-
-
-
-
Constructor Detail
-
FramedMessageChannel
public FramedMessageChannel(ConnectedStreamChannel channel, java.nio.ByteBuffer receiveBuffer, java.nio.ByteBuffer transmitBuffer)
Deprecated.Construct a new instance.- Parameters:
channel
- the channel to wrapreceiveBuffer
- the receive buffer (should be direct)transmitBuffer
- the send buffer (should be direct)
-
FramedMessageChannel
public FramedMessageChannel(ConnectedStreamChannel channel, Pooled<java.nio.ByteBuffer> receiveBuffer, Pooled<java.nio.ByteBuffer> transmitBuffer)
Deprecated.Construct a new instance.- Parameters:
channel
- the channel to wrapreceiveBuffer
- the receive buffer (should be direct)transmitBuffer
- the send buffer (should be direct)
-
-
Method Detail
-
receive
public int receive(java.nio.ByteBuffer buffer) throws java.io.IOException
Deprecated.Receive a message.- Specified by:
receive
in interfaceReadableMessageChannel
- Parameters:
buffer
- the buffer that will hold the message- Returns:
- 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
- Throws:
java.io.IOException
- if an I/O error occurs
-
receive
public long receive(java.nio.ByteBuffer[] buffers) throws java.io.IOException
Deprecated.Receive a message.- Specified by:
receive
in interfaceReadableMessageChannel
- Parameters:
buffers
- the buffers that will hold the message- Returns:
- 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
- Throws:
java.io.IOException
- if an I/O error occurs
-
receive
public long receive(java.nio.ByteBuffer[] buffers, int offs, int len) throws java.io.IOException
Deprecated.Receive a message.- Specified by:
receive
in interfaceReadableMessageChannel
- Parameters:
buffers
- the buffers that will hold the messageoffs
- the offset into the array of buffers of the first buffer to read intolen
- the number of buffers to fill- Returns:
- 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
- Throws:
java.io.IOException
- if an I/O error occurs
-
shutdownReadsAction
protected void shutdownReadsAction(boolean writeComplete) throws java.io.IOException
Deprecated.Description copied from class:TranslatingSuspendableChannel
The action to perform when reads are shut down. By default, this method delegates to the underlying channel.- Overrides:
shutdownReadsAction
in classTranslatingSuspendableChannel<ConnectedMessageChannel,ConnectedStreamChannel>
- Throws:
java.io.IOException
- if an error occurs
-
send
public boolean send(java.nio.ByteBuffer buffer) throws java.io.IOException
Deprecated.Send a complete message.- Specified by:
send
in interfaceWritableMessageChannel
- Parameters:
buffer
- the message to send- Returns:
- the result of the send operation;
true
if the message was sent, orfalse
if it would block - Throws:
java.io.IOException
- if an I/O error occurs
-
send
public boolean send(java.nio.ByteBuffer[] buffers) throws java.io.IOException
Deprecated.Send a complete message.- Specified by:
send
in interfaceWritableMessageChannel
- Parameters:
buffers
- the buffers holding the message to send- Returns:
- the result of the send operation;
true
if the message was sent, orfalse
if it would block - Throws:
java.io.IOException
- if an I/O error occurs
-
send
public boolean send(java.nio.ByteBuffer[] buffers, int offs, int len) throws java.io.IOException
Deprecated.Send a complete message.- Specified by:
send
in interfaceWritableMessageChannel
- Parameters:
buffers
- the buffers holding the message to sendoffs
- the offset into the buffer array of the first bufferlen
- the number of buffers that contain data to send- Returns:
- the result of the send operation;
true
if the message was sent, orfalse
if it would block - Throws:
java.io.IOException
- if an I/O error occurs
-
sendFinal
public boolean sendFinal(java.nio.ByteBuffer buffer) throws java.io.IOException
Deprecated.Description copied from interface:WritableMessageChannel
Send a complete message. If the message was successfully sent the channel with have its writes shutdown.- Specified by:
sendFinal
in interfaceWritableMessageChannel
- Parameters:
buffer
- the message to send- Returns:
- the result of the send operation;
true
if the message was sent, orfalse
if it would block - Throws:
java.io.IOException
- if an I/O error occurs
-
sendFinal
public boolean sendFinal(java.nio.ByteBuffer[] buffers) throws java.io.IOException
Deprecated.Description copied from interface:WritableMessageChannel
Send a complete message. If the message was successfully sent the channel with have its writes shutdown.- Specified by:
sendFinal
in interfaceWritableMessageChannel
- Parameters:
buffers
- the buffers holding the message to send- Returns:
- the result of the send operation;
true
if the message was sent, orfalse
if it would block - Throws:
java.io.IOException
- if an I/O error occurs
-
sendFinal
public boolean sendFinal(java.nio.ByteBuffer[] buffers, int offs, int len) throws java.io.IOException
Deprecated.Description copied from interface:WritableMessageChannel
Send a complete message. If the message was successfully sent the channel with have its writes shutdown.- Specified by:
sendFinal
in interfaceWritableMessageChannel
- Parameters:
buffers
- the buffers holding the message to sendoffs
- the offset into the buffer array of the first bufferlen
- the number of buffers that contain data to send- Returns:
- the result of the send operation;
true
if the message was sent, orfalse
if it would block - Throws:
java.io.IOException
- if an I/O error occurs
-
flushAction
protected boolean flushAction(boolean shutDown) throws java.io.IOException
Deprecated.Description copied from class:TranslatingSuspendableChannel
The action to perform when the channel is flushed. By default, this method delegates to the underlying channel. If theshutDown
parameter is set, and this method returnstrue
, the underlying channel will be shut down and this method will never be called again (future calls toTranslatingSuspendableChannel.flush()
will flush the underlying channel until it returnstrue
).- Overrides:
flushAction
in classTranslatingSuspendableChannel<ConnectedMessageChannel,ConnectedStreamChannel>
- Parameters:
shutDown
-true
if the channel's write side has been shut down,false
otherwise- Returns:
true
if the flush succeeded,false
if it would block- Throws:
java.io.IOException
- if an error occurs
-
shutdownWritesComplete
protected void shutdownWritesComplete(boolean readShutDown) throws java.io.IOException
Deprecated.Description copied from class:TranslatingSuspendableChannel
Notification that the channel has successfully flushed after having shut down writes. The underlying channel may not yet be fully flushed at this time.- Overrides:
shutdownWritesComplete
in classTranslatingSuspendableChannel<ConnectedMessageChannel,ConnectedStreamChannel>
- Parameters:
readShutDown
-true
if the read side was already shut down,false
otherwise- Throws:
java.io.IOException
- if an error occurs
-
closeAction
protected void closeAction(boolean readShutDown, boolean writeShutDown) throws java.io.IOException
Deprecated.Description copied from class:TranslatingSuspendableChannel
The action to perform when the channel is closed via theTranslatingSuspendableChannel.close()
method. By default, the underlying channel is closed.- Overrides:
closeAction
in classTranslatingSuspendableChannel<ConnectedMessageChannel,ConnectedStreamChannel>
- Parameters:
readShutDown
- if reads were previously shut downwriteShutDown
- if writes were previously shut down- Throws:
java.io.IOException
- if an error occurs
-
getPeerAddress
public java.net.SocketAddress getPeerAddress()
Deprecated.Get the peer address of this channel.- Specified by:
getPeerAddress
in interfaceConnectedChannel
- Returns:
- the peer address
-
getPeerAddress
public <A extends java.net.SocketAddress> A getPeerAddress(java.lang.Class<A> type)
Deprecated.Get the peer address of a given type, ornull
if the address is not of that type.- Specified by:
getPeerAddress
in interfaceConnectedChannel
- Parameters:
type
- the address type class- Returns:
- the peer address, or
null
if unknown
-
getLocalAddress
public java.net.SocketAddress getLocalAddress()
Deprecated.Get the local address that this channel is bound to.- Specified by:
getLocalAddress
in interfaceBoundChannel
- Returns:
- the local address
-
getLocalAddress
public <A extends java.net.SocketAddress> A getLocalAddress(java.lang.Class<A> type)
Deprecated.Get the local address of a given type, ornull
if the address is not of that type.- Specified by:
getLocalAddress
in interfaceBoundChannel
- Type Parameters:
A
- the address type- Parameters:
type
- the address type class- Returns:
- the local address, or
null
if unknown
-
getChannel
public ConnectedStreamChannel getChannel()
Deprecated.Get the underlying channel.- Specified by:
getChannel
in interfaceWrappedChannel<ConnectedStreamChannel>
- Overrides:
getChannel
in classTranslatingSuspendableChannel<ConnectedMessageChannel,ConnectedStreamChannel>
- Returns:
- the underlying channel
-
-