|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.extensions.surf.persister.AbstractObjectPersister org.springframework.extensions.surf.persister.AbstractCachedObjectPersister org.springframework.extensions.surf.persister.ReadOnlyStoreObjectPersister
public class ReadOnlyStoreObjectPersister
A persister that provides read-only inter-operability with Web Script Framework stores. This persister follows the pattern of store usage in the web script framework by treating the cache as a "master copy" of the persistence state. The cache is populated by the init() method and is then considered to be the master copy. If contents change inside of the underlying store, they will not be detected until the reset() method is employed. This persister implementation therefore lets the web framework accommodate a pattern of store usage that is analogous to the web script framework.
ClassPathStore
,
RemoteStore
,
WebApplicationStore
Field Summary | |
---|---|
protected String |
pathPrefix
|
protected Store |
store
|
Fields inherited from class org.springframework.extensions.surf.persister.AbstractCachedObjectPersister |
---|
cacheDelay, caches, GLOBAL_STORE_ID, useCache |
Fields inherited from class org.springframework.extensions.surf.persister.AbstractObjectPersister |
---|
MODELOBJECT_CLASSES |
Constructor Summary | |
---|---|
ReadOnlyStoreObjectPersister()
Instantiates a new store model object persister. |
Method Summary | |
---|---|
protected BasicCache<ModelObject> |
createCache()
Creates the cache. |
protected ModelObject |
createObject(org.dom4j.Document document,
String objectTypeId,
String objectId,
String path)
|
protected String |
generatePath(String objectTypeId,
String objectId)
Generates a persistence path for a given object id and object type id. |
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 objectIdPattern)
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)
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. |
protected String |
getObjectTypeId(org.dom4j.Document doc,
String path)
Determines the object type id of a serialized model object contained in a document. |
String |
getPathPrefix()
Gets the path prefix. |
long |
getTimestamp(ModelPersistenceContext context,
String objectTypeId,
String objectId)
Returns the timestamp of the given object in the underlying store |
boolean |
hasObject(ModelPersistenceContext context,
String objectTypeId,
String objectId)
Checks whether an object with the given path is persisted |
void |
init(ModelPersistenceContext context)
Initializes the persister by preloading the object cache |
protected boolean |
isModelObject(org.dom4j.Document doc,
String path)
Determines whether the xml contained in the given document describes a valid model object type |
protected Map<String,ModelObject> |
loadObjectsAndDependents(ModelPersistenceContext context,
org.dom4j.Document document,
String objectTypeId,
String objectId,
String path)
|
ModelObject |
newObject(ModelPersistenceContext context,
String objectTypeId,
String objectId)
Creates a new object |
boolean |
removeObject(ModelPersistenceContext context,
String objectTypeId,
String objectId)
Removes an object from persisted storage |
void |
reset()
Resets the persister, clearing cache and starting anew. |
boolean |
saveObject(ModelPersistenceContext context,
ModelObject modelObject)
Saves an object to persisted storage |
void |
setCache(boolean useCache)
|
void |
setCacheCheckDelay(int cacheCheckDelay)
|
void |
setPathPrefix(String pathPrefix)
Sets a path prefix to be applied to generated paths |
void |
setStore(Store store)
Sets the store. |
Methods inherited from class org.springframework.extensions.surf.persister.AbstractCachedObjectPersister |
---|
cacheGet, cachePut, cacheRemove, getCache, invalidateCache |
Methods inherited from class org.springframework.extensions.surf.persister.AbstractObjectPersister |
---|
disable, getId, getServiceRegistry, getWebFrameworkConfiguration, getWebFrameworkManager, hasObject, isEnabled, removeObject, setBeanName, setServiceRegistry |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Store store
protected String pathPrefix
Constructor Detail |
---|
public ReadOnlyStoreObjectPersister()
Method Detail |
---|
public void setStore(Store store)
store
- the new storepublic void setPathPrefix(String pathPrefix)
pathPrefix
- the path prefixpublic String getPathPrefix()
protected String generatePath(String objectTypeId, String objectId)
This method should never return a null value.
objectTypeId
- the object type idobjectId
- the object id
public boolean saveObject(ModelPersistenceContext context, ModelObject modelObject) throws ModelObjectPersisterException
ModelObjectPersister
ModelObjectPersisterException
public ModelObject newObject(ModelPersistenceContext context, String objectTypeId, String objectId) throws ModelObjectPersisterException
ModelObjectPersister
ModelObjectPersisterException
public boolean removeObject(ModelPersistenceContext context, String objectTypeId, String objectId) throws ModelObjectPersisterException
ModelObjectPersister
ModelObjectPersisterException
public ModelObject getObject(ModelPersistenceContext context, String objectTypeId, String objectId) throws ModelObjectPersisterException
ModelObjectPersister
ModelObjectPersisterException
public boolean hasObject(ModelPersistenceContext context, String objectTypeId, String objectId) throws ModelObjectPersisterException
ModelObjectPersister
ModelObjectPersisterException
public long getTimestamp(ModelPersistenceContext context, String objectTypeId, String objectId) throws ModelObjectPersisterException
ModelObjectPersister
ModelObjectPersisterException
public Map<String,ModelObject> getAllObjects(ModelPersistenceContext context, String objectTypeId) throws ModelObjectPersisterException
ModelObjectPersister
In 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.
ModelObjectPersisterException
public Map<String,ModelObject> getAllObjectsByFilter(ModelPersistenceContext context, String objectTypeId, String objectIdPattern) throws ModelObjectPersisterException
ModelObjectPersister
In 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.
ModelObjectPersisterException
public void init(ModelPersistenceContext context)
ModelObjectPersister
init
in interface ModelObjectPersister
init
in class AbstractObjectPersister
context
- the persistence contextpublic void reset()
ModelObjectPersister
reset
in interface ModelObjectPersister
reset
in class AbstractObjectPersister
protected BasicCache<ModelObject> createCache()
AbstractCachedObjectPersister
createCache
in class AbstractCachedObjectPersister
protected ModelObject getObjectByPath(ModelPersistenceContext context, String path) throws ModelObjectPersisterException
context
- path
-
ModelObjectPersisterException
protected Map<String,ModelObject> loadObjectsAndDependents(ModelPersistenceContext context, org.dom4j.Document document, String objectTypeId, String objectId, String path) throws ModelObjectPersisterException
ModelObjectPersisterException
protected ModelObject createObject(org.dom4j.Document document, String objectTypeId, String objectId, String path)
protected String getObjectTypeId(org.dom4j.Document doc, String path)
doc
- documentpath
- the path
protected String getObjectId(org.dom4j.Document doc, String path)
doc
- documentpath
- the path
protected boolean isModelObject(org.dom4j.Document doc, String path)
doc
- documentpath
- the path
public void setCache(boolean useCache)
setCache
in class AbstractCachedObjectPersister
public void setCacheCheckDelay(int cacheCheckDelay)
setCacheCheckDelay
in class AbstractCachedObjectPersister
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |