Class AbstractResourceCacheResolvable
- java.lang.Object
-
- org.onehippo.cms7.crisp.api.resource.AbstractResourceCacheResolvable
-
- All Implemented Interfaces:
ResourceCacheResolvable
- Direct Known Subclasses:
AbstractResourceResolver
public abstract class AbstractResourceCacheResolvable extends Object implements ResourceCacheResolvable
AbstractResourceCacheResolvable
base class.
-
-
Constructor Summary
Constructors Constructor Description AbstractResourceCacheResolvable()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ValueMap
createCacheKey(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.Resource
fromCacheData(Object cacheData)
ResourceDataCache
getResourceDataCache()
Returns aResourceDataCache
that represents the underlying cache store.boolean
isCacheable(Resource resource)
Returns true if the givenresource
is cacheable.boolean
isCacheEnabled()
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
.Object
toCacheData(Resource resource)
Convert the givenresource
to a cacheable data object to be stored inResourceDataCache
.
-
-
-
Method Detail
-
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
public boolean isCacheable(Resource resource)
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
public Object toCacheData(Resource resource) throws IOException
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
public Resource fromCacheData(Object cacheData) throws IOException
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
public ResourceDataCache 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
public void setResourceDataCache(ResourceDataCache resourceDataCache)
SetsResourceDataCache
.- Parameters:
resourceDataCache
-ResourceDataCache
representing an underlying cache store forResource
representations
-
-