org.apache.cayenne.access

## Class DataRowStore

- java.lang.Object
- - org.apache.cayenne.access.DataRowStore

- All Implemented Interfaces:
    Serializable

      public class DataRowStore
      extends Object
      implements Serializable

  A fixed size cache of DataRows keyed by ObjectId.
  Since:
    1.1
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `EVENT_BRIDGE_FACTORY_DEFAULT` Deprecated. since 4.0 does nothing.
    `static String` | `EVENT_BRIDGE_FACTORY_PROPERTY` Deprecated. since 4.0 `DataRowStoreFactory` establishes `EventBridge`.
    `protected EventManager` | `eventManager`
    `protected EventSubject` | `eventSubject`
    `protected String` | `name`
    `protected boolean` | `notifyingRemoteListeners` Deprecated. since 4.0 does nothing. Previously it used to check if need to create `EventBridge`.
    `static boolean` | `REMOTE_NOTIFICATION_DEFAULT` Deprecated.
    `static String` | `REMOTE_NOTIFICATION_PROPERTY` Deprecated. since 4.0 does nothing. Previously it used to check if need to create `EventBridge`.
    `protected EventBridge` | `remoteNotificationsHandler`
    `static int` | `SNAPSHOT_CACHE_SIZE_DEFAULT`
    `static String` | `SNAPSHOT_CACHE_SIZE_PROPERTY` Deprecated. since 4.0, use `Constants.SNAPSHOT_CACHE_SIZE_PROPERTY`
    `static long` | `SNAPSHOT_EXPIRATION_DEFAULT`
    `static String` | `SNAPSHOT_EXPIRATION_PROPERTY` Deprecated. since 4.0, never used actually
    `protected ConcurrentMap<ObjectId,DataRow>` | `snapshots`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DataRowStore(String name, RuntimeProperties properties, EventManager eventManager)` Creates new DataRowStore with a specified name and a set of properties.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clear()` Expires and removes all stored snapshots without sending any notification events.
    `void` | `forgetSnapshot(ObjectId id)` Evicts a snapshot from cache without generating any SnapshotEvents.
    `DataRow` | `getCachedSnapshot(ObjectId oid)` Returns cached snapshot or null if no snapshot is currently cached for the given ObjectId.
    `protected EventBridge` | `getEventBridge()`
    `EventManager` | `getEventManager()` Returns an EventManager associated with this DataRowStore.
    `String` | `getName()` Returns the name of this DataRowStore.
    `EventSubject` | `getSnapshotEventSubject()` Returns EventSubject used by this SnapshotCache to notify of snapshot changes.
    `protected void` | `initWithProperties(RuntimeProperties properties)`
    `boolean` | `isNotifyingRemoteListeners()` Deprecated.
    `int` | `maximumSize()` Returns maximum allowed cache size.
    `void` | `processRemoteEvent(SnapshotEvent event)` Handles remote events received via EventBridge.
    `void` | `processSnapshotChanges(Object postedBy, Map<ObjectId,DataRow> updatedSnapshots, Collection<ObjectId> deletedSnapshotIds, Collection<ObjectId> invalidatedSnapshotIds, Collection<ObjectId> indirectlyModifiedIds)` Processes changes made to snapshots.
    `protected void` | `setEventBridge(EventBridge eventBridge)`
    `void` | `setEventManager(EventManager eventManager)` Sets an EventManager associated with this DataRowStore.
    `void` | `setName(String name)` Sets the name of this DataRowStore.
    `void` | `setNotifyingRemoteListeners(boolean notifyingRemoteListeners)` Deprecated.
    `void` | `shutdown()` Shuts down any remote notification connections, and clears internal cache.
    `int` | `size()` Returns current cache size.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### SNAPSHOT_EXPIRATION_PROPERTY

          @Deprecated
          public static final String SNAPSHOT_EXPIRATION_PROPERTY

      Deprecated. since 4.0, never used actually
      See Also:
        Constant Field Values

    - #### SNAPSHOT_CACHE_SIZE_PROPERTY

          @Deprecated
          public static final String SNAPSHOT_CACHE_SIZE_PROPERTY

      Deprecated. since 4.0, use `Constants.SNAPSHOT_CACHE_SIZE_PROPERTY`
      See Also:
        Constant Field Values

    - #### REMOTE_NOTIFICATION_PROPERTY

          @Deprecated
          public static final String REMOTE_NOTIFICATION_PROPERTY

      Deprecated. since 4.0 does nothing. Previously it used to check if need to create `EventBridge`.
      See Also:
        Constant Field Values

    - #### EVENT_BRIDGE_FACTORY_PROPERTY

          @Deprecated
          public static final String EVENT_BRIDGE_FACTORY_PROPERTY

      Deprecated. since 4.0 `DataRowStoreFactory` establishes `EventBridge`.
      See Also:
        Constant Field Values

    - #### SNAPSHOT_EXPIRATION_DEFAULT

          public static final long SNAPSHOT_EXPIRATION_DEFAULT

      See Also:
        Constant Field Values

    - #### SNAPSHOT_CACHE_SIZE_DEFAULT

          public static final int SNAPSHOT_CACHE_SIZE_DEFAULT

      See Also:
        Constant Field Values

    - #### REMOTE_NOTIFICATION_DEFAULT

          @Deprecated
          public static final boolean REMOTE_NOTIFICATION_DEFAULT

      Deprecated.
      See Also:
        Constant Field Values

    - #### EVENT_BRIDGE_FACTORY_DEFAULT

          @Deprecated
          public static final String EVENT_BRIDGE_FACTORY_DEFAULT

      Deprecated. since 4.0 does nothing.
      See Also:
        Constant Field Values

    - #### name

          protected String name

    - #### snapshots

          protected ConcurrentMap<ObjectId,DataRow> snapshots

    - #### notifyingRemoteListeners

          @Deprecated
          protected boolean notifyingRemoteListeners

      Deprecated. since 4.0 does nothing. Previously it used to check if need to create `EventBridge`.

    - #### eventManager

          protected transient EventManager eventManager

    - #### remoteNotificationsHandler

          protected transient EventBridge remoteNotificationsHandler

    - #### eventSubject

          protected transient EventSubject eventSubject

  - ### Constructor Detail

    - #### DataRowStore

          public DataRowStore(String name,
                              RuntimeProperties properties,
                              EventManager eventManager)

      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 Detail

    - #### initWithProperties

          protected void initWithProperties(RuntimeProperties properties)

    - #### setEventBridge

          protected void setEventBridge(EventBridge eventBridge)

    - #### getEventBridge

          protected EventBridge 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

          public String getName()

      Returns the name of this DataRowStore. Name allows to create EventSubjects for event notifications addressed to or sent from this DataRowStore.

    - #### setName

          public void setName(String name)

      Sets the name of this DataRowStore. Name allows to create EventSubjects for event notifications addressed to or sent from this DataRowStore.

    - #### getEventManager

          public EventManager getEventManager()

      Returns an EventManager associated with this DataRowStore.
      Since:
        1.2

    - #### setEventManager

          public void setEventManager(EventManager eventManager)

      Sets an EventManager associated with this DataRowStore.
      Since:
        1.2

    - #### getCachedSnapshot

          public DataRow getCachedSnapshot(ObjectId oid)

      Returns cached snapshot or null if no snapshot is currently cached for the given ObjectId.

    - #### getSnapshotEventSubject

          public EventSubject 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

          public void forgetSnapshot(ObjectId id)

      Evicts a snapshot from cache without generating any SnapshotEvents.

    - #### processRemoteEvent

          public void processRemoteEvent(SnapshotEvent event)

      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.

    - #### isNotifyingRemoteListeners

          @Deprecated
          public boolean isNotifyingRemoteListeners()

      Deprecated.

    - #### setNotifyingRemoteListeners

          @Deprecated
          public void setNotifyingRemoteListeners(boolean notifyingRemoteListeners)

      Deprecated.

Copyright © 2001–2023 Apache Cayenne. All rights reserved.