Module org.eclipse.persistence.core
Class BasicIndirectionPolicy
java.lang.Object
org.eclipse.persistence.internal.indirection.IndirectionPolicy
org.eclipse.persistence.internal.indirection.BasicIndirectionPolicy
- All Implemented Interfaces:
Serializable
,Cloneable
- Direct Known Subclasses:
ContainerIndirectionPolicy
,ProxyIndirectionPolicy
,WeavedObjectBasicIndirectionPolicy
Purpose
: BasicIndirectionPolicy implements the behavior necessary for a aorg.eclipse.persistence.mappings.ForeignReferenceMapping
(or TransformationMapping) to
use ValueHolders to delay the reading of objects from the database
until they are actually needed.- Since:
- TOPLink/Java 2.5
- See Also:
-
Field Summary
Fields inherited from class org.eclipse.persistence.internal.indirection.IndirectionPolicy
mapping
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbackupCloneAttribute
(Object attributeValue, Object clone, Object backup, UnitOfWorkImpl unitOfWork) INTERNAL: Return a backup clone of the attribute.buildIndirectObject
(ValueHolderInterface valueHolder) INTERNAL: This method can be used when an Indirection Object is required to be built from a provided ValueHolderInterface object.cloneAttribute
(Object attributeValue, Object original, CacheKey cacheKey, Object clone, Integer refreshCascade, AbstractSession cloningSession, boolean buildDirectlyFromRow) INTERNAL: Return a clone of the attribute.extractPrimaryKeyForReferenceObject
(Object referenceObject, AbstractSession session) INTERNAL: Return the primary key for the reference object (i.e.extractReferenceRow
(Object referenceObject) INTERNAL: Return the reference row for the reference object.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.getOriginalIndirectionObject
(Object unitOfWorkIndirectionObject, AbstractSession session) INTERNAL: Return the original indirection object for a unit of work indirection object.getOriginalIndirectionObjectForMerge
(Object unitOfWorkIndirectionObject, AbstractSession session) INTERNAL: Return the original indirection object for a unit of work indirection object.getOriginalValueHolder
(Object unitOfWorkIndirectionObject, AbstractSession session) INTERNAL: Return the original valueHolder object.getRealAttributeValueFromObject
(Object object, Object attribute) INTERNAL: Return the "real" attribute value, as opposed to any wrapper.getValueFromRemoteValueHolder
(RemoteValueHolder<?> remoteValueHolder) INTERNAL: Extract and return the appropriate value from the specified remote value holder.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.void
iterateOnAttributeValue
(DescriptorIterator iterator, Object attributeValue) INTERNAL: Iterate over the specified attribute value,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.INTERNAL: Return the null value of the appropriate attribute.boolean
objectIsEasilyInstantiated
(Object object) INTERNAL: Return whether the specified object can be instantiated without database access.boolean
objectIsInstantiated
(Object object) INTERNAL: Return whether the specified object is instantiated.void
Reset the wrapper used to store the value.void
setRealAttributeValueInObject
(Object target, Object attributeValue) INTERNAL: Set the value of the appropriate attribute of target to attributeValue.void
setSourceObject
(Object sourceObject, Object attributeValue) INTERNAL: set the source object into QueryBasedValueHolder.protected boolean
typeIsValid
(Class<?> attributeType) INTERNAL: Return whether the type is appropriate for the indirection policy.validateAttributeOfInstantiatedObject
(Object attributeValue) INTERNAL: Verify that the value of the attribute within an instantiated object is of the appropriate type for the indirection policy.void
validateDeclaredAttributeType
(Class<?> attributeType, IntegrityChecker checker) INTERNAL: Verify that attributeType is correct for the indirection policy.void
validateGetMethodReturnType
(Class<?> returnType, IntegrityChecker checker) INTERNAL: Verify that getter returnType is correct for the indirection policy.void
validateSetMethodParameterType
(Class<?> parameterType, IntegrityChecker checker) INTERNAL: Verify that setter parameterType is correct for the indirection policy.valueFromBatchQuery
(ReadQuery batchQuery, AbstractRecord row, ObjectLevelReadQuery originalQuery, CacheKey parentCacheKey) INTERNAL: Return the value to be stored in the object's attribute.valueFromMethod
(Object object, AbstractRecord row, AbstractSession session) INTERNAL: Return the value to be stored in the object's attribute.valueFromQuery
(ReadQuery query, AbstractRecord row, Object sourceObject, AbstractSession session) INTERNAL: Return the value to be stored in the object's attribute.valueFromQuery
(ReadQuery query, AbstractRecord row, AbstractSession session) INTERNAL: Return the value to be stored in the object's attribute.valueFromRow
(Object object) INTERNAL: Return the value to be stored in the object's attribute.Methods inherited from class org.eclipse.persistence.internal.indirection.IndirectionPolicy
buildCascadeQuery, clone, getCollectionMapping, getForeignReferenceMapping, getMapping, getOneToOneMapping, getTransformationMapping, initialize, instantiateObject, isWeavedObjectBasicIndirectionPolicy, mergeClientIntoServerValueHolder, objectIsInstantiatedOrChanged, setMapping, setRealAttributeValueInObject, setUseLazyInstantiation, shouldUseLazyInstantiation, usesIndirection, usesTransparentIndirection, validateContainerPolicy, validateDeclaredAttributeTypeForCollection, validateGetMethodReturnTypeForCollection, validateSetMethodParameterTypeForCollection
-
Constructor Details
-
BasicIndirectionPolicy
public BasicIndirectionPolicy()INTERNAL: Construct a new indirection policy.
-
-
Method Details
-
backupCloneAttribute
public Object backupCloneAttribute(Object attributeValue, Object clone, Object backup, UnitOfWorkImpl unitOfWork) INTERNAL: Return a backup clone of the attribute.- Overrides:
backupCloneAttribute
in classIndirectionPolicy
-
buildIndirectObject
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.- Specified by:
buildIndirectObject
in classIndirectionPolicy
-
cloneAttribute
public Object cloneAttribute(Object attributeValue, Object original, CacheKey cacheKey, Object clone, Integer refreshCascade, AbstractSession cloningSession, boolean buildDirectlyFromRow) INTERNAL: Return a clone of the attribute.- Specified by:
cloneAttribute
in classIndirectionPolicy
- Parameters:
buildDirectlyFromRow
- 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.
-
extractPrimaryKeyForReferenceObject
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.- Overrides:
extractPrimaryKeyForReferenceObject
in classIndirectionPolicy
-
extractReferenceRow
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.- Specified by:
extractReferenceRow
in classIndirectionPolicy
-
fixObjectReferences
public 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.- Specified by:
fixObjectReferences
in classIndirectionPolicy
-
getOriginalIndirectionObject
public Object getOriginalIndirectionObject(Object unitOfWorkIndirectionObject, AbstractSession session) INTERNAL: Return the original indirection object for a unit of work indirection object. This is used when building a new object from the unit of work when the original fell out of the cache.- Specified by:
getOriginalIndirectionObject
in classIndirectionPolicy
-
getOriginalIndirectionObjectForMerge
public Object getOriginalIndirectionObjectForMerge(Object unitOfWorkIndirectionObject, AbstractSession session) INTERNAL: Return the original indirection object for a unit of work indirection object.- Overrides:
getOriginalIndirectionObjectForMerge
in classIndirectionPolicy
-
getOriginalValueHolder
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.- Specified by:
getOriginalValueHolder
in classIndirectionPolicy
-
reset
Reset the wrapper used to store the value.- Overrides:
reset
in classIndirectionPolicy
-
getRealAttributeValueFromObject
INTERNAL: Return the "real" attribute value, as opposed to any wrapper. This will trigger the wrapper to instantiate the value.- Specified by:
getRealAttributeValueFromObject
in classIndirectionPolicy
-
getValueFromRemoteValueHolder
INTERNAL: Extract and return the appropriate value from the specified remote value holder.- Specified by:
getValueFromRemoteValueHolder
in classIndirectionPolicy
-
isAttributeValueFullyBuilt
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- Overrides:
isAttributeValueFullyBuilt
in classIndirectionPolicy
- See Also:
-
iterateOnAttributeValue
INTERNAL: Iterate over the specified attribute value,- Overrides:
iterateOnAttributeValue
in classIndirectionPolicy
-
mergeRemoteValueHolder
public 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.- Specified by:
mergeRemoteValueHolder
in classIndirectionPolicy
-
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. In this case, return an empty ValueHolder.- Specified by:
nullValueFromRow
in classIndirectionPolicy
-
objectIsInstantiated
INTERNAL: Return whether the specified object is instantiated.- Specified by:
objectIsInstantiated
in classIndirectionPolicy
-
objectIsEasilyInstantiated
INTERNAL: Return whether the specified object can be instantiated without database access.- Specified by:
objectIsEasilyInstantiated
in classIndirectionPolicy
-
setRealAttributeValueInObject
INTERNAL: Set the value of the appropriate attribute of target to attributeValue. In this case, place the value inside the target's ValueHolder.- Overrides:
setRealAttributeValueInObject
in classIndirectionPolicy
-
setSourceObject
INTERNAL: set the source object into QueryBasedValueHolder. Used only by transparent indirection.- Overrides:
setSourceObject
in classIndirectionPolicy
-
typeIsValid
INTERNAL: Return whether the type is appropriate for the indirection policy. In this case, the attribute type MUST be ValueHolderInterface. -
validateAttributeOfInstantiatedObject
INTERNAL: Verify that the value of the attribute within an instantiated object is of the appropriate type for the indirection policy. In this case, the attribute must be non-null and it must be a ValueHolderInterface. If the value is null return a new indirection object to be used for the attribute.- Overrides:
validateAttributeOfInstantiatedObject
in classIndirectionPolicy
-
validateDeclaredAttributeType
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. In this case, the attribute type MUST be ValueHolderInterface.- Overrides:
validateDeclaredAttributeType
in classIndirectionPolicy
- Throws:
DescriptorException
-
validateGetMethodReturnType
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. In this case, the return type MUST be ValueHolderInterface.- Overrides:
validateGetMethodReturnType
in classIndirectionPolicy
- Throws:
DescriptorException
-
validateSetMethodParameterType
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. In this case, the parameter type MUST be ValueHolderInterface.- Overrides:
validateSetMethodParameterType
in classIndirectionPolicy
- Throws:
DescriptorException
-
valueFromBatchQuery
public 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. In this case, wrap the query in a ValueHolder for later invocation.- Specified by:
valueFromBatchQuery
in classIndirectionPolicy
-
valueFromMethod
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. In this case, wrap the row in a ValueHolder for later use.- Specified by:
valueFromMethod
in classIndirectionPolicy
-
valueFromQuery
public 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. In this case, wrap the query in a ValueHolder for later invocation.- Specified by:
valueFromQuery
in classIndirectionPolicy
-
valueFromQuery
INTERNAL: Return the value to be stored in the object's attribute. This value is determined by the query. In this case, wrap the query in a ValueHolder for later invocation.- Specified by:
valueFromQuery
in classIndirectionPolicy
-
valueFromRow
INTERNAL: Return the value to be stored in the object's attribute. This value is determined by the row. In this case, simply wrap the object in a ValueHolder.- Specified by:
valueFromRow
in classIndirectionPolicy
-