org.keycloak.models.map.storage.chm

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

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

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

      public class ConcurrentHashMapKeycloakTransaction<K,V extends AbstractEntity & UpdatableEntity,M>
      extends Object
      implements MapKeycloakTransaction<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<V,M> map, StringKeyConvertor<K> keyConvertor)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `addTask(String key, ConcurrentHashMapKeycloakTransaction.MapTaskWithValue task)` Adds a given task if not exists for the given key
    `void` | `begin()`
    `void` | `commit()`
    `V` | `create(V value)` Instructs this transaction to add a new value into the underlying store on commit.
    `long` | `delete(QueryParameters<M> queryParameters)` Instructs this transaction to remove values (identified by `mcb` filter) from the underlying store on commit.
    `boolean` | `delete(String key)` Instructs this transaction to delete a value associated with the identifier `key` from the underlying store on commit.
    `long` | `getCount(QueryParameters<M> queryParameters)` 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()`
    `boolean` | `isActive()`
    `Stream<V>` | `read(QueryParameters<M> queryParameters)` Returns the stream of records that match given criteria and includes changes made in this transaction, i.e.
    `V` | `read(String sKey)` Provides possibility to lookup for values by a `key` in the underlying store with respect to changes done in current transaction.
    `V` | `read(String key, Function<String,V> defaultValueFunc)`
    `V` | `registerEntityForChanges(V origEntity)` Returns a deep clone of an entity.
    `void` | `rollback()`
    `void` | `setRollbackOnly()`
    `V` | `updateIfChanged(V value, Predicate<V> shouldPut)`

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

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

- - ### Constructor Detail

    - #### ConcurrentHashMapKeycloakTransaction

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

  - ### 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(String key,
                                 ConcurrentHashMapKeycloakTransaction.MapTaskWithValue task)

      Adds a given task if not exists for the given key

    - #### registerEntityForChanges

          public V registerEntityForChanges(V origEntity)

      Returns a deep clone of an entity. If the clone is already in the transaction, returns this one.

      Usually used before giving an entity from a source back to the caller, to prevent changing it directly in the data store, but to keep transactional properties.

      Parameters:
        `origEntity` - Original entity
      Returns:

    - #### read

          public V read(String sKey)

      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. Updates to the returned instance would be visible in the current transaction and will propagate into the underlying store upon commit.
      Specified by:
        `read` in interface `MapKeycloakTransaction<V extends AbstractEntity & UpdatableEntity,M>`
      Parameters:
        `sKey` - identifier of a value
      Returns:
        a value associated with the given `key`

    - #### read

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

    - #### read

          public Stream<V> read(QueryParameters<M> queryParameters)

      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<V extends AbstractEntity & UpdatableEntity,M>`
      Parameters:
        `queryParameters` -
      Returns:

    - #### getCount

          public long getCount(QueryParameters<M> queryParameters)

      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<V extends AbstractEntity & UpdatableEntity,M>`
      Parameters:
        `queryParameters` - parameters for the query like firstResult, maxResult, requested ordering, etc.
      Returns:
        number of values present in the storage that fulfill the given criteria

    - #### create

          public V create(V value)

      Description copied from interface: `MapKeycloakTransaction`
      Instructs this transaction to add a new value into the underlying store on commit.

      Updates to the returned instances of `V` would be visible in the current transaction and will propagate into the underlying store upon commit.

      Specified by:
        `create` in interface `MapKeycloakTransaction<V extends AbstractEntity & UpdatableEntity,M>`
      Parameters:
        `value` - the value
      Returns:
        Entity representing the `value` in the store. It may or may not be the same instance as `value`

    - #### updateIfChanged

          public V updateIfChanged(V value,
                                   Predicate<V> shouldPut)

    - #### delete

          public boolean delete(String 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<V extends AbstractEntity & UpdatableEntity,M>`
      Parameters:
        `key` - identifier of a value
      Returns:
        Returns `true` if the object has been deleted or result cannot be determined, `false` otherwise.

    - #### delete

          public long delete(QueryParameters<M> queryParameters)

      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<V extends AbstractEntity & UpdatableEntity,M>`
      Parameters:
        `queryParameters` - parameters for the query like firstResult, maxResult, requested ordering, etc.
      Returns:
        number of removed objects (might return `-1` if not supported)

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