Package org.apache.cayenne.access
Class DataRowStore
java.lang.Object
org.apache.cayenne.access.DataRowStore
- All Implemented Interfaces:
Serializable
A fixed size cache of DataRows keyed by ObjectId.
- Since:
- 1.1
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected EventManagerprotected EventSubjectprotected Stringprotected EventBridgestatic final intstatic final longprotected ConcurrentMap<ObjectId,DataRow> -
Constructor Summary
ConstructorsConstructorDescriptionDataRowStore(String name, RuntimeProperties properties, EventManager eventManager) Creates new DataRowStore with a specified name and a set of properties. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Expires and removes all stored snapshots without sending any notification events.voidEvicts a snapshot from cache without generating any SnapshotEvents.Returns cached snapshot or null if no snapshot is currently cached for the given ObjectId.protected EventBridgeReturns an EventManager associated with this DataRowStore.getName()Returns the name of this DataRowStore.Returns EventSubject used by this SnapshotCache to notify of snapshot changes.protected voidinitWithProperties(RuntimeProperties properties) intReturns maximum allowed cache size.voidprocessRemoteEvent(SnapshotEvent event) Handles remote events received via EventBridge.voidprocessSnapshotChanges(Object postedBy, Map<ObjectId, DataRow> updatedSnapshots, Collection<ObjectId> deletedSnapshotIds, Collection<ObjectId> invalidatedSnapshotIds, Collection<ObjectId> indirectlyModifiedIds) Processes changes made to snapshots.protected voidsetEventBridge(EventBridge eventBridge) voidsetEventManager(EventManager eventManager) Sets an EventManager associated with this DataRowStore.voidSets the name of this DataRowStore.voidshutdown()Shuts down any remote notification connections, and clears internal cache.intsize()Returns current cache size.
-
Field Details
-
SNAPSHOT_EXPIRATION_DEFAULT
public static final long SNAPSHOT_EXPIRATION_DEFAULT- See Also:
-
SNAPSHOT_CACHE_SIZE_DEFAULT
public static final int SNAPSHOT_CACHE_SIZE_DEFAULT- See Also:
-
name
-
snapshots
-
eventManager
-
remoteNotificationsHandler
-
eventSubject
-
-
Constructor Details
-
DataRowStore
Creates new DataRowStore with a specified name and a set of properties. If no properties are defined, default values are used.- Parameters:
name- DataRowStore name. Used to identify this DataRowStore in events, etc. Can't be null.properties- Properties map used to configure DataRowStore parameters. Can be null.eventManager- EventManager that should be used for posting and receiving events.- Since:
- 1.2
-
-
Method Details
-
initWithProperties
-
setEventBridge
-
getEventBridge
-
size
public int size()Returns current cache size. -
maximumSize
public int maximumSize()Returns maximum allowed cache size. -
shutdown
public void shutdown()Shuts down any remote notification connections, and clears internal cache. -
getName
Returns the name of this DataRowStore. Name allows to create EventSubjects for event notifications addressed to or sent from this DataRowStore. -
setName
Sets the name of this DataRowStore. Name allows to create EventSubjects for event notifications addressed to or sent from this DataRowStore. -
getEventManager
Returns an EventManager associated with this DataRowStore.- Since:
- 1.2
-
setEventManager
Sets an EventManager associated with this DataRowStore.- Since:
- 1.2
-
getCachedSnapshot
Returns cached snapshot or null if no snapshot is currently cached for the given ObjectId. -
getSnapshotEventSubject
Returns EventSubject used by this SnapshotCache to notify of snapshot changes. -
clear
public void clear()Expires and removes all stored snapshots without sending any notification events. -
forgetSnapshot
Evicts a snapshot from cache without generating any SnapshotEvents. -
processRemoteEvent
Handles remote events received via EventBridge. Performs needed snapshot updates, and then resends the event to local listeners. -
processSnapshotChanges
public void processSnapshotChanges(Object postedBy, Map<ObjectId, DataRow> updatedSnapshots, Collection<ObjectId> deletedSnapshotIds, Collection<ObjectId> invalidatedSnapshotIds, Collection<ObjectId> indirectlyModifiedIds) Processes changes made to snapshots. Modifies internal cache state, and then sends the event to all listeners. Source of these changes is usually an ObjectStore.
-