Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0,
* or the Eclipse Distribution License v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
// Contributors:
// Oracle - initial API and implementation from Oracle TopLink
package org.eclipse.persistence.internal.indirection;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Map;
import org.eclipse.persistence.descriptors.changetracking.ChangeTracker;
import org.eclipse.persistence.exceptions.DescriptorException;
import org.eclipse.persistence.exceptions.IntegrityChecker;
import org.eclipse.persistence.indirection.ValueHolderInterface;
import org.eclipse.persistence.internal.helper.ClassConstants;
import org.eclipse.persistence.internal.identitymaps.CacheKey;
import org.eclipse.persistence.internal.queries.InterfaceContainerPolicy;
import org.eclipse.persistence.internal.sessions.AbstractRecord;
import org.eclipse.persistence.internal.sessions.AbstractSession;
import org.eclipse.persistence.internal.sessions.UnitOfWorkImpl;
import org.eclipse.persistence.internal.sessions.remote.ObjectDescriptor;
import org.eclipse.persistence.internal.sessions.remote.RemoteValueHolder;
import org.eclipse.persistence.queries.ObjectLevelReadQuery;
import org.eclipse.persistence.queries.ReadQuery;
import org.eclipse.persistence.sessions.remote.DistributedSession;
/**
*
Purpose
:
* NoIndirectionPolicy implements the behavior necessary for a
* a org.eclipse.persistence.mappings.ForeignReferenceMapping (or TransformationMapping) to
* directly use domain objects, as opposed to ValueHolders.
*
* @author Mike Norman
* @since TOPLink/Java 2.5
*/
public class NoIndirectionPolicy extends IndirectionPolicy {
/**
* INTERNAL:
* Construct a new indirection policy.
*/
public NoIndirectionPolicy() {
super();
}
/**
* 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.
*/
@Override
public Object buildIndirectObject(ValueHolderInterface valueHolder){
return valueHolder.getValue();
}
/**
* INTERNAL:
* Return a clone of the attribute.
* @param 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.
*/
@Override
public Object cloneAttribute(Object attributeValue, Object original, CacheKey cacheKey, Object clone, Integer refreshCascade, AbstractSession cloningSession, boolean buildDirectlyFromRow) {
// Since valueFromRow was called with the UnitOfWork, attributeValue
// is already a registered result.
if (buildDirectlyFromRow) {
return attributeValue;
}
if (!cloningSession.isUnitOfWork()){
return mapping.buildContainerClone(attributeValue, cloningSession);
}
boolean isExisting = !cloningSession.isUnitOfWork() || (((UnitOfWorkImpl) cloningSession).isObjectRegistered(clone) && (!(((UnitOfWorkImpl)cloningSession).isOriginalNewObject(original))));
return this.getMapping().buildCloneForPartObject(attributeValue, original, cacheKey, clone, cloningSession, refreshCascade, isExisting, isExisting);// only assume from shared cache if it is existing
}
/**
* INTERNAL:
* Return whether the collection type is appropriate for the indirection policy.
* In this case, the type MUST be a Vector (or, in the case of jdk1.2,
* Collection or Map).
*/
protected boolean collectionTypeIsValid(Class> collectionType) {
return getCollectionMapping().getContainerPolicy().isValidContainerType(collectionType);
}
/**
* 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.
*/
@Override
public AbstractRecord extractReferenceRow(Object referenceObject) {
return null;
}
/**
* 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.
*/
@Override
public void fixObjectReferences(Object object, Map