public class AnnotationBasedExpiration<K,V> extends Object implements BeanFactoryAware, org.apache.geode.cache.CustomExpiry<K,V>
AnnotationBasedExpiration
class is an implementation of the CustomExpiry
interface
that determines the Time-To-Live (TTL) or Idle-Timeout (TTI) expiration policy of a Region
entry
by introspecting the Region
entry's class type and reflecting on any Region
entries annotated
with SDG's Expiration-based Annotations.Annotation
,
BeanFactory
,
BeanFactoryAware
,
ExpirationActionType
,
Expiration
,
IdleTimeoutExpiration
,
TimeToLiveExpiration
,
CustomExpiry
,
ExpirationAction
,
ExpirationAttributes
,
Region
Modifier and Type | Class and Description |
---|---|
protected static class |
AnnotationBasedExpiration.ExpirationMetaData
The ExpirationMetaData class encapsulates the settings constituting the expiration policy including
the expiration timeout and the action performed when expiration occurs.
|
Modifier and Type | Field and Description |
---|---|
protected static AtomicReference<BeanFactory> |
BEAN_FACTORY_REFERENCE |
protected static AtomicReference<StandardEvaluationContext> |
EVALUATION_CONTEXT_REFERENCE |
Constructor and Description |
---|
AnnotationBasedExpiration()
Constructs a new instance of the AnnotationBasedExpiration class with no default expiration policy.
|
AnnotationBasedExpiration(org.apache.geode.cache.ExpirationAttributes defaultExpirationAttributes)
Constructs a new instance of
AnnotationBasedExpiration initialized with a specific, default
expiration policy. |
Modifier and Type | Method and Description |
---|---|
void |
close()
Called when the Region containing this callback is closed or destroyed, when the Cache is closed,
or when a callback is removed from a Region using an AttributesMutator.
|
static <K,V> AnnotationBasedExpiration<K,V> |
forIdleTimeout()
Factory method used to construct an instance of
AnnotationBasedExpiration having no default
ExpirationAttributes to process expired annotated Region entries
using Idle Timeout (TTI) Expiration. |
static <K,V> AnnotationBasedExpiration<K,V> |
forIdleTimeout(org.apache.geode.cache.ExpirationAttributes defaultExpirationAttributes)
Factory method used to construct an instance of
AnnotationBasedExpiration initialized with
default ExpirationAttributes to process expired annotated Region entries
using Idle Timeout (TTI) expiration. |
static <K,V> AnnotationBasedExpiration<K,V> |
forTimeToLive()
Factory method used to construct an instance of
AnnotationBasedExpiration having no default
ExpirationAttributes to process expired annotated Region entries
using Time-To-Live (TTL) Expiration. |
static <K,V> AnnotationBasedExpiration<K,V> |
forTimeToLive(org.apache.geode.cache.ExpirationAttributes defaultExpirationAttributes)
Factory method used to construct an instance of
AnnotationBasedExpiration initialized with
default ExpirationAttributes to process expired annotated Region entries
using Time-To-Live (TTL) expiration. |
protected BeanFactory |
getBeanFactory()
Gets a reference to the Spring
BeanFactory in which this AnnotationBasedExpiration bean
is managed. |
protected org.apache.geode.cache.ExpirationAttributes |
getDefaultExpirationAttributes()
Gets the expiration policy used by default when no application domain object specific expiration meta-data
has been specified.
|
protected Expiration |
getExpiration(org.apache.geode.cache.Region.Entry<K,V> entry)
Gets the Expiration Annotation meta-data from the Region Entry.
|
protected AnnotationBasedExpiration.ExpirationMetaData |
getExpirationMetaData(org.apache.geode.cache.Region.Entry<K,V> entry)
Gets custom expiration (Annotation-based) policy meta-data for the given
Region entry. |
org.apache.geode.cache.ExpirationAttributes |
getExpiry(org.apache.geode.cache.Region.Entry<K,V> entry)
Calculate the expiration for a given entry.
|
protected IdleTimeoutExpiration |
getIdleTimeout(org.apache.geode.cache.Region.Entry<K,V> entry)
Gets the IdleTimeoutExpiration Annotation meta-data from the Region Entry.
|
protected TimeToLiveExpiration |
getTimeToLive(org.apache.geode.cache.Region.Entry<K,V> entry)
Gets the TimeToLiveExpiration Annotation meta-data from the Region Entry.
|
protected void |
initEvaluationContext()
Initializes the Spring Expression Language (SpEL)
EvaluationContext used to parse property placeholder
and SpEL expressions in the Expiration annotation attribute values. |
protected boolean |
isExpirationConfigured(org.apache.geode.cache.Region.Entry<K,V> entry)
Determines whether the Region Entry has been annotated with the Expiration Annotation.
|
protected boolean |
isIdleTimeoutConfigured(org.apache.geode.cache.Region.Entry<K,V> entry)
Determines whether the Region Entry has been annotated with the IdleTimeoutExpiration Annotation.
|
protected boolean |
isTimeToLiveConfigured(org.apache.geode.cache.Region.Entry<K,V> entry)
Determines whether the Region Entry has been annotated with the TimeToLiveExpiration Annotation.
|
protected org.apache.geode.cache.ExpirationAttributes |
newExpirationAttributes(AnnotationBasedExpiration.ExpirationMetaData expirationMetaData)
Constructs a new instance of
ExpirationAttributes configured with the application domain object
specific expiration policy. |
void |
setBeanFactory(BeanFactory beanFactory)
Sets the
BeanFactory managing this AnnotationBasedExpiration bean in the Spring context. |
void |
setDefaultExpirationAttributes(org.apache.geode.cache.ExpirationAttributes defaultExpirationAttributes)
Sets the expiration policy to use by default when no application domain object specific expiration meta-data
has been specified.
|
protected static final AtomicReference<BeanFactory> BEAN_FACTORY_REFERENCE
protected static final AtomicReference<StandardEvaluationContext> EVALUATION_CONTEXT_REFERENCE
public AnnotationBasedExpiration()
public AnnotationBasedExpiration(org.apache.geode.cache.ExpirationAttributes defaultExpirationAttributes)
AnnotationBasedExpiration
initialized with a specific, default
expiration policy.defaultExpirationAttributes
- expiration settings used as the default expiration policy.ExpirationAttributes
public static <K,V> AnnotationBasedExpiration<K,V> forIdleTimeout()
AnnotationBasedExpiration
having no default
ExpirationAttributes
to process expired annotated Region
entries
using Idle Timeout (TTI) Expiration.K
- Class
type of the Region
entry key.V
- Class
type of the Region
entry value.AnnotationBasedExpiration
instance to process expired annotated Region
entries
using Idle Timeout expiration.AnnotationBasedExpiration
,
IdleTimeoutExpiration
,
forIdleTimeout(org.apache.geode.cache.ExpirationAttributes)
public static <K,V> AnnotationBasedExpiration<K,V> forIdleTimeout(org.apache.geode.cache.ExpirationAttributes defaultExpirationAttributes)
AnnotationBasedExpiration
initialized with
default ExpirationAttributes
to process expired annotated Region
entries
using Idle Timeout (TTI) expiration.K
- Class
type of the Region
entry key.V
- Class
type of the Region
entry value.defaultExpirationAttributes
- ExpirationAttributes
used by default if no expiration policy
was specified on the Region
.AnnotationBasedExpiration
instance to process expired annotated Region
entries
using Idle Timeout expiration.AnnotationBasedExpiration
,
IdleTimeoutExpiration
,
AnnotationBasedExpiration(ExpirationAttributes)
public static <K,V> AnnotationBasedExpiration<K,V> forTimeToLive()
AnnotationBasedExpiration
having no default
ExpirationAttributes
to process expired annotated Region
entries
using Time-To-Live (TTL) Expiration.K
- Class
type of the Region
entry key.V
- Class
type of the Region
entry value.AnnotationBasedExpiration
instance to process expired annotated Region
entries
using Time-To-Live expiration.AnnotationBasedExpiration
,
TimeToLiveExpiration
,
forTimeToLive(org.apache.geode.cache.ExpirationAttributes)
public static <K,V> AnnotationBasedExpiration<K,V> forTimeToLive(org.apache.geode.cache.ExpirationAttributes defaultExpirationAttributes)
AnnotationBasedExpiration
initialized with
default ExpirationAttributes
to process expired annotated Region
entries
using Time-To-Live (TTL) expiration.K
- Class
type of the Region
entry key.V
- Class
type of the Region
entry value.defaultExpirationAttributes
- ExpirationAttributes
used by default if no expiration policy
was specified on the Region
.AnnotationBasedExpiration
instance to process expired annotated Region
entries
using Time-To-Live expiration.AnnotationBasedExpiration
,
TimeToLiveExpiration
,
AnnotationBasedExpiration(ExpirationAttributes)
protected void initEvaluationContext()
EvaluationContext
used to parse property placeholder
and SpEL expressions in the Expiration annotation attribute values.public void setBeanFactory(BeanFactory beanFactory) throws BeansException
BeanFactory
managing this AnnotationBasedExpiration
bean in the Spring context.setBeanFactory
in interface BeanFactoryAware
beanFactory
- the Spring BeanFactory
to which this bean belongs.BeansException
- if the BeanFactory
reference cannot be initialized.BeanFactory
,
initEvaluationContext()
protected BeanFactory getBeanFactory()
BeanFactory
in which this AnnotationBasedExpiration
bean
is managed.BeanFactory
.IllegalStateException
- if the BeanFactory
reference was not properly initialized.BeanFactory
public void setDefaultExpirationAttributes(org.apache.geode.cache.ExpirationAttributes defaultExpirationAttributes)
defaultExpirationAttributes
- expiration settings used as the default expiration policy.getDefaultExpirationAttributes()
,
ExpirationAttributes
protected org.apache.geode.cache.ExpirationAttributes getDefaultExpirationAttributes()
setDefaultExpirationAttributes(org.apache.geode.cache.ExpirationAttributes)
,
ExpirationAttributes
public org.apache.geode.cache.ExpirationAttributes getExpiry(org.apache.geode.cache.Region.Entry<K,V> entry)
Region
should be used. The entry parameter should not be used after this method
invocation completes.getExpiry
in interface org.apache.geode.cache.CustomExpiry<K,V>
entry
- the entry used to determine the appropriate expiration policy.ExpirationAttributes
,
Region
,
getExpirationMetaData(Region.Entry)
,
newExpirationAttributes(ExpirationMetaData)
protected AnnotationBasedExpiration.ExpirationMetaData getExpirationMetaData(org.apache.geode.cache.Region.Entry<K,V> entry)
Region
entry.entry
- Region
entry used as the source of the expiration policy meta-data.AnnotationBasedExpiration.ExpirationMetaData
extracted from the Region
entry or null
if the expiration policy meta-data could not be determined from the Region
entry.AnnotationBasedExpiration.ExpirationMetaData
protected org.apache.geode.cache.ExpirationAttributes newExpirationAttributes(AnnotationBasedExpiration.ExpirationMetaData expirationMetaData)
ExpirationAttributes
configured with the application domain object
specific expiration policy. If the application domain object type has not been annotated with
custom expiration meta-data, then the default expiration settings are used.expirationMetaData
- application domain object specific expiration policy meta-data used to construct
the ExpirationAttributes
.ExpirationAttributes
configured from the application domain object specific
expiration policy or the default expiration settings if the application domain object has not been
annotated with custom expiration meta-data.AnnotationBasedExpiration.ExpirationMetaData
,
ExpirationAttributes
,
getDefaultExpirationAttributes()
protected boolean isExpirationConfigured(org.apache.geode.cache.Region.Entry<K,V> entry)
entry
- the Region.Entry to evaluate for the presence of the Expiration Annotation.Expiration
,
isAnnotationPresent(Object, Class)
protected Expiration getExpiration(org.apache.geode.cache.Region.Entry<K,V> entry)
entry
- the Region.Entry from which to extract the Expiration Annotation meta-data.null
if the Region Entry has not been annotated with @Expiration.Expiration
,
getAnnotation(Object, Class)
protected boolean isIdleTimeoutConfigured(org.apache.geode.cache.Region.Entry<K,V> entry)
entry
- the Region.Entry to evaluate for the presence of the IdleTimeoutExpiration Annotation.IdleTimeoutExpiration
,
isAnnotationPresent(Object, Class)
protected IdleTimeoutExpiration getIdleTimeout(org.apache.geode.cache.Region.Entry<K,V> entry)
entry
- the Region.Entry from which to extract the IdleTimeoutExpiration Annotation meta-data.null
if the Region Entry has not been annotated with @IdleTimeoutExpiration.IdleTimeoutExpiration
,
getAnnotation(Object, Class)
protected boolean isTimeToLiveConfigured(org.apache.geode.cache.Region.Entry<K,V> entry)
entry
- the Region.Entry to evaluate for the presence of the TimeToLiveExpiration Annotation.TimeToLiveExpiration
,
isAnnotationPresent(Object, Class)
protected TimeToLiveExpiration getTimeToLive(org.apache.geode.cache.Region.Entry<K,V> entry)
entry
- the Region.Entry from which to extract the TimeToLiveExpiration Annotation meta-data.null
if the Region Entry has not been annotated with @TimeToLiveExpiration.TimeToLiveExpiration
,
getAnnotation(Object, Class)
public void close()
close
in interface org.apache.geode.cache.CacheCallback
Copyright © 2011–2021 Pivotal Software, Inc.. All rights reserved.