eu.clarin.cmdi.mdservice.action
Class Cache

java.lang.Object
  extended by eu.clarin.cmdi.mdservice.action.Cache

public class Cache
extends java.lang.Object

This is a rudimentary caching mechanism. serializes the inputstream to a file (identifier => filename) and returns the inpustream based on the identifier

Author:
master

Field Summary
private  java.lang.Integer cachecounter
           
private  java.lang.String cachepath
           
static java.lang.String PREFIX
           
private static Cache singleton
           
private static java.lang.Integer start_cache
           
 
Constructor Summary
Cache()
           
 
Method Summary
protected  void finalize()
           
 java.lang.String formPath(java.lang.String id)
           
static Cache getCache()
           
 java.lang.Integer getCounter()
           
 java.io.InputStream getFromCache(java.lang.String id)
           
 java.lang.Integer initCachecounter()
          read counter-integer from file in cache or start that file
 java.lang.String putInCache(java.lang.String id, java.io.InputStream instream)
          here the external key for the data gets cache-internal counter-id assigned which is also returned back can be used (as shorthand instead of the (long) external key) from outside to retrieve the data.
 void updateCachecounter()
           
 void writeCachecounter(java.lang.Integer i)
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PREFIX

public static java.lang.String PREFIX

singleton

private static Cache singleton

cachepath

private java.lang.String cachepath

cachecounter

private java.lang.Integer cachecounter

start_cache

private static final java.lang.Integer start_cache
Constructor Detail

Cache

public Cache()
Method Detail

getCache

public static Cache getCache()

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

putInCache

public java.lang.String putInCache(java.lang.String id,
                                   java.io.InputStream instream)
here the external key for the data gets cache-internal counter-id assigned which is also returned back can be used (as shorthand instead of the (long) external key) from outside to retrieve the data. This is primarily meant to be able to reuse the recordset-data, when reading one record.

Parameters:
id -
instream -
Returns:

getFromCache

public java.io.InputStream getFromCache(java.lang.String id)

formPath

public java.lang.String formPath(java.lang.String id)

getCounter

public java.lang.Integer getCounter()

initCachecounter

public java.lang.Integer initCachecounter()
read counter-integer from file in cache or start that file

Returns:

updateCachecounter

public void updateCachecounter()

writeCachecounter

public void writeCachecounter(java.lang.Integer i)