public class PathStoreObjectPersister extends AbstractStoreObjectPersister implements ClusterMessageAware
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 ClusterService |
clusterService |
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
|
String |
getClusterMessageType()
The unique message cluster Type ID that this bean deals with and posts using.
|
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
|
protected ModelObject |
newObject(ModelPersistenceContext context,
String objectTypeId,
String objectId,
boolean addToCache) |
void |
onClusterMessage(Map<String,Serializable> payload)
Called by a ClusterService implementation when a message for this bean has been sent to
this cluster node and is ready to be processed by the handler based on the bean message
type as supplied in getClusterMessageType().
|
boolean |
removeObject(ModelPersistenceContext context,
String objectTypeId,
String objectId)
Removes an object from persisted storage
|
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 |
setClusterService(ClusterService service)
Called by a ClusterService implementation to set a ClusterService for this bean to use.
|
void |
setNoncachableObjectTypes(Set<String> types)
The Set of model object types that should never be cached by the persister
|
void |
setTenantObjectCache(boolean tenantObjectCache) |
protected void |
updateClusterCachePath(String path)
Add a cluster message for an invalid cache path for a model object in the cache.
|
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, newObjectcreateObject, 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
protected ClusterService clusterService
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 - StringModelObjectPersisterExceptionpublic boolean removeObject(ModelPersistenceContext context, String objectTypeId, String objectId) throws ModelObjectPersisterException
ModelObjectPersisterremoveObject in interface ModelObjectPersisterremoveObject in class AbstractStoreObjectPersistercontext - ModelPersistenceContextobjectTypeId - StringobjectId - StringModelObjectPersisterExceptionprotected ModelObject newObject(ModelPersistenceContext context, String objectTypeId, String objectId, boolean addToCache) throws ModelObjectPersisterException
newObject in class AbstractStoreObjectPersisterModelObjectPersisterExceptionprotected 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()public void setClusterService(ClusterService service)
ClusterMessageAwaresetClusterService in interface ClusterMessageAwareservice - ClusterService to use to post cluster message payloadspublic String getClusterMessageType()
ClusterMessageAwaregetClusterMessageType in interface ClusterMessageAwarepublic void onClusterMessage(Map<String,Serializable> payload)
ClusterMessageAwareonClusterMessage in interface ClusterMessageAwarepayload - Payload from the messageprotected void updateClusterCachePath(String path)
path - Object pathCopyright © 2005–2016 Alfresco Software. All rights reserved.