public class ConcurrentHashMapKeycloakTransaction<K,V extends AbstractEntity<K>,M> extends Object implements MapKeycloakTransaction<K,V,M>
| Modifier and Type | Class and Description |
|---|---|
protected class |
ConcurrentHashMapKeycloakTransaction.MapTaskWithValue |
| Constructor and Description |
|---|
ConcurrentHashMapKeycloakTransaction(MapStorage<K,V,M> map) |
| 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 |
public ConcurrentHashMapKeycloakTransaction(MapStorage<K,V,M> map)
public void begin()
begin in interface KeycloakTransactionpublic void commit()
commit in interface KeycloakTransactionpublic void rollback()
rollback in interface KeycloakTransactionpublic void setRollbackOnly()
setRollbackOnly in interface KeycloakTransactionpublic boolean getRollbackOnly()
getRollbackOnly in interface KeycloakTransactionpublic boolean isActive()
isActive in interface KeycloakTransactionprotected void addTask(K key, ConcurrentHashMapKeycloakTransaction.MapTaskWithValue task)
public V read(K key)
MapKeycloakTransactionkey in the underlying store with respect to changes done
in current transaction.read in interface MapKeycloakTransaction<K,V extends AbstractEntity<K>,M>key - identifier of a valuekeypublic V read(K key, Function<K,V> defaultValueFunc)
MapKeycloakTransactiondefaultValueFunc when
the transaction does not contain a value for the key identifier.read in interface MapKeycloakTransaction<K,V extends AbstractEntity<K>,M>key - identifier of a valuedefaultValueFunc - fallback function if the transaction does not contain a value that corresponds to keykey, or the result of defaultValueFuncpublic Stream<V> read(ModelCriteriaBuilder<M> mcb)
read in interface MapKeycloakTransaction<K,V extends AbstractEntity<K>,M>mcb - public long getCount(ModelCriteriaBuilder<M> mcb)
MapKeycloakTransactiongetCount in interface MapKeycloakTransaction<K,V extends AbstractEntity<K>,M>mcb - criteria to filter valuespublic V getUpdated(V orig)
MapKeycloakTransactionorig object as updated in this transaction.
If the underlying store handles transactions on its own, this can return orig directly.getUpdated in interface MapKeycloakTransaction<K,V extends AbstractEntity<K>,M>orig - possibly stale version of some object from the underlying storeorig object as visible from this transaction, or null if the object has been removed.public void update(K key, V value)
MapKeycloakTransactionvalue associated with the identifier key in the
underlying store on commit.update in interface MapKeycloakTransaction<K,V extends AbstractEntity<K>,M>key - identifier of the valuevalue - updated version of the valuepublic void create(K key, V value)
MapKeycloakTransactioncreate in interface MapKeycloakTransaction<K,V extends AbstractEntity<K>,M>key - an identifier that will be associated with the valuevalue - the valuepublic void updateIfChanged(K key, V value, Predicate<V> shouldPut)
MapKeycloakTransactionvalue associated with the identifier key in the
underlying store on commit, if by the time of commit the shouldPut predicate returns trueupdateIfChanged in interface MapKeycloakTransaction<K,V extends AbstractEntity<K>,M>key - identifier of the valuevalue - new version of the valueshouldPut - predicate to check in commit phasepublic void delete(K key)
MapKeycloakTransactionkey from the underlying store
on commit.delete in interface MapKeycloakTransaction<K,V extends AbstractEntity<K>,M>key - identifier of a valuepublic long delete(K artificialKey, ModelCriteriaBuilder<M> mcb)
MapKeycloakTransactionmcb filter) from the underlying store on commit.delete in interface MapKeycloakTransaction<K,V extends AbstractEntity<K>,M>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 transactionmcb - criteria to delete valuesCopyright © 2021 JBoss by Red Hat. All rights reserved.