
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, writeRequiresReadclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetCloseSetter, getReadSetter, getWriteSetterawaitReadable, awaitReadable, getReadThread, isReadResumed, resumeReads, shutdownReads, suspendReads, wakeupReadsawaitWritable, awaitWritable, close, flush, getWriteThread, isWriteResumed, resumeWrites, shutdownWrites, suspendWrites, wakeupWritesgetWorkergetOption, setOption, supportsOptionpublic 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 ReadableMessageChannelbuffer - 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 ReadableMessageChannelbuffers - 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 ReadableMessageChannelbuffers - 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
TranslatingSuspendableChannelshutdownReadsAction 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 WritableMessageChannelbuffer - 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 WritableMessageChannelbuffers - 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 WritableMessageChannelbuffers - 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
TranslatingSuspendableChannelshutDown 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
TranslatingSuspendableChannelshutdownWritesComplete 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
TranslatingSuspendableChannelTranslatingSuspendableChannel.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 ConnectedChannelpublic <A extends java.net.SocketAddress> A getPeerAddress(java.lang.Class<A> type)
null if the address is not of that
type.getPeerAddress in interface ConnectedChanneltype - the address type classnull if unknownpublic java.net.SocketAddress getLocalAddress()
getLocalAddress in interface BoundChannelpublic <A extends java.net.SocketAddress> A getLocalAddress(java.lang.Class<A> type)
null if the address is not of that
type.getLocalAddress in interface BoundChannelA - 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.