Package org.apache.axis2.saaj.util
Class SAAJDataSource
java.lang.Object
org.apache.axis2.saaj.util.SAAJDataSource
- All Implemented Interfaces:
jakarta.activation.DataSource
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected BufferedOutputStreamThis is the cached disk stream.protected booleanIf true the source input stream is now closed.protected StringThe content type.protected byte[]Hold the last memory buffer.protected intThe number of bytes written to the above buffer.protected booleanFlag to show if the resources behind this have been deleted.protected FileField diskCacheFilestatic final intField MAX_MEMORY_DISK_CACHEDprotected intField maxCachedprotected LinkedListThe linked list to hold the in memory buffers.static final intField MIN_MEMORY_DISK_CACHEDstatic final intField READ_CHUNK_SZprotected WeakHashMapField readersprotected longThe total size in bytes in this data source. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructor SAAJDataSource.SAAJDataSource(InputStream ss, int maxCached, String contentType) Create a new boundary stream.SAAJDataSource(InputStream ss, int maxCached, String contentType, boolean readall) Create a new boundary stream. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidclose()This method is a low level write.protected voidRoutine to flush data to disk if is in memory.get the filename of the content if it is cached to disk.getName()protected voidwrite(byte[] data) Write bytes to the stream.protected voidwrite(byte[] data, int length) This method is a low level write.protected voidwriteToMemory(byte[] data, int length) This method is a low level write.
-
Field Details
-
contentType
The content type. This defaults toapplication/octet-stream. -
MIN_MEMORY_DISK_CACHED
public static final int MIN_MEMORY_DISK_CACHEDField MIN_MEMORY_DISK_CACHED- See Also:
-
MAX_MEMORY_DISK_CACHED
public static final int MAX_MEMORY_DISK_CACHEDField MAX_MEMORY_DISK_CACHED- See Also:
-
maxCached
protected int maxCachedField maxCached -
diskCacheFile
Field diskCacheFile -
readers
Field readers -
deleted
protected boolean deletedFlag to show if the resources behind this have been deleted. -
READ_CHUNK_SZ
public static final int READ_CHUNK_SZField READ_CHUNK_SZ- See Also:
-
memorybuflist
The linked list to hold the in memory buffers. -
currentMemoryBuf
protected byte[] currentMemoryBufHold the last memory buffer. -
currentMemoryBufSz
protected int currentMemoryBufSzThe number of bytes written to the above buffer. -
totalsz
protected long totalszThe total size in bytes in this data source. -
cachediskstream
This is the cached disk stream. -
closed
protected boolean closedIf true the source input stream is now closed.
-
-
Constructor Details
-
SAAJDataSource
protected SAAJDataSource()Constructor SAAJDataSource. -
SAAJDataSource
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:
IOException
-
SAAJDataSource
public SAAJDataSource(InputStream ss, int maxCached, String contentType, boolean readall) throws 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:
IOException
-
-
Method Details
-
close
This method is a low level write. Close the stream.- Throws:
IOException
-
flushToDisk
Routine to flush data to disk if is in memory.- Throws:
IOExceptionFileNotFoundException
-
write
Write bytes to the stream.- Parameters:
data- all bytes of this array are written to the stream- Throws:
IOException- if there was a problem writing the data
-
write
This method is a low level write. Note it is designed to in the future to allow streaming to both memory AND to disk simultaneously.- Parameters:
data-length-- Throws:
IOException
-
writeToMemory
This method is a low level write. Writes only to memory- Parameters:
data-length-- Throws:
IOException
-
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
-
getInputStream
- Specified by:
getInputStreamin interfacejakarta.activation.DataSource- Throws:
IOException
-
getOutputStream
- Specified by:
getOutputStreamin interfacejakarta.activation.DataSource- Throws:
IOException
-
getContentType
- Specified by:
getContentTypein interfacejakarta.activation.DataSource
-
getName
- Specified by:
getNamein interfacejakarta.activation.DataSource
-