Module
Package org.xnio.channels
Class TranslatingSuspendableChannel<C extends SuspendableChannel,W extends SuspendableChannel>
- java.lang.Object
-
- org.xnio.channels.TranslatingSuspendableChannel<C,W>
-
- Type Parameters:
C- the channel type implemented by this classW- the channel type being wrapped by this class
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,java.nio.channels.Channel,java.nio.channels.InterruptibleChannel,CloseableChannel,CloseListenerSettable<C>,Configurable,ReadListenerSettable<C>,SuspendableChannel,SuspendableReadChannel,SuspendableWriteChannel,WrappedChannel<W>,WriteListenerSettable<C>
- Direct Known Subclasses:
FramedMessageChannel
@Deprecated public abstract class TranslatingSuspendableChannel<C extends SuspendableChannel,W extends SuspendableChannel> extends java.lang.Object implements SuspendableChannel, WrappedChannel<W>, ReadListenerSettable<C>, WriteListenerSettable<C>, CloseListenerSettable<C>
Deprecated.This class is deprecated; use conduits instead.An abstract wrapped channel.- Author:
- David M. Lloyd
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.xnio.channels.CloseListenerSettable
CloseListenerSettable.Setter<C extends java.nio.channels.Channel>
-
Nested classes/interfaces inherited from interface org.xnio.channels.ReadListenerSettable
ReadListenerSettable.Setter<C extends java.nio.channels.Channel>
-
Nested classes/interfaces inherited from interface org.xnio.channels.WriteListenerSettable
WriteListenerSettable.Setter<C extends java.nio.channels.Channel>
-
-
Field Summary
Fields Modifier and Type Field Description protected WchannelDeprecated.The wrapped channel.-
Fields inherited from interface org.xnio.channels.Configurable
EMPTY
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedTranslatingSuspendableChannel(W channel)Deprecated.Construct a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidawaitReadable()Deprecated.Block until this channel becomes readable again.voidawaitReadable(long time, java.util.concurrent.TimeUnit timeUnit)Deprecated.Block until this channel becomes readable again, or until the timeout expires.voidawaitWritable()Deprecated.Block until this channel becomes writable again.voidawaitWritable(long time, java.util.concurrent.TimeUnit timeUnit)Deprecated.Block until this channel becomes writable again, or until the timeout expires.protected voidclearReadReady()Deprecated.Indicate that the channel is no longer definitely immediately readable.protected voidclearReadRequiresWrite()Deprecated.Indicate that the channel no longer requires writability for reads to proceed.protected voidclearWriteReady()Deprecated.Indicate that the channel is no longer definitely immediately writable.protected voidclearWriteRequiresRead()Deprecated.Indicate that the channel no longer requires writability for writes to proceed.voidclose()Deprecated.Close this channel.protected voidcloseAction(boolean readShutDown, boolean writeShutDown)Deprecated.The action to perform when the channel is closed via theclose()method.booleanflush()Deprecated.Perform channel flush.protected booleanflushAction(boolean shutDown)Deprecated.The action to perform when the channel is flushed.WgetChannel()Deprecated.Get the channel which is wrapped by this object.ChannelListener<? super C>getCloseListener()Deprecated.Get the close listener.ChannelListener.Setter<C>getCloseSetter()Deprecated.Get the setter which can be used to change the close listener for this channel.XnioIoThreadgetIoThread()Deprecated.Get the I/O thread associated with this channel.<T> TgetOption(Option<T> option)Deprecated.Get the value of a channel option.ChannelListener<? super C>getReadListener()Deprecated.Get the read listener.ChannelListener.Setter<C>getReadSetter()Deprecated.Get the setter which can be used to change the read listener for this channel.XnioExecutorgetReadThread()Deprecated.XnioWorkergetWorker()Deprecated.Get the worker for this channel.ChannelListener<? super C>getWriteListener()Deprecated.Get the write listener.ChannelListener.Setter<C>getWriteSetter()Deprecated.Get the setter which can be used to change the write listener for this channel.XnioExecutorgetWriteThread()Deprecated.protected voidhandleClosed()Deprecated.Called when the underlying channel is closed.protected voidhandleReadable()Deprecated.Called when the underlying channel is readable.protected voidhandleWritable()Deprecated.Called when the underlying channel is writable.booleanisOpen()Deprecated.Determine whether this channel is open.booleanisReadResumed()Deprecated.Determine whether reads are resumed.protected booleanisReadShutDown()Deprecated.Determine whether the channel is shut down for reads.protected booleanisWriteComplete()Deprecated.booleanisWriteResumed()Deprecated.Determine whether writes are resumed.protected booleanisWriteShutDown()Deprecated.Determine whether the channel is shut down for writes.protected booleanreadRequiresWrite()Deprecated.Indicate if the channel is not readable until the write handler is called.protected voidremoveReadRequiresExternal()Deprecated.Indicate that one external read task was completed.protected voidremoveWriteRequiresExternal()Deprecated.Indicate that one external write task was completed.voidresumeReads()Deprecated.Resume reads on this channel.voidresumeWrites()Deprecated.Resume writes on this channel.protected booleansetClosed()Deprecated.Set both the channel read and write shut down flags.voidsetCloseListener(ChannelListener<? super C> closeListener)Deprecated.Set the close listener.<T> TsetOption(Option<T> option, T value)Deprecated.Set an option for this channel.voidsetReadListener(ChannelListener<? super C> readListener)Deprecated.Set the read listener.protected voidsetReadReady()Deprecated.Indicate that the channel is definitely immediately readable, regardless of the underlying channel state.protected voidsetReadRequiresWrite()Deprecated.Indicate that the channel will not be readable until the write handler is called.protected booleansetReadShutDown()Deprecated.Set the channel read shut down flag.voidsetWriteListener(ChannelListener<? super C> writeListener)Deprecated.Set the write listener.protected voidsetWriteReady()Deprecated.Indicate that the channel is definitely immediately writable, regardless of the underlying channel state.protected voidsetWriteRequiresRead()Deprecated.Indicate that the channel will not be writable until the read handler is called.protected booleansetWriteShutDown()Deprecated.Set the channel write shut down flag.voidshutdownReads()Deprecated.Perform the read shutdown action if it hasn't been performed already.protected voidshutdownReadsAction(boolean writeComplete)Deprecated.The action to perform when reads are shut down.voidshutdownWrites()Deprecated.Perform the write shutdown action if it hasn't been performed already.protected voidshutdownWritesAction()Deprecated.The action to perform when writes are requested to be shut down.protected voidshutdownWritesComplete(boolean readShutDown)Deprecated.Notification that the channel has successfully flushed after having shut down writes.booleansupportsOption(Option<?> option)Deprecated.Determine whether an option is supported on this channel.voidsuspendReads()Deprecated.Suspend further read notifications on this channel.voidsuspendWrites()Deprecated.Suspend further write notifications on this channel.protected CthisTyped()Deprecated.Get this channel, cast to the implemented channel type.java.lang.StringtoString()Deprecated.protected booleantryAddReadRequiresExternal()Deprecated.Indicate that read requires an external task to complete.protected booleantryAddWriteRequiresExternal()Deprecated.Indicate that write requires an external task to complete.voidwakeupReads()Deprecated.Resume readson this channel, and force the read listener to be triggered even if the channel isn't actually readable.voidwakeupWrites()Deprecated.Resume writeson this channel, and force the write listener to be triggered even if the channel isn't actually writable.protected booleanwriteRequiresRead()Deprecated.Indicate if the channel is not writable until the read handler is called.
-
-
-
Field Detail
-
channel
protected final W extends SuspendableChannel channel
Deprecated.The wrapped channel.
-
-
Constructor Detail
-
TranslatingSuspendableChannel
protected TranslatingSuspendableChannel(W channel)
Deprecated.Construct a new instance.- Parameters:
channel- the channel being wrapped
-
-
Method Detail
-
handleReadable
protected void handleReadable()
Deprecated.Called when the underlying channel is readable.
-
handleWritable
protected void handleWritable()
Deprecated.Called when the underlying channel is writable.
-
handleClosed
protected void handleClosed()
Deprecated.Called when the underlying channel is closed.
-
setReadReady
protected void setReadReady()
Deprecated.Indicate that the channel is definitely immediately readable, regardless of the underlying channel state.
-
clearReadReady
protected void clearReadReady()
Deprecated.Indicate that the channel is no longer definitely immediately readable.
-
setReadRequiresWrite
protected void setReadRequiresWrite()
Deprecated.Indicate that the channel will not be readable until the write handler is called.
-
readRequiresWrite
protected boolean readRequiresWrite()
Deprecated.Indicate if the channel is not readable until the write handler is called.
-
clearReadRequiresWrite
protected void clearReadRequiresWrite()
Deprecated.Indicate that the channel no longer requires writability for reads to proceed.
-
tryAddReadRequiresExternal
protected boolean tryAddReadRequiresExternal()
Deprecated.Indicate that read requires an external task to complete.- Returns:
trueif the flag was set,falseif too many tasks are already outstanding
-
removeReadRequiresExternal
protected void removeReadRequiresExternal()
Deprecated.Indicate that one external read task was completed. This method should be called once for every time thattryAddReadRequiresExternal()returnedtrue.
-
setReadShutDown
protected boolean setReadShutDown()
Deprecated.Set the channel read shut down flag.- Returns:
trueif the channel has fully closed due to this call,falseotherwise
-
setWriteReady
protected void setWriteReady()
Deprecated.Indicate that the channel is definitely immediately writable, regardless of the underlying channel state.
-
clearWriteReady
protected void clearWriteReady()
Deprecated.Indicate that the channel is no longer definitely immediately writable.
-
setWriteRequiresRead
protected void setWriteRequiresRead()
Deprecated.Indicate that the channel will not be writable until the read handler is called.
-
writeRequiresRead
protected boolean writeRequiresRead()
Deprecated.Indicate if the channel is not writable until the read handler is called.
-
clearWriteRequiresRead
protected void clearWriteRequiresRead()
Deprecated.Indicate that the channel no longer requires writability for writes to proceed.
-
tryAddWriteRequiresExternal
protected boolean tryAddWriteRequiresExternal()
Deprecated.Indicate that write requires an external task to complete.- Returns:
trueif the flag was set,falseif too many tasks are already outstanding
-
removeWriteRequiresExternal
protected void removeWriteRequiresExternal()
Deprecated.Indicate that one external write task was completed. This method should be called once for every time thattryAddWriteRequiresExternal()returnedtrue.
-
setWriteShutDown
protected boolean setWriteShutDown()
Deprecated.Set the channel write shut down flag.- Returns:
trueif the channel has fully closed due to this call,falseotherwise
-
setClosed
protected boolean setClosed()
Deprecated.Set both the channel read and write shut down flags.- Returns:
trueif the channel has fully closed (for the first time) due to this call,falseotherwise
-
thisTyped
protected final C thisTyped()
Deprecated.Get this channel, cast to the implemented channel type.- Returns:
this
-
setReadListener
public void setReadListener(ChannelListener<? super C> readListener)
Deprecated.Description copied from interface:ReadListenerSettableSet the read listener.- Specified by:
setReadListenerin interfaceReadListenerSettable<C extends SuspendableChannel>- Parameters:
readListener- the read listener
-
getReadListener
public ChannelListener<? super C> getReadListener()
Deprecated.Description copied from interface:ReadListenerSettableGet the read listener.- Specified by:
getReadListenerin interfaceReadListenerSettable<C extends SuspendableChannel>- Returns:
- the read listener
-
setWriteListener
public void setWriteListener(ChannelListener<? super C> writeListener)
Deprecated.Description copied from interface:WriteListenerSettableSet the write listener.- Specified by:
setWriteListenerin interfaceWriteListenerSettable<C extends SuspendableChannel>- Parameters:
writeListener- the write listener
-
getWriteListener
public ChannelListener<? super C> getWriteListener()
Deprecated.Description copied from interface:WriteListenerSettableGet the write listener.- Specified by:
getWriteListenerin interfaceWriteListenerSettable<C extends SuspendableChannel>- Returns:
- the write listener
-
setCloseListener
public void setCloseListener(ChannelListener<? super C> closeListener)
Deprecated.Description copied from interface:CloseListenerSettableSet the close listener.- Specified by:
setCloseListenerin interfaceCloseListenerSettable<C extends SuspendableChannel>- Parameters:
closeListener- the close listener
-
getCloseListener
public ChannelListener<? super C> getCloseListener()
Deprecated.Description copied from interface:CloseListenerSettableGet the close listener.- Specified by:
getCloseListenerin interfaceCloseListenerSettable<C extends SuspendableChannel>- Returns:
- the close listener
-
getCloseSetter
public ChannelListener.Setter<C> getCloseSetter()
Deprecated.Get the setter which can be used to change the close listener for this channel. If the channel is already closed, then the listener will not be called.- Specified by:
getCloseSetterin interfaceCloseableChannel- Specified by:
getCloseSetterin interfaceSuspendableChannel- Specified by:
getCloseSetterin interfaceSuspendableReadChannel- Specified by:
getCloseSetterin interfaceSuspendableWriteChannel- Returns:
- the setter
-
getReadSetter
public ChannelListener.Setter<C> getReadSetter()
Deprecated.Get the setter which can be used to change the read listener for this channel.- Specified by:
getReadSetterin interfaceSuspendableChannel- Specified by:
getReadSetterin interfaceSuspendableReadChannel- Returns:
- the setter
-
getWriteSetter
public ChannelListener.Setter<C> getWriteSetter()
Deprecated.Get the setter which can be used to change the write listener for this channel.- Specified by:
getWriteSetterin interfaceSuspendableChannel- Specified by:
getWriteSetterin interfaceSuspendableWriteChannel- Returns:
- the setter
-
suspendReads
public void suspendReads()
Deprecated.Suspend further read notifications on this channel.- Specified by:
suspendReadsin interfaceSuspendableReadChannel
-
resumeReads
public void resumeReads()
Deprecated.Resume reads on this channel. The read listener will be called as soon as there is data available to be read.- Specified by:
resumeReadsin interfaceSuspendableReadChannel
-
isReadResumed
public boolean isReadResumed()
Deprecated.Description copied from interface:SuspendableReadChannelDetermine whether reads are resumed.- Specified by:
isReadResumedin interfaceSuspendableReadChannel- Returns:
trueif reads are resumed,falseif reads are suspended
-
wakeupReads
public void wakeupReads()
Deprecated.Resume readson this channel, and force the read listener to be triggered even if the channel isn't actually readable.- Specified by:
wakeupReadsin interfaceSuspendableReadChannel
-
suspendWrites
public void suspendWrites()
Deprecated.Suspend further write notifications on this channel.- Specified by:
suspendWritesin interfaceSuspendableWriteChannel
-
resumeWrites
public void resumeWrites()
Deprecated.Resume writes on this channel. The write listener will be called as soon as the channel becomes writable.- Specified by:
resumeWritesin interfaceSuspendableWriteChannel
-
isWriteResumed
public boolean isWriteResumed()
Deprecated.Description copied from interface:SuspendableWriteChannelDetermine whether writes are resumed.- Specified by:
isWriteResumedin interfaceSuspendableWriteChannel- Returns:
trueif writes are resumed,falseif writes are suspended
-
wakeupWrites
public void wakeupWrites()
Deprecated.Resume writeson this channel, and force the write listener to be triggered even if the channel isn't actually writable.- Specified by:
wakeupWritesin interfaceSuspendableWriteChannel
-
supportsOption
public boolean supportsOption(Option<?> option)
Deprecated.Determine whether an option is supported on this channel.- Specified by:
supportsOptionin interfaceConfigurable- Parameters:
option- the option- Returns:
trueif it is supported
-
getOption
public <T> T getOption(Option<T> option) throws java.io.IOException
Deprecated.Get the value of a channel option.- Specified by:
getOptionin interfaceConfigurable- Type Parameters:
T- the type of the option value- Parameters:
option- the option to get- Returns:
- the value of the option, or
nullif it is not set - Throws:
java.io.IOException- if an I/O error occurred when reading the option
-
setOption
public <T> T setOption(Option<T> option, T value) throws java.lang.IllegalArgumentException, java.io.IOException
Deprecated.Set an option for this channel. Unsupported options are ignored.- Specified by:
setOptionin interfaceConfigurable- Type Parameters:
T- the type of the option value- Parameters:
option- the option to setvalue- the value of the option to set- Returns:
- the previous option value, if any
- Throws:
java.lang.IllegalArgumentException- if the value is not acceptable for this optionjava.io.IOException- if an I/O error occurred when modifying the option
-
flush
public final boolean flush() throws java.io.IOExceptionDeprecated.Perform channel flush. To change the action taken to flush, subclasses should overrideflushAction(boolean).- Specified by:
flushin interfaceSuspendableWriteChannel- Returns:
trueif the flush completed, orfalseif the operation would block- Throws:
java.io.IOException- if an error occurs
-
flushAction
protected boolean flushAction(boolean shutDown) throws java.io.IOExceptionDeprecated.The action to perform when the channel is flushed. By default, this method delegates to the underlying channel. If theshutDownparameter is set, and this method returnstrue, the underlying channel will be shut down and this method will never be called again (future calls toflush()will flush the underlying channel until it returnstrue).- Parameters:
shutDown-trueif the channel's write side has been shut down,falseotherwise- Returns:
trueif the flush succeeded,falseif it would block- Throws:
java.io.IOException- if an error occurs
-
shutdownWritesComplete
protected void shutdownWritesComplete(boolean readShutDown) throws java.io.IOExceptionDeprecated.Notification that the channel has successfully flushed after having shut down writes. The underlying channel may not yet be fully flushed at this time.- Parameters:
readShutDown-trueif the read side was already shut down,falseotherwise- Throws:
java.io.IOException- if an error occurs
-
shutdownReads
public void shutdownReads() throws java.io.IOExceptionDeprecated.Perform the read shutdown action if it hasn't been performed already.- Specified by:
shutdownReadsin interfaceSuspendableReadChannel- Throws:
java.io.IOException- if an I/O error occurs
-
shutdownReadsAction
protected void shutdownReadsAction(boolean writeComplete) throws java.io.IOExceptionDeprecated.The action to perform when reads are shut down. By default, this method delegates to the underlying channel.- Parameters:
writeComplete-- Throws:
java.io.IOException- if an error occurs
-
isReadShutDown
protected boolean isReadShutDown()
Deprecated.Determine whether the channel is shut down for reads.- Returns:
- whether the channel is shut down for reads
-
shutdownWrites
public void shutdownWrites() throws java.io.IOExceptionDeprecated.Perform the write shutdown action if it hasn't been performed already.- Specified by:
shutdownWritesin interfaceSuspendableWriteChannel- Throws:
java.io.IOException- if an I/O error occurs
-
shutdownWritesAction
protected void shutdownWritesAction() throws java.io.IOExceptionDeprecated.The action to perform when writes are requested to be shut down. By default, this method delegates to the underlying channel.- Throws:
java.io.IOException- if an error occurs
-
isWriteShutDown
protected boolean isWriteShutDown()
Deprecated.Determine whether the channel is shut down for writes.- Returns:
- whether the channel is shut down for writes
-
isWriteComplete
protected boolean isWriteComplete()
Deprecated.
-
awaitReadable
public void awaitReadable() throws java.io.IOExceptionDeprecated.Block until this channel becomes readable again. This method may return spuriously before the channel becomes readable.- Specified by:
awaitReadablein interfaceSuspendableReadChannel- Throws:
java.io.InterruptedIOException- if the operation is interrupted; the thread's interrupt flag will be set as welljava.io.IOException- if an I/O error occurs
-
awaitReadable
public void awaitReadable(long time, java.util.concurrent.TimeUnit timeUnit) throws java.io.IOExceptionDeprecated.Block until this channel becomes readable again, or until the timeout expires. This method may return spuriously before the channel becomes readable or the timeout expires.- Specified by:
awaitReadablein interfaceSuspendableReadChannel- Parameters:
time- the time to waittimeUnit- the time unit- Throws:
java.io.InterruptedIOException- if the operation is interrupted; the thread's interrupt flag will be set as welljava.io.IOException- if an I/O error occurs
-
getReadThread
@Deprecated public XnioExecutor getReadThread()
Deprecated.Description copied from interface:SuspendableReadChannelGet the read thread for this channel.- Specified by:
getReadThreadin interfaceSuspendableReadChannel- Returns:
- the thread, or
nullif none is configured or available
-
awaitWritable
public void awaitWritable() throws java.io.IOExceptionDeprecated.Block until this channel becomes writable again. This method may return spuriously before the channel becomes writable.- Specified by:
awaitWritablein interfaceSuspendableWriteChannel- Throws:
java.io.InterruptedIOException- if the operation is interrupted; the thread's interrupt flag will be set as welljava.io.IOException- if an I/O error occurs
-
awaitWritable
public void awaitWritable(long time, java.util.concurrent.TimeUnit timeUnit) throws java.io.IOExceptionDeprecated.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:
awaitWritablein interfaceSuspendableWriteChannel- Parameters:
time- the time to waittimeUnit- the time unit- Throws:
java.io.InterruptedIOException- if the operation is interrupted; the thread's interrupt flag will be set as welljava.io.IOException- if an I/O error occurs
-
getWriteThread
@Deprecated public XnioExecutor getWriteThread()
Deprecated.Description copied from interface:SuspendableWriteChannelGet the write thread for this channel.- Specified by:
getWriteThreadin interfaceSuspendableWriteChannel- Returns:
- the thread, or
nullif none is configured or available
-
close
public void close() throws java.io.IOExceptionDeprecated.Close this channel. This method is idempotent.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.nio.channels.Channel- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein interfaceCloseableChannel- Specified by:
closein interfacejava.nio.channels.InterruptibleChannel- Specified by:
closein interfaceSuspendableWriteChannel- Throws:
java.io.IOException- if an I/O error occurs
-
closeAction
protected void closeAction(boolean readShutDown, boolean writeShutDown) throws java.io.IOExceptionDeprecated.The action to perform when the channel is closed via theclose()method. By default, the underlying channel is closed.- Parameters:
readShutDown- if reads were previously shut downwriteShutDown- if writes were previously shut down- Throws:
java.io.IOException- if an error occurs
-
isOpen
public boolean isOpen()
Deprecated.Determine whether this channel is open. This method will returnfalseif all directions are shut down, even if there is unflushed write data pending.- Specified by:
isOpenin interfacejava.nio.channels.Channel- Specified by:
isOpenin interfaceSuspendableWriteChannel- Returns:
trueif the channel is open,falseotherwise
-
getChannel
public W getChannel()
Deprecated.Get the channel which is wrapped by this object.- Specified by:
getChannelin interfaceWrappedChannel<C extends SuspendableChannel>- Returns:
- the wrapped channel
-
getWorker
public XnioWorker getWorker()
Deprecated.Get the worker for this channel.- Specified by:
getWorkerin interfaceCloseableChannel- Returns:
- the worker
-
getIoThread
public XnioIoThread getIoThread()
Deprecated.Get the I/O thread associated with this channel.- Specified by:
getIoThreadin interfaceCloseableChannel- Returns:
- the I/O thread associated with this channel
-
toString
public java.lang.String toString()
Deprecated.- Overrides:
toStringin classjava.lang.Object
-
-