Class ConcurrentHashMapStorage<K,V extends AbstractEntity & UpdatableEntity,M>
- java.lang.Object
- 
- org.keycloak.models.map.storage.chm.ConcurrentHashMapStorage<K,V,M>
 
- 
- All Implemented Interfaces:
- KeycloakTransaction,- HasRealmId,- MapStorage<V,M>
 - Direct Known Subclasses:
- FileMapStorage,- HotRodUserSessionMapStorage,- SingleUseObjectMapStorage
 
 public class ConcurrentHashMapStorage<K,V extends AbstractEntity & UpdatableEntity,M> extends Object implements MapStorage<V,M>, KeycloakTransaction, HasRealmId 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description protected classConcurrentHashMapStorage.MapTaskWithValue
 - 
Field SummaryFields Modifier and Type Field Description protected booleanactiveprotected DeepClonerclonerprotected Map<SearchableModelField<? super M>,MapModelCriteriaBuilder.UpdatePredicatesFunc<K,V,M>>fieldPredicatesprotected StringKeyConverter<K>keyConverterprotected CrudOperations<V,M>mapprotected EntityField<V>realmIdEntityFieldprotected booleanrollbackprotected Map<String,ConcurrentHashMapStorage.MapTaskWithValue>tasks
 - 
Constructor SummaryConstructors Constructor Description ConcurrentHashMapStorage(CrudOperations<V,M> map, StringKeyConverter<K> keyConverter, DeepCloner cloner, Map<SearchableModelField<? super M>,MapModelCriteriaBuilder.UpdatePredicatesFunc<K,V,M>> fieldPredicates)ConcurrentHashMapStorage(CrudOperations<V,M> map, StringKeyConverter<K> keyConverter, DeepCloner cloner, Map<SearchableModelField<? super M>,MapModelCriteriaBuilder.UpdatePredicatesFunc<K,V,M>> fieldPredicates, EntityField<V> realmIdEntityField)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddTask(String key, ConcurrentHashMapStorage.MapTaskWithValue task)Adds a given task if not exists for the given keyvoidbegin()voidcommit()Vcreate(V value)Instructs this storage to add a new value into the underlying store on commit in the context of the current transaction.booleandelete(String key)Instructs this storage to delete a value associated with the identifierkeyfrom the underlying store upon commit.longdelete(QueryParameters<M> queryParameters)Instructs this transaction to remove values (identified bymcbfilter) from the underlying store upon commit.booleanexists(String key)Returnstrueif the object with the givenkeyexists in the underlying storage with respect to changes done in the current transaction.longgetCount(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.StringgetRealmId()Returns realm ID of the entity.booleangetRollbackOnly()booleanisActive()Vread(String sKey)Provides possibility to lookup for values by akeyin the underlying store with respect to changes done in current transaction.Stream<V>read(QueryParameters<M> queryParameters)Returns the stream of records that match given criteria and includes changes made in this transaction, i.e.VregisterEntityForChanges(V origEntity)Returns a deep clone of an entity.voidrollback()voidsetRealmId(String realmId)Sets the realm ID of this object.voidsetRollbackOnly()VupdateIfChanged(V value, Predicate<V> shouldPut)- 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.keycloak.models.map.storage.MapStorageexists
 
- 
 
- 
- 
- 
Field Detail- 
activeprotected boolean active 
 - 
rollbackprotected boolean rollback 
 - 
tasksprotected final Map<String,ConcurrentHashMapStorage.MapTaskWithValue> tasks 
 - 
mapprotected final CrudOperations<V extends AbstractEntity & UpdatableEntity,M> map 
 - 
keyConverterprotected final StringKeyConverter<K> keyConverter 
 - 
clonerprotected final DeepCloner cloner 
 - 
fieldPredicatesprotected final Map<SearchableModelField<? super M>,MapModelCriteriaBuilder.UpdatePredicatesFunc<K,V extends AbstractEntity & UpdatableEntity,M>> fieldPredicates 
 - 
realmIdEntityFieldprotected final EntityField<V extends AbstractEntity & UpdatableEntity> realmIdEntityField 
 
- 
 - 
Constructor Detail- 
ConcurrentHashMapStoragepublic ConcurrentHashMapStorage(CrudOperations<V,M> map, StringKeyConverter<K> keyConverter, DeepCloner cloner, Map<SearchableModelField<? super M>,MapModelCriteriaBuilder.UpdatePredicatesFunc<K,V,M>> fieldPredicates) 
 - 
ConcurrentHashMapStoragepublic ConcurrentHashMapStorage(CrudOperations<V,M> map, StringKeyConverter<K> keyConverter, DeepCloner cloner, Map<SearchableModelField<? super M>,MapModelCriteriaBuilder.UpdatePredicatesFunc<K,V,M>> fieldPredicates, EntityField<V> realmIdEntityField) 
 
- 
 - 
Method Detail- 
beginpublic void begin() - Specified by:
- beginin interface- KeycloakTransaction
 
 - 
commitpublic void commit() - Specified by:
- commitin interface- KeycloakTransaction
 
 - 
rollbackpublic void rollback() - Specified by:
- rollbackin interface- KeycloakTransaction
 
 - 
setRollbackOnlypublic void setRollbackOnly() - Specified by:
- setRollbackOnlyin interface- KeycloakTransaction
 
 - 
getRollbackOnlypublic boolean getRollbackOnly() - Specified by:
- getRollbackOnlyin interface- KeycloakTransaction
 
 - 
isActivepublic boolean isActive() - Specified by:
- isActivein interface- KeycloakTransaction
 
 - 
addTaskprotected void addTask(String key, ConcurrentHashMapStorage.MapTaskWithValue task) Adds a given task if not exists for the given key
 - 
registerEntityForChangespublic 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:
 
 - 
readpublic V read(String sKey) Description copied from interface:MapStorageProvides possibility to lookup for values by akeyin 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. IfVimplementsExpirableEntitythis method should not return entities that are expired. SeeExpirableEntityJavaDoc for more details.- Specified by:
- readin interface- MapStorage<K,V extends AbstractEntity & UpdatableEntity>
- Parameters:
- sKey- identifier of a value
- Returns:
- a value associated with the given key
 
 - 
readpublic 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:
- readin interface- MapStorage<K,V extends AbstractEntity & UpdatableEntity>
- Parameters:
- queryParameters-
- Returns:
 
 - 
getCountpublic long getCount(QueryParameters<M> queryParameters) Description copied from interface:MapStorageReturns 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:
- getCountin interface- MapStorage<K,V extends AbstractEntity & UpdatableEntity>
- 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
 
 - 
createpublic V create(V value) Description copied from interface:MapStorageInstructs this storage to add a new value into the underlying store on commit in the context of the current transaction.Updates to the returned instances of Vwould be visible in the current transaction and will propagate into the underlying store upon commit. The ID of the entity passed in the parameter might change to a different value in the returned value if the underlying storage decided this was necessary. If the ID of the entity was null before, it will be set on the returned value.- Specified by:
- createin interface- MapStorage<K,V extends AbstractEntity & UpdatableEntity>
- Parameters:
- value- the value
- Returns:
- Entity representing the valuein the store. It may or may not be the same instance asvalue.
 
 - 
deletepublic boolean delete(String key) Description copied from interface:MapStorageInstructs this storage to delete a value associated with the identifierkeyfrom the underlying store upon commit.- Specified by:
- deletein interface- MapStorage<K,V extends AbstractEntity & UpdatableEntity>
- Parameters:
- key- identifier of a value
- Returns:
- Returns trueif the object has been deleted or result cannot be determined,falseotherwise.
 
 - 
deletepublic long delete(QueryParameters<M> queryParameters) Description copied from interface:MapStorageInstructs this transaction to remove values (identified bymcbfilter) from the underlying store upon commit.- Specified by:
- deletein interface- MapStorage<K,V extends AbstractEntity & UpdatableEntity>
- Parameters:
- queryParameters- parameters for the query like firstResult, maxResult, requested ordering, etc.
- Returns:
- number of removed objects (might return -1if not supported)
 
 - 
existspublic boolean exists(String key) Description copied from interface:MapStorageReturnstrueif the object with the givenkeyexists in the underlying storage with respect to changes done in the current transaction.falseotherwise.- Specified by:
- existsin interface- MapStorage<K,V extends AbstractEntity & UpdatableEntity>
- Parameters:
- key- Key of the object. Must not be- null.
- Returns:
- See description
 
 - 
getRealmIdpublic String getRealmId() Description copied from interface:HasRealmIdReturns realm ID of the entity.- Specified by:
- getRealmIdin interface- HasRealmId
- Returns:
- See description
 
 - 
setRealmIdpublic void setRealmId(String realmId) Description copied from interface:HasRealmIdSets the realm ID of this object.- Specified by:
- setRealmIdin interface- HasRealmId
- Parameters:
- realmId- Realm ID.
 
 
- 
 
-