Package io.undertow.conduits
Class AbstractFixedLengthStreamSinkConduit
- java.lang.Object
-
- org.xnio.conduits.AbstractConduit<D>
-
- org.xnio.conduits.AbstractSinkConduit<D>
-
- org.xnio.conduits.AbstractStreamSinkConduit<org.xnio.conduits.StreamSinkConduit>
-
- io.undertow.conduits.AbstractFixedLengthStreamSinkConduit
-
- All Implemented Interfaces:
org.xnio.conduits.Conduit
,org.xnio.conduits.SinkConduit
,org.xnio.conduits.StreamSinkConduit
- Direct Known Subclasses:
ServerFixedLengthStreamSinkConduit
public abstract class AbstractFixedLengthStreamSinkConduit extends org.xnio.conduits.AbstractStreamSinkConduit<org.xnio.conduits.StreamSinkConduit>
A channel which writes a fixed amount of data. A listener is called once the data has been written.- Author:
- David M. Lloyd
-
-
Constructor Summary
Constructors Constructor Description AbstractFixedLengthStreamSinkConduit(org.xnio.conduits.StreamSinkConduit next, long contentLength, boolean configurable, boolean propagateClose)
Construct a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
awaitWritable()
void
awaitWritable(long time, java.util.concurrent.TimeUnit timeUnit)
protected void
channelFinished()
boolean
flush()
long
getRemaining()
Get the number of remaining bytes in this fixed length channel.boolean
isWriteResumed()
protected void
reset(long contentLength, boolean propagateClose)
void
terminateWrites()
long
transferFrom(java.nio.channels.FileChannel src, long position, long count)
long
transferFrom(org.xnio.channels.StreamSourceChannel source, long count, java.nio.ByteBuffer throughBuffer)
void
truncateWrites()
void
wakeupWrites()
int
write(java.nio.ByteBuffer src)
long
write(java.nio.ByteBuffer[] srcs, int offset, int length)
int
writeFinal(java.nio.ByteBuffer src)
long
writeFinal(java.nio.ByteBuffer[] srcs, int offset, int length)
-
Methods inherited from class org.xnio.conduits.AbstractSinkConduit
getWriteThread, isWriteShutdown, resumeWrites, setWriteReadyHandler, suspendWrites
-
-
-
-
Constructor Detail
-
AbstractFixedLengthStreamSinkConduit
public AbstractFixedLengthStreamSinkConduit(org.xnio.conduits.StreamSinkConduit next, long contentLength, boolean configurable, boolean propagateClose)
Construct a new instance.- Parameters:
next
- the next channelcontentLength
- the content lengthconfigurable
-true
if this instance should pass configuration to the nextpropagateClose
-true
if this instance should pass close to the next
-
-
Method Detail
-
reset
protected void reset(long contentLength, boolean propagateClose)
-
write
public int write(java.nio.ByteBuffer src) throws java.io.IOException
- Specified by:
write
in interfaceorg.xnio.conduits.StreamSinkConduit
- Overrides:
write
in classorg.xnio.conduits.AbstractStreamSinkConduit<org.xnio.conduits.StreamSinkConduit>
- Throws:
java.io.IOException
-
write
public long write(java.nio.ByteBuffer[] srcs, int offset, int length) throws java.io.IOException
- Specified by:
write
in interfaceorg.xnio.conduits.StreamSinkConduit
- Overrides:
write
in classorg.xnio.conduits.AbstractStreamSinkConduit<org.xnio.conduits.StreamSinkConduit>
- Throws:
java.io.IOException
-
writeFinal
public long writeFinal(java.nio.ByteBuffer[] srcs, int offset, int length) throws java.io.IOException
- Specified by:
writeFinal
in interfaceorg.xnio.conduits.StreamSinkConduit
- Overrides:
writeFinal
in classorg.xnio.conduits.AbstractStreamSinkConduit<org.xnio.conduits.StreamSinkConduit>
- Throws:
java.io.IOException
-
writeFinal
public int writeFinal(java.nio.ByteBuffer src) throws java.io.IOException
- Specified by:
writeFinal
in interfaceorg.xnio.conduits.StreamSinkConduit
- Overrides:
writeFinal
in classorg.xnio.conduits.AbstractStreamSinkConduit<org.xnio.conduits.StreamSinkConduit>
- Throws:
java.io.IOException
-
transferFrom
public long transferFrom(java.nio.channels.FileChannel src, long position, long count) throws java.io.IOException
- Specified by:
transferFrom
in interfaceorg.xnio.conduits.StreamSinkConduit
- Overrides:
transferFrom
in classorg.xnio.conduits.AbstractStreamSinkConduit<org.xnio.conduits.StreamSinkConduit>
- Throws:
java.io.IOException
-
transferFrom
public long transferFrom(org.xnio.channels.StreamSourceChannel source, long count, java.nio.ByteBuffer throughBuffer) throws java.io.IOException
- Specified by:
transferFrom
in interfaceorg.xnio.conduits.StreamSinkConduit
- Overrides:
transferFrom
in classorg.xnio.conduits.AbstractStreamSinkConduit<org.xnio.conduits.StreamSinkConduit>
- Throws:
java.io.IOException
-
flush
public boolean flush() throws java.io.IOException
- Specified by:
flush
in interfaceorg.xnio.conduits.SinkConduit
- Overrides:
flush
in classorg.xnio.conduits.AbstractSinkConduit<org.xnio.conduits.StreamSinkConduit>
- Throws:
java.io.IOException
-
isWriteResumed
public boolean isWriteResumed()
- Specified by:
isWriteResumed
in interfaceorg.xnio.conduits.SinkConduit
- Overrides:
isWriteResumed
in classorg.xnio.conduits.AbstractSinkConduit<org.xnio.conduits.StreamSinkConduit>
-
wakeupWrites
public void wakeupWrites()
- Specified by:
wakeupWrites
in interfaceorg.xnio.conduits.SinkConduit
- Overrides:
wakeupWrites
in classorg.xnio.conduits.AbstractSinkConduit<org.xnio.conduits.StreamSinkConduit>
-
terminateWrites
public void terminateWrites() throws java.io.IOException
- Specified by:
terminateWrites
in interfaceorg.xnio.conduits.SinkConduit
- Overrides:
terminateWrites
in classorg.xnio.conduits.AbstractSinkConduit<org.xnio.conduits.StreamSinkConduit>
- Throws:
java.io.IOException
-
truncateWrites
public void truncateWrites() throws java.io.IOException
- Specified by:
truncateWrites
in interfaceorg.xnio.conduits.SinkConduit
- Overrides:
truncateWrites
in classorg.xnio.conduits.AbstractSinkConduit<org.xnio.conduits.StreamSinkConduit>
- Throws:
java.io.IOException
-
awaitWritable
public void awaitWritable() throws java.io.IOException
- Specified by:
awaitWritable
in interfaceorg.xnio.conduits.SinkConduit
- Overrides:
awaitWritable
in classorg.xnio.conduits.AbstractSinkConduit<org.xnio.conduits.StreamSinkConduit>
- Throws:
java.io.IOException
-
awaitWritable
public void awaitWritable(long time, java.util.concurrent.TimeUnit timeUnit) throws java.io.IOException
- Specified by:
awaitWritable
in interfaceorg.xnio.conduits.SinkConduit
- Overrides:
awaitWritable
in classorg.xnio.conduits.AbstractSinkConduit<org.xnio.conduits.StreamSinkConduit>
- Throws:
java.io.IOException
-
getRemaining
public long getRemaining()
Get the number of remaining bytes in this fixed length channel.- Returns:
- the number of remaining bytes
-
channelFinished
protected void channelFinished()
-
-