org.keycloak.models.map.storage.chm

## Class ConcurrentHashMapKeycloakTransaction<K,V extends AbstractEntity<K>,M>

- java.lang.Object
- - org.keycloak.models.map.storage.chm.ConcurrentHashMapKeycloakTransaction<K,V,M>

- All Implemented Interfaces:
    KeycloakTransaction, MapKeycloakTransaction<K,V,M>

      public class ConcurrentHashMapKeycloakTransaction<K,V extends AbstractEntity<K>,M>
      extends Object
      implements MapKeycloakTransaction<K,V,M>

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected class` | `ConcurrentHashMapKeycloakTransaction.MapTaskWithValue`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ConcurrentHashMapKeycloakTransaction(MapStorage<K,V,M> map)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `addTask(K key, ConcurrentHashMapKeycloakTransaction.MapTaskWithValue task)` Adds a given task if not exists for the given key
    `void` | `begin()`
    `void` | `commit()`
    `void` | `create(K key, V value)` Instructs this transaction to add a new value into the underlying store on commit.
    `void` | `delete(K key)` Instructs this transaction to delete a value associated with the identifier `key` from the underlying store on commit.
    `long` | `delete(K artificialKey, ModelCriteriaBuilder<M> mcb)` Instructs this transaction to remove values (identified by `mcb` filter) from the underlying store on commit.
    `long` | `getCount(ModelCriteriaBuilder<M> mcb)` Returns a number of values present in the underlying storage that fulfill the given criteria with respect to changes done in the current transaction.
    `boolean` | `getRollbackOnly()`
    `V` | `getUpdated(V orig)` Returns an updated version of the `orig` object as updated in this transaction.
    `boolean` | `isActive()`
    `V` | `read(K key)` Provides possibility to lookup for values by a `key` in the underlying store with respect to changes done in current transaction.
    `V` | `read(K key, Function<K,V> defaultValueFunc)` Looks up a value in the current transaction with corresponding key, returns `defaultValueFunc` when the transaction does not contain a value for the `key` identifier.
    `Stream<V>` | `read(ModelCriteriaBuilder<M> mcb)` Returns the stream of records that match given criteria and includes changes made in this transaction, i.e.
    `void` | `rollback()`
    `void` | `setRollbackOnly()`
    `void` | `update(K key, V value)` Instructs this transaction to force-update the `value` associated with the identifier `key` in the underlying store on commit.
    `void` | `updateIfChanged(K key, V value, Predicate<V> shouldPut)` Instructs this transaction to update the `value` associated with the identifier `key` in the underlying store on commit, if by the time of `commit` the `shouldPut` predicate returns `true`

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

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

- - ### Constructor Detail

    - #### ConcurrentHashMapKeycloakTransaction

          public ConcurrentHashMapKeycloakTransaction(MapStorage<K,V,M> map)

  - ### Method Detail

    - #### begin

          public void begin()

      Specified by:
        `begin` in interface `KeycloakTransaction`

    - #### commit

          public void commit()

      Specified by:
        `commit` in interface `KeycloakTransaction`

    - #### rollback

          public void rollback()

      Specified by:
        `rollback` in interface `KeycloakTransaction`

    - #### setRollbackOnly

          public void setRollbackOnly()

      Specified by:
        `setRollbackOnly` in interface `KeycloakTransaction`

    - #### getRollbackOnly

          public boolean getRollbackOnly()

      Specified by:
        `getRollbackOnly` in interface `KeycloakTransaction`

    - #### isActive

          public boolean isActive()

      Specified by:
        `isActive` in interface `KeycloakTransaction`

    - #### addTask

          protected void addTask(K key,
                                 ConcurrentHashMapKeycloakTransaction.MapTaskWithValue task)

      Adds a given task if not exists for the given key

    - #### read

          public V read(K key)

      Description copied from interface: `MapKeycloakTransaction`
      Provides possibility to lookup for values by a `key` in the underlying store with respect to changes done in current transaction.
      Specified by:
        `read` in interface `MapKeycloakTransaction<K,V extends AbstractEntity<K>,M>`
      Parameters:
        `key` - identifier of a value
      Returns:
        a value associated with the given `key`

    - #### read

          public V read(K key,
                        Function<K,V> defaultValueFunc)

      Description copied from interface: `MapKeycloakTransaction`
      Looks up a value in the current transaction with corresponding key, returns `defaultValueFunc` when the transaction does not contain a value for the `key` identifier.
      Specified by:
        `read` in interface `MapKeycloakTransaction<K,V extends AbstractEntity<K>,M>`
      Parameters:
        `key` - identifier of a value
        `defaultValueFunc` - fallback function if the transaction does not contain a value that corresponds to `key`
      Returns:
        a value associated with the given `key`, or the result of `defaultValueFunc`

    - #### read

          public Stream<V> read(ModelCriteriaBuilder<M> mcb)

      Returns the stream of records that match given criteria and includes changes made in this transaction, i.e. the result contains updates and excludes records that have been deleted in this transaction.
      Specified by:
        `read` in interface `MapKeycloakTransaction<K,V extends AbstractEntity<K>,M>`
      Parameters:
        `mcb` -
      Returns:

    - #### getCount

          public long getCount(ModelCriteriaBuilder<M> mcb)

      Description copied from interface: `MapKeycloakTransaction`
      Returns a number of values present in the underlying storage that fulfill the given criteria with respect to changes done in the current transaction.
      Specified by:
        `getCount` in interface `MapKeycloakTransaction<K,V extends AbstractEntity<K>,M>`
      Parameters:
        `mcb` - criteria to filter values
      Returns:
        number of values present in the storage that fulfill the given criteria

    - #### getUpdated

          public V getUpdated(V orig)

      Description copied from interface: `MapKeycloakTransaction`
      Returns an updated version of the `orig` object as updated in this transaction. If the underlying store handles transactions on its own, this can return `orig` directly.
      Specified by:
        `getUpdated` in interface `MapKeycloakTransaction<K,V extends AbstractEntity<K>,M>`
      Parameters:
        `orig` - possibly stale version of some object from the underlying store
      Returns:
        the `orig` object as visible from this transaction, or `null` if the object has been removed.

    - #### update

          public void update(K key,
                             V value)

      Description copied from interface: `MapKeycloakTransaction`
      Instructs this transaction to force-update the `value` associated with the identifier `key` in the underlying store on commit.
      Specified by:
        `update` in interface `MapKeycloakTransaction<K,V extends AbstractEntity<K>,M>`
      Parameters:
        `key` - identifier of the `value`
        `value` - updated version of the value

    - #### create

          public void create(K key,
                             V value)

      Description copied from interface: `MapKeycloakTransaction`
      Instructs this transaction to add a new value into the underlying store on commit.
      Specified by:
        `create` in interface `MapKeycloakTransaction<K,V extends AbstractEntity<K>,M>`
      Parameters:
        `key` - an identifier that will be associated with the `value`
        `value` - the value

    - #### updateIfChanged

          public void updateIfChanged(K key,
                                      V value,
                                      Predicate<V> shouldPut)

      Description copied from interface: `MapKeycloakTransaction`
      Instructs this transaction to update the `value` associated with the identifier `key` in the underlying store on commit, if by the time of `commit` the `shouldPut` predicate returns `true`
      Specified by:
        `updateIfChanged` in interface `MapKeycloakTransaction<K,V extends AbstractEntity<K>,M>`
      Parameters:
        `key` - identifier of the `value`
        `value` - new version of the value
        `shouldPut` - predicate to check in commit phase

    - #### delete

          public void delete(K key)

      Description copied from interface: `MapKeycloakTransaction`
      Instructs this transaction to delete a value associated with the identifier `key` from the underlying store on commit.
      Specified by:
        `delete` in interface `MapKeycloakTransaction<K,V extends AbstractEntity<K>,M>`
      Parameters:
        `key` - identifier of a value

    - #### delete

          public long delete(K artificialKey,
                             ModelCriteriaBuilder<M> mcb)

      Description copied from interface: `MapKeycloakTransaction`
      Instructs this transaction to remove values (identified by `mcb` filter) from the underlying store on commit.
      Specified by:
        `delete` in interface `MapKeycloakTransaction<K,V extends AbstractEntity<K>,M>`
      Parameters:
        `artificialKey` - key to record the transaction with, must be a key that does not exist in this transaction to prevent collisions with other operations in this transaction
        `mcb` - criteria to delete values

Copyright © 2021 JBoss by Red Hat. All rights reserved.