org.jboss.xnio.nio
Class NioPipeSinkChannelImpl

java.lang.Object
  extended by org.jboss.xnio.nio.NioPipeSinkChannelImpl
All Implemented Interfaces:
java.io.Closeable, java.nio.channels.Channel, java.nio.channels.GatheringByteChannel, java.nio.channels.WritableByteChannel, Configurable, StreamSinkChannel, SuspendableWriteChannel

public final class NioPipeSinkChannelImpl
extends java.lang.Object
implements StreamSinkChannel


Constructor Summary
NioPipeSinkChannelImpl(java.nio.channels.Pipe.SinkChannel channel, IoHandler<? super StreamSinkChannel> handler, NioXnio nioXnio, java.util.concurrent.atomic.AtomicLong bytes, java.util.concurrent.atomic.AtomicLong messages, java.io.Closeable mbeanHandle)
           
 
Method Summary
 void awaitWritable()
          Block until this channel becomes writable again.
 void awaitWritable(long time, java.util.concurrent.TimeUnit timeUnit)
          Block until this channel becomes writable again, or until the timeout expires.
 void close()
           
<T> T
getOption(ChannelOption<T> option)
          Get the value of a channel option.
 java.util.Set<ChannelOption<?>> getOptions()
          Get the options that may be set on this channel.
 boolean isOpen()
           
 void resumeWrites()
          Resume writes on this channel.
<T> Configurable
setOption(ChannelOption<T> option, T value)
          Set an option for this channel.
 void shutdownWrites()
          Indicate that writing is complete for this channel.
 void suspendWrites()
          Suspend further writes on this channel.
 java.lang.String toString()
           
 int write(java.nio.ByteBuffer dst)
           
 long write(java.nio.ByteBuffer[] dsts)
           
 long write(java.nio.ByteBuffer[] dsts, int offset, int length)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NioPipeSinkChannelImpl

public NioPipeSinkChannelImpl(java.nio.channels.Pipe.SinkChannel channel,
                              IoHandler<? super StreamSinkChannel> handler,
                              NioXnio nioXnio,
                              java.util.concurrent.atomic.AtomicLong bytes,
                              java.util.concurrent.atomic.AtomicLong messages,
                              java.io.Closeable mbeanHandle)
                       throws java.io.IOException
Throws:
java.io.IOException
Method Detail

write

public int write(java.nio.ByteBuffer dst)
          throws java.io.IOException
Specified by:
write in interface java.nio.channels.WritableByteChannel
Throws:
java.io.IOException

write

public long write(java.nio.ByteBuffer[] dsts)
           throws java.io.IOException
Specified by:
write in interface java.nio.channels.GatheringByteChannel
Throws:
java.io.IOException

write

public long write(java.nio.ByteBuffer[] dsts,
                  int offset,
                  int length)
           throws java.io.IOException
Specified by:
write in interface java.nio.channels.GatheringByteChannel
Throws:
java.io.IOException

isOpen

public boolean isOpen()
Specified by:
isOpen in interface java.nio.channels.Channel

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Specified by:
close in interface java.nio.channels.Channel
Throws:
java.io.IOException

suspendWrites

public void suspendWrites()
Description copied from interface: SuspendableWriteChannel
Suspend further writes on this channel. The IoWriteHandler.handleWritable(java.nio.channels.Channel) method will not be called until writes are resumed.

Specified by:
suspendWrites in interface SuspendableWriteChannel

resumeWrites

public void resumeWrites()
Description copied from interface: SuspendableWriteChannel
Resume writes on this channel. The IoWriteHandler.handleWritable(java.nio.channels.Channel) method will be called as soon as there is space in the channel's transmit buffer.

Specified by:
resumeWrites in interface SuspendableWriteChannel

shutdownWrites

public void shutdownWrites()
                    throws java.io.IOException
Description copied from interface: SuspendableWriteChannel
Indicate that writing is complete for this channel. Further attempts to write after shutdown will result in an exception.

Specified by:
shutdownWrites in interface SuspendableWriteChannel
Throws:
java.io.IOException - if an I/O error occurs

awaitWritable

public void awaitWritable()
                   throws java.io.IOException
Description copied from interface: SuspendableWriteChannel
Block until this channel becomes writable again. This method may return spuriously before the channel becomes writable.

Specified by:
awaitWritable in interface SuspendableWriteChannel
Throws:
java.io.IOException - if an I/O error occurs

awaitWritable

public void awaitWritable(long time,
                          java.util.concurrent.TimeUnit timeUnit)
                   throws java.io.IOException
Description copied from interface: SuspendableWriteChannel
Block until this channel becomes writable again, or until the timeout expires. This method may return spuriously before the channel becomes writable or the timeout expires.

Specified by:
awaitWritable in interface SuspendableWriteChannel
Parameters:
time - the time to wait
timeUnit - the time unit
Throws:
java.io.IOException - if an I/O error occurs

getOption

public <T> T getOption(ChannelOption<T> option)
            throws UnsupportedOptionException,
                   java.io.IOException
Description copied from interface: Configurable
Get the value of a channel option.

Specified by:
getOption in interface Configurable
Type Parameters:
T - the type of the option value
Parameters:
option - the option to get
Returns:
the value of the option
Throws:
UnsupportedOptionException - if the option is not supported by this channel
java.io.IOException - if an I/O error occurred when reading the option

getOptions

public java.util.Set<ChannelOption<?>> getOptions()
Description copied from interface: Configurable
Get the options that may be set on this channel.

Specified by:
getOptions in interface Configurable
Returns:
an unmodifiable set of options

setOption

public <T> Configurable setOption(ChannelOption<T> option,
                                  T value)
                       throws java.lang.IllegalArgumentException,
                              java.io.IOException
Description copied from interface: Configurable
Set an option for this channel.

Specified by:
setOption in interface Configurable
Type Parameters:
T - the type of the option value
Parameters:
option - the option to set
value - the value of the option to set
Returns:
this channel
Throws:
UnsupportedOptionException - if the option is not supported by this channel
java.lang.IllegalArgumentException - if the value is not acceptable for this option
java.io.IOException - if an I/O error occured when modifying the option

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object