public abstract class Cache
extends java.lang.Object
Properties props = new Properties();
props.put( "report", "report1.rpt" );
props.put( "prompt0", "abc" );
Cache cache = Cache.getCache();
ReportCacheKey key = cache.getKey(props);
cache.getPageAndWait( key, 12, 5 * 60 * 1000 );
Modifier and Type | Field and Description |
---|---|
static int |
TYPE_DATABASE
Use a database as cache medium.
|
static int |
TYPE_HARDDISK
Use harddisk as cache medium.
|
static int |
TYPE_MEMORY
Use memory as cache medium (default cache type).
|
Modifier | Constructor and Description |
---|---|
protected |
Cache()
package Constructor
|
Modifier and Type | Method and Description |
---|---|
abstract void |
addEngine(Engine engine,
ReportCacheKey key)
Save a rendered Engine in the cache.
|
abstract void |
clear()
Removes all of the entries from this cache.
|
ReportCacheKey |
createKey(java.util.Properties props)
This method is calling the method getKey() of the current EngineFactory only.
|
ReportCacheKey |
createKey(java.util.Properties props,
PropertiesChecker checker,
java.lang.Object req)
This method is calling the method getKey() of the current EngineFactory only.
|
ReportCacheKey |
createKey(java.util.Properties props,
PropertiesChecker checker,
EngineFactory factory,
java.lang.Object req)
This method calls the method
EngineFactory.getKey(Properties) . |
abstract void |
delete(java.lang.String report)
Delete all reports with the name from the cache.
|
abstract void |
delete(ReportCacheKey key)
Removes one report from the cache.
|
abstract boolean |
exists(ReportCacheKey key)
Verify if a ReportCacheKey exists in the cache.
|
static Cache |
getCache()
Returns the singleton Cache instance.
|
abstract ReportGenerator |
getEngine(ReportCacheKey key)
Returns the engine for the specified key in the specified cache if active rendering.
|
static EngineFactory |
getEngineFactory()
Get the current EngineFactory.
|
java.lang.Throwable |
getFailureCause(ReportCacheKey key)
Returns the cause for the failure of the report.
|
ReportCacheKey |
getKey(java.util.Properties props)
Create a ReportCacheKey and start rendering if report does not exist in the Cache.
|
ReportCacheKey |
getKey(java.util.Properties props,
PropertiesChecker checker,
java.lang.Object req)
Create a ReportCacheKey and start rendering if report does not exist in the Cache.
|
abstract ReportCacheKey |
getKey(java.util.Properties props,
PropertiesChecker checker,
EngineFactory factory,
java.lang.Object req)
Create a ReportCacheKey and start rendering if report does not exist in the Cache.
|
abstract int |
getMemoryUsage(ReportCacheKey key)
Get the size a report uses in memory.
|
abstract int |
getMemoryUsage()
Get the amount of bytes used for cached reports in memory.
|
byte[] |
getPageAndWait(ReportCacheKey key,
int page)
The method returns the binary data of pages of a report.
|
abstract byte[] |
getPageAndWait(ReportCacheKey key,
int page,
int timeout)
The method returns the binary data of pages of a report.
|
int |
getPageCountAndWait(ReportCacheKey key)
Returns the total count of pages and blocks until the rendering is finished.
|
abstract int |
getPageCountAndWait(ReportCacheKey key,
int timeout)
Returns the total count of pages and blocks until the rendering is finished.
|
static PropertiesChecker |
getPropertiesChecker()
Get the current PropertiesChecker.
|
abstract ReportCacheKey[] |
getReports()
Returns all reports that are currently listed in the Cache.
|
abstract long |
getSwapSize(ReportCacheKey key)
Get the memory size a report uses on an external cache media.
|
abstract long |
getSwapSize()
Get the total amount of bytes used on an external cache media.
|
int |
getTotalPageSizeAndWait(ReportCacheKey key)
Returns the total size of all pages in
bytes and blocks
until the rendering is finished. |
abstract int |
getTotalPageSizeAndWait(ReportCacheKey key,
int timeout)
Returns the total size of all pages in
bytes and blocks
until the rendering is finished. |
abstract int |
getType()
Returns the defined Cache type.
|
abstract boolean |
isFailedReport(ReportCacheKey key)
Returns whether the report was rendered without errors.
|
abstract boolean |
isFinishWrittenToStore(ReportCacheKey key)
Deprecated.
As of i-net Clear Reports 16.1
|
abstract boolean |
isFinished(ReportCacheKey key)
Checks whether the rendering process is finished.
|
abstract boolean |
isPageLimitExceeded(ReportCacheKey key)
Check if the rendering of the report ran into a page limit.
|
abstract void |
lock(ReportCacheKey key)
Lock the data in the cache and prevent it from modification.
|
abstract void |
resetCacheTimeout(ReportCacheKey key)
Causes the timeout for the entry behind this key to be manually restarted.
|
static void |
setEngineFactory(EngineFactory engineFactory)
You can override the default EngineFactory.
|
abstract void |
unlock(ReportCacheKey key)
Unlock the data in the cache.
|
public static final int TYPE_MEMORY
public static final int TYPE_DATABASE
public static final int TYPE_HARDDISK
public static Cache getCache()
public static void setEngineFactory(EngineFactory engineFactory)
engineFactory
- the EngineFactory to set.java.lang.IllegalArgumentException
- If the supplied EngineFactory is null.EngineFactory
,
getEngineFactory()
public static EngineFactory getEngineFactory()
EngineFactory
,
setEngineFactory(com.inet.report.cache.EngineFactory)
public static PropertiesChecker getPropertiesChecker()
PropertiesChecker
public ReportCacheKey getKey(java.util.Properties props) throws ReportException
props
- The default Engine Factory need the parameter "report"ReportException
- e.g. if the reportfile does not existsetEngineFactory(EngineFactory)
,
EngineFactory
,
ReportCacheKey
,
Engine
public ReportCacheKey getKey(java.util.Properties props, PropertiesChecker checker, java.lang.Object req) throws ReportException
props
- The default Engine Factory needs the parameter "report"checker
- an implementation of PropertiesChecker for validate the Properties. Can be null.req
- The HTTP servlet request, either null or HttpServletRequestReportException
- e.g. if the reportfile does not existsetEngineFactory(EngineFactory)
,
EngineFactory
,
ReportCacheKey
,
PropertiesChecker
public abstract ReportCacheKey getKey(java.util.Properties props, PropertiesChecker checker, EngineFactory factory, java.lang.Object req) throws ReportException
EngineFactory
instance to be used instead of the system-wide
instance set in setEngineFactory(EngineFactory)
.props
- The default Engine Factory needs the parameter "report"checker
- an implementation of PropertiesChecker for validate the Properties. Can be null.factory
- EngineFactory
instance to use instead of the system-wide one set in setEngineFactory(EngineFactory)
.req
- The HTTP servlet request, either null or HttpServletRequestReportException
- e.g. if the reportfile does not existsetEngineFactory(EngineFactory)
,
EngineFactory
,
ReportCacheKey
,
PropertiesChecker
public final byte[] getPageAndWait(ReportCacheKey key, int page) throws PageOutOfRangeException, KeyNotFoundException, ReportException
getPageCountAndWait(ReportCacheKey, int)
Exception
Object.
The method Cache.isFailedReport(ReportCacheKey)
will give the information whether report execution failedkey
- the unique key to find the report in the Cachepage
- the page number of the page, from which the binary data are returned. The first page has page number 1.Exception
Object.PageOutOfRangeException
- If the page is out of range after the report is finish rendered.KeyNotFoundException
- If the key does not exist in the cache.
This can occur if the key has received its timeout and was removed from the cache.
You can change the cache timeout in the Cache Config Dialog.ReportException
- e.g. if using DBCache and something went wrong with database connectiongetKey(Properties)
,
getKey(Properties, PropertiesChecker, Object)
,
getPageAndWait(ReportCacheKey, int, int)
,
isFailedReport(ReportCacheKey)
public abstract byte[] getPageAndWait(ReportCacheKey key, int page, int timeout) throws PageOutOfRangeException, KeyNotFoundException, ReportException
getPageCountAndWait(ReportCacheKey, int)
Exception
Object.
The method Cache.isFailedReport(ReportCacheKey)
will give the information whether report execution failedkey
- the unique key to find the report in the Cachepage
- the page number of the page, from which the binary data are returned. The first page has page number 1.timeout
- the maximum time that is wait in milli seconds, 0 means unlimited wait.Exception
Object.PageOutOfRangeException
- If the page is out of range after the report is finish rendered.KeyNotFoundException
- If the key does not exist in the cache.
This can occur if the key has received its timeout and was removed from the cache.
You can change the cache timeout in the Cache Config Dialog.ReportException
- e.g. if using DBCache and something went wrong with database connectiongetKey(Properties)
,
getKey(Properties, PropertiesChecker, Object)
,
isFailedReport(ReportCacheKey)
public final int getPageCountAndWait(ReportCacheKey key) throws KeyNotFoundException, ReportException
key
- the key of the reportKeyNotFoundException
- If the key does not exist in the cache.
This can occur if the key has received its timeout and was removed from the cache.
You can change the cache timeout in the Cache Config Dialog.ReportException
- e.g. if using DBCache and something went wrong with database connectiongetPageAndWait(ReportCacheKey, int, int)
public abstract int getPageCountAndWait(ReportCacheKey key, int timeout) throws KeyNotFoundException, ReportException
key
- the key of the reporttimeout
- the maximum time that is wait in milli seconds, 0 means unlimited wait.KeyNotFoundException
- If the key does not exist in the cache.
This can occur if the key has received its timeout and was removed from the cache.
You can change the cache timeout in the Cache Config Dialog.ReportException
- e.g. if using DBCache and something went wrong with database connectiongetPageAndWait(ReportCacheKey, int, int)
public final int getTotalPageSizeAndWait(ReportCacheKey key) throws KeyNotFoundException, ReportException
bytes
and blocks
until the rendering is finished.key
- the key of the reportKeyNotFoundException
- If the key does not exist in the cache.
This can occur if the key has received its timeout and was removed from the cache.
You can change the cache timeout in the Cache Config Dialog.ReportException
- e.g. if using DBCache and something went wrong with database connectiongetPageAndWait(ReportCacheKey, int, int)
,
getPageCountAndWait(ReportCacheKey, int)
public abstract int getTotalPageSizeAndWait(ReportCacheKey key, int timeout) throws KeyNotFoundException, ReportException
bytes
and blocks
until the rendering is finished.key
- the key of the reporttimeout
- the maximum time that is wait in milli seconds, 0 means unlimited wait.KeyNotFoundException
- If the key does not exist in the cache.
This can occur if the key has received its timeout and was removed from the cache.
You can change the cache timeout in the Cache Config Dialog.ReportException
- e.g. if using DBCache and something went wrong with database connectiongetPageAndWait(ReportCacheKey, int, int)
,
getPageCountAndWait(ReportCacheKey,int)
public abstract boolean isPageLimitExceeded(ReportCacheKey key) throws KeyNotFoundException, ReportException
key
- the key of the reportKeyNotFoundException
- If the key does not exist in the cache. This can occur if the key has received its timeout and was
removed from the cache. You can change the cache timeout in the Cache Config Dialog.ReportException
- e.g. if using DBCache and something went wrong with database connectionpublic abstract void lock(ReportCacheKey key) throws KeyNotFoundException, ReportException
key
- the key of the reportKeyNotFoundException
- If the key does not exist in the cache.
This can occur if the key has received its timeout and was removed from the cache.
You can change the cache timeout in the Cache Config Dialog.ReportException
- e.g. if using DBCache and something went wrong with database connectionunlock(ReportCacheKey)
public abstract void unlock(ReportCacheKey key) throws KeyNotFoundException, ReportException
key
- the key of the reportKeyNotFoundException
- If the key does not exist in the cache.
This can occur if the key has received its timeout and was removed from the cache.
You can change the cache timeout in the Cache Config Dialog.ReportException
- e.g. if using DBCache and something went wrong with database connectionlock(ReportCacheKey)
,
lock(ReportCacheKey)
public abstract void clear() throws ReportException
ReportException
- - e.g. if using DBCache and something went wrong with database connectionpublic abstract void addEngine(Engine engine, ReportCacheKey key) throws ReportException
Cache cache = Cache.getCache();
ReportCacheKey key = cache.createKey(props);
if(!cache.exists(key)){
Engine engine = new Engine( Engine.NO_EXPORT );
engine.setReportName( props.get( "report" );
engine.execute();
cache.addEngine( engine, key );
}
cache.getPageAndWait( key, 12 );
engine
- the executed enginekey
- the key created for that reportReportException
- e.g. if there already exists a report in the cache for
the key. Possible solution is to call Cache.createKey() with an additional
Property or call Cache.delete() with reportname.public abstract boolean exists(ReportCacheKey key)
key
- the key of the reportgetKey(Properties)
,
getKey(Properties, PropertiesChecker, Object)
public ReportCacheKey createKey(java.util.Properties props) throws ReportException
props
- Properties for the reportReportException
- will be thrown if no value for the key "report" can be found in PropertiesgetKey(Properties, PropertiesChecker, Object)
,
createKey(Properties, PropertiesChecker, Object)
,
EngineFactory
public ReportCacheKey createKey(java.util.Properties props, PropertiesChecker checker, java.lang.Object req) throws ReportException
props
- Properties for the reportchecker
- an implementation of PropertiesChecker for validate the Properties. Can be null.req
- The HTTP servlet request, either null or HttpServletRequestReportException
- If an error occurred while checking the supplied
properties by the PropertiesChecker or while creating the key in the
EngineFactory of the cache.getKey(Properties, PropertiesChecker, Object)
,
EngineFactory
public ReportCacheKey createKey(java.util.Properties props, PropertiesChecker checker, EngineFactory factory, java.lang.Object req) throws ReportException
EngineFactory.getKey(Properties)
. Note it does not start the render job yet.
This method also gives you the opportunity to provide your own EngineFactory
instead of the system-wide one set in
setEngineFactory(EngineFactory)
.props
- Properties for the reportchecker
- an implementation of PropertiesChecker for validate the Properties. Can be null.factory
- EngineFactory
instance to use (can be different than the system-wide one set in setEngineFactory(EngineFactory)
req
- The HTTP servlet request, either null or HttpServletRequestReportException
- If an error occurred while checking the supplied
properties by the PropertiesChecker or while creating the key in the
EngineFactory of the cache.getKey(Properties, PropertiesChecker, Object)
,
EngineFactory
public abstract void delete(java.lang.String report) throws ReportException
report
- name of the reportReportException
- e.g. if using DBCache and something went wrong with
database connectionpublic abstract void delete(ReportCacheKey key) throws ReportException
key
- The ReportCacheKey of the report.ReportException
- e.g. if using DBCache and something went wrong with database connectionlock(ReportCacheKey)
,
unlock(ReportCacheKey)
public abstract boolean isFinished(ReportCacheKey key) throws ReportException
key
- This key is checkedtrue
if report is completely rendered.false
if report is not completely rendered.ReportException
- e.g. if using DBCache and something went wrong with database connectionisFinishWrittenToStore(ReportCacheKey)
,
getPageAndWait(ReportCacheKey, int, int)
,
getPageCountAndWait(ReportCacheKey, int)
,
getTotalPageSizeAndWait(ReportCacheKey, int)
public abstract int getMemoryUsage(ReportCacheKey key)
key
- the report keypublic abstract long getSwapSize(ReportCacheKey key)
key
- the report keypublic abstract long getSwapSize()
public abstract ReportCacheKey[] getReports() throws ReportException
ReportException
- If an error has occurred during cache request@Deprecated public abstract boolean isFinishWrittenToStore(ReportCacheKey key) throws ReportException, KeyNotFoundException
true
if you want to skip your application after writing a report in the cache.key
- The ReportCacheKey for the reporttrue
if the report for that key is completely written into the store or an error occur.KeyNotFoundException
- will be thrown if no report for that key exists in the cache.ReportException
- e.g. if using DBCache and something went wrong with database connectionisFinished(ReportCacheKey)
,
isFailedReport(ReportCacheKey)
public abstract boolean isFailedReport(ReportCacheKey key) throws ReportException
getFailureCause(ReportCacheKey)
.key
- The key belongs to the report.ReportException
- If there is no respective report in the cache.public java.lang.Throwable getFailureCause(ReportCacheKey key) throws ReportException
finished
. If the report execution
failed this will return the cause for the failure. If the report
execution finished without any error this will return null
.key
- The key identifying the report.null
if
the report rendered successfully.ReportException
- If there is no respective report in the cache.public abstract int getType()
cache.type
TYPE_MEMORY
,
TYPE_DATABASE
,
TYPE_HARDDISK
public abstract int getMemoryUsage()
public abstract void resetCacheTimeout(ReportCacheKey key)
If there is no entry associated with the given key, this will not restart creation of the entry.
key
- Key of the entry whose cache timeout is to be reset.@Nullable public abstract ReportGenerator getEngine(ReportCacheKey key)
key
- the keyCopyright © 1999-2020 by i-net software GmbH