org.springframework.extensions.surf
Class ModelObjectManager

java.lang.Object
  extended by org.springframework.extensions.surf.ModelObjectManager

public final class ModelObjectManager
extends Object

Provides core services for loading, retrieving and persisting model objects to one or more back-end Stores.

A model object type has an associated search path id. The search path defines the set of stores from which objects of a given model type can be loaded.

Loaded model objects are bound to a particular store and will be persisted back to that store unless copied or moved.

New model objects are created within a given store or they are created within the default store for the particular model object type (this is defined in configuration).

Author:
muzquiano, kevinr

Method Summary
 Map<String,ModelObject> getAllObjects(String objectTypeId)
          Retrieves all objects of a given type id.
 Map<String,ModelObject> getAllObjects(String objectTypeId, String filter)
          Retrieves all objects of a given type id with the given object ID filter
 ModelPersistenceContext getContext()
          Returns the model persistence context
 ModelObject getObject(String objectTypeId, String objectId)
          Retrieves an object from the persister that manages the given object type.
 void invalidateCache()
          Invalidates the cache for all persisters in this persistence context
 ModelObject newObject(String objectTypeId)
          Create a new object.
 ModelObject newObject(String objectTypeId, String objectId)
          Create a new object.
 boolean removeObject(ModelObject object)
          Removes the object.
 boolean removeObject(String objectTypeId, String objectId)
          Removes the object.
 boolean saveObject(ModelObject object)
          Saves the object to its persister.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getContext

public ModelPersistenceContext getContext()
Returns the model persistence context

Returns:
context

getObject

public ModelObject getObject(String objectTypeId,
                             String objectId)
Retrieves an object from the persister that manages the given object type.

If the object is not available in cache, it is loaded from storage.

Parameters:
objectTypeId - the object type id
objectId - the object id
Returns:
the ModelObject or null if not found

newObject

public ModelObject newObject(String objectTypeId,
                             String objectId)
Create a new object.

Parameters:
objectTypeId - the object type id
objectId - the object id
Returns:
the ModelObject or null if no persister for the given type can be found.

newObject

public ModelObject newObject(String objectTypeId)
Create a new object.

Parameters:
objectTypeId - the object type id
Returns:
the ModelObject or null if not found

saveObject

public boolean saveObject(ModelObject object)
Saves the object to its persister.

Parameters:
object - the ModelObject to save

removeObject

public boolean removeObject(ModelObject object)
Removes the object.

Parameters:
object - the ModelObject to remove
Returns:
true if successful, false otherwise

removeObject

public boolean removeObject(String objectTypeId,
                            String objectId)
Removes the object.

Parameters:
objectTypeId - the object type id
objectId - the object id
Returns:
true if successful, false otherwise

getAllObjects

public Map<String,ModelObject> getAllObjects(String objectTypeId)
Retrieves all objects of a given type id.

Parameters:
objectTypeId - Type ID
Returns:
a map of model objects (keyed by object id)

getAllObjects

public Map<String,ModelObject> getAllObjects(String objectTypeId,
                                             String filter)
Retrieves all objects of a given type id with the given object ID filter

Parameters:
objectTypeId - the object type id
Returns:
a map of model objects (keyed by object id)

invalidateCache

public void invalidateCache()
Invalidates the cache for all persisters in this persistence context



Copyright © 2009 SpringSource, Inc. All Rights Reserved.