|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jboss.xnio.channels.Channels
public final class Channels
A utility class containing static methods to convert from one channel type to another.
Method Summary | ||
---|---|---|
static ChannelSource<StreamChannel> |
convertAllocatedMessageToStream(ChannelSource<? extends AllocatedMessageChannel> messageChannelSource)
Create a channel source for a stream channel. |
|
static IoHandlerFactory<AllocatedMessageChannel> |
convertAllocatedMessageToStream(IoHandlerFactory<? super StreamChannel> handlerFactory)
Create a channel source for a stream channel. |
|
static ChannelSource<AllocatedMessageChannel> |
convertStreamToAllocatedMessage(ChannelSource<? extends StreamChannel> streamChannelSource,
int maxInboundMessageSize,
int maxOutboundMessageSize)
Create a channel source for an allocated message channel. |
|
static IoHandlerFactory<StreamChannel> |
convertStreamToAllocatedMessage(IoHandlerFactory<? super AllocatedMessageChannel> handlerFactory,
int maxInboundMessageSize,
int maxOutboundMessageSize)
Create a handler factory for an allocated message channel. |
|
static
|
createMergedHandler(IoHandler<? super T> readSide,
IoHandler<? super T> writeSide)
Create a handler that is a merged view of two separate handlers, one for read operations and one for write operations. |
|
static
|
createMergedHandlerFactory(IoHandlerFactory<? super T> readFactory,
IoHandlerFactory<? super T> writeFactory)
Create a handler factory that is a merged view of two separate handler factories, one for read operations and one for write operations. |
|
static
|
readBlocking(C channel,
java.nio.ByteBuffer buffer)
Simple utility method to execute a blocking read on a readable byte channel. |
|
static
|
readBlocking(C channel,
java.nio.ByteBuffer[] buffers,
int offs,
int len)
Simple utility method to execute a blocking read on a scattering byte channel. |
|
static
|
readBlocking(C channel,
java.nio.ByteBuffer[] buffers,
int offs,
int len,
long time,
java.util.concurrent.TimeUnit unit)
Simple utility method to execute a blocking read on a scattering byte channel with a timeout. |
|
static
|
readBlocking(C channel,
java.nio.ByteBuffer buffer,
long time,
java.util.concurrent.TimeUnit unit)
Simple utility method to execute a blocking read on a readable byte channel with a timeout. |
|
static
|
receiveBlocking(C channel,
java.nio.ByteBuffer buffer)
Simple utility method to execute a blocking receive on a readable message channel. |
|
static
|
receiveBlocking(C channel,
java.nio.ByteBuffer[] buffers,
int offs,
int len)
Simple utility method to execute a blocking receive on a readable message channel. |
|
static
|
receiveBlocking(C channel,
java.nio.ByteBuffer[] buffers,
int offs,
int len,
long time,
java.util.concurrent.TimeUnit unit)
Simple utility method to execute a blocking receive on a readable message channel with a timeout. |
|
static
|
receiveBlocking(C channel,
java.nio.ByteBuffer buffer,
long time,
java.util.concurrent.TimeUnit unit)
Simple utility method to execute a blocking receive on a readable message channel with a timeout. |
|
static
|
sendBlocking(C channel,
java.nio.ByteBuffer buffer)
Simple utility method to execute a blocking send on a message channel. |
|
static
|
sendBlocking(C channel,
java.nio.ByteBuffer[] buffers,
int offs,
int len)
Simple utility method to execute a blocking gathering send on a message channel. |
|
static
|
sendBlocking(C channel,
java.nio.ByteBuffer[] buffers,
int offs,
int len,
long time,
java.util.concurrent.TimeUnit unit)
Simple utility method to execute a blocking gathering send on a message channel with a timeout. |
|
static
|
sendBlocking(C channel,
java.nio.ByteBuffer buffer,
long time,
java.util.concurrent.TimeUnit unit)
Simple utility method to execute a blocking send on a message channel with a timeout. |
|
static
|
writeBlocking(C channel,
java.nio.ByteBuffer buffer)
Simple utility method to execute a blocking write on a byte channel. |
|
static
|
writeBlocking(C channel,
java.nio.ByteBuffer[] buffers,
int offs,
int len)
Simple utility method to execute a blocking write on a gathering byte channel. |
|
static
|
writeBlocking(C channel,
java.nio.ByteBuffer[] buffers,
int offs,
int len,
long time,
java.util.concurrent.TimeUnit unit)
Simple utility method to execute a blocking write on a gathering byte channel with a timeout. |
|
static
|
writeBlocking(C channel,
java.nio.ByteBuffer buffer,
long time,
java.util.concurrent.TimeUnit unit)
Simple utility method to execute a blocking write on a byte channel with a timeout. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static ChannelSource<AllocatedMessageChannel> convertStreamToAllocatedMessage(ChannelSource<? extends StreamChannel> streamChannelSource, int maxInboundMessageSize, int maxOutboundMessageSize)
streamChannelSource
- the stream channel source to encapsulatemaxInboundMessageSize
- the maximum incoming message sizemaxOutboundMessageSize
- the maximum outgoing message size
public static IoHandlerFactory<StreamChannel> convertStreamToAllocatedMessage(IoHandlerFactory<? super AllocatedMessageChannel> handlerFactory, int maxInboundMessageSize, int maxOutboundMessageSize)
handlerFactory
- the user allocated message channel handler factorymaxInboundMessageSize
- the maximum incoming message sizemaxOutboundMessageSize
- the maximum outgoing message size
public static ChannelSource<StreamChannel> convertAllocatedMessageToStream(ChannelSource<? extends AllocatedMessageChannel> messageChannelSource)
StreamChannel.resumeReads()
or
StreamChannel.awaitReadable()
, then the channel may block even though there
is more data to be read.
messageChannelSource
- the allocated message channel source
public static IoHandlerFactory<AllocatedMessageChannel> convertAllocatedMessageToStream(IoHandlerFactory<? super StreamChannel> handlerFactory)
StreamChannel.resumeReads()
or
StreamChannel.awaitReadable()
, then the channel may block even though there
is more data to be read.
handlerFactory
- the user stream channel handler factory
public static <T extends SuspendableChannel> IoHandler<T> createMergedHandler(IoHandler<? super T> readSide, IoHandler<? super T> writeSide)
handleOpened()
and handleClosed()
methods are called on each of the two sub-handlers.
T
- the resultant channel typereadSide
- the handler to handle read operationswriteSide
- the handler to handle write operations
public static <T extends SuspendableChannel> IoHandlerFactory<T> createMergedHandlerFactory(IoHandlerFactory<? super T> readFactory, IoHandlerFactory<? super T> writeFactory)
T
- the resultant channel typereadFactory
- the handler factory to create handlers that handle read operationswriteFactory
- the handler factory to create handlers that handle write operations
public static <C extends java.nio.channels.WritableByteChannel & SuspendableWriteChannel> int writeBlocking(C channel, java.nio.ByteBuffer buffer) throws java.io.IOException
C
- the channel typechannel
- the channel to write onbuffer
- the data to write
java.io.IOException
- if an I/O exception occurspublic static <C extends java.nio.channels.WritableByteChannel & SuspendableWriteChannel> int writeBlocking(C channel, java.nio.ByteBuffer buffer, long time, java.util.concurrent.TimeUnit unit) throws java.io.IOException
C
- the channel typechannel
- the channel to write onbuffer
- the data to writetime
- the amount of time to waitunit
- the unit of time to wait
java.io.IOException
- if an I/O exception occurspublic static <C extends java.nio.channels.GatheringByteChannel & SuspendableWriteChannel> long writeBlocking(C channel, java.nio.ByteBuffer[] buffers, int offs, int len) throws java.io.IOException
C
- the channel typechannel
- the channel to write onbuffers
- the data to writeoffs
- the index of the first buffer to writelen
- the number of buffers to write
java.io.IOException
- if an I/O exception occurspublic static <C extends java.nio.channels.GatheringByteChannel & SuspendableWriteChannel> long writeBlocking(C channel, java.nio.ByteBuffer[] buffers, int offs, int len, long time, java.util.concurrent.TimeUnit unit) throws java.io.IOException
C
- the channel typechannel
- the channel to write onbuffers
- the data to writeoffs
- the index of the first buffer to writelen
- the number of buffers to writetime
- the amount of time to waitunit
- the unit of time to wait
java.io.IOException
- if an I/O exception occurspublic static <C extends WritableMessageChannel & SuspendableWriteChannel> void sendBlocking(C channel, java.nio.ByteBuffer buffer) throws java.io.IOException
C
- the channel typechannel
- the channel to write onbuffer
- the data to write
java.io.IOException
- if an I/O exception occurspublic static <C extends WritableMessageChannel & SuspendableWriteChannel> boolean sendBlocking(C channel, java.nio.ByteBuffer buffer, long time, java.util.concurrent.TimeUnit unit) throws java.io.IOException
C
- the channel typechannel
- the channel to write onbuffer
- the data to writetime
- the amount of time to waitunit
- the unit of time to wait
true
if the message was written before the timeout
java.io.IOException
- if an I/O exception occurspublic static <C extends WritableMessageChannel & SuspendableWriteChannel> void sendBlocking(C channel, java.nio.ByteBuffer[] buffers, int offs, int len) throws java.io.IOException
C
- the channel typechannel
- the channel to write onbuffers
- the data to writeoffs
- the index of the first buffer to writelen
- the number of buffers to write
java.io.IOException
- if an I/O exception occurspublic static <C extends WritableMessageChannel & SuspendableWriteChannel> boolean sendBlocking(C channel, java.nio.ByteBuffer[] buffers, int offs, int len, long time, java.util.concurrent.TimeUnit unit) throws java.io.IOException
C
- the channel typechannel
- the channel to write onbuffers
- the data to writeoffs
- the index of the first buffer to writelen
- the number of buffers to writetime
- the amount of time to waitunit
- the unit of time to wait
true
if the message was written before the timeout
java.io.IOException
- if an I/O exception occurspublic static <C extends java.nio.channels.ReadableByteChannel & SuspendableReadChannel> int readBlocking(C channel, java.nio.ByteBuffer buffer) throws java.io.IOException
C
- the channel typechannel
- the channel to read frombuffer
- the buffer into which bytes are to be transferred
java.io.IOException
- if an I/O exception occurspublic static <C extends java.nio.channels.ReadableByteChannel & SuspendableReadChannel> int readBlocking(C channel, java.nio.ByteBuffer buffer, long time, java.util.concurrent.TimeUnit unit) throws java.io.IOException
C
- the channel typechannel
- the channel to read frombuffer
- the buffer into which bytes are to be transferredtime
- the amount of time to waitunit
- the unit of time to wait
java.io.IOException
- if an I/O exception occurspublic static <C extends java.nio.channels.ScatteringByteChannel & SuspendableReadChannel> long readBlocking(C channel, java.nio.ByteBuffer[] buffers, int offs, int len) throws java.io.IOException
C
- the channel typechannel
- the channel to read frombuffers
- the buffers into which bytes are to be transferredoffs
- the first buffer to uselen
- the number of buffers to use
java.io.IOException
- if an I/O exception occurspublic static <C extends java.nio.channels.ScatteringByteChannel & SuspendableReadChannel> long readBlocking(C channel, java.nio.ByteBuffer[] buffers, int offs, int len, long time, java.util.concurrent.TimeUnit unit) throws java.io.IOException
C
- the channel typechannel
- the channel to read frombuffers
- the buffers into which bytes are to be transferredoffs
- the first buffer to uselen
- the number of buffers to usetime
- the amount of time to waitunit
- the unit of time to wait
java.io.IOException
- if an I/O exception occurspublic static <C extends ReadableMessageChannel & SuspendableReadChannel> int receiveBlocking(C channel, java.nio.ByteBuffer buffer) throws java.io.IOException
C
- the channel typechannel
- the channel to read frombuffer
- the buffer into which bytes are to be transferred
java.io.IOException
- if an I/O exception occurspublic static <C extends ReadableMessageChannel & SuspendableReadChannel> int receiveBlocking(C channel, java.nio.ByteBuffer buffer, long time, java.util.concurrent.TimeUnit unit) throws java.io.IOException
C
- the channel typechannel
- the channel to read frombuffer
- the buffer into which bytes are to be transferredtime
- the amount of time to waitunit
- the unit of time to wait
java.io.IOException
- if an I/O exception occurspublic static <C extends ReadableMessageChannel & SuspendableReadChannel> long receiveBlocking(C channel, java.nio.ByteBuffer[] buffers, int offs, int len) throws java.io.IOException
C
- the channel typechannel
- the channel to read frombuffers
- the buffers into which bytes are to be transferredoffs
- the first buffer to uselen
- the number of buffers to use
java.io.IOException
- if an I/O exception occurspublic static <C extends ReadableMessageChannel & SuspendableReadChannel> long receiveBlocking(C channel, java.nio.ByteBuffer[] buffers, int offs, int len, long time, java.util.concurrent.TimeUnit unit) throws java.io.IOException
C
- the channel typechannel
- the channel to read frombuffers
- the buffers into which bytes are to be transferredoffs
- the first buffer to uselen
- the number of buffers to usetime
- the amount of time to waitunit
- the unit of time to wait
java.io.IOException
- if an I/O exception occurs
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |