public class ObjectStore extends Object implements Serializable, SnapshotEventListener, GraphManager
Modifier and Type | Field and Description |
---|---|
protected Map<Object,org.apache.cayenne.access.ObjectDiff> |
changes |
protected DataContext |
context
The DataContext that owns this ObjectStore.
|
protected DataRowStore |
dataRowCache
Stores a reference to the DataRowStore.
|
protected boolean |
dataRowCacheSet |
protected Map<Object,Persistent> |
objectMap |
Constructor and Description |
---|
ObjectStore(DataRowStore dataRowCache,
Map<Object,Persistent> objectMap)
Creates an ObjectStore with
DataRowStore and a map to use for storing
registered objects. |
Modifier and Type | Method and Description |
---|---|
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.
|
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<Persistent> |
objectsInState(int state)
Return a subset of registered objects that are in a certain persistence state.
|
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<Object> |
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 storing the node in some internal map using its
id as a key.
|
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.
|
Object |
unregisterNode(Object nodeId)
"Unregisters" a graph node, forgetting any information associated with nodeId.
|
protected Map<Object,Persistent> objectMap
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 boolean dataRowCacheSet
protected DataContext context
public ObjectStore(DataRowStore dataRowCache, Map<Object,Persistent> 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.public int registeredObjectsCount()
public DataRowStore getDataRowCache()
public void setDataRowCache(DataRowStore dataRowCache)
public void objectsUnregistered(Collection objects)
public void objectsRolledBack()
public DataRow getCachedSnapshot(ObjectId oid)
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<Persistent> 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 DataContext getContext()
public void setContext(DataContext context)
public Object getNode(Object nodeId)
getNode
in interface GraphManager
public Collection<Object> 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
Copyright © 2001–2015 Apache Cayenne. All rights reserved.