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 W
channel
Deprecated.The wrapped channel.-
Fields inherited from interface org.xnio.channels.Configurable
EMPTY
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
TranslatingSuspendableChannel(W channel)
Deprecated.Construct a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
awaitReadable()
Deprecated.Block until this channel becomes readable again.void
awaitReadable(long time, java.util.concurrent.TimeUnit timeUnit)
Deprecated.Block until this channel becomes readable again, or until the timeout expires.void
awaitWritable()
Deprecated.Block until this channel becomes writable again.void
awaitWritable(long time, java.util.concurrent.TimeUnit timeUnit)
Deprecated.Block until this channel becomes writable again, or until the timeout expires.protected void
clearReadReady()
Deprecated.Indicate that the channel is no longer definitely immediately readable.protected void
clearReadRequiresWrite()
Deprecated.Indicate that the channel no longer requires writability for reads to proceed.protected void
clearWriteReady()
Deprecated.Indicate that the channel is no longer definitely immediately writable.protected void
clearWriteRequiresRead()
Deprecated.Indicate that the channel no longer requires writability for writes to proceed.void
close()
Deprecated.Close this channel.protected void
closeAction(boolean readShutDown, boolean writeShutDown)
Deprecated.The action to perform when the channel is closed via theclose()
method.boolean
flush()
Deprecated.Perform channel flush.protected boolean
flushAction(boolean shutDown)
Deprecated.The action to perform when the channel is flushed.W
getChannel()
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.XnioIoThread
getIoThread()
Deprecated.Get the I/O thread associated with this channel.<T> T
getOption(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.XnioExecutor
getReadThread()
Deprecated.XnioWorker
getWorker()
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.XnioExecutor
getWriteThread()
Deprecated.protected void
handleClosed()
Deprecated.Called when the underlying channel is closed.protected void
handleReadable()
Deprecated.Called when the underlying channel is readable.protected void
handleWritable()
Deprecated.Called when the underlying channel is writable.boolean
isOpen()
Deprecated.Determine whether this channel is open.boolean
isReadResumed()
Deprecated.Determine whether reads are resumed.protected boolean
isReadShutDown()
Deprecated.Determine whether the channel is shut down for reads.protected boolean
isWriteComplete()
Deprecated.boolean
isWriteResumed()
Deprecated.Determine whether writes are resumed.protected boolean
isWriteShutDown()
Deprecated.Determine whether the channel is shut down for writes.protected boolean
readRequiresWrite()
Deprecated.Indicate if the channel is not readable until the write handler is called.protected void
removeReadRequiresExternal()
Deprecated.Indicate that one external read task was completed.protected void
removeWriteRequiresExternal()
Deprecated.Indicate that one external write task was completed.void
resumeReads()
Deprecated.Resume reads on this channel.void
resumeWrites()
Deprecated.Resume writes on this channel.protected boolean
setClosed()
Deprecated.Set both the channel read and write shut down flags.void
setCloseListener(ChannelListener<? super C> closeListener)
Deprecated.Set the close listener.<T> T
setOption(Option<T> option, T value)
Deprecated.Set an option for this channel.void
setReadListener(ChannelListener<? super C> readListener)
Deprecated.Set the read listener.protected void
setReadReady()
Deprecated.Indicate that the channel is definitely immediately readable, regardless of the underlying channel state.protected void
setReadRequiresWrite()
Deprecated.Indicate that the channel will not be readable until the write handler is called.protected boolean
setReadShutDown()
Deprecated.Set the channel read shut down flag.void
setWriteListener(ChannelListener<? super C> writeListener)
Deprecated.Set the write listener.protected void
setWriteReady()
Deprecated.Indicate that the channel is definitely immediately writable, regardless of the underlying channel state.protected void
setWriteRequiresRead()
Deprecated.Indicate that the channel will not be writable until the read handler is called.protected boolean
setWriteShutDown()
Deprecated.Set the channel write shut down flag.void
shutdownReads()
Deprecated.Perform the read shutdown action if it hasn't been performed already.protected void
shutdownReadsAction(boolean writeComplete)
Deprecated.The action to perform when reads are shut down.void
shutdownWrites()
Deprecated.Perform the write shutdown action if it hasn't been performed already.protected void
shutdownWritesAction()
Deprecated.The action to perform when writes are requested to be shut down.protected void
shutdownWritesComplete(boolean readShutDown)
Deprecated.Notification that the channel has successfully flushed after having shut down writes.boolean
supportsOption(Option<?> option)
Deprecated.Determine whether an option is supported on this channel.void
suspendReads()
Deprecated.Suspend further read notifications on this channel.void
suspendWrites()
Deprecated.Suspend further write notifications on this channel.protected C
thisTyped()
Deprecated.Get this channel, cast to the implemented channel type.java.lang.String
toString()
Deprecated.protected boolean
tryAddReadRequiresExternal()
Deprecated.Indicate that read requires an external task to complete.protected boolean
tryAddWriteRequiresExternal()
Deprecated.Indicate that write requires an external task to complete.void
wakeupReads()
Deprecated.Resume reads
on this channel, and force the read listener to be triggered even if the channel isn't actually readable.void
wakeupWrites()
Deprecated.Resume writes
on this channel, and force the write listener to be triggered even if the channel isn't actually writable.protected boolean
writeRequiresRead()
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:
true
if the flag was set,false
if 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:
true
if the channel has fully closed due to this call,false
otherwise
-
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:
true
if the flag was set,false
if 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:
true
if the channel has fully closed due to this call,false
otherwise
-
setClosed
protected boolean setClosed()
Deprecated.Set both the channel read and write shut down flags.- Returns:
true
if the channel has fully closed (for the first time) due to this call,false
otherwise
-
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:ReadListenerSettable
Set the read listener.- Specified by:
setReadListener
in interfaceReadListenerSettable<C extends SuspendableChannel>
- Parameters:
readListener
- the read listener
-
getReadListener
public ChannelListener<? super C> getReadListener()
Deprecated.Description copied from interface:ReadListenerSettable
Get the read listener.- Specified by:
getReadListener
in interfaceReadListenerSettable<C extends SuspendableChannel>
- Returns:
- the read listener
-
setWriteListener
public void setWriteListener(ChannelListener<? super C> writeListener)
Deprecated.Description copied from interface:WriteListenerSettable
Set the write listener.- Specified by:
setWriteListener
in interfaceWriteListenerSettable<C extends SuspendableChannel>
- Parameters:
writeListener
- the write listener
-
getWriteListener
public ChannelListener<? super C> getWriteListener()
Deprecated.Description copied from interface:WriteListenerSettable
Get the write listener.- Specified by:
getWriteListener
in interfaceWriteListenerSettable<C extends SuspendableChannel>
- Returns:
- the write listener
-
setCloseListener
public void setCloseListener(ChannelListener<? super C> closeListener)
Deprecated.Description copied from interface:CloseListenerSettable
Set the close listener.- Specified by:
setCloseListener
in interfaceCloseListenerSettable<C extends SuspendableChannel>
- Parameters:
closeListener
- the close listener
-
getCloseListener
public ChannelListener<? super C> getCloseListener()
Deprecated.Description copied from interface:CloseListenerSettable
Get the close listener.- Specified by:
getCloseListener
in 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:
getCloseSetter
in interfaceCloseableChannel
- Specified by:
getCloseSetter
in interfaceSuspendableChannel
- Specified by:
getCloseSetter
in interfaceSuspendableReadChannel
- Specified by:
getCloseSetter
in 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:
getReadSetter
in interfaceSuspendableChannel
- Specified by:
getReadSetter
in 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:
getWriteSetter
in interfaceSuspendableChannel
- Specified by:
getWriteSetter
in interfaceSuspendableWriteChannel
- Returns:
- the setter
-
suspendReads
public void suspendReads()
Deprecated.Suspend further read notifications on this channel.- Specified by:
suspendReads
in 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:
resumeReads
in interfaceSuspendableReadChannel
-
isReadResumed
public boolean isReadResumed()
Deprecated.Description copied from interface:SuspendableReadChannel
Determine whether reads are resumed.- Specified by:
isReadResumed
in interfaceSuspendableReadChannel
- Returns:
true
if reads are resumed,false
if reads are suspended
-
wakeupReads
public void wakeupReads()
Deprecated.Resume reads
on this channel, and force the read listener to be triggered even if the channel isn't actually readable.- Specified by:
wakeupReads
in interfaceSuspendableReadChannel
-
suspendWrites
public void suspendWrites()
Deprecated.Suspend further write notifications on this channel.- Specified by:
suspendWrites
in 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:
resumeWrites
in interfaceSuspendableWriteChannel
-
isWriteResumed
public boolean isWriteResumed()
Deprecated.Description copied from interface:SuspendableWriteChannel
Determine whether writes are resumed.- Specified by:
isWriteResumed
in interfaceSuspendableWriteChannel
- Returns:
true
if writes are resumed,false
if writes are suspended
-
wakeupWrites
public void wakeupWrites()
Deprecated.Resume writes
on this channel, and force the write listener to be triggered even if the channel isn't actually writable.- Specified by:
wakeupWrites
in interfaceSuspendableWriteChannel
-
supportsOption
public boolean supportsOption(Option<?> option)
Deprecated.Determine whether an option is supported on this channel.- Specified by:
supportsOption
in interfaceConfigurable
- Parameters:
option
- the option- Returns:
true
if 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:
getOption
in interfaceConfigurable
- Type Parameters:
T
- the type of the option value- Parameters:
option
- the option to get- Returns:
- the value of the option, or
null
if 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:
setOption
in 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.IOException
Deprecated.Perform channel flush. To change the action taken to flush, subclasses should overrideflushAction(boolean)
.- Specified by:
flush
in interfaceSuspendableWriteChannel
- Returns:
true
if the flush completed, orfalse
if the operation would block- Throws:
java.io.IOException
- if an error occurs
-
flushAction
protected boolean flushAction(boolean shutDown) throws java.io.IOException
Deprecated.The action to perform when the channel is flushed. By default, this method delegates to the underlying channel. If theshutDown
parameter 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
-true
if the channel's write side has been shut down,false
otherwise- Returns:
true
if the flush succeeded,false
if it would block- Throws:
java.io.IOException
- if an error occurs
-
shutdownWritesComplete
protected void shutdownWritesComplete(boolean readShutDown) throws java.io.IOException
Deprecated.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
-true
if the read side was already shut down,false
otherwise- Throws:
java.io.IOException
- if an error occurs
-
shutdownReads
public void shutdownReads() throws java.io.IOException
Deprecated.Perform the read shutdown action if it hasn't been performed already.- Specified by:
shutdownReads
in interfaceSuspendableReadChannel
- Throws:
java.io.IOException
- if an I/O error occurs
-
shutdownReadsAction
protected void shutdownReadsAction(boolean writeComplete) throws java.io.IOException
Deprecated.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.IOException
Deprecated.Perform the write shutdown action if it hasn't been performed already.- Specified by:
shutdownWrites
in interfaceSuspendableWriteChannel
- Throws:
java.io.IOException
- if an I/O error occurs
-
shutdownWritesAction
protected void shutdownWritesAction() throws java.io.IOException
Deprecated.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.IOException
Deprecated.Block until this channel becomes readable again. This method may return spuriously before the channel becomes readable.- Specified by:
awaitReadable
in 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.IOException
Deprecated.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:
awaitReadable
in 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:SuspendableReadChannel
Get the read thread for this channel.- Specified by:
getReadThread
in interfaceSuspendableReadChannel
- Returns:
- the thread, or
null
if none is configured or available
-
awaitWritable
public void awaitWritable() throws java.io.IOException
Deprecated.Block until this channel becomes writable again. This method may return spuriously before the channel becomes writable.- Specified by:
awaitWritable
in 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.IOException
Deprecated.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 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:SuspendableWriteChannel
Get the write thread for this channel.- Specified by:
getWriteThread
in interfaceSuspendableWriteChannel
- Returns:
- the thread, or
null
if none is configured or available
-
close
public void close() throws java.io.IOException
Deprecated.Close this channel. This method is idempotent.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.nio.channels.Channel
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in interfaceCloseableChannel
- Specified by:
close
in interfacejava.nio.channels.InterruptibleChannel
- Specified by:
close
in interfaceSuspendableWriteChannel
- Throws:
java.io.IOException
- if an I/O error occurs
-
closeAction
protected void closeAction(boolean readShutDown, boolean writeShutDown) throws java.io.IOException
Deprecated.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 returnfalse
if all directions are shut down, even if there is unflushed write data pending.- Specified by:
isOpen
in interfacejava.nio.channels.Channel
- Specified by:
isOpen
in interfaceSuspendableWriteChannel
- Returns:
true
if the channel is open,false
otherwise
-
getChannel
public W getChannel()
Deprecated.Get the channel which is wrapped by this object.- Specified by:
getChannel
in interfaceWrappedChannel<C extends SuspendableChannel>
- Returns:
- the wrapped channel
-
getWorker
public XnioWorker getWorker()
Deprecated.Get the worker for this channel.- Specified by:
getWorker
in interfaceCloseableChannel
- Returns:
- the worker
-
getIoThread
public XnioIoThread getIoThread()
Deprecated.Get the I/O thread associated with this channel.- Specified by:
getIoThread
in interfaceCloseableChannel
- Returns:
- the I/O thread associated with this channel
-
toString
public java.lang.String toString()
Deprecated.- Overrides:
toString
in classjava.lang.Object
-
-