org.apache.axis.attachments
Class ManagedMemoryDataSource

java.lang.Object
  extended byorg.apache.axis.attachments.ManagedMemoryDataSource
All Implemented Interfaces:
javax.activation.DataSource

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

This class allows small attachments to be cached in memory, while large ones are cached out. It implements a Java Activiation Data source interface.


Field Summary
static int MAX_MEMORY_DISK_CACHED
          Field MAX_MEMORY_DISK_CACHED
static int MIN_MEMORY_DISK_CACHED
          Field MIN_MEMORY_DISK_CACHED
static int READ_CHUNK_SZ
          Field READ_CHUNK_SZ
 
Constructor Summary
ManagedMemoryDataSource(java.io.InputStream ss, int maxCached, java.lang.String contentType)
          Create a new boundary stream.
ManagedMemoryDataSource(java.io.InputStream ss, int maxCached, java.lang.String contentType, boolean readall)
          Create a new boundary stream.
 
Method Summary
 boolean delete()
           
 java.lang.String getContentType()
          This method returns the MIME type of the data in the form of a string.
 java.io.File getDiskCacheFile()
          get the filename of the content if it is cached to disk.
 java.io.InputStream getInputStream()
          This method returns an InputStream representing the the data and throws the appropriate exception if it can not do so.
 java.lang.String getName()
          This will flush any memory source to disk and provide the name of the file if desired.
 java.io.OutputStream getOutputStream()
          This method returns an OutputStream where the data can be written and throws the appropriate exception if it can not do so.
static void main(java.lang.String[] arg)
          Method main
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MIN_MEMORY_DISK_CACHED

public static final int MIN_MEMORY_DISK_CACHED
Field MIN_MEMORY_DISK_CACHED

See Also:
Constant Field Values

MAX_MEMORY_DISK_CACHED

public static final int MAX_MEMORY_DISK_CACHED
Field MAX_MEMORY_DISK_CACHED

See Also:
Constant Field Values

READ_CHUNK_SZ

public static final int READ_CHUNK_SZ
Field READ_CHUNK_SZ

See Also:
Constant Field Values
Constructor Detail

ManagedMemoryDataSource

public ManagedMemoryDataSource(java.io.InputStream ss,
                               int maxCached,
                               java.lang.String contentType)
                        throws java.io.IOException
Create a new boundary stream.

Parameters:
ss - is the source input stream that is used to create this data source.
maxCached - This is the max memory that is to be used to cache the data.
contentType - the mime type for this data stream. by buffering you can some effiency in searching.
Throws:
java.io.IOException

ManagedMemoryDataSource

public ManagedMemoryDataSource(java.io.InputStream ss,
                               int maxCached,
                               java.lang.String contentType,
                               boolean readall)
                        throws java.io.IOException
Create a new boundary stream.

Parameters:
ss - is the source input stream that is used to create this data source.
maxCached - This is the max memory that is to be used to cache the data.
contentType - the mime type for this data stream. by buffering you can some effiency in searching.
readall - if true will read in the whole source.
Throws:
java.io.IOException
Method Detail

getContentType

public java.lang.String getContentType()
This method returns the MIME type of the data in the form of a string.

Specified by:
getContentType in interface javax.activation.DataSource
Returns:
The mime type.

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
This method returns an InputStream representing the the data and throws the appropriate exception if it can not do so.

Specified by:
getInputStream in interface javax.activation.DataSource
Returns:
the java.io.InputStream for the data source.
Throws:
java.io.IOException

getName

public java.lang.String getName()
This will flush any memory source to disk and provide the name of the file if desired.

Specified by:
getName in interface javax.activation.DataSource
Returns:
the name of the file of the stream

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
This method returns an OutputStream where the data can be written and throws the appropriate exception if it can not do so. NOT SUPPORTED, not need for axis, data sources are create by constructors.

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

delete

public boolean delete()

main

public static void main(java.lang.String[] arg)
Method main

Parameters:
arg -

getDiskCacheFile

public java.io.File getDiskCacheFile()
get the filename of the content if it is cached to disk.

Returns:
file object pointing to file, or null for memory-stored content


Copyright © 2003 Apache Web Services Project. A ll Rights Reserved.