Top Description Fields Constructors Methods
org.eclipse.persistence.descriptors.invalidation

public abstract Class CacheInvalidationPolicy

extends Object
implements Serializable, Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable, java.io.Serializable
Known Direct Subclasses
org.eclipse.persistence.descriptors.invalidation.DailyCacheInvalidationPolicy, org.eclipse.persistence.descriptors.invalidation.NoExpiryCacheInvalidationPolicy, org.eclipse.persistence.descriptors.invalidation.TimeToLiveCacheInvalidationPolicy
Imports
java.util.Random, org.eclipse.persistence.descriptors.ClassDescriptor, org.eclipse.persistence.internal.identitymaps.CacheKey, org.eclipse.persistence.internal.sessions.AbstractSession

PUBLIC: A CacheInvalidationPolicy is used to set objects in TopLink's identity maps to be invalid following given rules. CacheInvalidationPolicy is the abstract superclass for all policies used for cache invalidation. By default in EclipseLink, objects do not expire in the cache. Several different policies are available to allow objects to expire. These can be set on the ClassDescriptor.
See Also
org.eclipse.persistence.descriptors.ClassDescriptor, org.eclipse.persistence.descriptors.invalidation.NoExpiryCacheInvalidationPolicy, org.eclipse.persistence.descriptors.invalidation.DailyCacheInvalidationPolicy, org.eclipse.persistence.descriptors.invalidation.TimeToLiveCacheInvalidationPolicy

Field Summary

Modifier and TypeField and Description
protected boolean
isInvalidationRandomized

Allows the timeToLive to be randomized to avoid bottlenecks.

public static final long
protected Random
random

Random used for randomized invalidation.

protected boolean
shouldRefreshInvalidObjectsOnClone

Determines if expired object registered in the unit of work should be refreshed, default true.

protected boolean
shouldUpdateReadTimeOnUpdate

This will represent objects that do not expire.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Object
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.
public abstract long
getExpiryTimeInMillis(CacheKey key)

INTERNAL: Get the next time when this object will become invalid

public long
getRemainingValidTime(CacheKey key)

INTERNAL: Return the remaining life of this object

public void
initialize(ClassDescriptor descriptor, AbstractSession session)

INTERNAL: Allow initialization with the descriptor.

public boolean
isInvalidated(CacheKey key)

INTERNAL: return true if this object is expire, false otherwise.

public abstract boolean
isInvalidated(CacheKey key, long currentTimeMillis)

INTERNAL: return true if this object is expire, false otherwise.

public boolean
isInvalidationRandomized()

PUBLIC: Allows the timeToLive to be randomized to avoid bottlenecks.

public void
setIsInvalidationRandomized(boolean isInvalidationRandomized)

PUBLIC: Allows the timeToLive to be randomized to avoid bottlenecks.

public void
setShouldRefreshInvalidObjectsOnClone(boolean shouldRefreshInvalidObjectsOnClone)

PUBLIC: Set if expired object should be refreshed prior to cloning, default is true.

public void
setShouldUpdateReadTimeOnUpdate(boolean shouldUpdateReadTime)

PUBLIC: Set whether to update the stored time an object was read when an object is updated.

public boolean
shouldRefreshInvalidObjectsOnClone()

PUBLIC: Return if expired object should be refreshed prior to cloning.

public boolean
shouldUpdateReadTimeOnUpdate()

PUBLIC: Return whether objects affected by this CacheInvalidationPolicy should have the read time on their cache keys updated when an update occurs.

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

isInvalidationRandomizedback to summary
protected boolean isInvalidationRandomized

Allows the timeToLive to be randomized to avoid bottlenecks.

NO_EXPIRYback to summary
public static final long NO_EXPIRY
randomback to summary
protected Random random

Random used for randomized invalidation.

shouldRefreshInvalidObjectsOnCloneback to summary
protected boolean shouldRefreshInvalidObjectsOnClone

Determines if expired object registered in the unit of work should be refreshed, default true.

shouldUpdateReadTimeOnUpdateback to summary
protected boolean shouldUpdateReadTimeOnUpdate

This will represent objects that do not expire.

Constructor Detail

CacheInvalidationPolicyback to summary
public CacheInvalidationPolicy()

Method Detail

cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Returns:Object

a clone of this instance.

Annotations
@Override
getExpiryTimeInMillisback to summary
public abstract long getExpiryTimeInMillis(CacheKey key)

INTERNAL: Get the next time when this object will become invalid

getRemainingValidTimeback to summary
public long getRemainingValidTime(CacheKey key)

INTERNAL: Return the remaining life of this object

initializeback to summary
public void initialize(ClassDescriptor descriptor, AbstractSession session)

INTERNAL: Allow initialization with the descriptor.

isInvalidatedback to summary
public boolean isInvalidated(CacheKey key)

INTERNAL: return true if this object is expire, false otherwise.

isInvalidatedback to summary
public abstract boolean isInvalidated(CacheKey key, long currentTimeMillis)

INTERNAL: return true if this object is expire, false otherwise.

isInvalidationRandomizedback to summary
public boolean isInvalidationRandomized()

PUBLIC: Allows the timeToLive to be randomized to avoid bottlenecks.

setIsInvalidationRandomizedback to summary
public void setIsInvalidationRandomized(boolean isInvalidationRandomized)

PUBLIC: Allows the timeToLive to be randomized to avoid bottlenecks.

setShouldRefreshInvalidObjectsOnCloneback to summary
public void setShouldRefreshInvalidObjectsOnClone(boolean shouldRefreshInvalidObjectsOnClone)

PUBLIC: Set if expired object should be refreshed prior to cloning, default is true. Applies to Protected Entities and UnitOfWork registration.

setShouldUpdateReadTimeOnUpdateback to summary
public void setShouldUpdateReadTimeOnUpdate(boolean shouldUpdateReadTime)

PUBLIC: Set whether to update the stored time an object was read when an object is updated. When the read time is updated, it indicates to EclipseLink that the data in the object is up to date. This means that cache invalidation checks will occur relative to the new read time. By default, the read time will not be updated when an object is updated. Often it is possible to be confident that the object is up to date after an update because otherwise the update will fail because of the locking policies in use.

shouldRefreshInvalidObjectsOnCloneback to summary
public boolean shouldRefreshInvalidObjectsOnClone()

PUBLIC: Return if expired object should be refreshed prior to cloning. Applies to Protected Entities and UnitOfWork registration.

shouldUpdateReadTimeOnUpdateback to summary
public boolean shouldUpdateReadTimeOnUpdate()

PUBLIC: Return whether objects affected by this CacheInvalidationPolicy should have the read time on their cache keys updated when an update occurs.