java.lang.Object
org.keycloak.models.sessions.infinispan.changes.remote.updater.BaseUpdater<K,V>
Type Parameters:
K - The type of the Infinispan cache key.
V - The type of the Infinispan cache value.
All Implemented Interfaces:
BiFunction<K,V,V>, Updater<K,V>
Direct Known Subclasses:
AuthenticatedClientSessionUpdater, LoginFailuresUpdater, RootAuthenticationSessionUpdater, UserSessionUpdater

public abstract class BaseUpdater<K,V> extends Object implements Updater<K,V>
Base functionality of an Updater implementation.

It stores the Infinispan cache key, value, version, and it states. However, it does not keep track of the changed fields in the cache value, and it is the responsibility of the implementation to do that.

Implement the method isUnchanged() to signal if the entity was modified or not.

  • Constructor Details

  • Method Details

    • getKey

      public final K getKey()
      Specified by:
      getKey in interface Updater<K,V>
      Returns:
      The Infinispan cache key.
    • getValue

      public final V getValue()
      Specified by:
      getValue in interface Updater<K,V>
      Returns:
      The up-to-date entity used by the transaction.
    • getVersionRead

      public final long getVersionRead()
      Specified by:
      getVersionRead in interface Updater<K,V>
      Returns:
      The entity version when reading for the first time from Infinispan.
    • isDeleted

      public final boolean isDeleted()
      Specified by:
      isDeleted in interface Updater<K,V>
      Returns:
      true if the entity was removed during the Keycloak transaction and it should be removed from Infinispan.
    • isCreated

      public final boolean isCreated()
      Specified by:
      isCreated in interface Updater<K,V>
      Returns:
      true if the entity was created during the Keycloak transaction. Allows some optimization like put-if-absent.
    • isReadOnly

      public final boolean isReadOnly()
      Specified by:
      isReadOnly in interface Updater<K,V>
      Returns:
      true if the entity was not changed.
    • markDeleted

      public final void markDeleted()
      Description copied from interface: Updater
      Marks the entity as deleted.
      Specified by:
      markDeleted in interface Updater<K,V>
    • isTransient

      public boolean isTransient()
      Specified by:
      isTransient in interface Updater<K,V>
      Returns:
      true if the entity is transient and shouldn't be stored in the Infinispan cache.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • isUnchanged

      protected abstract boolean isUnchanged()
      Returns:
      true if the entity was changed after being created/read.