Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-02-12 06:43:39 -0500
committerEike Stepper2013-02-13 14:58:19 -0500
commitef70e75984ccdd2c0eb2cec0da13ac7e1319d4ea (patch)
treedef004d50655cf2d807bc11fa6b8067cddb8f48d
parentda7d59cf71edbd4b7333b38542072ed7c587224d (diff)
downloadcdo-ef70e75984ccdd2c0eb2cec0da13ac7e1319d4ea.tar.gz
cdo-ef70e75984ccdd2c0eb2cec0da13ac7e1319d4ea.tar.xz
cdo-ef70e75984ccdd2c0eb2cec0da13ac7e1319d4ea.zip
[400388] Integrate the new MinimalEStoreEObjectImpl
https://bugs.eclipse.org/bugs/show_bug.cgi?id=400388
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOClassInfo.java19
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOClassInfoImpl.java108
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/model/InternalCDOClassInfo.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/DelegatingCDORevision.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDORevision.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateQueryHandler.java6
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java7
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyWrapper.java21
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java28
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CommitIntegrityCheck.java69
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStateMachine.java62
11 files changed, 207 insertions, 131 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOClassInfo.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOClassInfo.java
index 8265895ddf..00e8e1e1eb 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOClassInfo.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOClassInfo.java
@@ -42,6 +42,16 @@ public interface CDOClassInfo extends Adapter
*/
public boolean isPersistent(int featureID);
+ /**
+ * @since 4.2
+ */
+ public boolean isPersistent(EStructuralFeature feature);
+
+ /**
+ * @since 4.2
+ */
+ public boolean hasPersistentOpposite(EStructuralFeature feature);
+
public EStructuralFeature[] getAllPersistentFeatures();
/**
@@ -50,13 +60,18 @@ public interface CDOClassInfo extends Adapter
public EReference[] getAllPersistentReferences();
/**
- * @deprecated As of 4.2 pushed down to {@link InternalCDOClassInfo#getFeatureIndex(EStructuralFeature)}.
+ * @since 4.2
+ */
+ public EStructuralFeature[] getAllPersistentContainments();
+
+ /**
+ * @deprecated As of 4.2 pushed down to {@link InternalCDOClassInfo#getPersistentFeatureIndex(EStructuralFeature)}.
*/
@Deprecated
public int getFeatureIndex(EStructuralFeature feature);
/**
- * @deprecated As of 4.2 pushed down to {@link InternalCDOClassInfo#getFeatureIndex(int)}.
+ * @deprecated As of 4.2 pushed down to {@link InternalCDOClassInfo#getPersistentFeatureIndex(int)}.
*/
@Deprecated
public int getFeatureIndex(int featureID);
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOClassInfoImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOClassInfoImpl.java
index 2cc5d2536e..9b7743880f 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOClassInfoImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOClassInfoImpl.java
@@ -17,12 +17,14 @@ import org.eclipse.emf.cdo.common.model.EMFUtil;
import org.eclipse.emf.cdo.internal.common.bundle.OM;
import org.eclipse.emf.cdo.spi.common.model.InternalCDOClassInfo;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.impl.EClassImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.FeatureMapUtil;
@@ -34,18 +36,24 @@ import java.util.List;
/**
* @author Eike Stepper
*/
-public final class CDOClassInfoImpl extends AdapterImpl implements InternalCDOClassInfo
+public final class CDOClassInfoImpl implements InternalCDOClassInfo, Adapter.Internal
{
private static final PersistenceFilter[] NO_FILTERS = {};
+ private EClass eClass;
+
private final BitSet persistentBits = new BitSet();
+ private final BitSet persistentOppositeBits = new BitSet();
+
private PersistenceFilter[] persistenceFilters = NO_FILTERS;
private EStructuralFeature[] allPersistentFeatures;
private EReference[] allPersistentReferences;
+ private EStructuralFeature[] allPersistentContainments;
+
private int[] persistentFeatureIndices;
private int settingsFeatureCount;
@@ -66,37 +74,48 @@ public final class CDOClassInfoImpl extends AdapterImpl implements InternalCDOCl
{
}
- @Override
public boolean isAdapterForType(Object type)
{
return type == CDOClassInfo.class;
}
- @Override
+ public void notifyChanged(Notification notification)
+ {
+ }
+
+ public EClass getTarget()
+ {
+ return eClass;
+ }
+
public void setTarget(Notifier newTarget)
{
init((EClass)newTarget);
- super.setTarget(newTarget);
+ }
+
+ public void unsetTarget(Notifier oldTarget)
+ {
+ eClass = null;
}
public EClass getEClass()
{
- return (EClass)getTarget();
+ return eClass;
}
public boolean isResource()
{
- return CDOModelUtil.isResource(getEClass());
+ return CDOModelUtil.isResource(eClass);
}
public boolean isResourceFolder()
{
- return CDOModelUtil.isResourceFolder(getEClass());
+ return CDOModelUtil.isResourceFolder(eClass);
}
public boolean isResourceNode()
{
- return CDOModelUtil.isResourceNode(getEClass());
+ return CDOModelUtil.isResourceNode(eClass);
}
public boolean isPersistent(int featureID)
@@ -104,6 +123,18 @@ public final class CDOClassInfoImpl extends AdapterImpl implements InternalCDOCl
return persistentBits.get(featureID);
}
+ public boolean isPersistent(EStructuralFeature feature)
+ {
+ int featureID = eClass.getFeatureID(feature);
+ return isPersistent(featureID);
+ }
+
+ public boolean hasPersistentOpposite(EStructuralFeature feature)
+ {
+ int featureID = eClass.getFeatureID(feature);
+ return persistentOppositeBits.get(featureID);
+ }
+
public EStructuralFeature[] getAllPersistentFeatures()
{
return allPersistentFeatures;
@@ -114,9 +145,14 @@ public final class CDOClassInfoImpl extends AdapterImpl implements InternalCDOCl
return allPersistentReferences;
}
+ public EStructuralFeature[] getAllPersistentContainments()
+ {
+ return allPersistentContainments;
+ }
+
public int getPersistentFeatureIndex(EStructuralFeature feature) throws IllegalArgumentException
{
- int featureID = getEClass().getFeatureID(feature);
+ int featureID = eClass.getFeatureID(feature);
return getPersistentFeatureIndex(featureID);
}
@@ -125,7 +161,7 @@ public final class CDOClassInfoImpl extends AdapterImpl implements InternalCDOCl
int index = persistentFeatureIndices[featureID];
if (index == NO_SLOT)
{
- throw new IllegalArgumentException("Feature not mapped: " + getEClass().getEStructuralFeature(featureID)); //$NON-NLS-1$
+ throw new IllegalArgumentException("Feature not mapped: " + eClass.getEStructuralFeature(featureID)); //$NON-NLS-1$
}
return index;
@@ -151,6 +187,12 @@ public final class CDOClassInfoImpl extends AdapterImpl implements InternalCDOCl
return transientFeatureIndices[featureID];
}
+ public int getTransientFeatureIndex(EStructuralFeature feature)
+ {
+ int featureID = eClass.getFeatureID(feature);
+ return getTransientFeatureIndex(featureID);
+ }
+
public PersistenceFilter getPersistenceFilter(EStructuralFeature feature)
{
if (persistenceFilters == NO_FILTERS)
@@ -158,7 +200,7 @@ public final class CDOClassInfoImpl extends AdapterImpl implements InternalCDOCl
return null;
}
- int featureID = getEClass().getFeatureID(feature);
+ int featureID = eClass.getFeatureID(feature);
return persistenceFilters[featureID];
}
@@ -185,13 +227,22 @@ public final class CDOClassInfoImpl extends AdapterImpl implements InternalCDOCl
private void init(EClass eClass)
{
+ this.eClass = eClass;
EList<EStructuralFeature> allFeatures = eClass.getEAllStructuralFeatures();
int featureCount = eClass.getFeatureCount();
List<EStructuralFeature> persistentFeatures = new ArrayList<EStructuralFeature>();
List<EReference> persistentReferences = new ArrayList<EReference>();
+ List<EStructuralFeature> persistentContainments = new ArrayList<EStructuralFeature>();
+
+ // Used for tests for containment
+ EStructuralFeature[] containments = ((EClassImpl.FeatureSubsetSupplier)eClass.getEAllStructuralFeatures())
+ .containments();
+
persistentBits.clear();
+ persistentOppositeBits.clear();
settingsFeatureIndices = new int[featureCount];
+
for (int i = 0; i < featureCount; i++)
{
EStructuralFeature feature = eClass.getEStructuralFeature(i);
@@ -201,9 +252,21 @@ public final class CDOClassInfoImpl extends AdapterImpl implements InternalCDOCl
persistentBits.set(featureID);
persistentFeatures.add(feature);
+ if (isContainment(containments, feature))
+ {
+ persistentContainments.add(feature);
+ }
+
if (feature instanceof EReference)
{
- persistentReferences.add((EReference)feature);
+ EReference reference = (EReference)feature;
+ persistentReferences.add(reference);
+
+ EReference opposite = reference.getEOpposite();
+ if (opposite != null && EMFUtil.isPersistent(opposite))
+ {
+ persistentOppositeBits.set(featureID);
+ }
}
if (feature.isMany() || FeatureMapUtil.isFeatureMap(feature))
@@ -237,6 +300,7 @@ public final class CDOClassInfoImpl extends AdapterImpl implements InternalCDOCl
allPersistentFeatures = persistentFeatures.toArray(new EStructuralFeature[persistentFeatures.size()]);
allPersistentReferences = persistentReferences.toArray(new EReference[persistentReferences.size()]);
+ allPersistentContainments = persistentContainments.toArray(new EStructuralFeature[persistentContainments.size()]);
persistentFeatureIndices = new int[allFeatures.size()];
Arrays.fill(persistentFeatureIndices, NO_SLOT);
@@ -260,6 +324,22 @@ public final class CDOClassInfoImpl extends AdapterImpl implements InternalCDOCl
}
}
+ private boolean isContainment(EStructuralFeature[] containments, EStructuralFeature feature)
+ {
+ if (containments != null)
+ {
+ for (EStructuralFeature containment : containments)
+ {
+ if (containment == feature)
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
@Deprecated
public int getFeatureIndex(EStructuralFeature feature)
{
@@ -275,6 +355,6 @@ public final class CDOClassInfoImpl extends AdapterImpl implements InternalCDOCl
@Override
public String toString()
{
- return getEClass().toString();
+ return eClass.toString();
}
}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/model/InternalCDOClassInfo.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/model/InternalCDOClassInfo.java
index c03e9e54cc..02f65a4a29 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/model/InternalCDOClassInfo.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/model/InternalCDOClassInfo.java
@@ -79,6 +79,11 @@ public interface InternalCDOClassInfo extends CDOClassInfo
public int getTransientFeatureIndex(int featureID);
/**
+ * @see #getTransientFeatureIndex(int)
+ */
+ public int getTransientFeatureIndex(EStructuralFeature feature);
+
+ /**
* Obtains a rule that filters/transforms the persist values of the given
* {@code feature}.
*
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/DelegatingCDORevision.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/DelegatingCDORevision.java
index dec885138b..748ed652cd 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/DelegatingCDORevision.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/DelegatingCDORevision.java
@@ -15,7 +15,6 @@ import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDProvider;
-import org.eclipse.emf.cdo.common.model.CDOClassInfo;
import org.eclipse.emf.cdo.common.protocol.CDODataInput;
import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
import org.eclipse.emf.cdo.common.revision.CDOList;
@@ -23,6 +22,7 @@ import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.CDORevisionData;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
import org.eclipse.emf.cdo.common.security.CDOPermission;
+import org.eclipse.emf.cdo.spi.common.model.InternalCDOClassInfo;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EStructuralFeature;
@@ -142,7 +142,10 @@ public abstract class DelegatingCDORevision implements InternalCDORevision
return null;
}
- public CDOClassInfo getClassInfo()
+ /**
+ * @since 4.2
+ */
+ public InternalCDOClassInfo getClassInfo()
{
return getDelegate().getClassInfo();
}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDORevision.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDORevision.java
index eeeb501f79..8e16a33dcd 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDORevision.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDORevision.java
@@ -21,6 +21,7 @@ import org.eclipse.emf.cdo.common.revision.CDOList;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.CDORevisionData;
import org.eclipse.emf.cdo.common.security.CDOPermission;
+import org.eclipse.emf.cdo.spi.common.model.InternalCDOClassInfo;
import org.eclipse.emf.ecore.EStructuralFeature;
@@ -36,6 +37,11 @@ import java.io.IOException;
*/
public interface InternalCDORevision extends CDORevision, CDORevisionData, CDOReferenceAdjustable
{
+ /**
+ * @since 4.2
+ */
+ public InternalCDOClassInfo getClassInfo();
+
public void setID(CDOID id);
public void setVersion(int version);
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateQueryHandler.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateQueryHandler.java
index b87eed9f0e..ed44ca2b7d 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateQueryHandler.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateQueryHandler.java
@@ -38,7 +38,7 @@ import java.lang.reflect.Array;
/**
* Implements server side HQL query execution..
- *
+ *
* @author Martin Taal
*/
public class HibernateQueryHandler implements IQueryHandler
@@ -63,7 +63,7 @@ public class HibernateQueryHandler implements IQueryHandler
* Executes hql queries. Gets the session from the {@link HibernateStoreAccessor} creates a hibernate query and sets
* the parameters taken from the {@link CDOQueryInfo#getParameters()}. Takes into account the
* {@link CDOQueryInfo#getMaxResults()} and the {@link IHibernateStore#FIRST_RESULT} values for paging.
- *
+ *
* @param info
* the object containing the query and parameters
* @param context
@@ -281,7 +281,7 @@ public class HibernateQueryHandler implements IQueryHandler
try
{
int featureID = revision.getClassInfo().getEClass().getFeatureID(feature);
- revision.getClassInfo().getFeatureIndex(featureID);
+ revision.getClassInfo().getPersistentFeatureIndex(featureID);
return true;
}
catch (IllegalArgumentException ex)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java
index 8e79a501a0..6156fa7679 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java
@@ -419,14 +419,12 @@ public class CDOObjectImpl extends MinimalEStoreEObjectImpl implements InternalC
if (eSettings != null)
{
- EClass eClass = eClass();
EStructuralFeature[] allPersistentFeatures = classInfo.getAllPersistentFeatures();
int length = allPersistentFeatures.length;
for (int i = 0; i < length; i++)
{
EStructuralFeature eFeature = allPersistentFeatures[i];
- int featureID = eClass.getFeatureID(eFeature);
- int transientIndex = classInfo.getTransientFeatureIndex(featureID);
+ int transientIndex = classInfo.getTransientFeatureIndex(eFeature);
Object setting = eSettings[transientIndex]; // Can be safely accessed directly because we come from TRANSIENT
instanceToRevisionFeature(viewAndState.view, this, eFeature, setting);
@@ -1321,8 +1319,7 @@ public class CDOObjectImpl extends MinimalEStoreEObjectImpl implements InternalC
private int getTransientFeatureIndex(InternalEObject eObject, EStructuralFeature feature)
{
CDOObjectImpl object = (CDOObjectImpl)eObject;
- int dynamicFeatureID = object.eDynamicFeatureID(feature);
- return object.classInfo.getTransientFeatureIndex(dynamicFeatureID);
+ return object.classInfo.getTransientFeatureIndex(feature);
}
public Object get(InternalEObject eObject, EStructuralFeature feature, int index)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyWrapper.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyWrapper.java
index f5604b13eb..2ab76cb779 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyWrapper.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyWrapper.java
@@ -18,7 +18,6 @@ import org.eclipse.emf.cdo.CDOState;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.model.CDOModelUtil;
import org.eclipse.emf.cdo.common.model.CDOType;
-import org.eclipse.emf.cdo.common.model.EMFUtil;
import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
import org.eclipse.emf.cdo.common.revision.CDOElementProxy;
import org.eclipse.emf.cdo.common.revision.CDORevision;
@@ -271,25 +270,27 @@ public abstract class CDOLegacyWrapper extends CDOObjectWrapper
// This loop adjusts the opposite wrapper objects to support dangling references. See Bugzilla_251263_Test
InternalCDORevision revision = cdoRevision();
- for (EStructuralFeature feature : classInfo.getAllPersistentFeatures())
+ for (EReference reference : classInfo.getAllPersistentReferences())
{
- EReference oppositeReference = ((EStructuralFeature.Internal)feature).getEOpposite();
- if (oppositeReference != null && !oppositeReference.isContainment() && EMFUtil.isPersistent(oppositeReference))
+ if (!reference.isContainer() && classInfo.hasPersistentOpposite(reference))
{
- if (feature.isMany())
+ if (reference.isMany())
{
- int size = revision.size(feature);
+ EReference oppositeReference = reference.getEOpposite();
+
+ int size = revision.size(reference);
for (int i = 0; i < size; i++)
{
- EObject object = (EObject)getValueFromRevision(feature, i);
+ EObject object = (EObject)getValueFromRevision(reference, i);
adjustPersistentOppositeReference(this, object, oppositeReference);
}
}
else
{
- EObject oppositeObject = (EObject)instance.eGet(feature);
+ EObject oppositeObject = (EObject)instance.eGet(reference);
if (oppositeObject != null)
{
+ EReference oppositeReference = reference.getEOpposite();
adjustPersistentOppositeReference(this, oppositeObject, oppositeReference);
}
}
@@ -641,7 +642,7 @@ public abstract class CDOLegacyWrapper extends CDOObjectWrapper
instance.eInverseAdd((InternalEObject)object, featureID, baseClass, null);
}
- if (!EMFUtil.isPersistent(oppositeReference))
+ if (!classInfo.hasPersistentOpposite(internalFeature))
{
adjustTransientOppositeReference(instance, (InternalEObject)object, oppositeReference);
}
@@ -1077,7 +1078,7 @@ public abstract class CDOLegacyWrapper extends CDOObjectWrapper
EList<Object> list = (EList<Object>)eObject.eGet(oppositeReference);
int index = list.indexOf(instance);
- if (!store.isEmpty(oppositeCDOObject, oppositeReference) && index != EStore.NO_INDEX)
+ if (index != EStore.NO_INDEX && !store.isEmpty(oppositeCDOObject, oppositeReference))
{
store.set(oppositeCDOObject, oppositeReference, index, cdoObject);
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java
index 852c54e408..241814e843 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java
@@ -73,6 +73,7 @@ import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil;
import org.eclipse.emf.cdo.spi.common.commit.CDORevisionAvailabilityInfo;
import org.eclipse.emf.cdo.spi.common.commit.InternalCDOCommitInfoManager;
import org.eclipse.emf.cdo.spi.common.lock.InternalCDOLockState;
+import org.eclipse.emf.cdo.spi.common.model.InternalCDOClassInfo;
import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
import org.eclipse.emf.cdo.spi.common.protocol.CDODataInputImpl;
import org.eclipse.emf.cdo.spi.common.protocol.CDODataOutputImpl;
@@ -138,11 +139,11 @@ import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.EStructuralFeature.Setting;
-import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.InternalEObject.EStore;
import org.eclipse.emf.ecore.impl.EClassImpl.FeatureSubsetSupplier;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.Resource.Internal;
+import org.eclipse.emf.ecore.util.EContentsEList;
import org.eclipse.emf.ecore.util.EContentsEList.FeatureIterator;
import org.eclipse.emf.ecore.util.ECrossReferenceEList;
import org.eclipse.emf.ecore.util.EcoreUtil;
@@ -2344,6 +2345,9 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
List<Pair<Setting, EObject>> objectsToBeRemoved = new LinkedList<Pair<Setting, EObject>>();
for (CDOObject referencer : referencers)
{
+ InternalCDOObject internalReferencer = (InternalCDOObject)referencer;
+ InternalCDOClassInfo referencerClassInfo = internalReferencer.cdoClassInfo();
+
FeatureIterator<EObject> it = getChangeableCrossReferences(referencer);
while (it.hasNext())
{
@@ -2359,7 +2363,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
// should we remove it. If this is not the case (i.e. it is dirty in a different
// way), we skip it. (If the reference is not persistent, then this exception
// doesn't apply: it must be removed for sure.)
- if (referencer.cdoState() == CDOState.DIRTY && EMFUtil.isPersistent(reference))
+ if (referencer.cdoState() == CDOState.DIRTY && referencerClassInfo.isPersistent(reference))
{
InternalCDORevision cleanRevision = cleanRevisions.get(referencer);
@@ -2372,7 +2376,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
}
}
- Setting setting = ((InternalEObject)referencer).eSetting(reference);
+ Setting setting = internalReferencer.eSetting(reference);
objectsToBeRemoved.add(new Pair<Setting, EObject>(setting, referencedObject));
}
}
@@ -2414,8 +2418,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
{
EStructuralFeature[] collectedStructuralFeatures = changeableReferences
.toArray(new EStructuralFeature[changeableReferences.size()]);
- return (FeatureIterator<EObject>)new ECrossReferenceEListDerived(object, collectedStructuralFeatures)
- .iterator();
+ return new EContentsEList.ResolvingFeatureIteratorImpl<EObject>(object, collectedStructuralFeatures);
}
}
@@ -3291,19 +3294,4 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
}
}
}
-
- public static class ECrossReferenceEListDerived extends ECrossReferenceEList<EObject>
- {
-
- public ECrossReferenceEListDerived(EObject eObject)
- {
- super(eObject);
- }
-
- public ECrossReferenceEListDerived(EObject eObject, EStructuralFeature[] eStructuralFeatures)
- {
- super(eObject, eStructuralFeatures);
- }
- }
-
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CommitIntegrityCheck.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CommitIntegrityCheck.java
index 4a809527c6..2eab4eaf5c 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CommitIntegrityCheck.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CommitIntegrityCheck.java
@@ -14,7 +14,6 @@ import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.CDOState;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDUtil;
-import org.eclipse.emf.cdo.common.model.EMFUtil;
import org.eclipse.emf.cdo.common.revision.delta.CDOAddFeatureDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDOClearFeatureDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDOContainerFeatureDelta;
@@ -26,6 +25,7 @@ import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDOSetFeatureDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDOUnsetFeatureDelta;
import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.spi.common.model.InternalCDOClassInfo;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.cdo.util.CommitIntegrityException;
@@ -147,13 +147,14 @@ public class CommitIntegrityCheck
InternalCDORevision cleanRev = transaction.getCleanRevisions().get(dirtyObject);
CheckUtil.checkNull(cleanRev, "Could not obtain clean revision for dirty object " + dirtyObject);
+ InternalCDOClassInfo classInfo = dirtyObject.cdoClassInfo();
InternalCDORevision dirtyRev = dirtyObject.cdoRevision();
- CDORevisionDelta rDelta = dirtyRev.compare(cleanRev);
+ CDORevisionDelta revisionDelta = dirtyRev.compare(cleanRev);
- for (CDOFeatureDelta featureDelta : rDelta.getFeatureDeltas())
+ for (CDOFeatureDelta featureDelta : revisionDelta.getFeatureDeltas())
{
- EStructuralFeature feat = featureDelta.getFeature();
- if (feat == CDOContainerFeatureDelta.CONTAINER_FEATURE)
+ EStructuralFeature feature = featureDelta.getFeature();
+ if (feature == CDOContainerFeatureDelta.CONTAINER_FEATURE)
{
// Three possibilities here:
// 1. Object's container has changed
@@ -196,18 +197,20 @@ public class CommitIntegrityCheck
}
}
}
- else if (feat instanceof EReference)
+ else if (feature instanceof EReference)
{
if (featureDelta instanceof CDOListFeatureDelta)
{
+ boolean hasPersistentOpposite = classInfo.hasPersistentOpposite(feature);
for (CDOFeatureDelta innerFeatDelta : ((CDOListFeatureDelta)featureDelta).getListChanges())
{
- checkFeatureDelta(innerFeatDelta, dirtyObject);
+ checkFeatureDelta(innerFeatDelta, hasPersistentOpposite, dirtyObject);
}
}
else
{
- checkFeatureDelta(featureDelta, dirtyObject);
+ boolean hasPersistentOpposite = classInfo.hasPersistentOpposite(feature);
+ checkFeatureDelta(featureDelta, hasPersistentOpposite, dirtyObject);
}
}
}
@@ -228,10 +231,11 @@ public class CommitIntegrityCheck
// else: Transient object -- ignore
}
- private void checkFeatureDelta(CDOFeatureDelta featureDelta, CDOObject dirtyObject) throws CommitIntegrityException
+ private void checkFeatureDelta(CDOFeatureDelta featureDelta, boolean hasPersistentOpposite, CDOObject dirtyObject)
+ throws CommitIntegrityException
{
EReference ref = (EReference)featureDelta.getFeature();
- boolean containmentOrWithOpposite = ref.isContainment() || hasPersistentOpposite(ref);
+ boolean containmentOrWithOpposite = ref.isContainment() || hasPersistentOpposite;
if (featureDelta instanceof CDOAddFeatureDelta)
{
@@ -387,31 +391,39 @@ public class CommitIntegrityCheck
private void checkCurrentRefTargetsIncluded(CDOObject referencer, String msgFrag) throws CommitIntegrityException
{
- for (EReference eRef : ((InternalCDOObject)referencer).cdoClassInfo().getAllPersistentReferences())
+ InternalCDOClassInfo classInfo = ((InternalCDOObject)referencer).cdoClassInfo();
+
+ for (EReference reference : classInfo.getAllPersistentReferences())
{
- if (eRef.isMany())
+ if (reference.isMany())
{
- EList<?> list = (EList<?>)referencer.eGet(eRef);
- for (Object refTarget : list)
+ EList<?> list = (EList<?>)referencer.eGet(reference);
+ if (!list.isEmpty())
{
- checkBidiRefTargetOrNewNonBidiTargetIncluded(referencer, eRef, refTarget, msgFrag);
+ boolean hasPersistentOpposite = classInfo.hasPersistentOpposite(reference);
+ for (Object refTarget : list)
+ {
+ checkBidiRefTargetOrNewNonBidiTargetIncluded(referencer, reference, refTarget, hasPersistentOpposite,
+ msgFrag);
+ }
}
}
else
{
- Object refTarget = referencer.eGet(eRef);
+ Object refTarget = referencer.eGet(reference);
if (refTarget != null)
{
- checkBidiRefTargetOrNewNonBidiTargetIncluded(referencer, eRef, refTarget, msgFrag);
+ boolean hasPersistentOpposite = classInfo.hasPersistentOpposite(reference);
+ checkBidiRefTargetOrNewNonBidiTargetIncluded(referencer, reference, refTarget, hasPersistentOpposite, msgFrag);
}
}
}
}
private void checkBidiRefTargetOrNewNonBidiTargetIncluded(CDOObject referencer, EReference eRef, Object refTarget,
- String msgFrag) throws CommitIntegrityException
+ boolean hasPersistentOpposite, String msgFrag) throws CommitIntegrityException
{
- if (hasPersistentOpposite(eRef))
+ if (hasPersistentOpposite)
{
// It's a bi-di ref; the target must definitely be included
checkBidiRefTargetIncluded(refTarget, referencer, eRef.getName(), msgFrag);
@@ -432,24 +444,25 @@ public class CommitIntegrityCheck
InternalCDORevision cleanRev = transaction.getCleanRevisions().get(referencer);
CheckUtil.checkState(cleanRev, "cleanRev");
- for (EReference eRef : ((InternalCDOObject)referencer).cdoClassInfo().getAllPersistentReferences())
+ InternalCDOClassInfo referencerClassInfo = ((InternalCDOObject)referencer).cdoClassInfo();
+ for (EReference reference : referencerClassInfo.getAllPersistentReferences())
{
- if (hasPersistentOpposite(eRef))
+ if (referencerClassInfo.hasPersistentOpposite(reference))
{
- Object value = cleanRev.get(eRef, EStore.NO_INDEX);
+ Object value = cleanRev.get(reference, EStore.NO_INDEX);
if (value != null)
{
- if (eRef.isMany())
+ if (reference.isMany())
{
EList<?> list = (EList<?>)value;
for (Object element : list)
{
- checkBidiRefTargetIncluded(element, referencer, eRef.getName(), msgFrag);
+ checkBidiRefTargetIncluded(element, referencer, reference.getName(), msgFrag);
}
}
else
{
- checkBidiRefTargetIncluded(value, referencer, eRef.getName(), msgFrag);
+ checkBidiRefTargetIncluded(value, referencer, reference.getName(), msgFrag);
}
}
}
@@ -487,12 +500,6 @@ public class CommitIntegrityCheck
checkIncluded(id, "former container (or resource) of detached", detachedObject);
}
- private static boolean hasPersistentOpposite(EReference ref)
- {
- EReference eOpposite = ref.getEOpposite();
- return eOpposite != null && EMFUtil.isPersistent(eOpposite);
- }
-
/**
* Designates an exception style for a {@link CommitIntegrityCheck}
*
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStateMachine.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStateMachine.java
index ba62937838..e132e40dff 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStateMachine.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStateMachine.java
@@ -14,7 +14,6 @@ package org.eclipse.emf.internal.cdo.view;
import org.eclipse.emf.cdo.CDOState;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDTemp;
-import org.eclipse.emf.cdo.common.model.EMFUtil;
import org.eclipse.emf.cdo.common.revision.CDORevisable;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.CDORevisionFactory;
@@ -52,6 +51,7 @@ import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.EStoreEObjectImpl;
import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.util.EContentsEList;
import org.eclipse.emf.spi.cdo.CDOSessionProtocol.CommitTransactionResult;
import org.eclipse.emf.spi.cdo.FSMUtil;
import org.eclipse.emf.spi.cdo.InternalCDOObject;
@@ -639,14 +639,27 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
transaction.registerAttached(object, !reattaching);
// Prepare content tree
- for (Iterator<InternalCDOObject> it = getProperContents(object, transaction); it.hasNext();)
+ for (Iterator<InternalEObject> it = getPersistentContents(object); it.hasNext();)
{
- InternalCDOObject content = it.next();
- contents.add(content);
- INSTANCE.process(content, CDOEvent.PREPARE, transactionAndContents);
+ InternalEObject content = it.next();
+ Resource.Internal directResource = content.eDirectResource();
+
+ boolean objectIsResource = directResource == object;
+ if (objectIsResource || directResource == null)
+ {
+ InternalCDOObject adapted = FSMUtil.adapt(content, transaction);
+ contents.add(adapted);
+ INSTANCE.process(adapted, CDOEvent.PREPARE, transactionAndContents);
+ }
}
}
+ private Iterator<InternalEObject> getPersistentContents(InternalCDOObject object)
+ {
+ EStructuralFeature[] features = object.cdoClassInfo().getAllPersistentContainments();
+ return new EContentsEList.ResolvingFeatureIteratorImpl<InternalEObject>(object, features);
+ }
+
private void checkPackageRegistrationProblems(InternalCDOSession session, EClass eClass)
{
if (session.options().isGeneratedPackageEmulationEnabled())
@@ -667,45 +680,6 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
}
}
}
-
- private Iterator<InternalCDOObject> getProperContents(final InternalCDOObject object,
- final CDOTransaction transaction)
- {
- final boolean isResource = object instanceof Resource;
- final Iterator<EObject> delegate = object.eContents().iterator();
-
- return new Iterator<InternalCDOObject>()
- {
- private Object next;
-
- public boolean hasNext()
- {
- while (delegate.hasNext())
- {
- InternalEObject eObject = (InternalEObject)delegate.next();
- EStructuralFeature eContainingFeature = eObject.eContainingFeature();
- if (isResource || eObject.eDirectResource() == null
- && (eContainingFeature == null || EMFUtil.isPersistent(eContainingFeature)))
- {
- next = FSMUtil.adapt(eObject, transaction);
- return true;
- }
- }
-
- return false;
- }
-
- public InternalCDOObject next()
- {
- return (InternalCDOObject)next;
- }
-
- public void remove()
- {
- throw new UnsupportedOperationException();
- }
- };
- }
}
/**

Back to the top