com.sibvisions.rad.persist
Class AbstractCachedStorage

java.lang.Object
  extended by com.sibvisions.rad.persist.AbstractStorage
      extended by com.sibvisions.rad.persist.AbstractCachedStorage
All Implemented Interfaces:
ICachedStorage, IStorage, INamedObject
Direct Known Subclasses:
AbstractMemStorage, DBStorage

public abstract class AbstractCachedStorage
extends AbstractStorage
implements ICachedStorage

The AbstractCachedStorage implemtns the caching mechanism of ICachedStorage. It is the abstract base class for storages with standard meta data caching.


Constructor Summary
AbstractCachedStorage()
          Creates a new instance of AbstractCachedStorage.
 
Method Summary
static void clearMetaData()
          Clears the meta data cache.
static void clearMetaData(String pApplicationName)
          Clears the meta data cache for the given application.
static Hashtable<String,MetaData> getMetaData(String pGroup)
          Gets meta data which are cached under a specific name.
 MetaData getMetaData(String pGroup, String pName)
          Returns the meta data for this AbstractStorage from the storage as MetaData and places the MetaData to the cache with a group name and meta data name.
 MetaDataCacheOption getMetaDataCacheOption()
          Gets the metadata cache option for this instance.
 Hashtable<String,MetaData> getMetaDataFromCache(String pGroup)
          Returns all available meta data from the cache for a specific cache group.
protected  MetaData getMetaDataFromCache(String pGroup, String pName)
          Gets meta data from the cache.
static boolean isGlobalMetaDataCacheEnabled()
          Gets whether the global meta data cache is enabled.
protected  boolean isMetaDataCacheEnabled()
          Gets whether the meta data cache should be used.
protected  void putMetaDataToCache(String pGroup, String pName, MetaData pMetaData)
          Puts meta data to the cache.
static boolean removeMetaData(String pGroup)
          Removes all metadata for the given group.
static void setGlobalMetaDataCacheEnabled(boolean pEnabled)
          Sets the global meta data cache en-/disabled.
 void setMetaDataCacheOption(MetaDataCacheOption pOption)
          Sets the metadata cache option for this instance.
 
Methods inherited from class com.sibvisions.rad.persist.AbstractStorage
createBean, createBeanType, createCSV, createCSV, createCSV, createEmptyBean, createPOJO, createPOJO, debug, delete, delete, error, eventAfterDelete, eventAfterInsert, eventAfterUpdate, eventBeforeDelete, eventBeforeInsert, eventBeforeUpdate, eventCalculateRow, executeDelete, executeDeleteAsBean, executeFetch, executeFetchAsBean, executeGetMetaData, executeInsert, executeInsertAsBean, executeRefetchRow, executeRefetchRowAsBean, executeUpdate, executeUpdateAsBean, fetch, fetch, fetch, fetchBean, fetchBean, getAndInitBeanType, getMetaData, getName, info, insert, insert, refetch, refetchRow, setName, setPropertyNameForColumn, update, update, updateBean, writeCSV
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.rad.persist.IStorage
delete, fetch, getEstimatedRowCount, getMetaData, insert, refetchRow, update
 

Constructor Detail

AbstractCachedStorage

public AbstractCachedStorage()
Creates a new instance of AbstractCachedStorage. This constructor checks if the global metadata cache option is en- or disabled.

Method Detail

getMetaData

public MetaData getMetaData(String pGroup,
                            String pName)
                     throws DataSourceException
Returns the meta data for this AbstractStorage from the storage as MetaData and places the MetaData to the cache with a group name and meta data name.

Specified by:
getMetaData in interface ICachedStorage
Parameters:
pGroup - the cache group name
pName - the name for the meta data in the cache group
Returns:
the meta data for this AbstractStorage from the storage as MetaData.
Throws:
DataSourceException - if an Exception occur during getting the meta data from the storage

getMetaDataFromCache

public Hashtable<String,MetaData> getMetaDataFromCache(String pGroup)
Returns all available meta data from the cache for a specific cache group.

Specified by:
getMetaDataFromCache in interface ICachedStorage
Parameters:
pGroup - the cache group name
Returns:
a Hashtable with the name of the meta data in the cache group and the meta data as value

putMetaDataToCache

protected void putMetaDataToCache(String pGroup,
                                  String pName,
                                  MetaData pMetaData)
Puts meta data to the cache.

Parameters:
pGroup - the group name e.g. the life-cycle name
pName - the name in the group
pMetaData - the meta data to cache

getMetaDataFromCache

protected MetaData getMetaDataFromCache(String pGroup,
                                        String pName)
Gets meta data from the cache.

Parameters:
pGroup - the group name e.g. the life-cycle name
pName - the name in the group
Returns:
the cached meta data or null if meta data are not cached

getMetaData

public static Hashtable<String,MetaData> getMetaData(String pGroup)
Gets meta data which are cached under a specific name.

Parameters:
pGroup - the cache name
Returns:
the meta data or null if there are no meta data with the name

removeMetaData

public static boolean removeMetaData(String pGroup)
Removes all metadata for the given group.

Parameters:
pGroup - the group name
Returns:
true if metadata were removed, false otherwise

clearMetaData

public static void clearMetaData()
Clears the meta data cache.


clearMetaData

public static void clearMetaData(String pApplicationName)
Clears the meta data cache for the given application.

Parameters:
pApplicationName - the application name

setGlobalMetaDataCacheEnabled

public static void setGlobalMetaDataCacheEnabled(boolean pEnabled)
Sets the global meta data cache en-/disabled. If it is enabled, then the meta data won't be updated after they are in the cache.

Parameters:
pEnabled - true to enable meta data cache, false otherwise

isGlobalMetaDataCacheEnabled

public static boolean isGlobalMetaDataCacheEnabled()
Gets whether the global meta data cache is enabled.

Returns:
true if meta data cache is enabled, false otherwise

setMetaDataCacheOption

public void setMetaDataCacheOption(MetaDataCacheOption pOption)
Sets the metadata cache option for this instance. If a session cache option is set, the instance cache option overrules the session setting.

Parameters:
pOption - the metadata cache option
See Also:
isMetaDataCacheEnabled()

getMetaDataCacheOption

public MetaDataCacheOption getMetaDataCacheOption()
Gets the metadata cache option for this instance.

Returns:
the metadata cache option
See Also:
setMetaDataCacheOption(MetaDataCacheOption)

isMetaDataCacheEnabled

protected boolean isMetaDataCacheEnabled()
Gets whether the meta data cache should be used.

Returns:
true when the metadata cache should be used. This means that either the instance cache option is MetaDataCacheOption.On, the session cache option is MetaDataCacheOption.On or the cache options are set to MetaDataCacheOption.Default and the global meta data cache is enabled.
The instance cache option overrules the session cache option.


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.