Class DefaultSessionCachedContextProvider
- java.lang.Object
-
- de.hybris.platform.cms2.common.service.impl.DefaultSessionCachedContextProvider
-
- All Implemented Interfaces:
SessionCachedContextProvider
public class DefaultSessionCachedContextProvider extends java.lang.Object implements SessionCachedContextProvider
Default implementation ofSessionCachedContextProvider
-
-
Constructor Summary
Constructors Constructor Description DefaultSessionCachedContextProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> voidaddItemToListCache(java.lang.String cacheKey, T value)Add a value to a cachedList.<K,V>
voidaddItemToMapCache(java.lang.String cacheKey, K key, V value)Add an element to a cachedMap<T> voidaddItemToSetCache(java.lang.String cacheKey, T value)Add a value to a cachedSet.voidclearListCache(java.lang.String cacheKey)Clear a list cache by its key.voidclearMapCache(java.lang.String cacheKey)Clear a map cache by its key.voidclearSetCache(java.lang.String cacheKey)Clear a set cache by its key.voidcreateEmptyListCache(java.lang.String cacheKey)Creates an empty cachedList.<T> java.util.List<T>getAllItemsFromListCache(java.lang.String cacheKey)Return a cachedList.<K,V>
java.util.Map<K,V>getAllItemsFromMapCache(java.lang.String cacheKey)Returns a cachedMap<T> java.util.Set<T>getAllItemsFromSetCache(java.lang.String cacheKey)Return a cachedSet.protected <T> TgetOrCreateCollectionInCache(java.lang.String cacheKey, java.lang.Class classType)Get a collection from cache or create an empty collection and cache it using the providedcacheKeyprotected <T> TgetOrCreateListCollectionInCache(java.lang.String cacheKey)Get aListfrom cache or create an emptyList.protected <T> TgetOrCreateMapCollectionInCache(java.lang.String cacheKey)Get aMapfrom cache or create an emptyMap.protected <T> TgetOrCreateSetCollectionInCache(java.lang.String cacheKey)Get aSetfrom cache or create an emptySet.protected SessionServicegetSessionService()protected <T> TgetWrappedObject(java.lang.Object rawValue)Get the collection object saved in the cache for a given object.booleanhasCacheKey(java.lang.String cacheKey)Checks if there's a cache with the given key.<T> voidremoveItemFromListCache(java.lang.String cacheKey, T value)Remove element from a cached list.<K> voidremoveItemFromMapCache(java.lang.String cacheKey, K key)Remove an element from a cached list<T> voidremoveItemFromSetCache(java.lang.String cacheKey, T value)Remove element from a cached set.voidsetSessionService(SessionService sessionService)
-
-
-
Method Detail
-
addItemToSetCache
public <T> void addItemToSetCache(java.lang.String cacheKey, T value)Description copied from interface:SessionCachedContextProviderAdd a value to a cachedSet.- Specified by:
addItemToSetCachein interfaceSessionCachedContextProvider- Type Parameters:
T- type of the value- Parameters:
cacheKey- the cache key to find a cached setvalue- the value to add to a cached set
-
getAllItemsFromSetCache
public <T> java.util.Set<T> getAllItemsFromSetCache(java.lang.String cacheKey)
Description copied from interface:SessionCachedContextProviderReturn a cachedSet.- Specified by:
getAllItemsFromSetCachein interfaceSessionCachedContextProvider- Type Parameters:
T- type of a set element- Parameters:
cacheKey- the cache key to find a cached set- Returns:
- the cached
Set.
-
removeItemFromSetCache
public <T> void removeItemFromSetCache(java.lang.String cacheKey, T value)Description copied from interface:SessionCachedContextProviderRemove element from a cached set.- Specified by:
removeItemFromSetCachein interfaceSessionCachedContextProvider- Type Parameters:
T- type of the value- Parameters:
cacheKey- the cache key to find a cached setvalue- the value to remove from a cached set
-
clearSetCache
public void clearSetCache(java.lang.String cacheKey)
Description copied from interface:SessionCachedContextProviderClear a set cache by its key.- Specified by:
clearSetCachein interfaceSessionCachedContextProvider- Parameters:
cacheKey- the cache key
-
addItemToListCache
public <T> void addItemToListCache(java.lang.String cacheKey, T value)Description copied from interface:SessionCachedContextProviderAdd a value to a cachedList.- Specified by:
addItemToListCachein interfaceSessionCachedContextProvider- Type Parameters:
T- type of the value- Parameters:
cacheKey- the cache key to find a cached listvalue- the value to add to a cached list
-
createEmptyListCache
public void createEmptyListCache(java.lang.String cacheKey)
Description copied from interface:SessionCachedContextProviderCreates an empty cachedList.- Specified by:
createEmptyListCachein interfaceSessionCachedContextProvider- Parameters:
cacheKey- the cache key
-
getAllItemsFromListCache
public <T> java.util.List<T> getAllItemsFromListCache(java.lang.String cacheKey)
Description copied from interface:SessionCachedContextProviderReturn a cachedList.- Specified by:
getAllItemsFromListCachein interfaceSessionCachedContextProvider- Type Parameters:
T- type of a list element- Parameters:
cacheKey- the cache key to find a cached list- Returns:
- the cached
List.
-
removeItemFromListCache
public <T> void removeItemFromListCache(java.lang.String cacheKey, T value)Description copied from interface:SessionCachedContextProviderRemove element from a cached list.- Specified by:
removeItemFromListCachein interfaceSessionCachedContextProvider- Type Parameters:
T- type of the value- Parameters:
cacheKey- the cache key to find a cached listvalue- the value to remove from a cached list
-
clearListCache
public void clearListCache(java.lang.String cacheKey)
Description copied from interface:SessionCachedContextProviderClear a list cache by its key.- Specified by:
clearListCachein interfaceSessionCachedContextProvider- Parameters:
cacheKey- the cache key
-
addItemToMapCache
public <K,V> void addItemToMapCache(java.lang.String cacheKey, K key, V value)Description copied from interface:SessionCachedContextProviderAdd an element to a cachedMap- Specified by:
addItemToMapCachein interfaceSessionCachedContextProvider- Type Parameters:
K- type of the keyV- type of the value- Parameters:
cacheKey- the cache key to find a cached mapkey- the key for the valuevalue- the value
-
getAllItemsFromMapCache
public <K,V> java.util.Map<K,V> getAllItemsFromMapCache(java.lang.String cacheKey)
Description copied from interface:SessionCachedContextProviderReturns a cachedMap- Specified by:
getAllItemsFromMapCachein interfaceSessionCachedContextProvider- Type Parameters:
K- type of the keyV- type of the value- Parameters:
cacheKey- the cache key to find a cached map- Returns:
- the
Map
-
removeItemFromMapCache
public <K> void removeItemFromMapCache(java.lang.String cacheKey, K key)Description copied from interface:SessionCachedContextProviderRemove an element from a cached list- Specified by:
removeItemFromMapCachein interfaceSessionCachedContextProvider- Type Parameters:
K- type of the key- Parameters:
cacheKey- the cache key to find a cached mapkey- the key to remove
-
clearMapCache
public void clearMapCache(java.lang.String cacheKey)
Description copied from interface:SessionCachedContextProviderClear a map cache by its key.- Specified by:
clearMapCachein interfaceSessionCachedContextProvider- Parameters:
cacheKey- the cache key
-
hasCacheKey
public boolean hasCacheKey(java.lang.String cacheKey)
Description copied from interface:SessionCachedContextProviderChecks if there's a cache with the given key.- Specified by:
hasCacheKeyin interfaceSessionCachedContextProvider- Parameters:
cacheKey- the cache key- Returns:
- true if there's a cache with the given key. false otherwise.
-
getOrCreateSetCollectionInCache
protected <T> T getOrCreateSetCollectionInCache(java.lang.String cacheKey)
Get aSetfrom cache or create an emptySet.- Type Parameters:
T- the type of collection- Parameters:
cacheKey- the cache key to get or save a cached set- Returns:
- a
Setthat is stored in cache
-
getOrCreateListCollectionInCache
protected <T> T getOrCreateListCollectionInCache(java.lang.String cacheKey)
Get aListfrom cache or create an emptyList.- Type Parameters:
T- the type of collection- Parameters:
cacheKey- the cache key to get or save a cached list- Returns:
- a
Listthat is stored in cache
-
getOrCreateMapCollectionInCache
protected <T> T getOrCreateMapCollectionInCache(java.lang.String cacheKey)
Get aMapfrom cache or create an emptyMap.- Type Parameters:
T- the type of collection- Parameters:
cacheKey- the cache key to get or save a cached map- Returns:
- a
Mapthat is stored in cache
-
getOrCreateCollectionInCache
protected <T> T getOrCreateCollectionInCache(java.lang.String cacheKey, java.lang.Class classType)Get a collection from cache or create an empty collection and cache it using the providedcacheKey- Parameters:
cacheKey- the cache key to save a cached setclassType- theClassused to instantiate a new object- Returns:
- the cached
AtomicReference - Throws:
InvalidTypeException- when the providedclassTypefails to be instantiated
-
getWrappedObject
protected <T> T getWrappedObject(java.lang.Object rawValue)
Get the collection object saved in the cache for a given object.- Parameters:
rawValue- anAtomicReferenceobject containing the cached value- Returns:
- the cached value saved in the
AtomicReference - Throws:
java.lang.IllegalStateException- when the givenrawValueis not of typeAtomicReference
-
getSessionService
protected SessionService getSessionService()
-
setSessionService
public void setSessionService(SessionService sessionService)
-
-