public class FramedMessageChannel extends TranslatingSuspendableChannel<ConnectedMessageChannel,ConnectedStreamChannel> implements ConnectedMessageChannel
channel
Constructor and Description |
---|
FramedMessageChannel(ConnectedStreamChannel channel,
java.nio.ByteBuffer receiveBuffer,
java.nio.ByteBuffer transmitBuffer)
Construct a new instance.
|
FramedMessageChannel(ConnectedStreamChannel channel,
Pooled<java.nio.ByteBuffer> receiveBuffer,
Pooled<java.nio.ByteBuffer> transmitBuffer)
Construct a new instance.
|
Modifier and Type | Method and Description |
---|---|
protected void |
closeAction(boolean readShutDown,
boolean writeShutDown)
The action to perform when the channel is closed via the
TranslatingSuspendableChannel.close() method. |
protected boolean |
flushAction(boolean shutDown)
The action to perform when the channel is flushed.
|
ConnectedStreamChannel |
getChannel()
Get the underlying channel.
|
java.net.SocketAddress |
getLocalAddress()
Get the local address that this channel is bound to.
|
<A extends java.net.SocketAddress> |
getLocalAddress(java.lang.Class<A> type)
Get the local address of a given type, or
null if the address is not of that
type. |
java.net.SocketAddress |
getPeerAddress()
Get the peer address of this channel.
|
<A extends java.net.SocketAddress> |
getPeerAddress(java.lang.Class<A> type)
Get the peer address of a given type, or
null if the address is not of that
type. |
int |
receive(java.nio.ByteBuffer buffer)
Receive a message.
|
long |
receive(java.nio.ByteBuffer[] buffers)
Receive a message.
|
long |
receive(java.nio.ByteBuffer[] buffers,
int offs,
int len)
Receive a message.
|
boolean |
send(java.nio.ByteBuffer buffer)
Send a complete message.
|
boolean |
send(java.nio.ByteBuffer[] buffers)
Send a complete message.
|
boolean |
send(java.nio.ByteBuffer[] buffers,
int offs,
int len)
Send a complete message.
|
protected void |
shutdownReadsAction(boolean writeComplete)
The action to perform when reads are shut down.
|
protected void |
shutdownWritesComplete(boolean readShutDown)
Notification that the channel has successfully flushed after having shut down writes.
|
awaitReadable, awaitReadable, awaitWritable, awaitWritable, clearReadReady, clearReadRequiresWrite, clearWriteReady, clearWriteRequiresRead, close, flush, getCloseSetter, getOption, getReadSetter, getReadThread, getWorker, getWriteSetter, getWriteThread, handleClosed, handleReadable, handleWritable, isOpen, isReadResumed, isReadShutDown, isWriteComplete, isWriteResumed, isWriteShutDown, readRequiresWrite, removeReadRequiresExternal, removeWriteRequiresExternal, resumeReads, resumeWrites, setClosed, setOption, setReadReady, setReadRequiresWrite, setReadShutDown, setWriteReady, setWriteRequiresRead, setWriteShutDown, shutdownReads, shutdownWrites, shutdownWritesAction, supportsOption, suspendReads, suspendWrites, thisTyped, toString, tryAddReadRequiresExternal, tryAddWriteRequiresExternal, wakeupReads, wakeupWrites, writeRequiresRead
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getCloseSetter, getReadSetter, getWriteSetter
awaitReadable, awaitReadable, getReadThread, isReadResumed, resumeReads, shutdownReads, suspendReads, wakeupReads
awaitWritable, awaitWritable, close, flush, getWriteThread, isWriteResumed, resumeWrites, shutdownWrites, suspendWrites, wakeupWrites
getWorker
getOption, setOption, supportsOption
public FramedMessageChannel(ConnectedStreamChannel channel, java.nio.ByteBuffer receiveBuffer, java.nio.ByteBuffer transmitBuffer)
channel
- the channel to wrapreceiveBuffer
- the receive buffer (should be direct)transmitBuffer
- the send buffer (should be direct)public FramedMessageChannel(ConnectedStreamChannel channel, Pooled<java.nio.ByteBuffer> receiveBuffer, Pooled<java.nio.ByteBuffer> transmitBuffer)
channel
- the channel to wrapreceiveBuffer
- the receive buffer (should be direct)transmitBuffer
- the send buffer (should be direct)public int receive(java.nio.ByteBuffer buffer) throws java.io.IOException
receive
in interface ReadableMessageChannel
buffer
- the buffer that will hold the messagejava.io.IOException
- if an I/O error occurspublic long receive(java.nio.ByteBuffer[] buffers) throws java.io.IOException
receive
in interface ReadableMessageChannel
buffers
- the buffers that will hold the messagejava.io.IOException
- if an I/O error occurspublic long receive(java.nio.ByteBuffer[] buffers, int offs, int len) throws java.io.IOException
receive
in interface ReadableMessageChannel
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 filljava.io.IOException
- if an I/O error occursprotected void shutdownReadsAction(boolean writeComplete) throws java.io.IOException
TranslatingSuspendableChannel
shutdownReadsAction
in class TranslatingSuspendableChannel<ConnectedMessageChannel,ConnectedStreamChannel>
java.io.IOException
- if an error occurspublic boolean send(java.nio.ByteBuffer buffer) throws java.io.IOException
send
in interface WritableMessageChannel
buffer
- the message to sendtrue
if the message was sent, or false
if it would blockjava.io.IOException
- if an I/O error occurspublic boolean send(java.nio.ByteBuffer[] buffers) throws java.io.IOException
send
in interface WritableMessageChannel
buffers
- the buffers holding the message to sendtrue
if the message was sent, or false
if it would blockjava.io.IOException
- if an I/O error occurspublic boolean send(java.nio.ByteBuffer[] buffers, int offs, int len) throws java.io.IOException
send
in interface WritableMessageChannel
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 sendtrue
if the message was sent, or false
if it would blockjava.io.IOException
- if an I/O error occursprotected boolean flushAction(boolean shutDown) throws java.io.IOException
TranslatingSuspendableChannel
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 TranslatingSuspendableChannel.flush()
will flush the underlying
channel until it returns true
).flushAction
in class TranslatingSuspendableChannel<ConnectedMessageChannel,ConnectedStreamChannel>
shutDown
- true
if the channel's write side has been shut down, false
otherwisetrue
if the flush succeeded, false
if it would blockjava.io.IOException
- if an error occursprotected void shutdownWritesComplete(boolean readShutDown) throws java.io.IOException
TranslatingSuspendableChannel
shutdownWritesComplete
in class TranslatingSuspendableChannel<ConnectedMessageChannel,ConnectedStreamChannel>
readShutDown
- true
if the read side was already shut down, false
otherwisejava.io.IOException
- if an error occursprotected void closeAction(boolean readShutDown, boolean writeShutDown) throws java.io.IOException
TranslatingSuspendableChannel
TranslatingSuspendableChannel.close()
method. By default, the underlying
channel is closed.closeAction
in class TranslatingSuspendableChannel<ConnectedMessageChannel,ConnectedStreamChannel>
readShutDown
- if reads were previously shut downwriteShutDown
- if writes were previously shut downjava.io.IOException
- if an error occurspublic java.net.SocketAddress getPeerAddress()
getPeerAddress
in interface ConnectedChannel
public <A extends java.net.SocketAddress> A getPeerAddress(java.lang.Class<A> type)
null
if the address is not of that
type.getPeerAddress
in interface ConnectedChannel
type
- the address type classnull
if unknownpublic java.net.SocketAddress getLocalAddress()
getLocalAddress
in interface BoundChannel
public <A extends java.net.SocketAddress> A getLocalAddress(java.lang.Class<A> type)
null
if the address is not of that
type.getLocalAddress
in interface BoundChannel
A
- the address typetype
- the address type classnull
if unknownpublic ConnectedStreamChannel getChannel()
getChannel
in interface WrappedChannel<ConnectedStreamChannel>
getChannel
in class TranslatingSuspendableChannel<ConnectedMessageChannel,ConnectedStreamChannel>
Copyright © 2010 JBoss, a division of Red Hat, Inc.