public abstract class AbstractResourceCacheResolvable extends Object implements ResourceCacheResolvable
ResourceCacheResolvable
base class.Constructor and Description |
---|
AbstractResourceCacheResolvable() |
Modifier and Type | Method and 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 a
ResourceDataCache that represents the underlying cache store. |
boolean |
isCacheable(Resource resource)
Returns true if the given
resource 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)
Sets
ResourceDataCache . |
Object |
toCacheData(Resource resource)
Convert the given
resource to a cacheable data object to be stored in ResourceDataCache . |
public boolean isCacheEnabled()
isCacheEnabled
in interface ResourceCacheResolvable
public void setCacheEnabled(boolean cacheEnabled)
cacheEnabled
- flag whether or not this is enabled with cachingpublic boolean isCacheable(Resource resource)
resource
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
any Resource
representations into cache store if this method returns false.
isCacheable
in interface ResourceCacheResolvable
resource
- resource representationresource
is cacheablepublic ValueMap createCacheKey(String resourceSpace, String operationKey, String resourcePath, Map<String,Object> pathVariables, ExchangeHint exchangeHint)
ResourceCacheResolvable
createCacheKey
in interface ResourceCacheResolvable
resourceSpace
- resource space nameoperationKey
- a unique operation name given by a ResourceServiceBroker
.resourcePath
- absolute path of a Resource
pathVariables
- the variables to expand the template given by absPath
exchangeHint
- a message exchange hint for the backendpublic Object toCacheData(Resource resource) throws IOException
resource
to a cacheable data object to be stored in ResourceDataCache
.
Implementations may simply return the resource
object directly without any conversion if the the
resource
object can be stored (for example, the resource
object is serializable) into the
underlying cache store.
Otherwise, the resource
object can be converted to something else and returned in order to be stored
into the underlying cache store by implementations.
toCacheData
in interface ResourceCacheResolvable
resource
- resource representationresource
to a cacheable data object to be stored in ResourceDataCache
IOException
- if IO error occurspublic Resource fromCacheData(Object cacheData) throws IOException
cacheData
from the ResourceDataCache
to a Resource
object.
Implementations may simply cast the cacheData
object directly to Resource
object without
any conversion if the the resource object was stored directly into the underlying cache store.
Otherwise, the cacheData
object can be converted back to a Resource
object by implementations.
fromCacheData
in interface ResourceCacheResolvable
cacheData
- cached data object that is stored in ResourceDataCache
Resource
object converted from the cacheData
IOException
- if IO error occurspublic ResourceDataCache getResourceDataCache()
ResourceDataCache
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 default ResourceDataCache
instance as a fallback cache store.
getResourceDataCache
in interface ResourceCacheResolvable
ResourceDataCache
that represents the underlying cache storepublic void setResourceDataCache(ResourceDataCache resourceDataCache)
ResourceDataCache
.resourceDataCache
- ResourceDataCache
representing an underlying cache store for Resource
representationsCopyright © 2017–2020 Hippo B.V. (http://www.onehippo.com). All rights reserved.