Class ProcessAwareServerOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- net.officefloor.server.stream.ServerOutputStream
-
- net.officefloor.server.stream.impl.ProcessAwareServerOutputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
public class ProcessAwareServerOutputStream extends ServerOutputStream
ProcessState
aware wrappingServerOutputStream
.- Author:
- Daniel Sagenschneider
-
-
Constructor Summary
Constructors Constructor Description ProcessAwareServerOutputStream(ServerOutputStream unsafeOutputStream, ManagedObjectContext context)
Instantiate.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
flush()
void
write(byte[] b)
void
write(byte[] b, int off, int len)
void
write(int b)
void
write(java.nio.ByteBuffer buffer)
Writes aByteBuffer
.void
write(java.nio.channels.FileChannel file, long position, long count, FileCompleteCallback callback)
Writes part of theFileChannel
contents.void
write(java.nio.channels.FileChannel file, FileCompleteCallback callback)
Writes the entireFileChannel
contents.
-
-
-
Constructor Detail
-
ProcessAwareServerOutputStream
public ProcessAwareServerOutputStream(ServerOutputStream unsafeOutputStream, ManagedObjectContext context)
Instantiate.- Parameters:
unsafeOutputStream
- UnsafeServerOutputStream
.context
-ManagedObjectContext
.
-
-
Method Detail
-
write
public void write(java.nio.ByteBuffer buffer) throws java.io.IOException
Description copied from class:ServerOutputStream
Writes a
ByteBuffer
.This is to enable efficient I/O of writing content (typically cached).
- Specified by:
write
in classServerOutputStream
- Parameters:
buffer
-ByteBuffer
that should never change its content.- Throws:
java.io.IOException
- If fails to write theByteBuffer
.
-
write
public void write(java.nio.channels.FileChannel file, long position, long count, FileCompleteCallback callback) throws java.io.IOException
Description copied from class:ServerOutputStream
Writes part of the
FileChannel
contents.This is to enable efficient I/O (ie DMA) of writing
FileChannel
content.To write the entire
FileChannel
contents, invokewrite(file, 0, -1)
.Note that the underlying implementation will need to support
FileChannel
efficiencies.- Specified by:
write
in classServerOutputStream
- Parameters:
file
-FileChannel
.position
- Position within theFileChannel
to start writing content. Must be non-negative number.count
- Count of bytes to write from theFileChannel
. A negative value (typically-1
) indicates to write the remainingFileChannel
content from position.callback
- OptionalFileCompleteCallback
. May benull
.- Throws:
java.io.IOException
- If fails to write theFileChannel
content.
-
write
public void write(java.nio.channels.FileChannel file, FileCompleteCallback callback) throws java.io.IOException
Description copied from class:ServerOutputStream
Writes the entire
FileChannel
contents.This is a convenience method for
write(file, 0, -1)
.- Specified by:
write
in classServerOutputStream
- Parameters:
file
-FileChannel
.callback
- OptionalFileCompleteCallback
. May benull
.- Throws:
java.io.IOException
- If fails to write theFileChannel
content.
-
write
public void write(int b) throws java.io.IOException
- Specified by:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
write
public void write(byte[] b) throws java.io.IOException
- Overrides:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
write
public void write(byte[] b, int off, int len) throws java.io.IOException
- Overrides:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException
- Specified by:
flush
in interfacejava.io.Flushable
- Overrides:
flush
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
-