Class HotRodMapStorage<K,E extends AbstractHotRodEntity,V extends HotRodEntityDelegate<E> & AbstractEntity,M>
- java.lang.Object
-
- org.keycloak.models.map.storage.hotRod.HotRodMapStorage<K,E,V,M>
-
- All Implemented Interfaces:
ConcurrentHashMapCrudOperations<V,M>
,MapStorage<V,M>
public class HotRodMapStorage<K,E extends AbstractHotRodEntity,V extends HotRodEntityDelegate<E> & AbstractEntity,M> extends Object implements MapStorage<V,M>, ConcurrentHashMapCrudOperations<V,M>
-
-
Constructor Summary
Constructors Constructor Description HotRodMapStorage(org.infinispan.client.hotrod.RemoteCache<K,E> remoteCache, StringKeyConverter<K> keyConverter, HotRodEntityDescriptor<E,V> storedEntityDescriptor, DeepCloner cloner)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description V
create(V value)
Creates an object in the store.IckleQueryMapModelCriteriaBuilder<E,M>
createCriteriaBuilder()
MapKeycloakTransaction<V,M>
createTransaction(KeycloakSession session)
Creates aMapKeycloakTransaction
object that tracks a new transaction related to this storage.boolean
delete(String key)
Deletes object with the givenkey
from the storage, if exists, no-op otherwise.long
delete(QueryParameters<M> queryParameters)
Deletes objects that match the given criteria.long
getCount(QueryParameters<M> queryParameters)
Returns the number of objects satisfying givencriteria
from the storage.V
read(String key)
Returns object with the givenkey
from the storage ornull
if object does not exist.Stream<V>
read(QueryParameters<M> queryParameters)
Returns stream of objects satisfying givencriteria
from the storage.V
update(V value)
Updates the object with the key of thevalue
's ID in the storage if it already exists.
-
-
-
Constructor Detail
-
HotRodMapStorage
public HotRodMapStorage(org.infinispan.client.hotrod.RemoteCache<K,E> remoteCache, StringKeyConverter<K> keyConverter, HotRodEntityDescriptor<E,V> storedEntityDescriptor, DeepCloner cloner)
-
-
Method Detail
-
create
public V create(V value)
Description copied from interface:ConcurrentHashMapCrudOperations
Creates an object in the store. ID of thevalue
may be prescribed in id of thevalue
. If the id isnull
or its format is not matching the store internal format for ID, then thevalue
's ID will be generated and returned in the id of the return value.- Specified by:
create
in interfaceConcurrentHashMapCrudOperations<K,E extends AbstractHotRodEntity>
- Parameters:
value
- Entity to create in the store- Returns:
- Entity representing the
value
in the store. It may or may not be the same instance asvalue
- See Also:
AbstractEntity.getId()
-
read
public V read(String key)
Description copied from interface:ConcurrentHashMapCrudOperations
Returns object with the givenkey
from the storage ornull
if object does not exist.
TODO: Consider returningOptional<V>
instead.- Specified by:
read
in interfaceConcurrentHashMapCrudOperations<K,E extends AbstractHotRodEntity>
- Parameters:
key
- Key of the object. Must not benull
.- Returns:
- See description
-
update
public V update(V value)
Description copied from interface:ConcurrentHashMapCrudOperations
Updates the object with the key of thevalue
's ID in the storage if it already exists.- Specified by:
update
in interfaceConcurrentHashMapCrudOperations<K,E extends AbstractHotRodEntity>
- Parameters:
value
- Updated value- See Also:
AbstractEntity.getId()
-
delete
public boolean delete(String key)
Description copied from interface:ConcurrentHashMapCrudOperations
Deletes object with the givenkey
from the storage, if exists, no-op otherwise.- Specified by:
delete
in interfaceConcurrentHashMapCrudOperations<K,E extends AbstractHotRodEntity>
- Returns:
- Returns
true
if the object has been deleted or result cannot be determined,false
otherwise.
-
read
public Stream<V> read(QueryParameters<M> queryParameters)
Description copied from interface:ConcurrentHashMapCrudOperations
Returns stream of objects satisfying givencriteria
from the storage. The criteria are specified in the given criteria builder based on model properties.- Specified by:
read
in interfaceConcurrentHashMapCrudOperations<K,E extends AbstractHotRodEntity>
- Parameters:
queryParameters
- parameters for the query like firstResult, maxResult, requested ordering, etc.- Returns:
- Stream of objects. Never returns
null
.
-
getCount
public long getCount(QueryParameters<M> queryParameters)
Description copied from interface:ConcurrentHashMapCrudOperations
Returns the number of objects satisfying givencriteria
from the storage. The criteria are specified in the given criteria builder based on model properties.- Specified by:
getCount
in interfaceConcurrentHashMapCrudOperations<K,E extends AbstractHotRodEntity>
- Parameters:
queryParameters
- parameters for the query like firstResult, maxResult, requested ordering, etc.- Returns:
- Number of objects. Never returns
null
.
-
delete
public long delete(QueryParameters<M> queryParameters)
Description copied from interface:ConcurrentHashMapCrudOperations
Deletes objects that match the given criteria.- Specified by:
delete
in interfaceConcurrentHashMapCrudOperations<K,E extends AbstractHotRodEntity>
- Parameters:
queryParameters
- parameters for the query like firstResult, maxResult, requested ordering, etc.- Returns:
- Number of removed objects (might return
-1
if not supported)
-
createCriteriaBuilder
public IckleQueryMapModelCriteriaBuilder<E,M> createCriteriaBuilder()
-
createTransaction
public MapKeycloakTransaction<V,M> createTransaction(KeycloakSession session)
Description copied from interface:MapStorage
Creates aMapKeycloakTransaction
object that tracks a new transaction related to this storage. In case of JPA or similar, the transaction object might be supplied by the container (via JTA) or shared same across storages accessing the same database within the same session; in other cases (e.g. plain map) a separate transaction handler might be created per each storage.- Specified by:
createTransaction
in interfaceMapStorage<K,E extends AbstractHotRodEntity>
- Returns:
- See description. Never returns
null
-
-