org.jboss.soa.esb.actions.soap.attachment
Class SwapableMemoryDataSource

java.lang.Object
  extended by org.jboss.soa.esb.actions.soap.attachment.SwapableMemoryDataSource
All Implemented Interfaces:
javax.activation.DataSource

public class SwapableMemoryDataSource
extends java.lang.Object
implements javax.activation.DataSource

A datasource which offloads large attachments to disk.

Author:
Thomas.Diesler@jboss.org, Jason T. Greene

Constructor Summary
SwapableMemoryDataSource(java.io.InputStream inputStream, java.lang.String contentType)
          Constructs a SwapableMemoryDataSource from inputStream, and contentType.
SwapableMemoryDataSource(java.io.InputStream inputStream, java.lang.String contentType, int maxMemorySize)
          Constructs a SwapableMemoryDataSource from inputStream, and contentType.
 
Method Summary
 void cleanup()
           
protected  void finalize()
           
 java.lang.String getContentType()
          Returns the content type of this data source.
 java.io.InputStream getInputStream()
          Returns a new input stream on this data source.
 java.lang.String getName()
          This method always returns null.
 java.io.OutputStream getOutputStream()
          This method always returns null.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SwapableMemoryDataSource

public SwapableMemoryDataSource(java.io.InputStream inputStream,
                                java.lang.String contentType)
                         throws java.io.IOException
Constructs a SwapableMemoryDataSource from inputStream, and contentType. The instance then reads from the input stream, and stores it in memory unless the size of the content is larger that 64KB, at whichpoint the stream is stored in a temporary file on disk.

Parameters:
inputStream - the stream to read from
contentType - the content type of this stream
Throws:
java.io.IOException

SwapableMemoryDataSource

public SwapableMemoryDataSource(java.io.InputStream inputStream,
                                java.lang.String contentType,
                                int maxMemorySize)
                         throws java.io.IOException
Constructs a SwapableMemoryDataSource from inputStream, and contentType. The instance then reads from the input stream, and stores it in memory unless the size of the content is larger than maxMemorySize, at whichpoint the stream is stored in a temporary file on disk.

Parameters:
inputStream - the stream to read from
contentType - the content type of this stream
maxMemorySize - the maximum size in bytes that this data source is allowed to allocate for stream storage
Throws:
java.io.IOException
Method Detail

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

cleanup

public void cleanup()

getContentType

public java.lang.String getContentType()
Returns the content type of this data source.

Specified by:
getContentType in interface javax.activation.DataSource
Returns:
the content type

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Returns a new input stream on this data source. Multiple calls are allowed because the data is stored.

Specified by:
getInputStream in interface javax.activation.DataSource
Returns:
a new input stream at the start of the data
Throws:
java.io.IOException

getName

public java.lang.String getName()
This method always returns null.

Specified by:
getName in interface javax.activation.DataSource
Returns:
null

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
This method always returns null.

Specified by:
getOutputStream in interface javax.activation.DataSource
Returns:
null
Throws:
java.io.IOException