|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.cayenne.access.ObjectStore
public class ObjectStore
ObjectStore stores objects using their ObjectId as a key. It works as a dedicated object cache for a DataContext. Users rarely need to access ObjectStore directly, as DataContext serves as a facade, providing cover methods for most ObjectStore operations.
Field Summary | |
---|---|
protected Map |
changes
|
protected DataContext |
context
The DataContext that owns this ObjectStore. |
protected DataRowStore |
dataRowCache
Stores a reference to the DataRowStore. |
protected Map |
objectMap
|
Constructor Summary | |
---|---|
ObjectStore()
|
|
ObjectStore(DataRowStore dataRowCache)
|
|
ObjectStore(DataRowStore dataRowCache,
Map objectMap)
Creates an ObjectStore with DataRowStore and a map to use for storing
registered objects. |
Method Summary | |
---|---|
void |
arcCreated(Object nodeId,
Object targetNodeId,
Object arcId)
Notifies implementing object that a new arc was created between two nodes. |
void |
arcDeleted(Object nodeId,
Object targetNodeId,
Object arcId)
Notifies implementing object that an arc between two nodes was deleted. |
int |
cachedQueriesCount()
Deprecated. since 3.0. See DataContext.getQueryCache() . |
void |
cacheQueryResult(String name,
List results)
Deprecated. since 3.0. See DataContext.getQueryCache() . |
List |
getCachedQueryResult(String name)
Deprecated. since 3.0. See DataContext.getQueryCache() . |
DataRow |
getCachedSnapshot(ObjectId oid)
Returns a snapshot for ObjectId from the underlying snapshot cache. |
DataContext |
getContext()
|
DataRowStore |
getDataRowCache()
Returns a DataRowStore associated with this ObjectStore. |
Object |
getNode(Object nodeId)
Returns a registered DataObject or null of no object exists for the ObjectId. |
Iterator |
getObjectIterator()
Returns an iterator over the registered objects. |
DataRow |
getSnapshot(ObjectId oid)
Returns a snapshot for ObjectId from the underlying snapshot cache. |
boolean |
hasChanges()
Returns true if there are any modified, deleted or new objects
registered with this ObjectStore, false otherwise. |
void |
nodeCreated(Object nodeId)
Notifies implementing object that a new node was created in the graph. |
void |
nodeIdChanged(Object nodeId,
Object newId)
Does nothing. |
void |
nodePropertyChanged(Object nodeId,
String property,
Object oldValue,
Object newValue)
Records dirty object snapshot. |
void |
nodeRemoved(Object nodeId)
Notifies implementing object that a node was removed from the graph. |
List |
objectsInState(int state)
Return a subset of registered objects that are in a certian persistence state. |
void |
objectsInvalidated(Collection objects)
Deprecated. since 3.0, use DataContext.invalidateObjects(Collection) or
RefreshQuery . |
void |
objectsRolledBack()
Reverts changes to all stored uncomitted objects. |
void |
objectsUnregistered(Collection objects)
Evicts a collection of DataObjects from the ObjectStore, invalidates the underlying cache snapshots. |
Collection |
registeredNodes()
Returns all registered DataObjects. |
int |
registeredObjectsCount()
Returns a number of objects currently registered with this ObjectStore. |
void |
registerNode(Object nodeId,
Object nodeObject)
"Registers" a graph node, usually striong the node in some internal map using its id as a key. |
void |
resolveHollow(Persistent object)
Deprecated. since 3.0 use ObjectContext.prepareForAccess(Persistent, String, boolean) . |
void |
setContext(DataContext context)
|
void |
setDataRowCache(DataRowStore dataRowCache)
Sets parent DataRowStore. |
void |
snapshotsChanged(SnapshotEvent event)
SnapshotEventListener implementation that processes snapshot change event, updating DataObjects that have the changes. |
void |
snapshotsUpdatedForObjects(List objects,
List snapshots,
boolean refresh)
Updates snapshots in the underlying DataRowStore. |
void |
startTrackingNewObjects()
Deprecated. since 3.0 as ObjectStore holds weak reference to unmodified objects and this feature is useless. |
void |
unregisterNewObjects()
Deprecated. since 3.0 as ObjectStore holds weak reference to unmodified objects and this feature is useless. |
Object |
unregisterNode(Object nodeId)
"Unregisters" a graph node, forgetting any information associated with nodeId. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Map objectMap
protected Map changes
protected transient DataRowStore dataRowCache
Serialization note: It is up to the owner of this ObjectStore to initialize DataRowStore after deserialization of this object. ObjectStore will not know how to restore the DataRowStore by itself.
protected DataContext context
Constructor Detail |
---|
public ObjectStore()
public ObjectStore(DataRowStore dataRowCache)
public ObjectStore(DataRowStore dataRowCache, Map objectMap)
DataRowStore
and a map to use for storing
registered objects. Passed map doesn't require any special synchronization
behavior, as ObjectStore is synchronized itself.
Method Detail |
---|
public int registeredObjectsCount()
public int cachedQueriesCount()
DataContext.getQueryCache()
.
public DataRowStore getDataRowCache()
public void setDataRowCache(DataRowStore dataRowCache)
public void objectsInvalidated(Collection objects)
DataContext.invalidateObjects(Collection)
or
RefreshQuery
.
public void objectsUnregistered(Collection objects)
objectsInvalidated(Collection)
public void objectsRolledBack()
public void snapshotsUpdatedForObjects(List objects, List snapshots, boolean refresh)
refresh
is
true, all snapshots in snapshots
will be loaded into DataRowStore,
regardless of the existing cache state. If refresh
is false, only
missing snapshots are loaded. This method is normally called internally by the
DataContext owning the ObjectStore to update the caches after a select query.
objects
- a list of object whose snapshots need to be updated.snapshots
- a list of snapshots. Must be of the same length and use the same
order as objects
list.refresh
- controls whether existing cached snapshots should be replaced with
the new ones.public void startTrackingNewObjects()
public void unregisterNewObjects()
public DataRow getCachedSnapshot(ObjectId oid)
public List getCachedQueryResult(String name)
DataContext.getQueryCache()
.
public void cacheQueryResult(String name, List results)
DataContext.getQueryCache()
.
public DataRow getSnapshot(ObjectId oid)
public Iterator getObjectIterator()
public boolean hasChanges()
true
if there are any modified, deleted or new objects
registered with this ObjectStore, false
otherwise. This method will
treat "phantom" modifications are real ones. I.e. if you "change" an object
property to an equivalent value, this method will still think such object is
modified. Phantom modifications are only detected and discarded during commit.
public List objectsInState(int state)
public void snapshotsChanged(SnapshotEvent event)
Implementation note: This method should not attempt to alter the underlying DataRowStore, since it is normally invoked *AFTER* the DataRowStore was modified as a result of some external interaction.
snapshotsChanged
in interface SnapshotEventListener
public void resolveHollow(Persistent object)
ObjectContext.prepareForAccess(Persistent, String, boolean)
.
public DataContext getContext()
public void setContext(DataContext context)
public Object getNode(Object nodeId)
getNode
in interface GraphManager
public Collection registeredNodes()
registeredNodes
in interface GraphManager
public void registerNode(Object nodeId, Object nodeObject)
GraphManager
registerNode
in interface GraphManager
public Object unregisterNode(Object nodeId)
GraphManager
unregisterNode
in interface GraphManager
public void nodeIdChanged(Object nodeId, Object newId)
nodeIdChanged
in interface GraphChangeHandler
public void nodeCreated(Object nodeId)
GraphChangeHandler
nodeCreated
in interface GraphChangeHandler
public void nodeRemoved(Object nodeId)
GraphChangeHandler
nodeRemoved
in interface GraphChangeHandler
public void nodePropertyChanged(Object nodeId, String property, Object oldValue, Object newValue)
nodePropertyChanged
in interface GraphChangeHandler
public void arcCreated(Object nodeId, Object targetNodeId, Object arcId)
GraphChangeHandler
arcCreated
in interface GraphChangeHandler
public void arcDeleted(Object nodeId, Object targetNodeId, Object arcId)
GraphChangeHandler
arcDeleted
in interface GraphChangeHandler
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |