org.caleigo.core.service
Class CachedDataService

java.lang.Object
  extended byorg.caleigo.core.AbstractDataService
      extended byorg.caleigo.core.service.CachedDataService
All Implemented Interfaces:
IDataService, IDistributable, ISecureService, IService, java.io.Serializable

public class CachedDataService
extends AbstractDataService

The CachedDataService is a wrapper around any other IDataService implementation to wich it adds transparent cache functionality.

Version:
1.00
Author:
Dennis Zikovic
See Also:
Serialized Form

Nested Class Summary
protected  class CachedDataService.CachedDataTransaction
           
protected  class CachedDataService.CacheEntry
           
 
Nested classes inherited from class org.caleigo.core.AbstractDataService
AbstractDataService.AbstractDataTransaction
 
Field Summary
protected static int DEFAULT_MINIMUM_ENTITY_CACHE_TIME
           
protected static int DEFAULT_MINIMUM_TABLE_CACHE_TIME
           
protected  IDataService mSourceDataService
           
protected static int QUERY_LIST_LIMIT
           
 
Fields inherited from class org.caleigo.core.AbstractDataService
DEFAULT_TIMEOUT
 
Constructor Summary
CachedDataService(IDataService sourceDataService)
          Creates a new instance of CachedDataService
 
Method Summary
protected  void addToQueryList(IEntity entity)
           
 void cacheEntityTable(IEntityDescriptor entityDescriptor)
          This method loads a complete entity table from the wrapped IDataService and stores it as a selection in the cache´s hashtable.
protected  void deleteCachedEntity(IEntity entity)
          Deletes the provided entity from the cache.
protected  ISelection getCachedEntityTable(IEntityDescriptor entityDescriptor)
          Access method that retrieves a selection containing the entire stored table of entities for the provided entity descriptor.
static int getMinimumEntityCacheTime()
           
static int getMinimumTableCacheTime()
           
 IDataService getSourceDataService()
          Access method that returns the IDataService object that cache functionality is added to by this class.
 boolean isQualifierProcessable(Qualifier qualifier, IEntityDescriptor entityDescriptor)
          Help methods that returns true if the provided qualifier can be processed internally by the table cache.
static boolean isTableCachable(IEntityDescriptor entityDescriptor)
          Access methods that returns true if the provided entity descriptor can be cached in the table cache.
 boolean isTableCached(IEntityDescriptor entityDescriptor)
          Access methods that returns true if the provided entity descriptor is currently cached in the table cache.
protected  void loadEntityFromCache(Qualifier qualifier, IEntity targetEntity)
          Loads a qualified entity from the cache.
protected  boolean loadEntityFromQueryList(Qualifier qualifier, IEntity targetEntity)
           
protected  void loadSelectionFromCache(DataQuery dataQuery, ISelection targetSelection)
          Loads a qualified selection from the cache using a data query.
protected  void loadSelectionFromCache(IEntityDescriptor entityDescriptor, Qualifier qualifier, ISelection targetSelection)
          Loads a qualified selection from the cache.
 IDataTransaction newTransaction()
          Returns a new IDataTransaction object that can be used to batch data operations and wrap them in a transaction.
 boolean ping()
          Should return true if the service is online and reponding to calls.
protected  void refreshCachedEntity(IEntity entity)
          Updates the provided entity in the cache.
 void resetCache()
          Completely resets the cache and "unloads" all cached data.
static void setMinimumEntityCacheTime(int minimumEntityCacheTime)
           
static void setMinimumTableCacheTime(int minimumTableCacheTime)
           
 void unloadEntityTable(IEntityDescriptor entityDescriptor)
          Unloads the entity table indentified by the provided entity descriptor.
 
Methods inherited from class org.caleigo.core.AbstractDataService
checkEntityAsDeletable, checkEntityAsStorable, delete, finalizeService, getCustomProxyService, getDataSourceDescriptor, getServiceIdentity, getServiceInterface, getServiceInterfaceClass, getServiceType, getTimeout, hasCustomProxyService, initializeService, isValidating, load, loadSelection, loadSelection, refresh, setEntityData, setTimeout, setValidating, store
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

QUERY_LIST_LIMIT

protected static final int QUERY_LIST_LIMIT
See Also:
Constant Field Values

DEFAULT_MINIMUM_TABLE_CACHE_TIME

protected static final int DEFAULT_MINIMUM_TABLE_CACHE_TIME
See Also:
Constant Field Values

DEFAULT_MINIMUM_ENTITY_CACHE_TIME

protected static final int DEFAULT_MINIMUM_ENTITY_CACHE_TIME
See Also:
Constant Field Values

mSourceDataService

protected final IDataService mSourceDataService
Constructor Detail

CachedDataService

public CachedDataService(IDataService sourceDataService)
Creates a new instance of CachedDataService

Method Detail

setMinimumTableCacheTime

public static void setMinimumTableCacheTime(int minimumTableCacheTime)

getMinimumTableCacheTime

public static int getMinimumTableCacheTime()

setMinimumEntityCacheTime

public static void setMinimumEntityCacheTime(int minimumEntityCacheTime)

getMinimumEntityCacheTime

public static int getMinimumEntityCacheTime()

isTableCachable

public static boolean isTableCachable(IEntityDescriptor entityDescriptor)
Access methods that returns true if the provided entity descriptor can be cached in the table cache.


newTransaction

public IDataTransaction newTransaction()
Description copied from interface: IDataService
Returns a new IDataTransaction object that can be used to batch data operations and wrap them in a transaction.

Specified by:
newTransaction in interface IDataService
Specified by:
newTransaction in class AbstractDataService

ping

public boolean ping()
Should return true if the service is online and reponding to calls.

Specified by:
ping in interface IService
Specified by:
ping in class AbstractDataService

resetCache

public void resetCache()
Completely resets the cache and "unloads" all cached data.


unloadEntityTable

public void unloadEntityTable(IEntityDescriptor entityDescriptor)
Unloads the entity table indentified by the provided entity descriptor.


cacheEntityTable

public void cacheEntityTable(IEntityDescriptor entityDescriptor)
This method loads a complete entity table from the wrapped IDataService and stores it as a selection in the cache´s hashtable. This method can be used to "prepare" the cache.


getSourceDataService

public IDataService getSourceDataService()
Access method that returns the IDataService object that cache functionality is added to by this class.


isTableCached

public boolean isTableCached(IEntityDescriptor entityDescriptor)
Access methods that returns true if the provided entity descriptor is currently cached in the table cache.


getCachedEntityTable

protected ISelection getCachedEntityTable(IEntityDescriptor entityDescriptor)
Access method that retrieves a selection containing the entire stored table of entities for the provided entity descriptor. If the table is not present in the cache it will be loaded and stored there first. If the entity type is not cacheable then null is returned.


isQualifierProcessable

public boolean isQualifierProcessable(Qualifier qualifier,
                                      IEntityDescriptor entityDescriptor)
Help methods that returns true if the provided qualifier can be processed internally by the table cache.


loadEntityFromCache

protected void loadEntityFromCache(Qualifier qualifier,
                                   IEntity targetEntity)
Loads a qualified entity from the cache.


loadSelectionFromCache

protected void loadSelectionFromCache(IEntityDescriptor entityDescriptor,
                                      Qualifier qualifier,
                                      ISelection targetSelection)
Loads a qualified selection from the cache.


loadSelectionFromCache

protected void loadSelectionFromCache(DataQuery dataQuery,
                                      ISelection targetSelection)
Loads a qualified selection from the cache using a data query.


refreshCachedEntity

protected void refreshCachedEntity(IEntity entity)
Updates the provided entity in the cache.


deleteCachedEntity

protected void deleteCachedEntity(IEntity entity)
Deletes the provided entity from the cache.


loadEntityFromQueryList

protected boolean loadEntityFromQueryList(Qualifier qualifier,
                                          IEntity targetEntity)

addToQueryList

protected void addToQueryList(IEntity entity)


Copyright © 2005 Caleigo. All Rights Reserved.