public class MultiObjectPersister extends AbstractObjectPersister implements CachedPersister
MultiModelObjectPersister class maintains the ModelObjectPersister contract
but redirects the retrieval of objects to a number of delegates. The delegate persisters can
be of any persister implementation and are called in order of the supplied map of persisters
during construction.
MODELOBJECT_CLASSES| Constructor and Description |
|---|
MultiObjectPersister() |
| Modifier and Type | Method and Description |
|---|---|
Map<String,ModelObject> |
getAllObjects(ModelPersistenceContext context,
String objectTypeId)
Returns a map of all of the objects referenced by this persister.
|
Map<String,ModelObject> |
getAllObjectsByFilter(ModelPersistenceContext context,
String objectTypeId,
String filter)
Returns a map of all of the objects referenced by this persister filtered by
the given ID filter.
|
ModelObject |
getObject(ModelPersistenceContext context,
String objectTypeId,
String objectId)
Iterates over the
persisters list attempting to find a ModelObject of
the supplied type with the supplied id. |
List<ModelObjectPersister> |
getPersisters()
Gets the persisters.
|
long |
getTimestamp(ModelPersistenceContext context,
String objectTypeId,
String objectId)
Returns the timestamp of the given object in the underlying store
|
boolean |
hasObject(ModelPersistenceContext context,
ModelObject object)
Checks whether the given object is persisted
|
boolean |
hasObject(ModelPersistenceContext context,
String objectTypeId,
String objectId)
Checks whether an object with the given path is persisted
|
boolean |
hasReadOnlyStore()
Indicates whether or not the persister uses a store that is read only.
|
void |
init(ModelPersistenceContext context)
If this
MultiObjectPerister has been added to the list of ModelObjectPersisters
managed by a PeristerService then this method will be invoked when that PeristerService
is initialised. |
void |
invalidateCache()
Invalidates the cache
|
ModelObject |
newObject(ModelPersistenceContext context,
String objectTypeId,
String objectId)
Creates a new object of the supplied type with the supplied id using the
|
boolean |
removeObject(ModelPersistenceContext context,
ModelObject object)
Removes the supplied object the first
ModelObjectPersister containing a match. |
boolean |
removeObject(ModelPersistenceContext context,
String objectTypeId,
String objectId)
Removes an object with the supplied type and id from the first
ModelObjectPersister
containing a match. |
boolean |
saveObject(ModelPersistenceContext context,
ModelObject object)
Saves the supplied
ModelObject using the default ModelObjectPersister (Please
note: saving does not iterate over the persisters list - it only used the default
persister. |
boolean |
saveObjects(ModelPersistenceContext context,
List<ModelObject> objects)
Saves the supplied
ModelObject list using the default ModelObjectPersister (Please
note: saving does not iterate over the persisters list - it only used the default
persister. |
void |
setCache(boolean cache)
Enables or disables the caching mechanics
|
void |
setCacheCheckDelay(int cacheCheckDelay)
Sets the number of seconds to wait between cache checks, -1 for never.
|
void |
setCacheMaxSize(int cacheMaxSize)
Sets the maximum size of the underlying cache, -1 for no max size.
|
void |
setDefaultPersister(ModelObjectPersister defaultPersister)
Sets the default persister.
|
void |
setPersisters(List<ModelObjectPersister> persisters)
Sets the persisters.
|
String |
toString() |
disable, getId, getPersisterService, getServiceRegistry, getWebFrameworkConfiguration, isEnabled, reset, setBeanName, setPersisterService, setServiceRegistry, setWebFrameworkConfigpublic void setPersisters(List<ModelObjectPersister> persisters)
persisters - the new persisterspublic List<ModelObjectPersister> getPersisters()
public void setDefaultPersister(ModelObjectPersister defaultPersister)
defaultPersister - the new default persisterpublic ModelObject getObject(ModelPersistenceContext context, String objectTypeId, String objectId) throws ModelObjectPersisterException
Iterates over the persisters list attempting to find a ModelObject of
the supplied type with the supplied id. The first match will be returned.
getObject in interface ModelObjectPersistercontext - The current persistence contextobjectTypeId - The type of object to retrieveobjectId - The id of the object to retrieveModelObject matching the supplied type and id (or null if a match
could not be found.ModelObjectPersisterExceptionpublic boolean saveObject(ModelPersistenceContext context, ModelObject object) throws ModelObjectPersisterException
Saves the supplied ModelObject using the default ModelObjectPersister (Please
note: saving does not iterate over the persisters list - it only used the default
persister.
saveObject in interface ModelObjectPersistercontext - The current persistence contextobject - The ModelObject to save.true if the object was successfully saved and false otherwise.ModelObjectPersisterException - If an error occurred saving the object.public boolean saveObjects(ModelPersistenceContext context, List<ModelObject> objects) throws ModelObjectPersisterException
Saves the supplied ModelObject list using the default ModelObjectPersister (Please
note: saving does not iterate over the persisters list - it only used the default
persister.
saveObjects in interface ModelObjectPersistercontext - The current persistence contextobjects - The List of ModelObjects to save.true if the objects were successfully saved and false otherwise.ModelObjectPersisterException - If an error occurred saving the objects.public boolean removeObject(ModelPersistenceContext context, ModelObject object) throws ModelObjectPersisterException
Removes the supplied object the first ModelObjectPersister containing a match.
removeObject in interface ModelObjectPersisterremoveObject in class AbstractObjectPersistercontext - The current persistence contextobject - The object to removetrue if the object was successfully removed and false otherwise.ModelObjectPersisterException - If an error occurs while removing the object.public boolean removeObject(ModelPersistenceContext context, String objectTypeId, String objectId) throws ModelObjectPersisterException
Removes an object with the supplied type and id from the first ModelObjectPersister
containing a match.
removeObject in interface ModelObjectPersistercontext - The current persistence contextobjectTypeId - The type of object to removeobjectId - The id of the object to removetrue if the object was successfully removed and false otherwise.ModelObjectPersisterException - If an error occurs while removing the object.public boolean hasObject(ModelPersistenceContext context, ModelObject object) throws ModelObjectPersisterException
ModelObjectPersisterhasObject in interface ModelObjectPersisterhasObject in class AbstractObjectPersistercontext - ModelPersistenceContextobject - ModelObjectModelObjectPersisterExceptionpublic boolean hasObject(ModelPersistenceContext context, String objectTypeId, String objectId) throws ModelObjectPersisterException
ModelObjectPersisterhasObject in interface ModelObjectPersistercontext - ModelPersistenceContextobjectTypeId - StringobjectId - StringModelObjectPersisterExceptionpublic ModelObject newObject(ModelPersistenceContext context, String objectTypeId, String objectId) throws ModelObjectPersisterException
Creates a new object of the supplied type with the supplied id using the
newObject in interface ModelObjectPersistercontext - ModelPersistenceContextobjectTypeId - StringobjectId - StringModelObjectPersisterExceptionpublic 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 ModelObjectPersistercontext - ModelPersistenceContextobjectTypeId - StringModelObjectPersisterExceptionpublic Map<String,ModelObject> getAllObjectsByFilter(ModelPersistenceContext context, String objectTypeId, String filter) throws ModelObjectPersisterException
ModelObjectPersisterIn general, this is an expensive call but less expensive than getAllObjects(). Each object descriptor referenced by the persister found using the filter is loaded into the model object cache.
getAllObjectsByFilter in interface ModelObjectPersistercontext - ModelPersistenceContextobjectTypeId - Stringfilter - StringModelObjectPersisterExceptionpublic long getTimestamp(ModelPersistenceContext context, String objectTypeId, String objectId) throws ModelObjectPersisterException
ModelObjectPersistergetTimestamp in interface ModelObjectPersistercontext - ModelPersistenceContextobjectTypeId - StringobjectId - StringModelObjectPersisterExceptionpublic void init(ModelPersistenceContext context)
If this MultiObjectPerister has been added to the list of ModelObjectPersisters
managed by a PeristerService then this method will be invoked when that PeristerService
is initialised. It initialises all the delegate ModelObjectPersisters used for retrieving objects
as well as the default ModelObjectPersister used for creating/saving objects (which will also be
added to the list of delegates if it has not been configured as such).
init in interface ModelObjectPersisterinit in class AbstractObjectPersistercontext - the persistence contextpublic void invalidateCache()
CachedPersisterinvalidateCache in interface CachedPersisterCachedPersister.invalidateCache()public void setCache(boolean cache)
CachedPersistersetCache in interface CachedPersistercache - booleanCachedPersister.setCache(boolean)public void setCacheCheckDelay(int cacheCheckDelay)
CachedPersistersetCacheCheckDelay in interface CachedPersistercacheCheckDelay - intCachedPersister.setCacheCheckDelay(int)public void setCacheMaxSize(int cacheMaxSize)
CachedPersistersetCacheMaxSize in interface CachedPersistercacheMaxSize - intCachedPersister.setCacheMaxSize(int)public boolean hasReadOnlyStore()
ModelObjectPersisterhasReadOnlyStore in interface ModelObjectPersisterCopyright © 2005–2016 Alfresco Software. All rights reserved.