Class DefaultConfigurationCache
- java.lang.Object
-
- com.hybris.cockpitng.core.config.impl.cache.DefaultConfigurationCache
-
- All Implemented Interfaces:
ConfigurationCache
public class DefaultConfigurationCache extends java.lang.Object implements ConfigurationCache
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classDefaultConfigurationCache.CachedContextImplprotected classDefaultConfigurationCache.CachedContextList
-
Constructor Summary
Constructors Constructor Description DefaultConfigurationCache()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcacheAttributes(DefaultConfigurationCache.CachedContextImpl context, java.util.Map<java.lang.String,java.lang.String> attributes)<C> voidcacheConfiguration(ConfigContext context, java.lang.Class<C> configType, C config)Sets configuration in cache.voidcacheContexts(Config config, java.util.Collection<Context> contexts, ConfigurationContextResolver resolver)Sets contexts for specified configuration.protected voidcacheMatchingContexts(java.lang.String name, java.lang.String value, java.util.Collection<DefaultConfigurationCache.CachedContextImpl> contexts)voidcacheRootConfiguration(Config config, long origin)Adds root configuration to cache.voidclear()Removes all values that has been cachedvoidclearAttributes()Removes all attributes for all contexts that has been cachedvoidclearAttributes(Context context)Removes all attributes for specified context that has been cachedvoidclearConfigurations()Removes all configurations that has been cached.ContextQuerycreateContextQuery(Config config, ContextAttributeComparator comparator)Initialises search for context basing on their attributesprotected java.util.Collection<DefaultConfigurationCache.CachedContextImpl>createContextsContainer(java.util.Collection<? extends Context> elements)protected java.util.stream.Stream<java.util.Map.Entry<java.lang.String,java.lang.String>>extractAttributes(java.util.stream.Stream<Context> contexts)protected java.util.stream.Stream<org.apache.commons.lang3.tuple.Pair<java.lang.String,java.lang.String>>extractConstantValues(ContextSearchRequest request, java.util.Set<java.lang.String> constants)java.util.Map<java.lang.String,java.lang.String>getAttributes(Context context)Gets cached attributes defined by provided contextprotected java.util.Collection<DefaultConfigurationCache.CachedContextImpl>getCachedMatchingContexts(java.lang.String name, java.lang.String value)<C> CgetConfiguration(ConfigContext context, java.lang.Class<C> configType)Gets configuration from cache.protected java.util.Map<ConfigContext,java.lang.Object>getConfigurations(java.lang.Class<?> configType)java.util.Collection<Context>getContexts(Config config)Gets cached contexts for provided configurationprotected java.util.Collection<DefaultConfigurationCache.CachedContextImpl>getContextsForAttribute(java.util.Collection<? extends Context> rootContexts, java.lang.String name, java.lang.String value, ContextAttributeComparator comparator)protected java.util.stream.Stream<Context>getMatchingContexts(java.util.Collection<? extends Context> contexts, java.util.stream.Stream<org.apache.commons.lang3.tuple.Pair<java.lang.String,java.lang.String>> attributes, ContextAttributeComparator comparator)ConfiggetRootConfiguration()Returns root configuration from cachebooleanisValid(long origin)Checks whether configuration is up to dateConfigurationSearchFilterprepareSearchFilter(ContextSearchRequest request, java.util.Set<java.lang.String> constants, ContextAttributeComparator comparator)Prepares an object that is able to decide which queries should not be evaluated.protected voidreleaseReadLock()protected voidreleaseWriteLock()protected voidrequestReadLock()protected voidrequestWriteLock()protected DefaultConfigurationCache.CachedContextImplwrapContext(DefaultConfigurationCache.CachedContextImpl parent, Context context)protected DefaultConfigurationCache.CachedContextImplwrapContext(Context context)
-
-
-
Method Detail
-
createContextsContainer
protected java.util.Collection<DefaultConfigurationCache.CachedContextImpl> createContextsContainer(java.util.Collection<? extends Context> elements)
-
isValid
public boolean isValid(long origin)
Description copied from interface:ConfigurationCacheChecks whether configuration is up to date- Specified by:
isValidin interfaceConfigurationCache- Parameters:
origin- last modification time of configuration- Returns:
trueif cache was valid and no changes where done
-
clear
public void clear()
Description copied from interface:ConfigurationCacheRemoves all values that has been cached- Specified by:
clearin interfaceConfigurationCache
-
getRootConfiguration
public Config getRootConfiguration()
Description copied from interface:ConfigurationCacheReturns root configuration from cache- Specified by:
getRootConfigurationin interfaceConfigurationCache- Returns:
- cached configuration or
nullif not available
-
cacheRootConfiguration
public void cacheRootConfiguration(Config config, long origin)
Description copied from interface:ConfigurationCacheAdds root configuration to cache.If any root configuration was already cached, then it is replaced
- Specified by:
cacheRootConfigurationin interfaceConfigurationCache- Parameters:
config- configuration to cacheorigin- origin time of configuration that is being cached
-
getContexts
public java.util.Collection<Context> getContexts(Config config)
Description copied from interface:ConfigurationCacheGets cached contexts for provided configuration- Specified by:
getContextsin interfaceConfigurationCache- Parameters:
config- configuration which contexts are requested- Returns:
- contexts cached or
nullif unavailable
-
cacheContexts
public void cacheContexts(Config config, java.util.Collection<Context> contexts, ConfigurationContextResolver resolver)
Description copied from interface:ConfigurationCacheSets contexts for specified configuration.If any contexts for this configuration was already cached, then they are replaced
- Specified by:
cacheContextsin interfaceConfigurationCache- Parameters:
config- configuration which contexts are being cachedcontexts- contexts to cacheresolver- an object able to retrieve all needed data from context
-
clearAttributes
public void clearAttributes()
Description copied from interface:ConfigurationCacheRemoves all attributes for all contexts that has been cached- Specified by:
clearAttributesin interfaceConfigurationCache- See Also:
ConfigurationCache.getAttributes(Context)
-
clearAttributes
public void clearAttributes(Context context)
Description copied from interface:ConfigurationCacheRemoves all attributes for specified context that has been cached- Specified by:
clearAttributesin interfaceConfigurationCache- See Also:
ConfigurationCache.getAttributes(Context)
-
getAttributes
public java.util.Map<java.lang.String,java.lang.String> getAttributes(Context context)
Description copied from interface:ConfigurationCacheGets cached attributes defined by provided context- Specified by:
getAttributesin interfaceConfigurationCache- Parameters:
context- context which attributes are requested- Returns:
- attributes <name, value> map or
nullif unavailable
-
createContextQuery
public ContextQuery createContextQuery(Config config, ContextAttributeComparator comparator)
Description copied from interface:ConfigurationCacheInitialises search for context basing on their attributes- Specified by:
createContextQueryin interfaceConfigurationCache- Parameters:
config- configuration which contexts are to be queriedcomparator- a object capable of comparing values of attributes- Returns:
- initialised query or
nullif configuration has been cached
-
cacheAttributes
protected void cacheAttributes(DefaultConfigurationCache.CachedContextImpl context, java.util.Map<java.lang.String,java.lang.String> attributes)
-
requestReadLock
protected void requestReadLock()
-
releaseReadLock
protected void releaseReadLock()
-
requestWriteLock
protected void requestWriteLock()
-
releaseWriteLock
protected void releaseWriteLock()
-
getCachedMatchingContexts
protected java.util.Collection<DefaultConfigurationCache.CachedContextImpl> getCachedMatchingContexts(java.lang.String name, java.lang.String value)
-
cacheMatchingContexts
protected void cacheMatchingContexts(java.lang.String name, java.lang.String value, java.util.Collection<DefaultConfigurationCache.CachedContextImpl> contexts)
-
getContextsForAttribute
protected java.util.Collection<DefaultConfigurationCache.CachedContextImpl> getContextsForAttribute(java.util.Collection<? extends Context> rootContexts, java.lang.String name, java.lang.String value, ContextAttributeComparator comparator)
-
clearConfigurations
public void clearConfigurations()
Description copied from interface:ConfigurationCacheRemoves all configurations that has been cached.- Specified by:
clearConfigurationsin interfaceConfigurationCache- See Also:
ConfigurationCache.getConfiguration(ConfigContext, Class),ConfigurationCache.cacheConfiguration(ConfigContext, Class, Object)
-
getConfiguration
public <C> C getConfiguration(ConfigContext context, java.lang.Class<C> configType)
Description copied from interface:ConfigurationCacheGets configuration from cache.- Specified by:
getConfigurationin interfaceConfigurationCache- Type Parameters:
C- type of configuration- Parameters:
context- context of requested configurationconfigType- expected configuration model class- Returns:
- configuration found or
nullif not available
-
getConfigurations
protected java.util.Map<ConfigContext,java.lang.Object> getConfigurations(java.lang.Class<?> configType)
-
cacheConfiguration
public <C> void cacheConfiguration(ConfigContext context, java.lang.Class<C> configType, C config)
Description copied from interface:ConfigurationCacheSets configuration in cache.If any configurations bound to provided context was already cached, then it is replaced
- Specified by:
cacheConfigurationin interfaceConfigurationCache- Parameters:
context- context of requested configurationconfig- configuration to be cached
-
extractConstantValues
protected java.util.stream.Stream<org.apache.commons.lang3.tuple.Pair<java.lang.String,java.lang.String>> extractConstantValues(ContextSearchRequest request, java.util.Set<java.lang.String> constants)
-
getMatchingContexts
protected java.util.stream.Stream<Context> getMatchingContexts(java.util.Collection<? extends Context> contexts, java.util.stream.Stream<org.apache.commons.lang3.tuple.Pair<java.lang.String,java.lang.String>> attributes, ContextAttributeComparator comparator)
-
extractAttributes
protected java.util.stream.Stream<java.util.Map.Entry<java.lang.String,java.lang.String>> extractAttributes(java.util.stream.Stream<Context> contexts)
-
prepareSearchFilter
public ConfigurationSearchFilter prepareSearchFilter(ContextSearchRequest request, java.util.Set<java.lang.String> constants, ContextAttributeComparator comparator)
Description copied from interface:ConfigurationCachePrepares an object that is able to decide which queries should not be evaluated.- Specified by:
prepareSearchFilterin interfaceConfigurationCache- Parameters:
request- request that will be processedconstants- attributes that will not change during the search- Returns:
- exclusions or
nullif all queries should be applied
-
wrapContext
protected DefaultConfigurationCache.CachedContextImpl wrapContext(DefaultConfigurationCache.CachedContextImpl parent, Context context)
-
wrapContext
protected DefaultConfigurationCache.CachedContextImpl wrapContext(Context context)
-
-