Package net.sf.jasperreports.engine.fill
Class JRAbstractLRUVirtualizer
java.lang.Object
net.sf.jasperreports.engine.fill.JRAbstractLRUVirtualizer
- All Implemented Interfaces:
JRVirtualizer
- Direct Known Subclasses:
JRFileVirtualizer,JRGzipVirtualizer,StoreFactoryVirtualizer,StoreVirtualizer
Abstract base for LRU and serialization based virtualizer
- Author:
- John Bindel
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classThis class keeps track of how many objects are currently in memory, and when there are too many, it pushes the last touched one to disk.protected static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.apache.commons.collections4.map.ReferenceMap<JRVirtualizationContext, Object> protected WeakReference<JRVirtualizable> protected final JRAbstractLRUVirtualizer.Cacheprotected final VirtualizationSerializer -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedJRAbstractLRUVirtualizer(int maxSize) protectedJRAbstractLRUVirtualizer(VirtualizationSerializer serializer, int maxSize) -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled when the virtual object paged-out data should be freed.voidcontextChanged(JRVirtualizable<?> o, JRVirtualizationContext oldContext) voidLets this virtualizer know that it no longer must track the object.protected abstract voidRemoves the external data associated with a virtualizable object.protected voidprotected final voidprotected voidevict()protected voidfinalize()protected booleanisEvictable(JRVirtualizable value) protected final booleanisPagedOut(String id) protected booleanisPagedOutAndTouch(JRVirtualizable o, String uid) booleanDetermines whether the virtualizer is in read-only mode.protected final booleanprotected JRVirtualizableprotected abstract voidReads a virtualizable object's data from an external storage.protected abstract voidWrites a virtualizable object's data to an external storage.protected final voidreadData(JRVirtualizable o, InputStream in) Reads serialized identity and virtual data for a virtualizable object from a stream.voidLets this virtualizer know that it must track the object.voidCalled when the virtual object must be paged-in.protected voidreset()protected final voidvoidsetReadOnly(boolean ro) Sets the read only mode for the virtualizer.voidLets the virtualizer know that this object is still being used.voidCalled when the virtual object should be paged-out.protected final voidwriteData(JRVirtualizable o, OutputStream out) Writes serialized indentity and virtual data of a virtualizable object to a stream.Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.sf.jasperreports.engine.JRVirtualizer
cleanup
-
Field Details
-
serializer
-
pagedIn
-
pagedOut
-
lastObjectRef
-
lastObjectMap
protected org.apache.commons.collections4.map.ReferenceMap<JRVirtualizationContext,Object> lastObjectMap -
lastObjectSet
-
-
Constructor Details
-
JRAbstractLRUVirtualizer
protected JRAbstractLRUVirtualizer(int maxSize) - Parameters:
maxSize- the maximum size (in JRVirtualizable objects) of the paged in cache.
-
JRAbstractLRUVirtualizer
-
-
Method Details
-
isPagedOut
-
isPagedOutAndTouch
-
lastObject
-
setLastObject
-
contextChanged
- Specified by:
contextChangedin interfaceJRVirtualizer
-
setReadOnly
public void setReadOnly(boolean ro) Sets the read only mode for the virtualizer. When in read-only mode, the virtualizer assumes that virtualizable objects are final and any change in a virtualizable object's data is discarded. When the virtualizer is used for multiple virtualization contexts (in shared mode), calling this method would override the read-only flags from all the contexts and all the objects will be manipulated in read-only mode. UseJRVirtualizationContext.setReadOnly(boolean)to set the read-only mode for one specific context.- Parameters:
ro- the read-only mode to set
-
isReadOnly
public boolean isReadOnly()Determines whether the virtualizer is in read-only mode.- Returns:
- whether the virtualizer is in read-only mode
- See Also:
-
isReadOnly
-
registerObject
Description copied from interface:JRVirtualizerLets this virtualizer know that it must track the object.All virtualizable object must register with their virtualizer upon construction.
- Specified by:
registerObjectin interfaceJRVirtualizer
-
isEvictable
-
evict
protected void evict() -
deregisterObject
Description copied from interface:JRVirtualizerLets this virtualizer know that it no longer must track the object.- Specified by:
deregisterObjectin interfaceJRVirtualizer
-
touch
Description copied from interface:JRVirtualizerLets the virtualizer know that this object is still being used. This should be called to help the virtualizer determine which objects to keep in its cache, and which objects to page-out when it must do some paging-out.The virtualizer gets to decide what type of caching strategy it will use.
- Specified by:
touchin interfaceJRVirtualizer
-
requestData
Description copied from interface:JRVirtualizerCalled when the virtual object must be paged-in.If the object's virtual data is not paged-out, the object will only be
touched.- Specified by:
requestDatain interfaceJRVirtualizer
-
clearData
Description copied from interface:JRVirtualizerCalled when the virtual object paged-out data should be freed.If the object's virtual data is not paged-out, the object will only be
touched.- Specified by:
clearDatain interfaceJRVirtualizer
-
virtualizeData
Description copied from interface:JRVirtualizerCalled when the virtual object should be paged-out.- Specified by:
virtualizeDatain interfaceJRVirtualizer
-
finalize
-
writeData
Writes serialized indentity and virtual data of a virtualizable object to a stream.- Parameters:
o- the serialized objectout- the output stream- Throws:
JRRuntimeException
-
readData
Reads serialized identity and virtual data for a virtualizable object from a stream.- Parameters:
o- the virtualizable objectin- the input stream- Throws:
JRRuntimeException
-
reset
protected void reset() -
disposeAll
protected final void disposeAll() -
pageOut
Writes a virtualizable object's data to an external storage.- Parameters:
o- a virtualizable object- Throws:
IOException
-
pageIn
Reads a virtualizable object's data from an external storage.- Parameters:
o- a virtualizable object- Throws:
IOException
-
dispose
-
dispose
Removes the external data associated with a virtualizable object.- Parameters:
virtualId- the ID of the virtualizable object
-