|
|||||||||
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 java.util.Map |
changes
|
protected DataContext |
context
The DataContext that owns this ObjectStore. |
protected DataRowStore |
dataRowCache
Stores a reference to the DataRowStore. |
protected java.util.Map |
newObjectsMap
|
protected java.util.Map |
objectMap
|
protected java.util.Map |
queryResultMap
|
Constructor Summary | |
---|---|
ObjectStore()
|
|
ObjectStore(DataRowStore dataRowCache)
|
Method Summary | |
---|---|
void |
addObject(DataObject object)
Deprecated. since 1.2 as a different change tracking algorithm is used. |
void |
arcCreated(java.lang.Object nodeId,
java.lang.Object targetNodeId,
java.lang.Object arcId)
Does nothing. |
void |
arcDeleted(java.lang.Object nodeId,
java.lang.Object targetNodeId,
java.lang.Object arcId)
Does nothing. |
int |
cachedQueriesCount()
Returns a number of query results cached by this object store. |
void |
cacheQueryResult(java.lang.String name,
java.util.List results)
Caches a list of query results. |
java.util.List |
getCachedQueryResult(java.lang.String name)
Returns cached query results for a given query, or null if no results are cached. |
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. |
java.lang.Object |
getNode(java.lang.Object nodeId)
Returns a registered DataObject or null of no object exists for the ObjectId. |
DataObject |
getObject(ObjectId id)
Deprecated. since 1.2 a GraphManager getNode(Object) method should be
used. |
java.util.Iterator |
getObjectIterator()
Returns an iterator over the registered objects. |
java.util.List |
getObjects()
Deprecated. since 1.2 use GraphManager method registeredNodes() . |
DataRow |
getSnapshot(ObjectId oid)
Returns a snapshot for ObjectId from the underlying snapshot cache. |
DataRow |
getSnapshot(ObjectId oid,
QueryEngine engine)
Deprecated. since 1.2. Use getSnapshot(ObjectId) instead. |
void |
graphCommitAborted()
Does nothing. |
void |
graphCommitStarted()
Does nothing. |
void |
graphCommitted()
Does nothing. |
void |
graphRolledback()
Does nothing. |
boolean |
hasChanges()
Returns true if there are any modified, deleted or new objects
registered with this ObjectStore, false otherwise. |
void |
nodeCreated(java.lang.Object nodeId)
Does nothing. |
void |
nodeIdChanged(java.lang.Object nodeId,
java.lang.Object newId)
Does nothing. |
void |
nodePropertyChanged(java.lang.Object nodeId,
java.lang.String property,
java.lang.Object oldValue,
java.lang.Object newValue)
Does nothing. |
void |
nodeRemoved(java.lang.Object nodeId)
Does nothing. |
void |
objectRelationshipSet(DataObject source,
DataObject target,
ObjRelationship relationship,
boolean processFlattened)
Deprecated. since 1.2 use recordArcCreated(Persistent, ObjectId, String) . |
void |
objectRelationshipUnset(DataObject source,
DataObject target,
ObjRelationship relationship,
boolean processFlattened)
Deprecated. since 1.2 use recordArcDeleted(Persistent, ObjectId, String) . |
void |
objectsCommitted()
Deprecated. since 1.2 unused. |
java.util.List |
objectsInState(int state)
Return a subset of registered objects that are in a certian persistence state. |
void |
objectsInvalidated(java.util.Collection objects)
Invalidates a collection of DataObjects. |
void |
objectsRolledBack()
Reverts changes to all stored uncomitted objects. |
void |
objectsUnregistered(java.util.Collection objects)
Evicts a collection of DataObjects from the ObjectStore, invalidates the underlying cache snapshots. |
void |
recordArcCreated(Persistent object,
ObjectId targetId,
java.lang.String relationshipName)
Performs tracking of object relationship changes. |
void |
recordArcDeleted(Persistent object,
ObjectId targetId,
java.lang.String relationshipName)
Performs tracking of object relationship changes. |
java.util.Collection |
registeredNodes()
Returns all registered DataObjects. |
int |
registeredObjectsCount()
Returns a number of objects currently registered with this ObjectStore. |
void |
registerNode(java.lang.Object nodeId,
java.lang.Object nodeObject)
"Registers" a graph node, usually striong the node in some internal map using its id as a key. |
void |
resolveHollow(DataObject object)
Initializes object with data from cache or from the database, if this object is not fully resolved. |
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(java.util.List objects,
java.util.List snapshots,
boolean refresh)
Updates snapshots in the underlying DataRowStore. |
void |
startTrackingNewObjects()
Starts tracking the registration of new objects from this ObjectStore. |
void |
unregisterNewObjects()
Unregisters the newly registered DataObjects from this objectStore. |
java.lang.Object |
unregisterNode(java.lang.Object nodeId)
"Unregisters" a graph node, forgetting any information associated with nodeId. |
void |
validateUncommittedObjects()
Deprecated. since 1.2 - This method is no longer used in Cayenne internally. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected transient java.util.Map newObjectsMap
protected java.util.Map objectMap
protected java.util.Map queryResultMap
protected java.util.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)
Method Detail |
---|
public void recordArcCreated(Persistent object, ObjectId targetId, java.lang.String relationshipName)
public void recordArcDeleted(Persistent object, ObjectId targetId, java.lang.String relationshipName)
public int registeredObjectsCount()
public int cachedQueriesCount()
public DataRowStore getDataRowCache()
public void setDataRowCache(DataRowStore dataRowCache)
public void objectsInvalidated(java.util.Collection objects)
objectsUnregistered(Collection)
public void objectsUnregistered(java.util.Collection objects)
objectsInvalidated(Collection)
public void objectsRolledBack()
public void objectRelationshipUnset(DataObject source, DataObject target, ObjRelationship relationship, boolean processFlattened)
recordArcDeleted(Persistent, ObjectId, String)
.
public void objectRelationshipSet(DataObject source, DataObject target, ObjRelationship relationship, boolean processFlattened)
recordArcCreated(Persistent, ObjectId, String)
.
public void snapshotsUpdatedForObjects(java.util.List objects, java.util.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 objectsCommitted()
public void addObject(DataObject object)
public void startTrackingNewObjects()
unregisterNewObjects()
public void unregisterNewObjects()
startTrackingNewObjects()
public DataObject getObject(ObjectId id)
getNode(Object)
method should be
used.
public DataRow getCachedSnapshot(ObjectId oid)
public java.util.List getCachedQueryResult(java.lang.String name)
public void cacheQueryResult(java.lang.String name, java.util.List results)
public DataRow getSnapshot(ObjectId oid, QueryEngine engine)
getSnapshot(ObjectId)
instead.
public DataRow getSnapshot(ObjectId oid)
public java.util.List getObjects()
registeredNodes()
.
public java.util.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 java.util.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 validateUncommittedObjects() throws ValidationException
ValidationException
public void resolveHollow(DataObject object)
public DataContext getContext()
public void setContext(DataContext context)
public java.lang.Object getNode(java.lang.Object nodeId)
getNode
in interface GraphManager
public java.util.Collection registeredNodes()
registeredNodes
in interface GraphManager
public void registerNode(java.lang.Object nodeId, java.lang.Object nodeObject)
GraphManager
registerNode
in interface GraphManager
public java.lang.Object unregisterNode(java.lang.Object nodeId)
GraphManager
unregisterNode
in interface GraphManager
public void graphCommitAborted()
public void graphCommitStarted()
public void graphCommitted()
public void graphRolledback()
public void nodeIdChanged(java.lang.Object nodeId, java.lang.Object newId)
nodeIdChanged
in interface GraphChangeHandler
public void nodeCreated(java.lang.Object nodeId)
nodeCreated
in interface GraphChangeHandler
public void nodeRemoved(java.lang.Object nodeId)
nodeRemoved
in interface GraphChangeHandler
public void nodePropertyChanged(java.lang.Object nodeId, java.lang.String property, java.lang.Object oldValue, java.lang.Object newValue)
nodePropertyChanged
in interface GraphChangeHandler
public void arcCreated(java.lang.Object nodeId, java.lang.Object targetNodeId, java.lang.Object arcId)
arcCreated
in interface GraphChangeHandler
public void arcDeleted(java.lang.Object nodeId, java.lang.Object targetNodeId, java.lang.Object arcId)
arcDeleted
in interface GraphChangeHandler
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |