i-net Clear Reports

Cache Programming

The cache is useful if you want to write your own client interface. If you use the Engine class directly then you need to implement your own cache feature. A cache feature is needed to cache the Engine result between the single page requests.

The package of the cache is com.inet.report.cache.

Typical API call

A typical API call looks like:

// create the properties that descript the report
Properties props = new Properties();
props.put( "report", "report1.rpt" );
props.put( "prompt0", "abc" );
 
// request the page 12
Cache cache = Cache.getCache();
ReportCacheKey key = cache.getKey(props);
cache.getPageAndWait( key, 12 );

The properties object should include all what is needed to describe a report like prompt, format, etc. The minimum requirement is the “report” property. After you created the ReportCacheKey you can recycle the property object.

The following picture shows the internal mechanism. The hard-disk store and the database store are available in i-net Clear Reports Plus, only.

cache.png (23219 Byte)

Using ones own EngineFactory

You can use your own EngineFactory if you to want modify your reports at runtime or design it at runtime with RDC. To activate your own EngineFactory you need to call the static method Cache.setEngineFactory(EngineFactory). The interface EngineFactory include 2 methods.

createEngine( Properties )

This method needs to return a non execute Engine. You can create it with the constructor and set a report file name. Or you can create it with RDC.createEmptyEngine().

createKey( Properties )

This method needs to return a ReportCacheKey. The key has to be unique for given Properties and the resulting Engine. This means an equal Engine has also equal ReportCacheKeys.

Using RDC without EngineFactory (addEngine)

In general it is recommended to use an EngineFactory if you want to use the Cache with RDC. If you cannot do it (for example you have a external serialized Engine) then you can use cache.addEngine( Engine, ReportCacheKey ). The engine should already be executed but has not to be finished.

The problem with this method is that you do not know if an Engine already exists in the Cache or not. You can verify it with cache.exists(ReportCacheKey)

A typical use is:

Cache cache = Cache.getCache();
ReportCacheKey key = cache.createKey(props);
if(!cache.exists(key)){
	Engine engine = new Engine();
	engine.setReportName( props.get( "report" );
	engine.execute();
	cache.addEngine( engine, key );
}

i-net software strives to provide accurate product documentation. Please give us your feedback using the form below.
NOTE: This form is for documentation feedback only. For technical assistance, please send an email to clearreports@inetsoftware.de.

 

© Copyright 1996 - 2012, i-net software; All Rights Reserved.