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
ProcessStateaware 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 voidclose()voidflush()voidwrite(byte[] b)voidwrite(byte[] b, int off, int len)voidwrite(int b)voidwrite(java.nio.ByteBuffer buffer)Writes aByteBuffer.voidwrite(java.nio.channels.FileChannel file, long position, long count, FileCompleteCallback callback)Writes part of theFileChannelcontents.voidwrite(java.nio.channels.FileChannel file, FileCompleteCallback callback)Writes the entireFileChannelcontents.
-
-
-
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.IOExceptionDescription copied from class:ServerOutputStreamWrites a
ByteBuffer.This is to enable efficient I/O of writing content (typically cached).
- Specified by:
writein classServerOutputStream- Parameters:
buffer-ByteBufferthat 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.IOExceptionDescription copied from class:ServerOutputStreamWrites part of the
FileChannelcontents.This is to enable efficient I/O (ie DMA) of writing
FileChannelcontent.To write the entire
FileChannelcontents, invokewrite(file, 0, -1).Note that the underlying implementation will need to support
FileChannelefficiencies.- Specified by:
writein classServerOutputStream- Parameters:
file-FileChannel.position- Position within theFileChannelto 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 remainingFileChannelcontent from position.callback- OptionalFileCompleteCallback. May benull.- Throws:
java.io.IOException- If fails to write theFileChannelcontent.
-
write
public void write(java.nio.channels.FileChannel file, FileCompleteCallback callback) throws java.io.IOExceptionDescription copied from class:ServerOutputStreamWrites the entire
FileChannelcontents.This is a convenience method for
write(file, 0, -1).- Specified by:
writein classServerOutputStream- Parameters:
file-FileChannel.callback- OptionalFileCompleteCallback. May benull.- Throws:
java.io.IOException- If fails to write theFileChannelcontent.
-
write
public void write(int b) throws java.io.IOException- Specified by:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
write
public void write(byte[] b) throws java.io.IOException- Overrides:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
write
public void write(byte[] b, int off, int len) throws java.io.IOException- Overrides:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException- Specified by:
flushin interfacejava.io.Flushable- Overrides:
flushin classjava.io.OutputStream- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.OutputStream- Throws:
java.io.IOException
-
-