Class ContainerIndirectionPolicy
- java.lang.Object
-
- org.eclipse.persistence.internal.indirection.IndirectionPolicy
-
- org.eclipse.persistence.internal.indirection.BasicIndirectionPolicy
-
- org.eclipse.persistence.internal.indirection.ContainerIndirectionPolicy
-
- All Implemented Interfaces:
Serializable
,Cloneable
public class ContainerIndirectionPolicy extends BasicIndirectionPolicy
Purpose: Provide ability for developers to wrap ValueHolders (Basic Indirection)Responsibilities:
- Wrap & un-wrap a ValueHolder within an IndirectContainer
- Reflectively instantiate the containers as required
- Since:
- 2.5.0.5
- Author:
- Doug Clarke (TOP)
- See Also:
IndirectContainer
, Serialized Form
-
-
Field Summary
-
Fields inherited from class org.eclipse.persistence.internal.indirection.IndirectionPolicy
mapping
-
-
Constructor Summary
Constructors Constructor Description ContainerIndirectionPolicy()
INTERNAL: Construct a new indirection policy.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
backupCloneAttribute(Object attributeValue, Object clone, Object backup, UnitOfWorkImpl unitOfWork)
INTERNAL: Return a backup clone of the attribute.protected IndirectContainer
buildContainer(ValueHolderInterface<?> valueHolder)
Build a container with the initialized constructor.Object
buildIndirectObject(ValueHolderInterface valueHolder)
INTERNAL: This method can be used when an Indirection Object is required to be built from a provided ValueHolderInterface object.Object
cloneAttribute(Object attributeValue, Object original, CacheKey cacheKey, Object clone, Integer refreshCascade, AbstractSession cloningSession, boolean buildDirectlyFromRow)
INTERNAL: Return a clone of the attribute.AbstractRecord
extractReferenceRow(Object referenceObject)
INTERNAL: Return the reference row for the reference object.Class
getContainerClass()
Returns the Container class which implements IndirectContainer.String
getContainerClassName()
INTERNAL: Used by MW.protected Constructor
getContainerConstructor()
Object
getOriginalIndirectionObject(Object unitOfWorkIndirectionObject, AbstractSession session)
INTERNAL: Return the original indirection object for a unit of work indirection object.Object
getOriginalIndirectionObjectForMerge(Object unitOfWorkIndirectionObject, AbstractSession session)
INTERNAL: Return the original indirection object for a unit of work indirection object.Object
getRealAttributeValueFromObject(Object object, Object attribute)
INTERNAL: Return the "real" attribute value, as opposed to any wrapper.void
initialize()
INTERNAL: Ensure the container class implements IndirectContainer and that it has a constructor which can be used.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,Object
nullValueFromRow()
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(Object target)
Reset the wrapper used to store the value.void
setContainerClass(Class containerClass)
Sets the Container class which implements IndirectContainervoid
setContainterClassName(String containerClassName)
Set the container classname for the MWvoid
setRealAttributeValueInObject(Object target, Object attributeValue)
INTERNAL: Set the value of the appropriate attribute of target to attributeValue.protected boolean
typeIsValid(Class attributeType)
INTERNAL: Return whether the type is appropriate for the indirection policy.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.Object
valueFromBatchQuery(ReadQuery batchQuery, AbstractRecord row, ObjectLevelReadQuery originalQuery, CacheKey parentCacheKey)
INTERNAL: Return the value to be stored in the object's attribute.Object
valueFromMethod(Object object, AbstractRecord row, AbstractSession session)
INTERNAL: Return the value to be stored in the object's attribute.Object
valueFromQuery(ReadQuery query, AbstractRecord row, AbstractSession session)
INTERNAL: Return the value to be stored in the object's attribute.Object
valueFromRow(Object object)
INTERNAL: Return the value to be stored in the object's attribute.-
Methods inherited from class org.eclipse.persistence.internal.indirection.BasicIndirectionPolicy
extractPrimaryKeyForReferenceObject, fixObjectReferences, getOriginalValueHolder, getValueFromRemoteValueHolder, mergeRemoteValueHolder, setSourceObject, validateDeclaredAttributeType, validateGetMethodReturnType, validateSetMethodParameterType, valueFromQuery
-
Methods inherited from class org.eclipse.persistence.internal.indirection.IndirectionPolicy
buildCascadeQuery, clone, getCollectionMapping, getForeignReferenceMapping, getMapping, getOneToOneMapping, getTransformationMapping, instantiateObject, isWeavedObjectBasicIndirectionPolicy, mergeClientIntoServerValueHolder, objectIsInstantiatedOrChanged, setMapping, setRealAttributeValueInObject, setUseLazyInstantiation, shouldUseLazyInstantiation, usesIndirection, usesTransparentIndirection, validateContainerPolicy, validateDeclaredAttributeTypeForCollection, validateGetMethodReturnTypeForCollection, validateSetMethodParameterTypeForCollection
-
-
-
-
Method Detail
-
backupCloneAttribute
public Object backupCloneAttribute(Object attributeValue, Object clone, Object backup, UnitOfWorkImpl unitOfWork)
INTERNAL: Return a backup clone of the attribute.- Overrides:
backupCloneAttribute
in classBasicIndirectionPolicy
-
buildContainer
protected IndirectContainer buildContainer(ValueHolderInterface<?> valueHolder)
Build a container with the initialized constructor.
-
buildIndirectObject
public Object buildIndirectObject(ValueHolderInterface 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.- Overrides:
buildIndirectObject
in classBasicIndirectionPolicy
-
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.- Overrides:
cloneAttribute
in classBasicIndirectionPolicy
- 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.
-
extractReferenceRow
public 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.- Overrides:
extractReferenceRow
in classBasicIndirectionPolicy
-
getContainerClass
public Class getContainerClass()
Returns the Container class which implements IndirectContainer.
-
getContainerClassName
public String getContainerClassName()
INTERNAL: Used by MW.
-
getContainerConstructor
protected Constructor getContainerConstructor()
- Returns:
- java.lang.reflect.Constructor
-
getOriginalIndirectionObject
public Object getOriginalIndirectionObject(Object unitOfWorkIndirectionObject, AbstractSession session)
INTERNAL: Return the original indirection object for a unit of work indirection object.- Overrides:
getOriginalIndirectionObject
in classBasicIndirectionPolicy
-
getOriginalIndirectionObjectForMerge
public Object getOriginalIndirectionObjectForMerge(Object unitOfWorkIndirectionObject, AbstractSession session)
INTERNAL: Return the original indirection object for a unit of work indirection object.- Overrides:
getOriginalIndirectionObjectForMerge
in classBasicIndirectionPolicy
-
getRealAttributeValueFromObject
public 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.- Overrides:
getRealAttributeValueFromObject
in classBasicIndirectionPolicy
-
initialize
public void initialize()
INTERNAL: Ensure the container class implements IndirectContainer and that it has a constructor which can be used.- Overrides:
initialize
in classIndirectionPolicy
-
isAttributeValueFullyBuilt
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- Overrides:
isAttributeValueFullyBuilt
in classBasicIndirectionPolicy
- Parameters:
attributeValue
-- Returns:
- See Also:
validateAttributeOfInstantiatedObject(java.lang.Object)
-
iterateOnAttributeValue
public void iterateOnAttributeValue(DescriptorIterator iterator, Object attributeValue)
INTERNAL: Iterate over the specified attribute value,- Overrides:
iterateOnAttributeValue
in classBasicIndirectionPolicy
-
nullValueFromRow
public 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. In this case, return an empty ValueHolder.- Overrides:
nullValueFromRow
in classBasicIndirectionPolicy
-
reset
public void reset(Object target)
Reset the wrapper used to store the value.- Overrides:
reset
in classBasicIndirectionPolicy
-
objectIsInstantiated
public boolean objectIsInstantiated(Object object)
INTERNAL: Return whether the specified object is instantiated.- Overrides:
objectIsInstantiated
in classBasicIndirectionPolicy
-
objectIsEasilyInstantiated
public boolean objectIsEasilyInstantiated(Object object)
INTERNAL: Return whether the specified object can be instantiated without database access.- Overrides:
objectIsEasilyInstantiated
in classBasicIndirectionPolicy
-
setContainerClass
public void setContainerClass(Class containerClass)
Sets the Container class which implements IndirectContainer
-
setContainterClassName
public void setContainterClassName(String containerClassName)
Set the container classname for the MW
-
setRealAttributeValueInObject
public void setRealAttributeValueInObject(Object target, Object attributeValue)
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 classBasicIndirectionPolicy
-
typeIsValid
protected boolean typeIsValid(Class attributeType)
INTERNAL: Return whether the type is appropriate for the indirection policy. In this case, the type must either be assignable from IndirectContainer or allow the conatinerClass to be assigned to it.- Overrides:
typeIsValid
in classBasicIndirectionPolicy
-
validateAttributeOfInstantiatedObject
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. In this case, the attribute must be non-null and it must be a ValueHolderInterface.- Overrides:
validateAttributeOfInstantiatedObject
in classBasicIndirectionPolicy
-
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.- Overrides:
valueFromBatchQuery
in classBasicIndirectionPolicy
-
valueFromMethod
public 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. In this case, wrap the row in a ValueHolder for later use.- Overrides:
valueFromMethod
in classBasicIndirectionPolicy
-
valueFromQuery
public 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. In this case, wrap the query in a ValueHolder for later invocation.- Overrides:
valueFromQuery
in classBasicIndirectionPolicy
-
valueFromRow
public Object valueFromRow(Object object)
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.- Overrides:
valueFromRow
in classBasicIndirectionPolicy
-
-