Class AbstractResourceCacheResolvable
- All Implemented Interfaces:
ResourceCacheResolvable
- Direct Known Subclasses:
AbstractResourceResolver
ResourceCacheResolvable
base class.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncreateCacheKey
(String resourceSpace, String operationKey, String resourcePath, Map<String, Object> pathVariables, ExchangeHint exchangeHint) Create cache key based on given operation key, resource path, path variables and exchange hint.fromCacheData
(Object cacheData) Returns aResourceDataCache
that represents the underlying cache store.boolean
isCacheable
(Resource resource) Returns true if the givenresource
is cacheable.boolean
Returns true if caching is enabled with this.void
setCacheEnabled
(boolean cacheEnabled) Sets flag whether or not this is enabled with caching.void
setResourceDataCache
(ResourceDataCache resourceDataCache) SetsResourceDataCache
.toCacheData
(Resource resource) Convert the givenresource
to a cacheable data object to be stored inResourceDataCache
.
-
Constructor Details
-
AbstractResourceCacheResolvable
public AbstractResourceCacheResolvable()
-
-
Method Details
-
isCacheEnabled
public boolean isCacheEnabled()Returns true if caching is enabled with this.- Specified by:
isCacheEnabled
in interfaceResourceCacheResolvable
- Returns:
- true if caching is enabled with this
-
setCacheEnabled
public void setCacheEnabled(boolean cacheEnabled) Sets flag whether or not this is enabled with caching.- Parameters:
cacheEnabled
- flag whether or not this is enabled with caching
-
isCacheable
Returns true if the givenresource
is cacheable.Note that if an implementation does not want to cache
Resource
representations at all for any reason, then it may always return false.ResourceServiceBroker
implementation should not try to cache anyResource
representations into cache store if this method returns false.- Specified by:
isCacheable
in interfaceResourceCacheResolvable
- Parameters:
resource
- resource representation- Returns:
- true if the given
resource
is cacheable
-
createCacheKey
public ValueMap createCacheKey(String resourceSpace, String operationKey, String resourcePath, Map<String, Object> pathVariables, ExchangeHint exchangeHint) Description copied from interface:ResourceCacheResolvable
Create cache key based on given operation key, resource path, path variables and exchange hint. Or return null if no cache should be available.- Specified by:
createCacheKey
in interfaceResourceCacheResolvable
- Parameters:
resourceSpace
- resource space nameoperationKey
- a unique operation name given by aResourceServiceBroker
.resourcePath
- absolute path of aResource
pathVariables
- the variables to expand the template given byabsPath
exchangeHint
- a message exchange hint for the backend- Returns:
- cache key based on given operation key, resource path, path variables and exchange hint, or null if no cache should be available
-
toCacheData
Convert the givenresource
to a cacheable data object to be stored inResourceDataCache
.Implementations may simply return the
resource
object directly without any conversion if the theresource
object can be stored (for example, theresource
object is serializable) into the underlying cache store. Otherwise, theresource
object can be converted to something else and returned in order to be stored into the underlying cache store by implementations.- Specified by:
toCacheData
in interfaceResourceCacheResolvable
- Parameters:
resource
- resource representation- Returns:
- converted the given
resource
to a cacheable data object to be stored inResourceDataCache
- Throws:
IOException
- if IO error occurs
-
fromCacheData
Convert and restore back the givencacheData
from theResourceDataCache
to aResource
object.Implementations may simply cast the
cacheData
object directly toResource
object without any conversion if the the resource object was stored directly into the underlying cache store. Otherwise, thecacheData
object can be converted back to aResource
object by implementations.- Specified by:
fromCacheData
in interfaceResourceCacheResolvable
- Parameters:
cacheData
- cached data object that is stored inResourceDataCache
- Returns:
Resource
object converted from thecacheData
- Throws:
IOException
- if IO error occurs
-
getResourceDataCache
Returns aResourceDataCache
that represents the underlying cache store.Note that an implementation may return null if it doesn't want to have its own cache store representation. In that case, a
ResourceServiceBroker
implementation may use a defaultResourceDataCache
instance as a fallback cache store.- Specified by:
getResourceDataCache
in interfaceResourceCacheResolvable
- Returns:
- a
ResourceDataCache
that represents the underlying cache store
-
setResourceDataCache
SetsResourceDataCache
.- Parameters:
resourceDataCache
-ResourceDataCache
representing an underlying cache store forResource
representations
-