org.springframework.extensions.surf.persister
Class AbstractCachedObjectPersister

java.lang.Object
  extended by org.springframework.extensions.surf.persister.AbstractObjectPersister
      extended by org.springframework.extensions.surf.persister.AbstractCachedObjectPersister
All Implemented Interfaces:
org.springframework.beans.factory.BeanNameAware, ModelObjectPersister
Direct Known Subclasses:
ReadOnlyStoreObjectPersister

public abstract class AbstractCachedObjectPersister
extends AbstractObjectPersister

Extends the abstract implementation by offering a caching layer. The caching layer is tiered intentionally to allow for composite keys formed from a combination of store ids and object type ids. The objective is to allow persisters to interrogate the cache and ask for objects of a specified type in the current store context. The store context is allowed to shift in the Web Framework runtime and the cache must be sensitive to that.

Author:
muzquiano, kevinr

Field Summary
protected  long cacheDelay
           
protected  Map<String,BasicCache<ModelObject>> caches
           
protected static String GLOBAL_STORE_ID
           
protected  boolean useCache
           
 
Fields inherited from class org.springframework.extensions.surf.persister.AbstractObjectPersister
MODELOBJECT_CLASSES
 
Constructor Summary
AbstractCachedObjectPersister()
           
 
Method Summary
protected  ModelObject cacheGet(ModelPersistenceContext context, String objectTypeId, String objectId)
          Returns an object from the cache
protected  void cachePut(ModelPersistenceContext context, ModelObject obj)
          Places an object into this persister's cache.
protected  void cacheRemove(ModelPersistenceContext context, String objectTypeId, String objectId)
          Removes an object from the cache
protected  BasicCache<ModelObject> createCache()
          Creates the cache.
protected  BasicCache<ModelObject> getCache(ModelPersistenceContext context, String objectTypeId)
          Gets the cache for a particular model persistence context
 void invalidateCache()
           
 void setCache(boolean useCache)
           
 void setCacheCheckDelay(int cacheCheckDelay)
           
 
Methods inherited from class org.springframework.extensions.surf.persister.AbstractObjectPersister
disable, getId, getServiceRegistry, getWebFrameworkConfiguration, getWebFrameworkManager, hasObject, init, isEnabled, removeObject, reset, setBeanName, setServiceRegistry
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.extensions.surf.ModelObjectPersister
getAllObjects, getAllObjectsByFilter, getObject, getTimestamp, hasObject, newObject, removeObject, saveObject
 

Field Detail

GLOBAL_STORE_ID

protected static String GLOBAL_STORE_ID

caches

protected Map<String,BasicCache<ModelObject>> caches

useCache

protected boolean useCache

cacheDelay

protected long cacheDelay
Constructor Detail

AbstractCachedObjectPersister

public AbstractCachedObjectPersister()
Method Detail

getCache

protected BasicCache<ModelObject> getCache(ModelPersistenceContext context,
                                           String objectTypeId)
Gets the cache for a particular model persistence context

Parameters:
context -
objectTypeId -
Returns:
the cache

createCache

protected BasicCache<ModelObject> createCache()
Creates the cache.

Returns:
the basic cache< model object>

cacheGet

protected ModelObject cacheGet(ModelPersistenceContext context,
                               String objectTypeId,
                               String objectId)
Returns an object from the cache

Parameters:
context - the context
objectTypeId -
objectId -
Returns:
the model object

cachePut

protected void cachePut(ModelPersistenceContext context,
                        ModelObject obj)
Places an object into this persister's cache.

Parameters:
context - the context
obj - the obj

cacheRemove

protected void cacheRemove(ModelPersistenceContext context,
                           String objectTypeId,
                           String objectId)
Removes an object from the cache

Parameters:
context - the context
objectTypeId -
objectId -

setCache

public void setCache(boolean useCache)

setCacheCheckDelay

public void setCacheCheckDelay(int cacheCheckDelay)

invalidateCache

public void invalidateCache()


Copyright © 2009 SpringSource, Inc. All Rights Reserved.