Class BaseMetadataCacheBuilderSpec<IdentifierType,MetadataType>
- java.lang.Object
-
- net.shibboleth.oidc.metadata.cache.impl.BaseMetadataCacheBuilderSpec<IdentifierType,MetadataType>
-
- Type Parameters:
IdentifierType- the identifier type.MetadataType- the metadata type.
- Direct Known Subclasses:
BatchMetadataCacheBuilderSpec,DynamicMetadataCacheBuilderSpec,FetchThroughMetadataCacheBuilderSpec
public abstract class BaseMetadataCacheBuilderSpec<IdentifierType,MetadataType> extends Object
A based metadata cache builder specification.
-
-
Field Summary
Fields Modifier and Type Field Description private StringcacheIdAn identifier to give the cache this specification builds.private Function<CriteriaSet,IdentifierType>criteriaToIdentifierStrategyMap criteria to identifiers to use as keys to the backing store.private Function<MetadataType,IdentifierType>identifierExtractionStrategyStrategy used to extract an identifier from the given metadata.private BiConsumer<List<MetadataType>,IdentifierType>metadataBeforeRemovalHookA hook that is executed just before a cache entry will been removed/invalidated/evicted.private BiFunction<MetadataType,MetadataFilterContext,MetadataType>metadataFilterStrategyA strategy to filter metadata.private Predicate<MetadataType>metadataValidPredicateIs the metadata valid? Defaults to true.private FloatrefreshDelayFactorFactor used to compute when the next refresh interval will occur.
-
Constructor Summary
Constructors Modifier Constructor Description protectedBaseMetadataCacheBuilderSpec()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StringgetCacheId()Get the cache identifier.protected Function<CriteriaSet,IdentifierType>getCriteriaToIdentifierStrategy()Get the criteria set to identifier lookup strategy.protected Function<MetadataType,IdentifierType>getIdentifierExtractionStrategy()Get the identifier extraction strategy.protected BiConsumer<List<MetadataType>,IdentifierType>getMetadataBeforeRemovalHook()Get the metadata before removal hook.protected BiFunction<MetadataType,MetadataFilterContext,MetadataType>getMetadataFilterStrategy()Get the metadata filter strategy.protected Predicate<MetadataType>getMetadataValidPredicate()Get the predicate which determines if a piece of metadata is valid or not.protected FloatgetRefreshDelayFactor()Gets the delay factor used to compute the next refresh time.voidsetCacheId(String id)Set the cache identifier of the cache this specification builds.voidsetCriteriaToIdentifierStrategy(Function<CriteriaSet,IdentifierType> strategy)Set the criteria set to identifier lookup strategy.voidsetIdentifierExtractionStrategy(Function<MetadataType,IdentifierType> strategy)Set the identifier extraction strategy.voidsetMetadataBeforeRemovalHook(BiConsumer<List<MetadataType>,IdentifierType> hook)Set a hook to run before a metadata cache entry is removed from the cache.voidsetMetadataFilterStrategy(BiFunction<MetadataType,MetadataFilterContext,MetadataType> strategy)Set the metadata filtering strategy.voidsetMetadataValidPredicate(Predicate<MetadataType> predicate)Set the predicate which determines if a piece of metadata is valid or not.voidsetRefreshDelayFactor(Float factor)Sets the delay factor used to compute the next refresh time.
-
-
-
Field Detail
-
refreshDelayFactor
@Positive private Float refreshDelayFactor
Factor used to compute when the next refresh interval will occur. Default value: 0.75
-
identifierExtractionStrategy
@Nullable private Function<MetadataType,IdentifierType> identifierExtractionStrategy
Strategy used to extract an identifier from the given metadata.
-
criteriaToIdentifierStrategy
@Nullable private Function<CriteriaSet,IdentifierType> criteriaToIdentifierStrategy
Map criteria to identifiers to use as keys to the backing store.
-
metadataFilterStrategy
@Nonnull private BiFunction<MetadataType,MetadataFilterContext,MetadataType> metadataFilterStrategy
A strategy to filter metadata.
-
cacheId
@Nonnull private String cacheId
An identifier to give the cache this specification builds. Used for logging.
-
metadataBeforeRemovalHook
@Nullable private BiConsumer<List<MetadataType>,IdentifierType> metadataBeforeRemovalHook
A hook that is executed just before a cache entry will been removed/invalidated/evicted. The metadata list could be null, the identifier is never null.
-
metadataValidPredicate
@Nonnull private Predicate<MetadataType> metadataValidPredicate
Is the metadata valid? Defaults to true.
-
-
Method Detail
-
setMetadataValidPredicate
public void setMetadataValidPredicate(@Nonnull Predicate<MetadataType> predicate)Set the predicate which determines if a piece of metadata is valid or not.- Parameters:
predicate- the predicate.
-
getMetadataValidPredicate
@Nonnull protected Predicate<MetadataType> getMetadataValidPredicate()
Get the predicate which determines if a piece of metadata is valid or not.- Returns:
- the predicate.
-
setCacheId
public void setCacheId(@Nonnull @NotEmpty String id)
Set the cache identifier of the cache this specification builds.- Parameters:
id- the cache identifier.
-
getCacheId
@Nonnull protected String getCacheId()
Get the cache identifier.- Returns:
- the cache identifier.
-
setMetadataBeforeRemovalHook
public void setMetadataBeforeRemovalHook(@Nullable BiConsumer<List<MetadataType>,IdentifierType> hook)Set a hook to run before a metadata cache entry is removed from the cache.The hook is required to gracefully handle null metadata lists.
- Parameters:
hook- the hook to run.
-
getMetadataBeforeRemovalHook
@Nullable protected BiConsumer<List<MetadataType>,IdentifierType> getMetadataBeforeRemovalHook()
Get the metadata before removal hook. Could be null.- Returns:
- the hook.
-
setMetadataFilterStrategy
public void setMetadataFilterStrategy(@Nonnull BiFunction<MetadataType,MetadataFilterContext,MetadataType> strategy)Set the metadata filtering strategy.Defaults to a no-op strategy.
- Parameters:
strategy- the metadata filtering strategy.
-
getMetadataFilterStrategy
@Nonnull protected BiFunction<MetadataType,MetadataFilterContext,MetadataType> getMetadataFilterStrategy()
Get the metadata filter strategy.- Returns:
- the metadata filtering strategy
-
setIdentifierExtractionStrategy
public void setIdentifierExtractionStrategy(@Nonnull Function<MetadataType,IdentifierType> strategy)Set the identifier extraction strategy.- Parameters:
strategy- the strategy to set.
-
getIdentifierExtractionStrategy
@Nullable protected Function<MetadataType,IdentifierType> getIdentifierExtractionStrategy()
Get the identifier extraction strategy.- Returns:
- strategy the strategy.
-
setCriteriaToIdentifierStrategy
public void setCriteriaToIdentifierStrategy(@Nonnull Function<CriteriaSet,IdentifierType> strategy)Set the criteria set to identifier lookup strategy.- Parameters:
strategy- the strategy to set.
-
getCriteriaToIdentifierStrategy
@Nullable protected Function<CriteriaSet,IdentifierType> getCriteriaToIdentifierStrategy()
Get the criteria set to identifier lookup strategy.- Returns:
- strategy the strategy.
-
getRefreshDelayFactor
@Nonnull protected Float getRefreshDelayFactor()
Gets the delay factor used to compute the next refresh time.Defaults to: 0.75.
- Returns:
- delay factor used to compute the next refresh time
-
setRefreshDelayFactor
public void setRefreshDelayFactor(@Nonnull Float factor)Sets the delay factor used to compute the next refresh time. The delay must be between 0.0 and 1.0, exclusive.Defaults to: 0.75.
- Parameters:
factor- delay factor used to compute the next refresh time
-
-