com.atlassian.core.spool
Class SmartSpool

java.lang.Object
  extended bycom.atlassian.core.spool.SmartSpool
All Implemented Interfaces:
Spool, ThresholdingSpool

public class SmartSpool
extends java.lang.Object
implements ThresholdingSpool

Spool that delegates to the overThresholdSpool immediately if InputStream::available() is greater than the threshold of the secondary Thresholding spool. This avoids needless spooling of data into memory from InputStreams with large amounts of initial data available


Constructor Summary
SmartSpool()
           
 
Method Summary
 int getThresholdBytes()
           
 void setOverThresholdSpool(Spool overThresholdSpool)
          Set the spooling strategy to use when InputStream::available is greater than the threshold of the configured ThresholdingSpool
 void setThresholdBytes(int bytes)
           
 void setThresholdingSpool(ThresholdingSpool thresholdingSpool)
          Set the spooling strategy that will be used when InputStream::available() is less than or equal to the value of the strategy's threshold.
 java.io.InputStream spool(java.io.InputStream is)
          Return a new InputStream to the data provided.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SmartSpool

public SmartSpool()
Method Detail

setThresholdBytes

public void setThresholdBytes(int bytes)
Specified by:
setThresholdBytes in interface ThresholdingSpool

getThresholdBytes

public int getThresholdBytes()
Specified by:
getThresholdBytes in interface ThresholdingSpool

spool

public java.io.InputStream spool(java.io.InputStream is)
                          throws java.io.IOException
Description copied from interface: Spool
Return a new InputStream to the data provided. Implementations should guarantee that the returned input stream is independent of the stream passed in. For example, the returned InputStream should still be useable once the original InputStream is closed and its associated resources are released.

Specified by:
spool in interface Spool
Parameters:
is - - Source stream to be spooled
Returns:
Spooled stream
Throws:
java.io.IOException

setOverThresholdSpool

public void setOverThresholdSpool(Spool overThresholdSpool)
Set the spooling strategy to use when InputStream::available is greater than the threshold of the configured ThresholdingSpool

Parameters:
overThresholdSpool -

setThresholdingSpool

public void setThresholdingSpool(ThresholdingSpool thresholdingSpool)
Set the spooling strategy that will be used when InputStream::available() is less than or equal to the value of the strategy's threshold.

Parameters:
thresholdingSpool -


Copyright © 2008 Atlassian Pty Ltd. All Rights Reserved.