org.apache.cxf.io
Class CachedOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by org.apache.cxf.io.CachedOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable
Direct Known Subclasses:
CacheAndWriteOutputStream, JBIConduitOutputStream, JBIDestinationOutputStream, WriteOnCloseOutputStream

public class CachedOutputStream
extends java.io.OutputStream


Field Summary
protected  java.io.OutputStream currentStream
           
protected  boolean outputLocked
           
 
Constructor Summary
CachedOutputStream()
           
CachedOutputStream(long threshold)
           
CachedOutputStream(java.io.PipedInputStream stream)
           
 
Method Summary
 void close()
           
static void copyStream(java.io.InputStream in, java.io.OutputStream out, int bufferSize)
           
 void deregisterCallback(CachedOutputStreamCallback cb)
           
protected  void doClose()
          Perform any actions required on stream closure (handle response etc.)
protected  void doFlush()
          Perform any actions required on stream flush (freeze headers, reset output stream ...
 boolean equals(java.lang.Object obj)
           
 void flush()
           
 byte[] getBytes()
           
 java.util.List<CachedOutputStreamCallback> getCallbacks()
           
 java.io.InputStream getInputStream()
           
 java.io.OutputStream getOut()
           
 java.io.File getTempFile()
           
 int hashCode()
           
 void holdTempFile()
           
 void lockOutputStream()
          Locks the output stream to prevent additional writes, but maintains a pointer to it so an InputStream can be obtained
protected  void onWrite()
           
protected  void postClose()
          Perform any actions required after stream closure (close the other related stream etc.)
 void registerCallback(CachedOutputStreamCallback cb)
           
 void releaseTempFileHold()
           
 void resetOut(java.io.OutputStream out, boolean copyOldContent)
          Replace the original stream with the new one, optionally copying the content of the old one into the new one.
 void setOutputDir(java.io.File outputDir)
           
 void setThreshold(long threshold)
           
 int size()
           
 java.lang.String toString()
           
 void write(byte[] b)
           
 void write(byte[] b, int off, int len)
           
 void write(int b)
           
 void writeCacheTo(java.io.OutputStream out)
           
 void writeCacheTo(java.lang.StringBuilder out)
           
 void writeCacheTo(java.lang.StringBuilder out, int limit)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

outputLocked

protected boolean outputLocked

currentStream

protected java.io.OutputStream currentStream
Constructor Detail

CachedOutputStream

public CachedOutputStream(java.io.PipedInputStream stream)
                   throws java.io.IOException
Throws:
java.io.IOException

CachedOutputStream

public CachedOutputStream()

CachedOutputStream

public CachedOutputStream(long threshold)
Method Detail

holdTempFile

public void holdTempFile()

releaseTempFileHold

public void releaseTempFileHold()

registerCallback

public void registerCallback(CachedOutputStreamCallback cb)

deregisterCallback

public void deregisterCallback(CachedOutputStreamCallback cb)

getCallbacks

public java.util.List<CachedOutputStreamCallback> getCallbacks()

doFlush

protected void doFlush()
                throws java.io.IOException
Perform any actions required on stream flush (freeze headers, reset output stream ... etc.)

Throws:
java.io.IOException

flush

public void flush()
           throws java.io.IOException
Specified by:
flush in interface java.io.Flushable
Overrides:
flush in class java.io.OutputStream
Throws:
java.io.IOException

doClose

protected void doClose()
                throws java.io.IOException
Perform any actions required on stream closure (handle response etc.)

Throws:
java.io.IOException

postClose

protected void postClose()
                  throws java.io.IOException
Perform any actions required after stream closure (close the other related stream etc.)

Throws:
java.io.IOException

lockOutputStream

public void lockOutputStream()
                      throws java.io.IOException
Locks the output stream to prevent additional writes, but maintains a pointer to it so an InputStream can be obtained

Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.OutputStream
Throws:
java.io.IOException

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

resetOut

public void resetOut(java.io.OutputStream out,
                     boolean copyOldContent)
              throws java.io.IOException
Replace the original stream with the new one, optionally copying the content of the old one into the new one. When with Attachment, needs to replace the xml writer stream with the stream used by AttachmentSerializer or copy the cached output stream to the "real" output stream, i.e. onto the wire.

Parameters:
out - the new output stream
copyOldContent - flag indicating if the old content should be copied
Throws:
java.io.IOException

copyStream

public static void copyStream(java.io.InputStream in,
                              java.io.OutputStream out,
                              int bufferSize)
                       throws java.io.IOException
Throws:
java.io.IOException

size

public int size()

getBytes

public byte[] getBytes()
                throws java.io.IOException
Throws:
java.io.IOException

writeCacheTo

public void writeCacheTo(java.io.OutputStream out)
                  throws java.io.IOException
Throws:
java.io.IOException

writeCacheTo

public void writeCacheTo(java.lang.StringBuilder out,
                         int limit)
                  throws java.io.IOException
Throws:
java.io.IOException

writeCacheTo

public void writeCacheTo(java.lang.StringBuilder out)
                  throws java.io.IOException
Throws:
java.io.IOException

getOut

public java.io.OutputStream getOut()
Returns:
the underlying output stream

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

onWrite

protected void onWrite()
                throws java.io.IOException
Throws:
java.io.IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Overrides:
write in class java.io.OutputStream
Throws:
java.io.IOException

write

public void write(byte[] b)
           throws java.io.IOException
Overrides:
write in class java.io.OutputStream
Throws:
java.io.IOException

write

public void write(int b)
           throws java.io.IOException
Specified by:
write in class java.io.OutputStream
Throws:
java.io.IOException

getTempFile

public java.io.File getTempFile()

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Throws:
java.io.IOException

setOutputDir

public void setOutputDir(java.io.File outputDir)
                  throws java.io.IOException
Throws:
java.io.IOException

setThreshold

public void setThreshold(long threshold)


Apache CXF