Top Description Fields Constructors Methods
org.eclipse.persistence.internal.indirection

public abstract Class IndirectionPolicy

extends Object
implements Cloneable, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, java.lang.Cloneable
Known Direct Subclasses
org.eclipse.persistence.internal.indirection.NoIndirectionPolicy, org.eclipse.persistence.internal.indirection.TransparentIndirectionPolicy, org.eclipse.persistence.internal.indirection.BasicIndirectionPolicy
Imports
java.io.Serializable, java.util.Map, org.eclipse.persistence.exceptions.DescriptorException, .IntegrityChecker, org.eclipse.persistence.indirection.ValueHolderInterface, org.eclipse.persistence.internal.descriptors.DescriptorIterator, org.eclipse.persistence.internal.identitymaps.CacheKey, org.eclipse.persistence.internal.sessions.AbstractRecord, .AbstractSession, .MergeManager, .UnitOfWorkImpl, org.eclipse.persistence.internal.sessions.remote.ObjectDescriptor, .RemoteValueHolder, org.eclipse.persistence.mappings.CollectionMapping, .DatabaseMapping, .ForeignReferenceMapping, .ObjectReferenceMapping, org.eclipse.persistence.mappings.foundation.AbstractTransformationMapping, org.eclipse.persistence.queries.ObjectLevelReadQuery, .ReadObjectQuery, .ReadQuery, org.eclipse.persistence.sessions.remote.DistributedSession

Purpose

:

An IndirectionPolicy acts as a 'rules' holder that determines the behavior of a ForeignReferenceMapping (or TransformationMapping) with respect to indirection, or lack thereof.

Description

:

IndirectionPolicy is an abstract class that defines the protocol to be implemented by subclasses so that the assorted DatabaseMappings can use an assortment of indirection policies:

Responsibilities

:
Author
Mike Norman
Since
TOPLink/Java 2.5
See Also
ForeignReferenceMapping

Field Summary

Modifier and TypeField and Description
protected DatabaseMapping

Constructor Summary

AccessConstructor and Description
protected
IndirectionPolicy()

INTERNAL: Construct a new indirection policy.

Method Summary

Modifier and TypeMethod and Description
public Object
backupCloneAttribute(Object attributeValue, Object clone, Object backup, UnitOfWorkImpl unitOfWork)

INTERNAL: Return a backup clone of the attribute.

protected ReadObjectQuery
buildCascadeQuery(MergeManager mergeManager)

INTERNAL Return true if the refresh should refresh on this mapping or not.

public abstract Object
buildIndirectObject(ValueHolderInterface<T> valueHolder)

INTERNAL: This method can be used when an Indirection Object is required to be built from a provided ValueHolderInterface object.

public Object
clone()

Overrides java.lang.Object.clone.

INTERNAL: Clones itself.
public abstract Object
cloneAttribute(Object attributeValue, Object original, CacheKey cacheKey, Object clone, Integer refreshCascade, AbstractSession cloningSession, boolean
indicates that we are building the clone directly from a row as opposed to building the original from the row, putting it in the shared cache, and then cloning the original.
buildDirectlyFromRow
)

INTERNAL: Return a clone of the attribute.

public Object
extractPrimaryKeyForReferenceObject(Object referenceObject, AbstractSession session)

INTERNAL: Return the primary key for the reference object (i.e. the object object referenced by domainObject and specified by mapping).

public abstract AbstractRecord
extractReferenceRow(Object referenceObject)

INTERNAL: Return the reference row for the reference object.

public abstract void
fixObjectReferences(Object object, Map<Object, ObjectDescriptor> objectDescriptors, Map<Object, Object> processedObjects, ObjectLevelReadQuery query, DistributedSession session)

INTERNAL: An object has been serialized from the server to the client.

protected CollectionMapping
getCollectionMapping()

INTERNAL: Reduce casting clutter....

protected ForeignReferenceMapping
getForeignReferenceMapping()

INTERNAL: Reduce casting clutter....

public DatabaseMapping
getMapping()

INTERNAL: Return the database mapping that uses the indirection policy.

protected ObjectReferenceMapping
getOneToOneMapping()

INTERNAL: Reduce casting clutter....

public abstract Object
getOriginalIndirectionObject(Object unitOfWorkIndirectionObject, AbstractSession session)

INTERNAL: Return the original indirection object for a unit of work indirection object.

public Object
getOriginalIndirectionObjectForMerge(Object unitOfWorkIndirectionObject, AbstractSession session)

INTERNAL: Return the original indirection object for a unit of work indirection object.

public abstract Object
getOriginalValueHolder(Object unitOfWorkIndirectionObject, AbstractSession session)

INTERNAL: Return the original valueHolder object.

public abstract Object
getRealAttributeValueFromObject(Object object, Object attribute)

INTERNAL: Return the "real" attribute value, as opposed to any wrapper.

protected AbstractTransformationMapping
getTransformationMapping()

INTERNAL: Reduce casting clutter....

public abstract Object
getValueFromRemoteValueHolder(RemoteValueHolder<?> remoteValueHolder)

INTERNAL: Extract and return the appropriate value from the specified remote value holder.

public void
initialize()

INTERNAL: Initialize the indirection policy (Do nothing by default)

public void
instantiateObject(Object object, Object attribute)

INTERNAL: Trigger the instantiation of the value.

public boolean
isAttributeValueFullyBuilt(Object attributeValue)

INTERNAL: The method validateAttributeOfInstantiatedObject(Object attributeValue) fixes the value of the attributeValue in cases where it is null and indirection requires that it contain some specific data structure.

public boolean
public void
iterateOnAttributeValue(DescriptorIterator iterator, Object attributeValue)

INTERNAL: Iterate over the specified attribute value, heeding the settings in the iterator.

protected void
mergeClientIntoServerValueHolder(RemoteValueHolder<?> serverValueHolder, MergeManager mergeManager)

INTERNAL Replace the client value holder with the server value holder, after copying some of the settings from the client value holder.

public abstract void
mergeRemoteValueHolder(Object clientSideDomainObject, Object serverSideDomainObject, MergeManager mergeManager)

INTERNAL Replace the client value holder with the server value holder, after copying some of the settings from the client value holder.

public abstract Object
nullValueFromRow()

INTERNAL: Return the null value of the appropriate attribute.

public abstract boolean
objectIsEasilyInstantiated(Object object)

INTERNAL: Return whether the specified object can be instantiated without database access.

public abstract boolean
objectIsInstantiated(Object object)

INTERNAL: Return whether the specified object is instantiated.

public boolean
objectIsInstantiatedOrChanged(Object object)

INTERNAL: Return whether the specified object is instantiated, or if it has changes.

public void
reset(Object target)

Reset the wrapper used to store the value.

public void
setMapping(DatabaseMapping mapping)

INTERNAL: set the database mapping that uses the indirection policy.

public void
setRealAttributeValueInObject(Object target, Object attributeValue)

INTERNAL: Set the value of the appropriate attribute of target to attributeValue.

public void
setRealAttributeValueInObject(Object target, Object attributeValue, boolean allowChangeTracking)

INTERNAL: Same functionality as setRealAttributeValueInObject(Object target, Object attributeValue) but allows overridden behavior for IndirectionPolicies that track changes

public void
setSourceObject(Object sourceObject, Object attributeValue)

INTERNAL: set the source object into QueryBasedValueHolder.

public void
setUseLazyInstantiation(Boolean useLazyInstantiation)

ADVANCED: This method will only change the behavior of TransparentIndirectionPolicy.

public Boolean
shouldUseLazyInstantiation()

ADVANCED: Returns false unless this is a transparent indirection policy IndirectList and IndirectSet can be configured not to instantiate the list from the database when you add and remove from them.

public boolean
usesIndirection()

INTERNAL: Return whether the indirection policy actually uses indirection.

public boolean
usesTransparentIndirection()

INTERNAL: Return whether the indirection policy uses transparent indirection.

public Object
validateAttributeOfInstantiatedObject(Object attributeValue)

INTERNAL: Verify that the value of the attribute within an instantiated object is of the appropriate type for the indirection policy.

public void
validateContainerPolicy(IntegrityChecker checker)

INTERNAL: Verify that the container policy is compatible with the indirection policy.

public void
validateDeclaredAttributeType(Class<?> attributeType, IntegrityChecker checker)

INTERNAL: Verify that attributeType is correct for the indirection policy.

public void
validateDeclaredAttributeTypeForCollection(Class<?> attributeType, IntegrityChecker checker)

INTERNAL: Verify that attributeType is an appropriate collection type for the indirection policy.

public void
validateGetMethodReturnType(Class<?> returnType, IntegrityChecker checker)

INTERNAL: Verify that getter returnType is correct for the indirection policy.

public void
validateGetMethodReturnTypeForCollection(Class<?> returnType, IntegrityChecker checker)

INTERNAL: Verify that getter returnType is an appropriate collection type for the indirection policy.

public void
validateSetMethodParameterType(Class<?> parameterType, IntegrityChecker checker)

INTERNAL: Verify that setter parameterType is correct for the indirection policy.

public void
validateSetMethodParameterTypeForCollection(Class<?> parameterType, IntegrityChecker checker)

INTERNAL: Verify that setter parameterType is an appropriate collection type for the indirection policy.

public abstract Object
valueFromBatchQuery(ReadQuery batchQuery, AbstractRecord row, ObjectLevelReadQuery originalQuery, CacheKey parentCacheKey)

INTERNAL: Return the value to be stored in the object's attribute.

public abstract Object
valueFromMethod(Object object, AbstractRecord row, AbstractSession session)

INTERNAL: Return the value to be stored in the object's attribute.

public abstract Object
valueFromQuery(ReadQuery query, AbstractRecord row, Object sourceObject, AbstractSession session)

INTERNAL: Return the value to be stored in the object's attribute.

public abstract Object
valueFromQuery(ReadQuery query, AbstractRecord row, AbstractSession session)

INTERNAL: Return the value to be stored in the object's attribute.

public abstract Object
valueFromRow(Object object)

INTERNAL: Return the value to be stored in the object's attribute.

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

mappingback to summary
protected DatabaseMapping mapping

Constructor Detail

IndirectionPolicyback to summary
protected IndirectionPolicy()

INTERNAL: Construct a new indirection policy.

Method Detail

backupCloneAttributeback to summary
public Object backupCloneAttribute(Object attributeValue, Object clone, Object backup, UnitOfWorkImpl unitOfWork)

INTERNAL: Return a backup clone of the attribute.

buildCascadeQueryback to summary
protected ReadObjectQuery buildCascadeQuery(MergeManager mergeManager)

INTERNAL Return true if the refresh should refresh on this mapping or not.

buildIndirectObjectback to summary
public abstract Object buildIndirectObject(ValueHolderInterface<T> valueHolder)

INTERNAL: This method can be used when an Indirection Object is required to be built from a provided ValueHolderInterface object. This may be used for custom value holder types. Certain policies like the TransparentIndirectionPolicy may wrap the valueholder in another object.

cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

INTERNAL: Clones itself.

Returns:Object

Doc from java.lang.Object.clone.

a clone of this instance.

Annotations
@Override
cloneAttributeback to summary
public abstract Object cloneAttribute(Object attributeValue, Object original, CacheKey cacheKey, Object clone, Integer refreshCascade, AbstractSession cloningSession, boolean buildDirectlyFromRow)

INTERNAL: Return a clone of the attribute.

Parameters
buildDirectlyFromRow:boolean

indicates that we are building the clone directly from a row as opposed to building the original from the row, putting it in the shared cache, and then cloning the original.

extractPrimaryKeyForReferenceObjectback to summary
public Object extractPrimaryKeyForReferenceObject(Object referenceObject, AbstractSession session)

INTERNAL: Return the primary key for the reference object (i.e. the object object referenced by domainObject and specified by mapping). This key will be used by a RemoteValueHolder.

extractReferenceRowback to summary
public abstract AbstractRecord extractReferenceRow(Object referenceObject)

INTERNAL: Return the reference row for the reference object. This allows the new row to be built without instantiating the reference object. Return null if the object has already been instantiated.

fixObjectReferencesback to summary
public abstract void fixObjectReferences(Object object, Map<Object, ObjectDescriptor> objectDescriptors, Map<Object, Object> processedObjects, ObjectLevelReadQuery query, DistributedSession session)

INTERNAL: An object has been serialized from the server to the client. Replace the transient attributes of the remote value holders with client-side objects.

getCollectionMappingback to summary
protected CollectionMapping getCollectionMapping()

INTERNAL: Reduce casting clutter....

getForeignReferenceMappingback to summary
protected ForeignReferenceMapping getForeignReferenceMapping()

INTERNAL: Reduce casting clutter....

getMappingback to summary
public DatabaseMapping getMapping()

INTERNAL: Return the database mapping that uses the indirection policy.

getOneToOneMappingback to summary
protected ObjectReferenceMapping getOneToOneMapping()

INTERNAL: Reduce casting clutter....

getOriginalIndirectionObjectback to summary
public abstract Object getOriginalIndirectionObject(Object unitOfWorkIndirectionObject, AbstractSession session)

INTERNAL: Return the original indirection object for a unit of work indirection object.

getOriginalIndirectionObjectForMergeback to summary
public Object getOriginalIndirectionObjectForMerge(Object unitOfWorkIndirectionObject, AbstractSession session)

INTERNAL: Return the original indirection object for a unit of work indirection object.

getOriginalValueHolderback to summary
public abstract Object getOriginalValueHolder(Object unitOfWorkIndirectionObject, AbstractSession session)

INTERNAL: Return the original valueHolder object. Access to the underlying valueholder may be required when serializing the valueholder or converting the valueHolder to another type.

getRealAttributeValueFromObjectback to summary
public abstract Object getRealAttributeValueFromObject(Object object, Object attribute)

INTERNAL: Return the "real" attribute value, as opposed to any wrapper. This will trigger the wrapper to instantiate the value.

getTransformationMappingback to summary
protected AbstractTransformationMapping getTransformationMapping()

INTERNAL: Reduce casting clutter....

getValueFromRemoteValueHolderback to summary
public abstract Object getValueFromRemoteValueHolder(RemoteValueHolder<?> remoteValueHolder)

INTERNAL: Extract and return the appropriate value from the specified remote value holder.

initializeback to summary
public void initialize()

INTERNAL: Initialize the indirection policy (Do nothing by default)

instantiateObjectback to summary
public void instantiateObject(Object object, Object attribute)

INTERNAL: Trigger the instantiation of the value.

isAttributeValueFullyBuiltback to summary
public boolean isAttributeValueFullyBuilt(Object attributeValue)

INTERNAL: The method validateAttributeOfInstantiatedObject(Object attributeValue) fixes the value of the attributeValue in cases where it is null and indirection requires that it contain some specific data structure. Return whether this will happen. This method is used to help determine if indirection has been triggered

See Also
validateAttributeOfInstantiatedObject(Object)
isWeavedObjectBasicIndirectionPolicyback to summary
public boolean isWeavedObjectBasicIndirectionPolicy()

INTERNAL:

iterateOnAttributeValueback to summary
public void iterateOnAttributeValue(DescriptorIterator iterator, Object attributeValue)

INTERNAL: Iterate over the specified attribute value, heeding the settings in the iterator.

mergeClientIntoServerValueHolderback to summary
protected void mergeClientIntoServerValueHolder(RemoteValueHolder<?> serverValueHolder, MergeManager mergeManager)

INTERNAL Replace the client value holder with the server value holder, after copying some of the settings from the client value holder.

mergeRemoteValueHolderback to summary
public abstract void mergeRemoteValueHolder(Object clientSideDomainObject, Object serverSideDomainObject, MergeManager mergeManager)

INTERNAL Replace the client value holder with the server value holder, after copying some of the settings from the client value holder.

nullValueFromRowback to summary
public abstract Object nullValueFromRow()

INTERNAL: Return the null value of the appropriate attribute. That is, the field from the database is NULL, return what should be placed in the object's attribute as a result.

objectIsEasilyInstantiatedback to summary
public abstract boolean objectIsEasilyInstantiated(Object object)

INTERNAL: Return whether the specified object can be instantiated without database access.

objectIsInstantiatedback to summary
public abstract boolean objectIsInstantiated(Object object)

INTERNAL: Return whether the specified object is instantiated.

objectIsInstantiatedOrChangedback to summary
public boolean objectIsInstantiatedOrChanged(Object object)

INTERNAL: Return whether the specified object is instantiated, or if it has changes.

resetback to summary
public void reset(Object target)

Reset the wrapper used to store the value. This is only required if a wrapper is used.

setMappingback to summary
public void setMapping(DatabaseMapping mapping)

INTERNAL: set the database mapping that uses the indirection policy.

setRealAttributeValueInObjectback to summary
public void setRealAttributeValueInObject(Object target, Object attributeValue)

INTERNAL: Set the value of the appropriate attribute of target to attributeValue. In this case, simply place the value inside the target.

setRealAttributeValueInObjectback to summary
public void setRealAttributeValueInObject(Object target, Object attributeValue, boolean allowChangeTracking)

INTERNAL: Same functionality as setRealAttributeValueInObject(Object target, Object attributeValue) but allows overridden behavior for IndirectionPolicies that track changes

setSourceObjectback to summary
public void setSourceObject(Object sourceObject, Object attributeValue)

INTERNAL: set the source object into QueryBasedValueHolder. Used only by transparent indirection.

setUseLazyInstantiationback to summary
public void setUseLazyInstantiation(Boolean useLazyInstantiation)

ADVANCED: This method will only change the behavior of TransparentIndirectionPolicy. IndirectList and IndirectSet can be configured not to instantiate the list from the database when you add and remove from them. IndirectList defaults to this behavior. When Set to true, the collection associated with this TransparentIndirection will be setup so as not to instantiate for adds and removes. The weakness of this setting for an IndirectSet is that when the set is not instantiated, if a duplicate element is added, it will not be detected until commit time.

shouldUseLazyInstantiationback to summary
public Boolean shouldUseLazyInstantiation()

ADVANCED: Returns false unless this is a transparent indirection policy IndirectList and IndirectSet can be configured not to instantiate the list from the database when you add and remove from them. IndirectList defaults to this behavior. When Set to true, the collection associated with this TransparentIndirection will be setup so as not to instantiate for adds and removes. The weakness of this setting for an IndirectSet is that when the set is not instantiated, if a duplicate element is added, it will not be detected until commit time.

usesIndirectionback to summary
public boolean usesIndirection()

INTERNAL: Return whether the indirection policy actually uses indirection. The default is true.

usesTransparentIndirectionback to summary
public boolean usesTransparentIndirection()

INTERNAL: Return whether the indirection policy uses transparent indirection. The default is false.

validateAttributeOfInstantiatedObjectback to summary
public Object validateAttributeOfInstantiatedObject(Object attributeValue) throws DescriptorException

INTERNAL: Verify that the value of the attribute within an instantiated object is of the appropriate type for the indirection policy. If it is incorrect, throw an exception. If the value is null return a new indirection object to be used for the attribute.

validateContainerPolicyback to summary
public void validateContainerPolicy(IntegrityChecker checker) throws DescriptorException

INTERNAL: Verify that the container policy is compatible with the indirection policy. If it is incorrect, add an exception to the integrity checker.

validateDeclaredAttributeTypeback to summary
public void validateDeclaredAttributeType(Class<?> attributeType, IntegrityChecker checker) throws DescriptorException

INTERNAL: Verify that attributeType is correct for the indirection policy. If it is incorrect, add an exception to the integrity checker.

validateDeclaredAttributeTypeForCollectionback to summary
public void validateDeclaredAttributeTypeForCollection(Class<?> attributeType, IntegrityChecker checker) throws DescriptorException

INTERNAL: Verify that attributeType is an appropriate collection type for the indirection policy. If it is incorrect, add an exception to the integrity checker.

validateGetMethodReturnTypeback to summary
public void validateGetMethodReturnType(Class<?> returnType, IntegrityChecker checker) throws DescriptorException

INTERNAL: Verify that getter returnType is correct for the indirection policy. If it is incorrect, add an exception to the integrity checker.

validateGetMethodReturnTypeForCollectionback to summary
public void validateGetMethodReturnTypeForCollection(Class<?> returnType, IntegrityChecker checker) throws DescriptorException

INTERNAL: Verify that getter returnType is an appropriate collection type for the indirection policy. If it is incorrect, add an exception to the integrity checker.

validateSetMethodParameterTypeback to summary
public void validateSetMethodParameterType(Class<?> parameterType, IntegrityChecker checker) throws DescriptorException

INTERNAL: Verify that setter parameterType is correct for the indirection policy. If it is incorrect, add an exception to the integrity checker.

validateSetMethodParameterTypeForCollectionback to summary
public void validateSetMethodParameterTypeForCollection(Class<?> parameterType, IntegrityChecker checker) throws DescriptorException

INTERNAL: Verify that setter parameterType is an appropriate collection type for the indirection policy. If it is incorrect, add an exception to the integrity checker.

valueFromBatchQueryback to summary
public abstract Object valueFromBatchQuery(ReadQuery batchQuery, AbstractRecord row, ObjectLevelReadQuery originalQuery, CacheKey parentCacheKey)

INTERNAL: Return the value to be stored in the object's attribute. This value is determined by the batchQuery.

valueFromMethodback to summary
public abstract Object valueFromMethod(Object object, AbstractRecord row, AbstractSession session)

INTERNAL: Return the value to be stored in the object's attribute. This value is determined by invoking the appropriate method on the object and passing it the row and session.

valueFromQueryback to summary
public abstract Object valueFromQuery(ReadQuery query, AbstractRecord row, Object sourceObject, AbstractSession session)

INTERNAL: Return the value to be stored in the object's attribute. This value is determined by the query.

valueFromQueryback to summary
public abstract Object valueFromQuery(ReadQuery query, AbstractRecord row, AbstractSession session)

INTERNAL: Return the value to be stored in the object's attribute. This value is determined by the query.

valueFromRowback to summary
public abstract Object valueFromRow(Object object)

INTERNAL: Return the value to be stored in the object's attribute. This value is determined by the row.