ProviderType
- This type will be used for looking for factories that produce instances of desired providersStorageProviderModelType
- Type of model used for creating provider, it needs to extend
CacheableStorageProviderModel as it has isEnabled()
method and also extend
PrioritizedComponentModel which is required for sorting providers based on its
prioritiespublic abstract class AbstractStorageManager<ProviderType extends Provider,StorageProviderModelType extends CacheableStorageProviderModel> extends Object
Modifier and Type | Field and Description |
---|---|
protected KeycloakSession |
session |
Constructor and Description |
---|
AbstractStorageManager(KeycloakSession session,
Class<? extends ProviderFactory> factoryTypeClass,
Class<ProviderType> providerTypeClass,
Function<ComponentModel,StorageProviderModelType> toStorageProviderModelTypeFunction,
String configScope) |
Modifier and Type | Method and Description |
---|---|
protected <T> void |
consumeEnabledStorageProvidersWithTimeout(RealmModel realm,
Class<T> capabilityInterface,
Consumer<T> consumer)
Gets all enabled StorageProviders that implements the capabilityInterface and call applyFunction on each
!! Each StorageProvider has a limited time for consuming !!
|
protected <R,T> Stream<R> |
flatMapEnabledStorageProvidersWithTimeout(RealmModel realm,
Class<T> capabilityInterface,
Function<T,? extends Stream<R>> applyFunction)
Gets all enabled StorageProviders that implements the capabilityInterface, applies applyFunction on each of
them and then join the results together.
|
protected <T> Stream<T> |
getEnabledStorageProviders(RealmModel realm,
Class<T> capabilityInterface)
Returns stream of all storageProviders within the realm that implements the capabilityInterface.
|
protected <T extends ProviderType> |
getStorageProviderFactory(String providerId)
Returns a factory with the providerId, which produce instances of type CreatedProviderType
|
protected <T> T |
getStorageProviderInstance(RealmModel realm,
String providerId,
Class<T> capabilityInterface) |
protected <T> T |
getStorageProviderInstance(RealmModel realm,
String providerId,
Class<T> capabilityInterface,
boolean includeDisabled)
Returns an instance of provider with the providerId within the realm or null if storage provider with providerId
doesn't implement capabilityInterface.
|
protected <T> T |
getStorageProviderInstance(StorageProviderModelType model,
Class<T> capabilityInterface)
Returns an instance of provider for the model or null if storage provider based on the model doesn't implement capabilityInterface.
|
protected <T> T |
getStorageProviderInstance(StorageProviderModelType model,
Class<T> capabilityInterface,
boolean includeDisabled)
Returns an instance of provider for the model or null if storage provider based on the model doesn't implement capabilityInterface.
|
protected StorageProviderModelType |
getStorageProviderModel(RealmModel realm,
String providerId)
Returns an instance of StorageProvider model corresponding realm and providerId
|
static Stream<ComponentModel> |
getStorageProviderModels(RealmModel realm,
Class<? extends Provider> storageType)
Stream of ComponentModels of storageType.
|
protected Long |
getStorageProviderTimeout() |
protected <R,T> Stream<R> |
mapEnabledStorageProvidersWithTimeout(RealmModel realm,
Class<T> capabilityInterface,
Function<T,R> applyFunction)
Gets all enabled StorageProviders that implements the capabilityInterface, applies applyFunction on each of
them and returns the stream.
|
protected final KeycloakSession session
public AbstractStorageManager(KeycloakSession session, Class<? extends ProviderFactory> factoryTypeClass, Class<ProviderType> providerTypeClass, Function<ComponentModel,StorageProviderModelType> toStorageProviderModelTypeFunction, String configScope)
protected Long getStorageProviderTimeout()
protected <T extends ProviderType> ComponentFactory<T,ProviderType> getStorageProviderFactory(String providerId)
providerId
- id of factory that produce desired instancesComponentFactory<CreatedProviderType, ProviderType>
protected <T> Stream<T> getEnabledStorageProviders(RealmModel realm, Class<T> capabilityInterface)
realm
- realmcapabilityInterface
- class of desired capabilityInterface.
For example, GroupLookupProvider
or UserQueryProvider
protected <R,T> Stream<R> flatMapEnabledStorageProvidersWithTimeout(RealmModel realm, Class<T> capabilityInterface, Function<T,? extends Stream<R>> applyFunction)
R
- result of applyFunctionrealm
- realmcapabilityInterface
- class of desired capabilityInterface.
For example, GroupLookupProvider
or UserQueryProvider
applyFunction
- function that is applied on StorageProvidersprotected <R,T> Stream<R> mapEnabledStorageProvidersWithTimeout(RealmModel realm, Class<T> capabilityInterface, Function<T,R> applyFunction)
R
- Result of applyFunctionrealm
- realmcapabilityInterface
- class of desired capabilityInterface.
For example, GroupLookupProvider
or UserQueryProvider
applyFunction
- function that is applied on StorageProvidersprotected <T> void consumeEnabledStorageProvidersWithTimeout(RealmModel realm, Class<T> capabilityInterface, Consumer<T> consumer)
realm
- realmcapabilityInterface
- class of desired capabilityInterface.
For example, GroupLookupProvider
or UserQueryProvider
consumer
- function that is applied on StorageProvidersprotected <T> T getStorageProviderInstance(RealmModel realm, String providerId, Class<T> capabilityInterface)
protected <T> T getStorageProviderInstance(RealmModel realm, String providerId, Class<T> capabilityInterface, boolean includeDisabled)
realm
- realmproviderId
- id of ComponentModel within database/storagecapabilityInterface
- class of desired capabilityInterface.
For example, GroupLookupProvider
or UserQueryProvider
protected StorageProviderModelType getStorageProviderModel(RealmModel realm, String providerId)
realm
- Realm.providerId
- Id of desired provider.protected <T> T getStorageProviderInstance(StorageProviderModelType model, Class<T> capabilityInterface)
T
- Required capability interface typemodel
- StorageProviderModel obtained from database/storagecapabilityInterface
- class of desired capabilityInterface.
For example, GroupLookupProvider
or UserQueryProvider
protected <T> T getStorageProviderInstance(StorageProviderModelType model, Class<T> capabilityInterface, boolean includeDisabled)
model
- StorageProviderModel obtained from database/storagecapabilityInterface
- class of desired capabilityInterface.
For example, GroupLookupProvider
or UserQueryProvider
includeDisabled
- If set to true, the method will return also disabled providers.public static Stream<ComponentModel> getStorageProviderModels(RealmModel realm, Class<? extends Provider> storageType)
realm
- Realm.storageType
- Type.Copyright © 2021 JBoss by Red Hat. All rights reserved.