public class PathStoreObjectPersister extends AbstractStoreObjectPersister
Unlike the read-only implementation, this implementation does not assume the cache as the "master copy" of the data. Rather, the "master copy" is considered to be the store itself. Any put or remote based interactions with persisted content are delegated to the store itself. All get operations utilize the cache for performance benefits, with a configured timeout to reintegrogate last modified dates of actual store content.
Since remote stores are completely based on file-path semantics, this persister must make assumptions on how to map ids to to file-paths. The ID of an object is intrinsically linked to it's path within the store - the object type is not relevant - therefore all caching is based on storage path.
The id to file-path and file-path to id conversion methods are split out so that they can be adjusted in inheriting implementations.
In addition, path prefixes support token replacement for object type ids and object ids.
| Modifier and Type | Field and Description |
|---|---|
protected ReadWriteLock |
cacheLock
Lock object for cache construction
|
protected Set<String> |
noncachableObjectTypes
Set of types that should not be cached by the persister.
|
protected ModelObjectCache |
objectCache
Default object cache
|
protected boolean |
tenantObjectCache
Settings to use a tenant partitioned object cache - based on \@domain in username field
Default is true.
|
XML_EXTpathPrefix, storecacheDelay, cacheMaxSize, caches, GLOBAL_STORE_ID_SUFFIX, useCacheMODELOBJECT_CLASSES| Constructor and Description |
|---|
PathStoreObjectPersister() |
| Modifier and Type | Method and Description |
|---|---|
protected ModelObject |
cacheGet(ModelPersistenceContext context,
String path)
Returns an object from the cache
|
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 |
cachePut(ModelPersistenceContext context,
String path,
ModelObject obj)
Places an object into this persister's cache.
|
protected void |
cacheRemove(ModelPersistenceContext context,
ModelObject obj)
Removes an object from the cache
|
protected void |
cacheRemove(ModelPersistenceContext context,
String objectTypeId,
String objectId)
Removes an object from the cache
|
Map<String,ModelObject> |
getAllObjects(ModelPersistenceContext context,
String objectTypeId)
Returns a map of all of the objects referenced by this persister.
|
protected ContentCache<ModelObject> |
getCache(ModelPersistenceContext context,
String bucket)
Gets the cache for a particular model persistence context
|
ModelObject |
getObject(ModelPersistenceContext context,
String objectTypeId,
String objectId)
Gets an object from persisted storage by id
|
protected ModelObject |
getObjectByPath(ModelPersistenceContext context,
String path)
Retrieves an object from the underlying store by path
This performs an interrogation of the underlying document
to determine its object type and object id.
|
protected String |
getObjectId(org.dom4j.Document doc,
String path)
Determines the object id of a serialized model object
contained in a document.
|
void |
init(ModelPersistenceContext context)
Initializes the persister by preloading the object cache
|
void |
invalidateCache()
Invalidates the cache
|
boolean |
saveObject(ModelPersistenceContext context,
ModelObject modelObject)
Saves an object to persisted storage
|
boolean |
saveObjects(ModelPersistenceContext context,
List<ModelObject> modelObjects)
Saves a collection of objects to persisted storage
|
void |
setNoncachableObjectTypes(Set<String> types)
The Set of model object types that should never be cached by the persister
|
void |
setTenantObjectCache(boolean tenantObjectCache) |
protected boolean |
useCacheForType(String objectTypeId)
Return true if the cache should be used for the given object type ID.
|
createCache, generatePath, getAllObjectsByFilter, getObjectsFromPaths, getPathPrefix, getTimestamp, hasObject, newObject, newObject, removeObjectcreateObject, getObjectTypeId, getPathPrefix, hasReadOnlyStore, isModelObject, loadObjectAndDependants, reset, setPathPrefix, setStore, toStringsetCache, setCacheCheckDelay, setCacheMaxSizedisable, getId, getPersisterService, getServiceRegistry, getWebFrameworkConfiguration, hasObject, isEnabled, removeObject, setBeanName, setPersisterService, setServiceRegistry, setWebFrameworkConfigprotected ModelObjectCache objectCache
protected Set<String> noncachableObjectTypes
protected final ReadWriteLock cacheLock
protected boolean tenantObjectCache
public void init(ModelPersistenceContext context)
ModelObjectPersisterinit in interface ModelObjectPersisterinit in class ReadOnlyStoreObjectPersistercontext - the persistence contextpublic void setNoncachableObjectTypes(Set<String> types)
public void setTenantObjectCache(boolean tenantObjectCache)
tenantObjectCache - true to use a tenant partitioned object cache based on \@domain usernamepublic boolean saveObject(ModelPersistenceContext context, ModelObject modelObject) throws ModelObjectPersisterException
ModelObjectPersistersaveObject in interface ModelObjectPersistersaveObject in class ReadOnlyStoreObjectPersistercontext - ModelPersistenceContextmodelObject - ModelObjectModelObjectPersisterExceptionpublic boolean saveObjects(ModelPersistenceContext context, List<ModelObject> modelObjects) throws ModelObjectPersisterException
ModelObjectPersistersaveObjects in interface ModelObjectPersistersaveObjects in class ReadOnlyStoreObjectPersistercontext - ModelPersistenceContextmodelObjects - ListModelObjectPersisterExceptionpublic ModelObject getObject(ModelPersistenceContext context, String objectTypeId, String objectId) throws ModelObjectPersisterException
ModelObjectPersistergetObject in interface ModelObjectPersistergetObject in class ReadOnlyStoreObjectPersistercontext - ModelPersistenceContextobjectTypeId - StringobjectId - StringModelObjectPersisterExceptionprotected boolean useCacheForType(String objectTypeId)
objectTypeId - to checkprotected void cachePut(ModelPersistenceContext context, String path, ModelObject obj)
context - the contextpath - the pathobj - the objprotected void cachePut(ModelPersistenceContext context, ModelObject obj)
cachePut in class AbstractCachedObjectPersistercontext - the contextobj - the objprotected void cacheRemove(ModelPersistenceContext context, ModelObject obj)
cacheRemove in class AbstractCachedObjectPersistercontext - the contextobj - ModelObjectprotected void cacheRemove(ModelPersistenceContext context, String objectTypeId, String objectId)
cacheRemove in class ReadOnlyStoreObjectPersistercontext - the contextobjectTypeId - StringobjectId - Stringprotected ModelObject cacheGet(ModelPersistenceContext context, String path)
context - the contextpath - the pathprotected ModelObject cacheGet(ModelPersistenceContext context, String objectTypeId, String objectId)
cacheGet in class ReadOnlyStoreObjectPersistercontext - the contextobjectTypeId - StringobjectId - Stringpublic Map<String,ModelObject> getAllObjects(ModelPersistenceContext context, String objectTypeId) throws ModelObjectPersisterException
ModelObjectPersisterIn general, this is a very expensive call and should be avoided. Each object descriptor referenced by the persister is loaded into the model object cache.
getAllObjects in interface ModelObjectPersistergetAllObjects in class AbstractStoreObjectPersistercontext - ModelPersistenceContextobjectTypeId - StringModelObjectPersisterExceptionprotected ModelObject getObjectByPath(ModelPersistenceContext context, String path) throws ModelObjectPersisterException
getObjectByPath in class ReadOnlyStoreObjectPersistercontext - ModelPersistenceContextpath - StringModelObjectPersisterExceptionprotected String getObjectId(org.dom4j.Document doc, String path)
getObjectId in class ReadOnlyStoreObjectPersisterdoc - documentpath - the pathprotected ContentCache<ModelObject> getCache(ModelPersistenceContext context, String bucket)
getCache in class ReadOnlyStoreObjectPersistercontext - ModelPersistenceContextbucket - Cache bucket to pick (not used by PathStore)public void invalidateCache()
CachedPersisterinvalidateCache in interface CachedPersisterinvalidateCache in class AbstractCachedObjectPersisterCachedPersister.invalidateCache()Copyright © 2005–2015 Alfresco Software. All rights reserved.