Module org.eclipse.persistence.core
Class ProxyIndirectionPolicy
java.lang.Object
org.eclipse.persistence.internal.indirection.IndirectionPolicy
org.eclipse.persistence.internal.indirection.BasicIndirectionPolicy
org.eclipse.persistence.internal.indirection.ProxyIndirectionPolicy
- All Implemented Interfaces:
Serializable
,Cloneable
ProxyIndirectionPolicy
Define the behavior for Proxy Indirection.
Proxy Indirection uses the Proxy
and InvocationHandler
features
of JDK 1.3 to provide "transparent indirection" for 1:1 relationships. In order to use Proxy
Indirection:
- The target class must implement at least one public interface
- The attribute on the source class must be typed as that public interface
toString
is called on the proxy the real object data is retrieved from the database.- Since:
- TopLink 3.0
- 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.cloneAttribute
(Object attributeValue, Object original, CacheKey cacheKey, Object clone, Integer refreshCascade, AbstractSession cloningSession, boolean buildDirectlyFromRow) INTERNAL: Return a clone of the attribute.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.getRealAttributeValueFromObject
(Object obj, Object object) INTERNAL: Return the "real" attribute value, as opposed to any wrapper.static Object
getValueFromProxy
(Object value) INTERNAL: Given a proxy object, trigger the indirection and return the actual object represented by the proxy.boolean
INTERNAL: Return if targetInterfaces is not empty.void
INTERNAL: Nothing required.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.boolean
isValidType
(Class<?> attributeType) INTERNAL: Verify that a class type is valid to use for the proxy.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 "real" value of the attribute to attributeValue.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 attribute type is correct for the indirection policy.void
validateGetMethodReturnType
(Class<?> returnType, IntegrityChecker checker) INTERNAL: Verify that the return type of the attribute's get method is correct for the indirection policy.void
validateSetMethodParameterType
(Class<?> parameterType, IntegrityChecker checker) INTERNAL: Verify that the parameter type of the attribute's set method 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, 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.BasicIndirectionPolicy
buildIndirectObject, extractPrimaryKeyForReferenceObject, getOriginalIndirectionObjectForMerge, getOriginalValueHolder, getValueFromRemoteValueHolder, setSourceObject, typeIsValid, 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
-
Constructor Details
-
ProxyIndirectionPolicy
-
ProxyIndirectionPolicy
public ProxyIndirectionPolicy()
-
-
Method Details
-
initialize
public void initialize()INTERNAL: Nothing required.- Overrides:
initialize
in classIndirectionPolicy
-
reset
Reset the wrapper used to store the value.- Overrides:
reset
in classBasicIndirectionPolicy
-
hasTargetInterfaces
public boolean hasTargetInterfaces()INTERNAL: Return if targetInterfaces is not empty. -
valueFromRow
INTERNAL: Return the value to be stored in the object's attribute. This will be a proxy object.- Overrides:
valueFromRow
in classBasicIndirectionPolicy
-
valueFromQuery
INTERNAL: Return the value to be stored in the object's attribute. This will be a proxy object.- Overrides:
valueFromQuery
in classBasicIndirectionPolicy
-
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.- Overrides:
valueFromMethod
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 batch query. * NOTE: Currently not supported anyway.- Overrides:
valueFromBatchQuery
in classBasicIndirectionPolicy
-
objectIsInstantiated
INTERNAL: Return whether the specified object is instantiated.- Overrides:
objectIsInstantiated
in classBasicIndirectionPolicy
-
objectIsEasilyInstantiated
INTERNAL: Return whether the specified object can be instantiated without database access.- Overrides:
objectIsEasilyInstantiated
in classBasicIndirectionPolicy
-
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.- Overrides:
nullValueFromRow
in classBasicIndirectionPolicy
-
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.- Overrides:
mergeRemoteValueHolder
in classBasicIndirectionPolicy
-
getRealAttributeValueFromObject
INTERNAL: Return the "real" attribute value, as opposed to any wrapper. This will trigger the wrapper to instantiate the value.- Overrides:
getRealAttributeValueFromObject
in classBasicIndirectionPolicy
-
getValueFromProxy
INTERNAL: Given a proxy object, trigger the indirection and return the actual object represented by the proxy. -
setRealAttributeValueInObject
INTERNAL: Set the "real" value of the attribute to attributeValue.- Overrides:
setRealAttributeValueInObject
in classBasicIndirectionPolicy
-
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
-
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.- Overrides:
fixObjectReferences
in classBasicIndirectionPolicy
-
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.- Overrides:
extractReferenceRow
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.
-
backupCloneAttribute
public Object backupCloneAttribute(Object attributeValue, Object clone, Object backup, UnitOfWorkImpl unitOfWork) INTERNAL: Return a backup clone of the attribute.- Overrides:
backupCloneAttribute
in classBasicIndirectionPolicy
-
iterateOnAttributeValue
INTERNAL: Iterate over the specified attribute value.- Overrides:
iterateOnAttributeValue
in classBasicIndirectionPolicy
-
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 non-null and implement some public interface.- Overrides:
validateAttributeOfInstantiatedObject
in classBasicIndirectionPolicy
-
validateDeclaredAttributeType
public void validateDeclaredAttributeType(Class<?> attributeType, IntegrityChecker checker) throws DescriptorException INTERNAL: Verify that attribute type 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 contained in targetInterfaces.- Overrides:
validateDeclaredAttributeType
in classBasicIndirectionPolicy
- Throws:
DescriptorException
-
validateGetMethodReturnType
public void validateGetMethodReturnType(Class<?> returnType, IntegrityChecker checker) throws DescriptorException INTERNAL: Verify that the return type of the attribute's get method 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 a public interface.- Overrides:
validateGetMethodReturnType
in classBasicIndirectionPolicy
- Throws:
DescriptorException
-
validateSetMethodParameterType
public void validateSetMethodParameterType(Class<?> parameterType, IntegrityChecker checker) throws DescriptorException INTERNAL: Verify that the parameter type of the attribute's set method 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 a public interface.- Overrides:
validateSetMethodParameterType
in classBasicIndirectionPolicy
- Throws:
DescriptorException
-
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 classBasicIndirectionPolicy
- See Also:
-
isValidType
INTERNAL: Verify that a class type is valid to use for the proxy. The class must be one of the interfaces intargetInterfaces
.
-