Package net.sf.jasperreports.engine.fill
Class JRFileVirtualizer
- java.lang.Object
-
- net.sf.jasperreports.engine.fill.JRAbstractLRUVirtualizer
-
- net.sf.jasperreports.engine.fill.JRFileVirtualizer
-
- All Implemented Interfaces:
JRVirtualizer
public class JRFileVirtualizer extends JRAbstractLRUVirtualizer
Virtualizes data to the filesystem. When this object is finalized, it removes the swap files it makes. The virtualized objects have references to this object, so finalization does not occur until this object and the objects using it are only weakly referenced.- Author:
- John Bindel
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.sf.jasperreports.engine.fill.JRAbstractLRUVirtualizer
JRAbstractLRUVirtualizer.Cache, JRAbstractLRUVirtualizer.CacheReference
-
-
Field Summary
Fields Modifier and Type Field Description static String
PROPERTY_TEMP_FILES_SET_DELETE_ON_EXIT
Property used to decide whetherdeleteOnExit
should be requested for temporary files created by the virtualizer.-
Fields inherited from class net.sf.jasperreports.engine.fill.JRAbstractLRUVirtualizer
lastObjectMap, lastObjectRef, lastObjectSet, pagedIn, pagedOut, serializer
-
-
Constructor Summary
Constructors Constructor Description JRFileVirtualizer(int maxSize)
Uses the process's working directory as the location to store files.JRFileVirtualizer(int maxSize, String directory)
JRFileVirtualizer(JasperReportsContext jasperReportsContext, int maxSize, String directory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cleanup()
Called when we are done with the virtualizer and wish to cleanup any resources it has.protected void
dispose(String virtualId)
Removes the external data associated with a virtualizable object.protected void
pageIn(JRVirtualizable o)
Reads a virtualizable object's data from an external storage.protected void
pageOut(JRVirtualizable o)
Writes a virtualizable object's data to an external storage.-
Methods inherited from class net.sf.jasperreports.engine.fill.JRAbstractLRUVirtualizer
clearData, contextChanged, deregisterObject, dispose, disposeAll, evict, finalize, isEvictable, isPagedOut, isPagedOutAndTouch, isReadOnly, isReadOnly, lastObject, readData, registerObject, requestData, reset, setLastObject, setReadOnly, touch, virtualizeData, writeData
-
-
-
-
Field Detail
-
PROPERTY_TEMP_FILES_SET_DELETE_ON_EXIT
public static final String PROPERTY_TEMP_FILES_SET_DELETE_ON_EXIT
Property used to decide whetherdeleteOnExit
should be requested for temporary files created by the virtualizer.Calling
File.deleteOnExit()
will accumulate JVM process memory (see this bug), and this should abviously be avoided in long-running applications.Temporary files will be deleted by explicitly calling
cleanup()
or from the virtualizerfinalize()
method.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JRFileVirtualizer
public JRFileVirtualizer(int maxSize)
Uses the process's working directory as the location to store files.- Parameters:
maxSize
- the maximum size (in JRVirtualizable objects) of the paged in cache.
-
JRFileVirtualizer
public JRFileVirtualizer(int maxSize, String directory)
- Parameters:
maxSize
- the maximum size (in JRVirtualizable objects) of the paged in cache.directory
- the base directory in the filesystem where the paged out data is to be stored
-
JRFileVirtualizer
public JRFileVirtualizer(JasperReportsContext jasperReportsContext, int maxSize, String directory)
- Parameters:
jasperReportsContext
- the JasperReportsContext to use for reading configuration from.maxSize
- the maximum size (in JRVirtualizable objects) of the paged in cache.directory
- the base directory in the filesystem where the paged out data is to be stored
-
-
Method Detail
-
pageOut
protected void pageOut(JRVirtualizable o) throws IOException
Description copied from class:JRAbstractLRUVirtualizer
Writes a virtualizable object's data to an external storage.- Specified by:
pageOut
in classJRAbstractLRUVirtualizer
- Parameters:
o
- a virtualizable object- Throws:
IOException
-
pageIn
protected void pageIn(JRVirtualizable o) throws IOException
Description copied from class:JRAbstractLRUVirtualizer
Reads a virtualizable object's data from an external storage.- Specified by:
pageIn
in classJRAbstractLRUVirtualizer
- Parameters:
o
- a virtualizable object- Throws:
IOException
-
dispose
protected void dispose(String virtualId)
Description copied from class:JRAbstractLRUVirtualizer
Removes the external data associated with a virtualizable object.- Specified by:
dispose
in classJRAbstractLRUVirtualizer
- Parameters:
virtualId
- the ID of the virtualizable object
-
cleanup
public void cleanup()
Called when we are done with the virtualizer and wish to cleanup any resources it has.
-
-