|
XNIO API 2.0.0.GA | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jboss.xnio.channels.Channels
public final class Channels
A utility class containing static methods to support channel usage.
Method Summary | ||
---|---|---|
static MessageHandler.Setter |
createMessageReader(StreamSourceChannel channel,
OptionMap optionMap)
Create and install a stream channel listener which unwraps messages and passes them to a handler. |
|
static WritableMessageChannel |
createMessageWriter(StreamSinkChannel channel,
OptionMap optionMap)
Create a writable message channel which wraps a stream sink channel using a simple length-body protocol. |
|
static SslTcpChannel |
createSslTcpChannel(javax.net.ssl.SSLContext sslContext,
TcpChannel tcpChannel,
java.util.concurrent.Executor executor,
OptionMap optionMap)
Create a SSL/TLS-enabled channel over a TCP channel. |
|
static ChannelListener<TcpChannel> |
createSslTcpChannelListener(javax.net.ssl.SSLContext sslContext,
ChannelListener<? super SslTcpChannel> sslChannelListener,
java.util.concurrent.Executor executor,
OptionMap optionMap)
Create a channel lister which wraps the incoming connection with an SSL connection. |
|
static void |
flushBlocking(SuspendableWriteChannel channel)
Simple utility method to execute a blocking flush on a writable channel. |
|
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 void |
shutdownWritesBlocking(SuspendableWriteChannel channel)
Simple utility method to execute a blocking write shutdown on a writable channel. |
|
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 MessageHandler.Setter createMessageReader(StreamSourceChannel channel, OptionMap optionMap)
createMessageWriter(StreamSinkChannel, org.jboss.xnio.OptionMap)
.
channel
- the stream source channeloptionMap
- the initial options
Options.MAX_INBOUND_MESSAGE_SIZE
public static WritableMessageChannel createMessageWriter(StreamSinkChannel channel, OptionMap optionMap)
createMessageReader(StreamSourceChannel, org.jboss.xnio.OptionMap)
.
channel
- the stream sink channeloptionMap
- the initial options
Options.MAX_OUTBOUND_MESSAGE_SIZE
public static SslTcpChannel createSslTcpChannel(javax.net.ssl.SSLContext sslContext, TcpChannel tcpChannel, java.util.concurrent.Executor executor, OptionMap optionMap) throws java.io.IOException
SSLContext
, and uses the option map to configure
the parameters of the connection (including whether this side is the client or the server). By default, the channel
will run in client mode.
sslContext
- the SSL context to usetcpChannel
- the TCP channel over which the connection is encapsulatedexecutor
- the executor to use for executing asynchronous tasksoptionMap
- the configuration options for the channel
java.io.IOException
Options.SSL_CLIENT_AUTH_MODE
,
Options.SSL_USE_CLIENT_MODE
,
Options.SSL_ENABLE_SESSION_CREATION
,
Options.SSL_ENABLED_CIPHER_SUITES
,
Options.SSL_ENABLED_PROTOCOLS
public static ChannelListener<TcpChannel> createSslTcpChannelListener(javax.net.ssl.SSLContext sslContext, ChannelListener<? super SslTcpChannel> sslChannelListener, java.util.concurrent.Executor executor, OptionMap optionMap)
sslContext
- the SSL context to usesslChannelListener
- the SSL TCP channel listener which should be executed with the SSL connectionexecutor
- the executor to use for executing asynchronous tasksoptionMap
- the configuration options for the channel
Options.SSL_CLIENT_AUTH_MODE
,
Options.SSL_USE_CLIENT_MODE
,
Options.SSL_ENABLE_SESSION_CREATION
,
Options.SSL_ENABLED_CIPHER_SUITES
,
Options.SSL_ENABLED_PROTOCOLS
public static void flushBlocking(SuspendableWriteChannel channel) throws java.io.IOException
channel
- the writable channel
java.io.IOException
- if an I/O exception occurspublic static void shutdownWritesBlocking(SuspendableWriteChannel channel) throws java.io.IOException
channel
- the writable channel
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) throws java.io.IOException
flushBlocking(SuspendableWriteChannel)
method should be called after all writes are complete.
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
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
|
XNIO API 2.0.0.GA | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |