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 KeycloakTransaction
public void commit()
commit
in interface KeycloakTransaction
public void rollback()
rollback
in interface KeycloakTransaction
public void setRollbackOnly()
setRollbackOnly
in interface KeycloakTransaction
public boolean getRollbackOnly()
getRollbackOnly
in interface KeycloakTransaction
public boolean isActive()
isActive
in interface KeycloakTransaction
protected void addTask(K key, ConcurrentHashMapKeycloakTransaction.MapTaskWithValue task)
public V read(K key)
MapKeycloakTransaction
key
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 valuekey
public V read(K key, Function<K,V> defaultValueFunc)
MapKeycloakTransaction
defaultValueFunc
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 key
key
, or the result of defaultValueFunc
public Stream<V> read(ModelCriteriaBuilder<M> mcb)
read
in interface MapKeycloakTransaction<K,V extends AbstractEntity<K>,M>
mcb
- public long getCount(ModelCriteriaBuilder<M> mcb)
MapKeycloakTransaction
getCount
in interface MapKeycloakTransaction<K,V extends AbstractEntity<K>,M>
mcb
- criteria to filter valuespublic V getUpdated(V orig)
MapKeycloakTransaction
orig
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)
MapKeycloakTransaction
value
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 value
value
- updated version of the valuepublic void create(K key, V value)
MapKeycloakTransaction
create
in interface MapKeycloakTransaction<K,V extends AbstractEntity<K>,M>
key
- an identifier that will be associated with the value
value
- the valuepublic void updateIfChanged(K key, V value, Predicate<V> shouldPut)
MapKeycloakTransaction
value
associated with the identifier key
in the
underlying store on commit, if by the time of commit
the shouldPut
predicate returns true
updateIfChanged
in interface MapKeycloakTransaction<K,V extends AbstractEntity<K>,M>
key
- identifier of the value
value
- new version of the valueshouldPut
- predicate to check in commit phasepublic void delete(K key)
MapKeycloakTransaction
key
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)
MapKeycloakTransaction
mcb
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.