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:
java.io.Serializable,java.lang.Cloneable
public class ProxyIndirectionPolicy extends BasicIndirectionPolicy
ProxyIndirectionPolicy
Define the behavior for Proxy Indirection.Proxy Indirection uses the
ProxyandInvocationHandlerfeatures 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
toStringis called on the proxy the real object data is retrieved from the database.- Since:
- TopLink 3.0
- Author:
- Rick Barkhouse
- See Also:
ProxyIndirectionHandler, Serialized Form
-
-
Field Summary
-
Fields inherited from class org.eclipse.persistence.internal.indirection.IndirectionPolicy
mapping
-
-
Constructor Summary
Constructors Constructor Description ProxyIndirectionPolicy()ProxyIndirectionPolicy(java.lang.Class[] targetInterfaces)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ObjectbackupCloneAttribute(java.lang.Object attributeValue, java.lang.Object clone, java.lang.Object backup, UnitOfWorkImpl unitOfWork)INTERNAL: Return a backup clone of the attribute.java.lang.ObjectcloneAttribute(java.lang.Object attributeValue, java.lang.Object original, CacheKey cacheKey, java.lang.Object clone, java.lang.Integer refreshCascade, AbstractSession cloningSession, boolean buildDirectlyFromRow)INTERNAL: Return a clone of the attribute.AbstractRecordextractReferenceRow(java.lang.Object referenceObject)INTERNAL: Return the reference row for the reference object.voidfixObjectReferences(java.lang.Object object, java.util.Map objectDescriptors, java.util.Map processedObjects, ObjectLevelReadQuery query, DistributedSession session)INTERNAL: An object has been serialized from the server to the client.java.lang.ObjectgetOriginalIndirectionObject(java.lang.Object unitOfWorkIndirectionObject, AbstractSession session)INTERNAL: Return the original indirection object for a unit of work indirection object.java.lang.ObjectgetRealAttributeValueFromObject(java.lang.Object obj, java.lang.Object object)INTERNAL: Return the "real" attribute value, as opposed to any wrapper.static java.lang.ObjectgetValueFromProxy(java.lang.Object value)INTERNAL: Given a proxy object, trigger the indirection and return the actual object represented by the proxy.booleanhasTargetInterfaces()INTERNAL: Return if targetInterfaces is not empty.voidinitialize()INTERNAL: Nothing required.booleanisAttributeValueFullyBuilt(java.lang.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.booleanisValidType(java.lang.Class attributeType)INTERNAL: Verify that a class type is valid to use for the proxy.voiditerateOnAttributeValue(DescriptorIterator iterator, java.lang.Object attributeValue)INTERNAL: Iterate over the specified attribute value.voidmergeRemoteValueHolder(java.lang.Object clientSideDomainObject, java.lang.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.java.lang.ObjectnullValueFromRow()INTERNAL: Return the null value of the appropriate attribute.booleanobjectIsEasilyInstantiated(java.lang.Object object)INTERNAL: Return whether the specified object can be instantiated without database access.booleanobjectIsInstantiated(java.lang.Object object)INTERNAL: Return whether the specified object is instantiated.voidreset(java.lang.Object target)Reset the wrapper used to store the value.voidsetRealAttributeValueInObject(java.lang.Object target, java.lang.Object attributeValue)INTERNAL: Set the "real" value of the attribute to attributeValue.java.lang.ObjectvalidateAttributeOfInstantiatedObject(java.lang.Object attributeValue)INTERNAL: Verify that the value of the attribute within an instantiated object is of the appropriate type for the indirection policy.voidvalidateDeclaredAttributeType(java.lang.Class attributeType, IntegrityChecker checker)INTERNAL: Verify that attribute type is correct for the indirection policy.voidvalidateGetMethodReturnType(java.lang.Class returnType, IntegrityChecker checker)INTERNAL: Verify that the return type of the attribute's get method is correct for the indirection policy.voidvalidateSetMethodParameterType(java.lang.Class parameterType, IntegrityChecker checker)INTERNAL: Verify that the parameter type of the attribute's set method is correct for the indirection policy.java.lang.ObjectvalueFromBatchQuery(ReadQuery batchQuery, AbstractRecord row, ObjectLevelReadQuery originalQuery, CacheKey parentCacheKey)INTERNAL: Return the value to be stored in the object's attribute.java.lang.ObjectvalueFromMethod(java.lang.Object object, AbstractRecord row, AbstractSession session)INTERNAL: Return the value to be stored in the object's attribute.java.lang.ObjectvalueFromQuery(ReadQuery query, AbstractRecord row, AbstractSession session)INTERNAL: Return the value to be stored in the object's attribute.java.lang.ObjectvalueFromRow(java.lang.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
-
-
-
-
Method Detail
-
initialize
public void initialize()
INTERNAL: Nothing required.- Overrides:
initializein classIndirectionPolicy
-
reset
public void reset(java.lang.Object target)
Reset the wrapper used to store the value.- Overrides:
resetin classBasicIndirectionPolicy
-
hasTargetInterfaces
public boolean hasTargetInterfaces()
INTERNAL: Return if targetInterfaces is not empty.
-
valueFromRow
public java.lang.Object valueFromRow(java.lang.Object object)
INTERNAL: Return the value to be stored in the object's attribute. This will be a proxy object.- Overrides:
valueFromRowin classBasicIndirectionPolicy
-
valueFromQuery
public java.lang.Object valueFromQuery(ReadQuery query, AbstractRecord row, AbstractSession session)
INTERNAL: Return the value to be stored in the object's attribute. This will be a proxy object.- Overrides:
valueFromQueryin classBasicIndirectionPolicy
-
valueFromMethod
public java.lang.Object valueFromMethod(java.lang.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.- Overrides:
valueFromMethodin classBasicIndirectionPolicy
-
valueFromBatchQuery
public java.lang.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:
valueFromBatchQueryin classBasicIndirectionPolicy
-
objectIsInstantiated
public boolean objectIsInstantiated(java.lang.Object object)
INTERNAL: Return whether the specified object is instantiated.- Overrides:
objectIsInstantiatedin classBasicIndirectionPolicy
-
objectIsEasilyInstantiated
public boolean objectIsEasilyInstantiated(java.lang.Object object)
INTERNAL: Return whether the specified object can be instantiated without database access.- Overrides:
objectIsEasilyInstantiatedin classBasicIndirectionPolicy
-
nullValueFromRow
public java.lang.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.- Overrides:
nullValueFromRowin classBasicIndirectionPolicy
-
mergeRemoteValueHolder
public void mergeRemoteValueHolder(java.lang.Object clientSideDomainObject, java.lang.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:
mergeRemoteValueHolderin classBasicIndirectionPolicy
-
getRealAttributeValueFromObject
public java.lang.Object getRealAttributeValueFromObject(java.lang.Object obj, java.lang.Object object)INTERNAL: Return the "real" attribute value, as opposed to any wrapper. This will trigger the wrapper to instantiate the value.- Overrides:
getRealAttributeValueFromObjectin classBasicIndirectionPolicy
-
getValueFromProxy
public static java.lang.Object getValueFromProxy(java.lang.Object value)
INTERNAL: Given a proxy object, trigger the indirection and return the actual object represented by the proxy.
-
setRealAttributeValueInObject
public void setRealAttributeValueInObject(java.lang.Object target, java.lang.Object attributeValue)INTERNAL: Set the "real" value of the attribute to attributeValue.- Overrides:
setRealAttributeValueInObjectin classBasicIndirectionPolicy
-
getOriginalIndirectionObject
public java.lang.Object getOriginalIndirectionObject(java.lang.Object unitOfWorkIndirectionObject, AbstractSession session)INTERNAL: Return the original indirection object for a unit of work indirection object.- Overrides:
getOriginalIndirectionObjectin classBasicIndirectionPolicy
-
fixObjectReferences
public void fixObjectReferences(java.lang.Object object, java.util.Map objectDescriptors, java.util.Map 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:
fixObjectReferencesin classBasicIndirectionPolicy
-
extractReferenceRow
public AbstractRecord extractReferenceRow(java.lang.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:
extractReferenceRowin classBasicIndirectionPolicy
-
cloneAttribute
public java.lang.Object cloneAttribute(java.lang.Object attributeValue, java.lang.Object original, CacheKey cacheKey, java.lang.Object clone, java.lang.Integer refreshCascade, AbstractSession cloningSession, boolean buildDirectlyFromRow)INTERNAL: Return a clone of the attribute.- Overrides:
cloneAttributein 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 java.lang.Object backupCloneAttribute(java.lang.Object attributeValue, java.lang.Object clone, java.lang.Object backup, UnitOfWorkImpl unitOfWork)INTERNAL: Return a backup clone of the attribute.- Overrides:
backupCloneAttributein classBasicIndirectionPolicy
-
iterateOnAttributeValue
public void iterateOnAttributeValue(DescriptorIterator iterator, java.lang.Object attributeValue)
INTERNAL: Iterate over the specified attribute value.- Overrides:
iterateOnAttributeValuein classBasicIndirectionPolicy
-
validateAttributeOfInstantiatedObject
public java.lang.Object validateAttributeOfInstantiatedObject(java.lang.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 non-null and implement some public interface.- Overrides:
validateAttributeOfInstantiatedObjectin classBasicIndirectionPolicy
-
validateDeclaredAttributeType
public void validateDeclaredAttributeType(java.lang.Class attributeType, IntegrityChecker checker) throws DescriptorExceptionINTERNAL: 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:
validateDeclaredAttributeTypein classBasicIndirectionPolicy- Throws:
DescriptorException
-
validateGetMethodReturnType
public void validateGetMethodReturnType(java.lang.Class returnType, IntegrityChecker checker) throws DescriptorExceptionINTERNAL: 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:
validateGetMethodReturnTypein classBasicIndirectionPolicy- Throws:
DescriptorException
-
validateSetMethodParameterType
public void validateSetMethodParameterType(java.lang.Class parameterType, IntegrityChecker checker) throws DescriptorExceptionINTERNAL: 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:
validateSetMethodParameterTypein classBasicIndirectionPolicy- Throws:
DescriptorException
-
isAttributeValueFullyBuilt
public boolean isAttributeValueFullyBuilt(java.lang.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:
isAttributeValueFullyBuiltin classBasicIndirectionPolicy- Parameters:
attributeValue-- Returns:
- See Also:
validateAttributeOfInstantiatedObject(java.lang.Object)
-
isValidType
public boolean isValidType(java.lang.Class attributeType)
INTERNAL: Verify that a class type is valid to use for the proxy. The class must be one of the interfaces intargetInterfaces.
-
-