Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-02-11 08:45:01 -0500
committerEike Stepper2013-02-13 14:58:16 -0500
commitda7d59cf71edbd4b7333b38542072ed7c587224d (patch)
treeb0cedd9000759579dfce2fdefaf7a6790814b4ec
parent1de2ed6f432205d8b65580eb54594f34b433b6a3 (diff)
downloadcdo-da7d59cf71edbd4b7333b38542072ed7c587224d.tar.gz
cdo-da7d59cf71edbd4b7333b38542072ed7c587224d.tar.xz
cdo-da7d59cf71edbd4b7333b38542072ed7c587224d.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/.settings/.api_filters14
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOClassInfo.java30
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOModelUtil.java14
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/EMFUtil.java12
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevision.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionUtil.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOClassInfoImpl.java106
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionImpl.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORevisionDeltaImpl.java24
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/model/InternalCDOClassInfo.java58
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/AbstractCDORevision.java27
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/BaseCDORevision.java4
-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.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalClassMapping.java23
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyClassProposed.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyObject.java30
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyObjectManager.java13
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/ObjyMapper.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/XRefsQueryHandler.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InitialTest.java17
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/plugin.properties2
-rw-r--r--plugins/org.eclipse.emf.cdo/.settings/.api_filters27
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java654
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyAdapter.java11
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyWrapper.java41
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOObjectWrapperBase.java3
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/DynamicCDOObjectImpl.java17
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java27
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CommitIntegrityCheck.java31
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStateMachine.java14
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOObject.java6
33 files changed, 668 insertions, 597 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/.settings/.api_filters b/plugins/org.eclipse.emf.cdo.common/.settings/.api_filters
index 79f6aba7df..365504f10a 100644
--- a/plugins/org.eclipse.emf.cdo.common/.settings/.api_filters
+++ b/plugins/org.eclipse.emf.cdo.common/.settings/.api_filters
@@ -80,4 +80,18 @@
</message_arguments>
</filter>
</resource>
+ <resource path="src/org/eclipse/emf/cdo/spi/common/revision/AbstractCDORevision.java" type="org.eclipse.emf.cdo.spi.common.revision.AbstractCDORevision">
+ <filter id="338792546">
+ <message_arguments>
+ <message_argument value="org.eclipse.emf.cdo.spi.common.revision.AbstractCDORevision"/>
+ <message_argument value="setClassInfo(CDOClassInfo)"/>
+ </message_arguments>
+ </filter>
+ <filter id="421654647">
+ <message_arguments>
+ <message_argument value="org.eclipse.emf.cdo.spi.common.revision.AbstractCDORevision"/>
+ <message_argument value="getEClass()"/>
+ </message_arguments>
+ </filter>
+ </resource>
</component>
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 5682b0dc81..8265895ddf 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
@@ -10,8 +10,11 @@
*/
package org.eclipse.emf.cdo.common.model;
+import org.eclipse.emf.cdo.spi.common.model.InternalCDOClassInfo;
+
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
/**
@@ -26,11 +29,6 @@ import org.eclipse.emf.ecore.EStructuralFeature;
*/
public interface CDOClassInfo extends Adapter
{
- /**
- * @since 4.2
- */
- public static final int NO_SETTING = -1;
-
public EClass getEClass();
public boolean isResourceNode();
@@ -39,19 +37,27 @@ public interface CDOClassInfo extends Adapter
public boolean isResource();
- public EStructuralFeature[] getAllPersistentFeatures();
-
- public int getFeatureIndex(EStructuralFeature feature);
+ /**
+ * @since 4.2
+ */
+ public boolean isPersistent(int featureID);
- public int getFeatureIndex(int featureID);
+ public EStructuralFeature[] getAllPersistentFeatures();
/**
* @since 4.2
*/
- public int getSettingsFeatureCount();
+ public EReference[] getAllPersistentReferences();
/**
- * @since 4.2
+ * @deprecated As of 4.2 pushed down to {@link InternalCDOClassInfo#getFeatureIndex(EStructuralFeature)}.
*/
- public int getSettingsFeatureIndex(int featureID);
+ @Deprecated
+ public int getFeatureIndex(EStructuralFeature feature);
+
+ /**
+ * @deprecated As of 4.2 pushed down to {@link InternalCDOClassInfo#getFeatureIndex(int)}.
+ */
+ @Deprecated
+ public int getFeatureIndex(int featureID);
}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOModelUtil.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOModelUtil.java
index b51bc3332d..04cf3c5f2d 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOModelUtil.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOModelUtil.java
@@ -496,6 +496,11 @@ public final class CDOModelUtil implements CDOModelConstants
}
/**
+ * Returns additional CDO infos for an {@link EClass}.
+ * <p>
+ * This operation is somewhat expensive because it synchronizes on the EClass and iterates over all adapters.
+ * Whenever possible use {@link CDORevision#getClassInfo()} or <code>InternalCDOObject.getClassInfo()</code>.
+ *
* @since 2.0
*/
public static CDOClassInfo getClassInfo(EClass eClass)
@@ -507,7 +512,7 @@ public final class CDOModelUtil implements CDOModelConstants
if (classInfo == null)
{
classInfo = new CDOClassInfoImpl();
- adapters.add(classInfo);
+ adapters.add(0, classInfo);
}
return classInfo;
@@ -515,8 +520,15 @@ public final class CDOModelUtil implements CDOModelConstants
}
/**
+ * Returns all persistent {@link EStructuralFeature features} of an {@link EClass}.
+ * <p>
+ * This operation is somewhat expensive because it synchronizes on the EClass and iterates over all adapters.
+ *
* @since 2.0
+ * @deprecated As of 4.2 use <code>CDOModelUtil.getClassInfo(eClass).getAllPersistentFeatures()</code>.
+ * @see #getClassInfo(EClass)
*/
+ @Deprecated
public static EStructuralFeature[] getAllPersistentFeatures(EClass eClass)
{
CDOClassInfo classInfo = getClassInfo(eClass);
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/EMFUtil.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/EMFUtil.java
index 3c0aaf1132..d8a92b38bf 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/EMFUtil.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/EMFUtil.java
@@ -310,7 +310,10 @@ public final class EMFUtil
/**
* @since 3.0
+ * @deprecated This method is expensive and will be removed in the future.
+ * @see #isPersistent(EStructuralFeature)
*/
+ @Deprecated
public static List<EStructuralFeature> getPersistentFeatures(EList<EStructuralFeature> eFeatures)
{
List<EStructuralFeature> result = new ArrayList<EStructuralFeature>();
@@ -326,6 +329,15 @@ public final class EMFUtil
}
/**
+ * Returns <code>true</code> if CDO considers the given feature <i>persistent</i>, <code>false</code> otherwise.
+ * <p>
+ * Note that CDO <i>persistent</i> is not identical to {@link EStructuralFeature#isTransient() non-transient} because that can be
+ * overridden with {@link #CDO_ANNOTATION_KEY_PERSISTENT}. Another reason for possible deviations is that CDO considers transient
+ * {@link EReference references} <i>persistent</i> if they have a <i>persistent</i> {@link EReference#getEOpposite() opposite}.
+ * <p>
+ * Note also that the checks for the aforementioned deviations from {@link EStructuralFeature#isTransient()} make this method somewhat
+ * expensive. Whenever possible {@link CDOClassInfo#isPersistent(int) CDOClassInfo.isPersistent()} should be called instead.
+ *
* @since 3.0
*/
public static boolean isPersistent(EStructuralFeature feature)
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevision.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevision.java
index 75eb411b21..6f5fc50993 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevision.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevision.java
@@ -15,6 +15,7 @@ import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+import org.eclipse.emf.cdo.common.model.CDOClassInfo;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
import org.eclipse.emf.cdo.common.security.CDOPermission;
import org.eclipse.emf.cdo.common.security.CDOPermissionProvider;
@@ -69,6 +70,11 @@ public interface CDORevision extends CDORevisionKey, CDORevisable
};
/**
+ * @since 4.2
+ */
+ public CDOClassInfo getClassInfo();
+
+ /**
* @since 2.0
*/
public EClass getEClass();
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionUtil.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionUtil.java
index b5a8cd9364..476f7b4e97 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionUtil.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionUtil.java
@@ -308,9 +308,7 @@ public final class CDORevisionUtil
{
StringBuilder builder = new StringBuilder();
getResourceNodePath((InternalCDORevision)revision, provider, builder);
- String string = builder.toString();
- System.out.println("Path: " + revision + " --> " + string);
- return string;
+ return builder.toString();
}
private static void getResourceNodePath(InternalCDORevision revision, CDORevisionProvider provider,
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 25e17dde3b..2cc5d2536e 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
@@ -21,33 +21,47 @@ 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.util.EcoreUtil;
import org.eclipse.emf.ecore.util.FeatureMapUtil;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.BitSet;
import java.util.List;
/**
* @author Eike Stepper
*/
-public class CDOClassInfoImpl extends AdapterImpl implements InternalCDOClassInfo
+public final class CDOClassInfoImpl extends AdapterImpl implements InternalCDOClassInfo
{
- private static final int NOT_MAPPED = -1;
-
private static final PersistenceFilter[] NO_FILTERS = {};
- private EStructuralFeature[] allPersistentFeatures;
+ private final BitSet persistentBits = new BitSet();
private PersistenceFilter[] persistenceFilters = NO_FILTERS;
- private int[] featureIDMappings;
+ private EStructuralFeature[] allPersistentFeatures;
+
+ private EReference[] allPersistentReferences;
+
+ private int[] persistentFeatureIndices;
private int settingsFeatureCount;
private int[] settingsFeatureIndices;
+ /**
+ * The number of *extra* features on top of {@link #settingsFeatureCount} when the object is TRANSIENT.
+ */
+ private int transientFeatureCount;
+
+ /**
+ * This is not about transient features! But about indices of all features of TRANSIENT objects.
+ */
+ private int[] transientFeatureIndices;
+
public CDOClassInfoImpl()
{
}
@@ -85,21 +99,31 @@ public class CDOClassInfoImpl extends AdapterImpl implements InternalCDOClassInf
return CDOModelUtil.isResourceNode(getEClass());
}
+ public boolean isPersistent(int featureID)
+ {
+ return persistentBits.get(featureID);
+ }
+
public EStructuralFeature[] getAllPersistentFeatures()
{
return allPersistentFeatures;
}
- public int getFeatureIndex(EStructuralFeature feature)
+ public EReference[] getAllPersistentReferences()
+ {
+ return allPersistentReferences;
+ }
+
+ public int getPersistentFeatureIndex(EStructuralFeature feature) throws IllegalArgumentException
{
int featureID = getEClass().getFeatureID(feature);
- return getFeatureIndex(featureID);
+ return getPersistentFeatureIndex(featureID);
}
- public int getFeatureIndex(int featureID)
+ public int getPersistentFeatureIndex(int featureID) throws IllegalArgumentException
{
- int index = featureIDMappings[featureID];
- if (index == NOT_MAPPED)
+ int index = persistentFeatureIndices[featureID];
+ if (index == NO_SLOT)
{
throw new IllegalArgumentException("Feature not mapped: " + getEClass().getEStructuralFeature(featureID)); //$NON-NLS-1$
}
@@ -117,6 +141,16 @@ public class CDOClassInfoImpl extends AdapterImpl implements InternalCDOClassInf
return settingsFeatureIndices[featureID];
}
+ public int getTransientFeatureCount()
+ {
+ return transientFeatureCount;
+ }
+
+ public int getTransientFeatureIndex(int featureID)
+ {
+ return transientFeatureIndices[featureID];
+ }
+
public PersistenceFilter getPersistenceFilter(EStructuralFeature feature)
{
if (persistenceFilters == NO_FILTERS)
@@ -151,24 +185,34 @@ public class CDOClassInfoImpl extends AdapterImpl implements InternalCDOClassInf
private void init(EClass eClass)
{
- List<EStructuralFeature> persistentFeatures = new ArrayList<EStructuralFeature>();
EList<EStructuralFeature> allFeatures = eClass.getEAllStructuralFeatures();
-
int featureCount = eClass.getFeatureCount();
+
+ List<EStructuralFeature> persistentFeatures = new ArrayList<EStructuralFeature>();
+ List<EReference> persistentReferences = new ArrayList<EReference>();
+ persistentBits.clear();
settingsFeatureIndices = new int[featureCount];
for (int i = 0; i < featureCount; i++)
{
EStructuralFeature feature = eClass.getEStructuralFeature(i);
- if (EMFUtil.isPersistent(feature))
+ if (EMFUtil.isPersistent(feature)) // persistentBits is not initialized, yet
{
+ int featureID = eClass.getFeatureID(feature);
+ persistentBits.set(featureID);
+
persistentFeatures.add(feature);
+ if (feature instanceof EReference)
+ {
+ persistentReferences.add((EReference)feature);
+ }
+
if (feature.isMany() || FeatureMapUtil.isFeatureMap(feature))
{
settingsFeatureIndices[i] = settingsFeatureCount++;
}
else
{
- settingsFeatureIndices[i] = NO_SETTING;
+ settingsFeatureIndices[i] = NO_SLOT;
}
}
else
@@ -177,15 +221,31 @@ public class CDOClassInfoImpl extends AdapterImpl implements InternalCDOClassInf
}
}
+ transientFeatureIndices = new int[featureCount];
+ for (int featureID = 0; featureID < featureCount; featureID++)
+ {
+ if (isPersistent(featureID))
+ {
+ transientFeatureIndices[featureID] = settingsFeatureCount + transientFeatureCount++;
+ }
+ else
+ {
+ // Transient *features* are already allocated to a slot (see above)
+ transientFeatureIndices[featureID] = settingsFeatureIndices[featureID];
+ }
+ }
+
allPersistentFeatures = persistentFeatures.toArray(new EStructuralFeature[persistentFeatures.size()]);
- featureIDMappings = new int[allFeatures.size()];
- Arrays.fill(featureIDMappings, NOT_MAPPED);
+ allPersistentReferences = persistentReferences.toArray(new EReference[persistentReferences.size()]);
+
+ persistentFeatureIndices = new int[allFeatures.size()];
+ Arrays.fill(persistentFeatureIndices, NO_SLOT);
for (int i = 0; i < allPersistentFeatures.length; i++)
{
EStructuralFeature feature = allPersistentFeatures[i];
int featureID = eClass.getFeatureID(feature);
- featureIDMappings[featureID] = i;
+ persistentFeatureIndices[featureID] = i;
PersistenceFilter persistenceFilter = initPersistenceFilter(feature);
if (persistenceFilter != null)
@@ -200,6 +260,18 @@ public class CDOClassInfoImpl extends AdapterImpl implements InternalCDOClassInf
}
}
+ @Deprecated
+ public int getFeatureIndex(EStructuralFeature feature)
+ {
+ return getPersistentFeatureIndex(feature);
+ }
+
+ @Deprecated
+ public int getFeatureIndex(int featureID)
+ {
+ return getPersistentFeatureIndex(featureID);
+ }
+
@Override
public String toString()
{
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionImpl.java
index 0721bbdbb9..6d8f8d8ed5 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionImpl.java
@@ -39,17 +39,19 @@ public class CDORevisionImpl extends BaseCDORevision
protected CDORevisionImpl(CDORevisionImpl source)
{
super(source);
- EStructuralFeature[] features = CDOModelUtil.getAllPersistentFeatures(getEClass());
+ EStructuralFeature[] features = getClassInfo().getAllPersistentFeatures();
initValues(features);
- for (int i = 0; i < features.length; i++)
+
+ int length = features.length;
+ for (int i = 0; i < length; i++)
{
EStructuralFeature feature = features[i];
- EClassifier classifier = feature.getEType();
if (feature.isMany())
{
InternalCDOList sourceList = (InternalCDOList)source.values[i];
if (sourceList != null)
{
+ EClassifier classifier = feature.getEType();
setValue(i, sourceList.clone(classifier));
}
}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORevisionDeltaImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORevisionDeltaImpl.java
index e3980d508f..3116aa35b5 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORevisionDeltaImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORevisionDeltaImpl.java
@@ -16,7 +16,6 @@ import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.id.CDOWithID;
-import org.eclipse.emf.cdo.common.model.CDOModelUtil;
import org.eclipse.emf.cdo.common.protocol.CDODataInput;
import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
import org.eclipse.emf.cdo.common.revision.CDOElementProxy;
@@ -109,7 +108,7 @@ public class CDORevisionDeltaImpl implements InternalCDORevisionDelta
version = sourceRevision.getVersion();
target = CDORevisionUtil.copyRevisable(targetRevision);
- compare(sourceRevision, targetRevision);
+ compare((InternalCDORevision)sourceRevision, (InternalCDORevision)targetRevision);
CDORevisionData originData = sourceRevision.data();
CDORevisionData dirtyData = targetRevision.data();
@@ -120,9 +119,9 @@ public class CDORevisionDeltaImpl implements InternalCDORevisionDelta
dirtyContainerID = ((CDOWithID)dirtyContainerID).cdoID();
}
- if (!compare(originData.getContainerID(), dirtyContainerID)
- || !compare(originData.getContainingFeatureID(), dirtyData.getContainingFeatureID())
- || !compare(originData.getResourceID(), dirtyData.getResourceID()))
+ if (!compareValue(originData.getContainerID(), dirtyContainerID)
+ || !compareValue(originData.getContainingFeatureID(), dirtyData.getContainingFeatureID())
+ || !compareValue(originData.getResourceID(), dirtyData.getResourceID()))
{
addFeatureDelta(new CDOContainerFeatureDeltaImpl(dirtyData.getResourceID(), dirtyContainerID,
dirtyData.getContainingFeatureID()));
@@ -310,13 +309,12 @@ public class CDORevisionDeltaImpl implements InternalCDORevisionDelta
}
}
- private void compare(final CDORevision originRevision, final CDORevision dirtyRevision)
+ private void compare(final InternalCDORevision originRevision, final InternalCDORevision dirtyRevision)
{
CDORevisionData originData = originRevision.data();
CDORevisionData dirtyData = dirtyRevision.data();
- EStructuralFeature[] allPersistentFeatures = CDOModelUtil.getAllPersistentFeatures(eClass);
- for (final EStructuralFeature feature : allPersistentFeatures)
+ for (final EStructuralFeature feature : originRevision.getClassInfo().getAllPersistentFeatures())
{
if (feature.isMany())
{
@@ -373,7 +371,7 @@ public class CDORevisionDeltaImpl implements InternalCDORevisionDelta
@Override
protected boolean equal(Object originValue, Object dirtyValue)
{
- return compare(originValue, dirtyValue);
+ return compareValue(originValue, dirtyValue);
}
private void checkNoProxies(EList<?> list, CDORevision revision)
@@ -391,8 +389,8 @@ public class CDORevisionDeltaImpl implements InternalCDORevisionDelta
}
};
- CDOList originList = ((InternalCDORevision)originRevision).getList(feature);
- CDOList dirtyList = ((InternalCDORevision)dirtyRevision).getList(feature);
+ CDOList originList = originRevision.getList(feature);
+ CDOList dirtyList = dirtyRevision.getList(feature);
analyzer.analyzeLists(originList, dirtyList, new NOOPList());
if (!changes.isEmpty())
@@ -405,7 +403,7 @@ public class CDORevisionDeltaImpl implements InternalCDORevisionDelta
{
Object originValue = originData.get(feature, 0);
Object dirtyValue = dirtyData.get(feature, 0);
- if (!compare(originValue, dirtyValue))
+ if (!compareValue(originValue, dirtyValue))
{
if (dirtyValue == null)
{
@@ -420,7 +418,7 @@ public class CDORevisionDeltaImpl implements InternalCDORevisionDelta
}
}
- private boolean compare(Object originValue, Object dirtyValue)
+ private boolean compareValue(Object originValue, Object dirtyValue)
{
Object origin = convertEObject(originValue);
Object dirty = convertEObject(dirtyValue);
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 2526cb8890..c03e9e54cc 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
@@ -11,15 +11,73 @@
package org.eclipse.emf.cdo.spi.common.model;
import org.eclipse.emf.cdo.common.model.CDOClassInfo;
+import org.eclipse.emf.cdo.common.model.EMFUtil;
+import org.eclipse.emf.cdo.internal.common.revision.CDORevisionImpl;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.InternalEObject.EStore;
/**
* @since 4.2
+ * @author Eike Stepper
*/
public interface InternalCDOClassInfo extends CDOClassInfo
{
+ public static final int NO_SLOT = EStore.NO_INDEX;
+
+ /**
+ * Returns the index of the specified {@link EStructuralFeature feature} in the {@link CDORevisionImpl#values} array, never {@link #NO_SLOT}.
+ *
+ * @throws IllegalArgumentException if the specified feature is <b>not</b> {@link #isPersistent(int) persistent}.
+ * @see #getPersistentFeatureIndex(int)
+ */
+ public int getPersistentFeatureIndex(EStructuralFeature feature) throws IllegalArgumentException;
+
+ /**
+ * Returns the index of the specified {@link EStructuralFeature feature} in the {@link CDORevisionImpl#values} array, never {@link #NO_SLOT}.
+ *
+ * @throws IllegalArgumentException if the specified feature is <b>not</b> {@link #isPersistent(int) persistent}.
+ * @see #getPersistentFeatureIndex(EStructuralFeature)
+ */
+ public int getPersistentFeatureIndex(int featureID) throws IllegalArgumentException;
+
+ /**
+ * Returns the number of {@link EStructuralFeature features} whose values are <b>always</b> stored in the
+ * <code>CDOObjectImpl.eSettings</code> array, whether an object is in <code>CDOState.TRANSIENT</code> or not.
+ * <p>
+ * These are the {@link EMFUtil#isPersistent(EStructuralFeature) transient} and/or {@link EStructuralFeature#isMany() many-valued} features.
+ *
+ * @see #getSettingsFeatureIndex(int)
+ */
+ public int getSettingsFeatureCount();
+
+ /**
+ * Returns the index of the specified {@link EStructuralFeature feature} in the <code>CDOObjectImpl.eSettings</code> array,
+ * or {@link #NO_SLOT} if the feature is {@link EMFUtil#isPersistent(EStructuralFeature) non-transient} or {@link EStructuralFeature#isMany() single-valued}.
+ *
+ * @see #getSettingsFeatureCount()
+ */
+ public int getSettingsFeatureIndex(int featureID);
+
+ /**
+ * Returns the number of {@link EStructuralFeature features} whose values are additionally stored in the <code>CDOObjectImpl.eSettings</code> array,
+ * if an object is in <code>CDOState.TRANSIENT</code>.
+ * <p>
+ * These are the {@link EMFUtil#isPersistent(EStructuralFeature) non-transient} and/or {@link EStructuralFeature#isMany() single-valued} features.
+ *
+ * @see #getTransientFeatureIndex(int)
+ */
+ public int getTransientFeatureCount();
+
+ /**
+ * Returns the index of the specified {@link EStructuralFeature feature} in the <code>CDOObjectImpl.eSettings</code> array,
+ * or {@link #NO_SLOT} if the feature is {@link EMFUtil#isPersistent(EStructuralFeature) transient} or {@link EStructuralFeature#isMany() many-valued}
+ *
+ * @see #getTransientFeatureCount()
+ */
+ public int getTransientFeatureIndex(int featureID);
+
/**
* 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/AbstractCDORevision.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/AbstractCDORevision.java
index f725ed8312..c0b8b9de8d 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/AbstractCDORevision.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/AbstractCDORevision.java
@@ -15,12 +15,12 @@ package org.eclipse.emf.cdo.spi.common.revision;
import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.model.CDOClassInfo;
import org.eclipse.emf.cdo.common.model.CDOModelUtil;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.CDORevisionData;
import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
import org.eclipse.emf.cdo.internal.common.messages.Messages;
+import org.eclipse.emf.cdo.spi.common.model.InternalCDOClassInfo;
import org.eclipse.net4j.util.ObjectUtil;
@@ -37,7 +37,7 @@ import java.text.MessageFormat;
*/
public abstract class AbstractCDORevision implements InternalCDORevision
{
- private CDOClassInfo classInfo;
+ private InternalCDOClassInfo classInfo;
/**
* @since 3.0
@@ -51,21 +51,20 @@ public abstract class AbstractCDORevision implements InternalCDORevision
throw new IllegalArgumentException(MessageFormat.format(Messages.getString("AbstractCDORevision.0"), eClass)); //$NON-NLS-1$
}
- classInfo = CDOModelUtil.getClassInfo(eClass);
+ initClassInfo(eClass);
}
}
/**
- * @since 3.0
+ * @since 4.2
*/
- public CDOClassInfo getClassInfo()
+ public final InternalCDOClassInfo getClassInfo()
{
return classInfo;
}
- public EClass getEClass()
+ public final EClass getEClass()
{
- CDOClassInfo classInfo = getClassInfo();
if (classInfo != null)
{
return classInfo.getEClass();
@@ -76,17 +75,17 @@ public abstract class AbstractCDORevision implements InternalCDORevision
public boolean isResourceNode()
{
- return getClassInfo().isResourceNode();
+ return classInfo.isResourceNode();
}
public boolean isResourceFolder()
{
- return getClassInfo().isResourceFolder();
+ return classInfo.isResourceFolder();
}
public boolean isResource()
{
- return getClassInfo().isResource();
+ return classInfo.isResource();
}
public CDORevisionData data()
@@ -197,11 +196,11 @@ public abstract class AbstractCDORevision implements InternalCDORevision
}
/**
- * @since 3.0
+ * @since 4.2
*/
- protected void setClassInfo(CDOClassInfo classInfo)
+ protected void initClassInfo(EClass eClass)
{
- this.classInfo = classInfo;
+ classInfo = (InternalCDOClassInfo)CDOModelUtil.getClassInfo(eClass);
}
/**
@@ -217,6 +216,6 @@ public abstract class AbstractCDORevision implements InternalCDORevision
*/
protected int getFeatureIndex(EStructuralFeature feature)
{
- return classInfo.getFeatureIndex(feature);
+ return classInfo.getPersistentFeatureIndex(feature);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/BaseCDORevision.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/BaseCDORevision.java
index 57b71e4ab0..da4f902f66 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/BaseCDORevision.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/BaseCDORevision.java
@@ -19,7 +19,6 @@ import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDProvider;
import org.eclipse.emf.cdo.common.id.CDOIDTemp;
import org.eclipse.emf.cdo.common.id.CDOIDUtil;
-import org.eclipse.emf.cdo.common.model.CDOClassInfo;
import org.eclipse.emf.cdo.common.model.CDOClassifierRef;
import org.eclipse.emf.cdo.common.model.CDOModelUtil;
import org.eclipse.emf.cdo.common.model.CDOType;
@@ -175,8 +174,7 @@ public abstract class BaseCDORevision extends AbstractCDORevision
protected void readSystemValues(CDODataInput in) throws IOException
{
EClassifier classifier = in.readCDOClassifierRefAndResolve();
- CDOClassInfo classInfo = CDOModelUtil.getClassInfo((EClass)classifier);
- setClassInfo(classInfo);
+ initClassInfo((EClass)classifier);
id = in.readCDOID();
branchPoint = in.readCDOBranchPoint();
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 18ef89b15a..eeeb501f79 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
@@ -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;
@@ -37,11 +36,6 @@ import java.io.IOException;
*/
public interface InternalCDORevision extends CDORevision, CDORevisionData, CDOReferenceAdjustable
{
- /**
- * @since 3.0
- */
- public CDOClassInfo getClassInfo();
-
public void setID(CDOID id);
public void setVersion(int version);
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalClassMapping.java
index 6ef87c90a7..f08844d000 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalClassMapping.java
@@ -18,6 +18,7 @@ import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.model.CDOClassInfo;
import org.eclipse.emf.cdo.common.model.CDOModelUtil;
import org.eclipse.emf.cdo.common.revision.CDOList;
import org.eclipse.emf.cdo.common.revision.CDORevision;
@@ -101,9 +102,12 @@ public abstract class AbstractHorizontalClassMapping implements IClassMapping
{
this.mappingStrategy = mappingStrategy;
this.eClass = eClass;
-
initTable();
- initFeatures();
+
+ CDOClassInfo classInfo = CDOModelUtil.getClassInfo(eClass);
+ EStructuralFeature[] allPersistentFeatures = classInfo.getAllPersistentFeatures();
+ initFeatures(allPersistentFeatures);
+
initSQLStrings();
}
@@ -144,19 +148,17 @@ public abstract class AbstractHorizontalClassMapping implements IClassMapping
return null;
}
- private void initFeatures()
+ private void initFeatures(EStructuralFeature[] features)
{
- EStructuralFeature[] allPersistentFeatures = CDOModelUtil.getAllPersistentFeatures(eClass);
-
- if (allPersistentFeatures == null)
+ if (features == null)
{
valueMappings = Collections.emptyList();
listMappings = Collections.emptyList();
}
else
{
- valueMappings = createValueMappings(allPersistentFeatures);
- listMappings = createListMappings(allPersistentFeatures);
+ valueMappings = createValueMappings(features);
+ listMappings = createListMappings(features);
}
}
@@ -204,7 +206,7 @@ public abstract class AbstractHorizontalClassMapping implements IClassMapping
}
}
- // add unsettable fields to end of table
+ // Add unsettable fields to end of table
if (unsettableFields != null)
{
for (String fieldName : unsettableFields.values())
@@ -235,7 +237,7 @@ public abstract class AbstractHorizontalClassMapping implements IClassMapping
listMappings.add(mapping);
- // add field for list sizes
+ // Add field for list sizes
createListSizeField(feature);
}
}
@@ -799,7 +801,6 @@ public abstract class AbstractHorizontalClassMapping implements IClassMapping
public final boolean queryXRefs(IDBStoreAccessor accessor, QueryXRefsContext context, String idString)
{
String tableName = getTable().getName();
- EClass eClass = getEClass();
List<EReference> refs = context.getSourceCandidates().get(eClass);
List<EReference> scalarRefs = new ArrayList<EReference>();
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyClassProposed.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyClassProposed.java
index 896e0495e6..e5e4a86442 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyClassProposed.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyClassProposed.java
@@ -11,7 +11,6 @@
*/
package org.eclipse.emf.cdo.server.internal.objectivity.db;
-import org.eclipse.emf.cdo.common.model.EMFUtil;
import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
import org.eclipse.emf.cdo.server.internal.objectivity.mapper.ITypeMapper;
import org.eclipse.emf.cdo.server.internal.objectivity.mapper.ObjyMapper;
@@ -102,7 +101,7 @@ public class ObjyClassProposed
ArrayList<EClass> toBeProcessed = new ArrayList<EClass>();
for (EStructuralFeature feature : listFeatures)
{
- if (!(feature instanceof EAttribute || feature instanceof EReference) || !EMFUtil.isPersistent(feature))
+ if (!(feature instanceof EAttribute || feature instanceof EReference) || !ObjyObject.isPersistent(feature))
{
continue;
}
@@ -171,7 +170,7 @@ public class ObjyClassProposed
ArrayList<EClass> toBeEvolve = new ArrayList<EClass>();
for (EStructuralFeature feature : listFeatures)
{
- if (!(feature instanceof EAttribute || feature instanceof EReference) || !EMFUtil.isPersistent(feature))
+ if (!(feature instanceof EAttribute || feature instanceof EReference) || !ObjyObject.isPersistent(feature))
{
continue;
}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyObject.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyObject.java
index 59d073ed72..b0f108191e 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyObject.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyObject.java
@@ -66,7 +66,6 @@ import java.util.Map;
*/
public class ObjyObject
{
-
private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjyObject.class);
protected Class_Object classObject;
@@ -212,8 +211,8 @@ public class ObjyObject
}
/**
- *
- */
+ *
+ */
public ooId ooId()
{
return objectId;
@@ -466,7 +465,7 @@ public class ObjyObject
}
for (EStructuralFeature feature : eClass.getEAllStructuralFeatures())
{
- if (!(feature instanceof EAttribute || feature instanceof EReference) || !EMFUtil.isPersistent(feature))
+ if (!(feature instanceof EAttribute || feature instanceof EReference) || !isPersistent(feature))
{
continue;
}
@@ -528,7 +527,7 @@ public class ObjyObject
/**
* Use the revision info to update the object in the store.
- *
+ *
* @param storeAccessor
* @param revision
*/
@@ -561,7 +560,7 @@ public class ObjyObject
/**
* Use the revision info to update the object in the store.
- *
+ *
* @param storeAccessor
* @param revision
*/
@@ -588,7 +587,7 @@ public class ObjyObject
for (EStructuralFeature feature : eClass.getEAllStructuralFeatures())
{
- if (!(feature instanceof EAttribute || feature instanceof EReference) || !EMFUtil.isPersistent(feature))
+ if (!(feature instanceof EAttribute || feature instanceof EReference) || !isPersistent(feature))
{
continue;
}
@@ -829,7 +828,7 @@ public class ObjyObject
for (EStructuralFeature feature : eClass.getEAllStructuralFeatures())
{
- if (!(feature instanceof EAttribute || feature instanceof EReference) || !EMFUtil.isPersistent(feature))
+ if (!(feature instanceof EAttribute || feature instanceof EReference) || !isPersistent(feature))
{
continue;
}
@@ -1044,7 +1043,7 @@ public class ObjyObject
/**
* Get the size of the composite object using the store info.
- *
+ *
* @param feature
* @return
*/
@@ -1091,7 +1090,7 @@ public class ObjyObject
/**
* Get the value of an attribute at index (if many) from the persistent object.
- *
+ *
* @param feature
* @param index
* @return
@@ -1136,7 +1135,7 @@ public class ObjyObject
/**
* Get all the values of an attribute, used for feature.isMany(). This function is also used by the
* ObjectivityStoreChunkReader to read chunks of data from a feature.
- *
+ *
* @param feature
* @param size
* @return
@@ -1357,7 +1356,7 @@ public class ObjyObject
{
for (EStructuralFeature feature : eClass.getEAllStructuralFeatures())
{
- if (!(feature instanceof EAttribute || feature instanceof EReference) || !EMFUtil.isPersistent(feature))
+ if (!(feature instanceof EAttribute || feature instanceof EReference) || !isPersistent(feature))
{
continue;
}
@@ -1579,7 +1578,7 @@ public class ObjyObject
/**
* Return the revision that satisfies the timeStamp and branchId constrains.
- *
+ *
* @param objyObjectManager
*/
public ObjyObject getRevision(long timeStamp, int branchId, ObjyObjectManager objyObjectManager)
@@ -1689,4 +1688,9 @@ public class ObjyObject
}
}
+ public static boolean isPersistent(EStructuralFeature feature)
+ {
+ return EMFUtil.isPersistent(feature);
+ }
+
}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyObjectManager.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyObjectManager.java
index 704d0d4d0d..fabce20f51 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyObjectManager.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyObjectManager.java
@@ -11,7 +11,6 @@
package org.eclipse.emf.cdo.server.internal.objectivity.db;
import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.model.EMFUtil;
import org.eclipse.emf.cdo.server.internal.objectivity.ObjectivityStoreAccessor;
import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
import org.eclipse.emf.cdo.server.internal.objectivity.clustering.ObjyPlacementManager;
@@ -65,8 +64,8 @@ public class ObjyObjectManager
}
/**
- *
- */
+ *
+ */
public ObjyObject newObject(EClass eClass, ooId nearObject)
{
if (nearObject == null)
@@ -128,7 +127,7 @@ public class ObjyObjectManager
// Initialize the object
for (EStructuralFeature feature : eClass.getEAllStructuralFeatures())
{
- if (!(feature instanceof EAttribute || feature instanceof EReference) || !EMFUtil.isPersistent(feature))
+ if (!(feature instanceof EAttribute || feature instanceof EReference) || !ObjyObject.isPersistent(feature))
{
continue;
}
@@ -200,7 +199,7 @@ public class ObjyObjectManager
/***
* The following are utility function that get the base attributes from the object.
- *
+ *
* @param objyObject
* @return replaced by the ones in ObjyObject. public Object getEContainer(ObjyObject objyObject) { Class_Position
* position = objyObject.objyClass().resolve_position(ooBaseClass.ClassName_containerid); ooId oid = (ooId)
@@ -226,7 +225,7 @@ public class ObjyObjectManager
/**
* Construct an ObjyObject from an existing Class_Object and add it to the idToObjyObjectMap.
- *
+ *
* @param classObject
* @return
*/
@@ -239,7 +238,7 @@ public class ObjyObjectManager
/***
* TODO - Remove the eClass and just use the objyObject attributes to do the clean up.
- *
+ *
* @param objyObject
*/
public void remove(ObjyObject objyObject)
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/ObjyMapper.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/ObjyMapper.java
index 2e5bf1d569..32a44c215e 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/ObjyMapper.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/ObjyMapper.java
@@ -11,8 +11,8 @@
*/
package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
-import org.eclipse.emf.cdo.common.model.EMFUtil;
import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
import org.eclipse.net4j.util.om.trace.ContextTracer;
@@ -60,7 +60,7 @@ public class ObjyMapper
public ITypeMapper getTypeMapper(EStructuralFeature feature)
{
- if (feature == null || !EMFUtil.isPersistent(feature))
+ if (feature == null || !ObjyObject.isPersistent(feature))
{
if (TRACER_DEBUG.isEnabled())
{
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java
index daeb7c1aad..f4b3dfbc71 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java
@@ -33,7 +33,6 @@ import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo;
import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo.Operation;
import org.eclipse.emf.cdo.common.lock.CDOLockState;
import org.eclipse.emf.cdo.common.lock.CDOLockUtil;
-import org.eclipse.emf.cdo.common.model.CDOModelUtil;
import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
import org.eclipse.emf.cdo.common.model.EMFUtil;
import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
@@ -576,11 +575,8 @@ public class Repository extends Container<Object> implements InternalRepository
@Deprecated
protected void ensureChunks(InternalCDORevision revision, int referenceChunk, IStoreAccessor accessor)
{
- EClass eClass = revision.getEClass();
- EStructuralFeature[] allPersistentFeatures = CDOModelUtil.getAllPersistentFeatures(eClass);
- for (int i = 0; i < allPersistentFeatures.length; i++)
+ for (EStructuralFeature feature : revision.getClassInfo().getAllPersistentFeatures())
{
- EStructuralFeature feature = allPersistentFeatures[i];
if (feature.isMany())
{
MoveableList<Object> list = revision.getList(feature);
@@ -594,9 +590,7 @@ public class Repository extends Container<Object> implements InternalRepository
{
if (!revision.isUnchunked())
{
- EClass eClass = revision.getEClass();
- EStructuralFeature[] allPersistentFeatures = CDOModelUtil.getAllPersistentFeatures(eClass);
- for (EStructuralFeature feature : allPersistentFeatures)
+ for (EStructuralFeature feature : revision.getClassInfo().getAllPersistentFeatures())
{
if (feature.isMany())
{
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java
index c7d542ce98..45c32ad665 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java
@@ -22,7 +22,6 @@ import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo;
-import org.eclipse.emf.cdo.common.model.CDOModelUtil;
import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
import org.eclipse.emf.cdo.common.revision.CDORevision;
@@ -52,7 +51,6 @@ import org.eclipse.net4j.util.lifecycle.LifecycleEventAdapter;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import org.eclipse.net4j.util.om.log.OMLogger;
-import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
@@ -329,11 +327,8 @@ public class Session extends Container<IView> implements InternalSession
Set<CDOID> revisions, List<CDORevision> additionalRevisions)
{
InternalCDORevisionManager revisionManager = getManager().getRepository().getRevisionManager();
- EClass eClass = revision.getEClass();
- EStructuralFeature[] allPersistentFeatures = CDOModelUtil.getAllPersistentFeatures(eClass);
- for (int i = 0; i < allPersistentFeatures.length; i++)
+ for (EStructuralFeature feature : revision.getClassInfo().getAllPersistentFeatures())
{
- EStructuralFeature feature = allPersistentFeatures[i];
// TODO Clarify feature maps
if (feature instanceof EReference && !feature.isMany() && ((EReference)feature).isContainment())
{
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/XRefsQueryHandler.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/XRefsQueryHandler.java
index 619180eb48..a738b2eeae 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/XRefsQueryHandler.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/XRefsQueryHandler.java
@@ -17,11 +17,11 @@ import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDReference;
import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.model.CDOClassifierRef;
+import org.eclipse.emf.cdo.common.model.CDOModelUtil;
import org.eclipse.emf.cdo.common.model.CDOPackageInfo;
import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
import org.eclipse.emf.cdo.common.model.CDOPackageUnit.State;
-import org.eclipse.emf.cdo.common.model.EMFUtil;
import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
import org.eclipse.emf.cdo.common.util.CDOQueryInfo;
import org.eclipse.emf.cdo.server.IQueryContext;
@@ -42,7 +42,6 @@ import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
import java.util.ArrayList;
import java.util.Collection;
@@ -133,12 +132,9 @@ public class XRefsQueryHandler implements IQueryHandler
{
if (!eClass.isAbstract() && !eClass.isInterface())
{
- for (EStructuralFeature eStructuralFeature : eClass.getEAllStructuralFeatures())
+ for (EReference eReference : CDOModelUtil.getClassInfo(eClass).getAllPersistentReferences())
{
- if (eStructuralFeature instanceof EReference && EMFUtil.isPersistent(eStructuralFeature))
- {
- collectSourceCandidates(eClass, (EReference)eStructuralFeature, concreteTypes, sourceCandidates);
- }
+ collectSourceCandidates(eClass, eReference, concreteTypes, sourceCandidates);
}
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InitialTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InitialTest.java
index 0951389106..a47bff5f9b 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InitialTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InitialTest.java
@@ -147,17 +147,13 @@ public class InitialTest extends AbstractCDOTest
public void testAttachResource() throws Exception
{
- msg("Opening session");
CDOSession session = openSession();
-
- msg("Opening transaction");
CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
CDOResource resource = transaction.createResource(getResourcePath("/test1"));
assertNew(resource, transaction);
assertEquals(URI.createURI("cdo://" + session.getRepositoryInfo().getUUID() + getResourcePath("/test1")),
resource.getURI());
+
ResourceSet expected = transaction.getResourceSet();
ResourceSet actual = resource.getResourceSet();
assertEquals(expected, actual);
@@ -165,25 +161,14 @@ public class InitialTest extends AbstractCDOTest
public void testAttachObject() throws Exception
{
- msg("Creating supplier");
Supplier supplier = getModel1Factory().createSupplier();
-
- msg("Setting name");
supplier.setName("Stepper");
- msg("Opening session");
CDOSession session = openSession();
-
- msg("Opening transaction");
CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- msg("Getting contents");
EList<EObject> contents = resource.getContents();
-
- msg("Adding supplier");
contents.add(supplier);
assertNew(supplier, transaction);
assertEquals(transaction, CDOUtil.getCDOObject(supplier).cdoView());
diff --git a/plugins/org.eclipse.emf.cdo.ui/plugin.properties b/plugins/org.eclipse.emf.cdo.ui/plugin.properties
index 193912be37..3933204b02 100644
--- a/plugins/org.eclipse.emf.cdo.ui/plugin.properties
+++ b/plugins/org.eclipse.emf.cdo.ui/plugin.properties
@@ -86,4 +86,4 @@ _UI_Menu_Help_label = &Help
_UI_Menu_About_label = Editor &About...
_UI_About_title = Editor Application
_UI_About_text = Editor Application about box goes here.
-
+
diff --git a/plugins/org.eclipse.emf.cdo/.settings/.api_filters b/plugins/org.eclipse.emf.cdo/.settings/.api_filters
index 47a98726d8..1d5e02595d 100644
--- a/plugins/org.eclipse.emf.cdo/.settings/.api_filters
+++ b/plugins/org.eclipse.emf.cdo/.settings/.api_filters
@@ -172,6 +172,12 @@
<filter id="338792546">
<message_arguments>
<message_argument value="org.eclipse.emf.internal.cdo.CDOObjectImpl"/>
+ <message_argument value="cdoSettings()"/>
+ </message_arguments>
+ </filter>
+ <filter id="338792546">
+ <message_arguments>
+ <message_argument value="org.eclipse.emf.internal.cdo.CDOObjectImpl"/>
<message_argument value="eInitializeContainer()"/>
</message_arguments>
</filter>
@@ -223,6 +229,27 @@
</message_arguments>
</filter>
</resource>
+ <resource path="src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java" type="org.eclipse.emf.internal.cdo.CDOObjectImpl$CDOStoreEcoreEMap">
+ <filter id="337686583">
+ <message_arguments>
+ <message_argument value="org.eclipse.emf.internal.cdo.CDOObjectImpl.CDOStoreEcoreEMap"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java" type="org.eclipse.emf.internal.cdo.CDOObjectImpl$CDOStoreFeatureMap">
+ <filter id="337686583">
+ <message_arguments>
+ <message_argument value="org.eclipse.emf.internal.cdo.CDOObjectImpl.CDOStoreFeatureMap"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java" type="org.eclipse.emf.internal.cdo.CDOObjectImpl$CDOStoreUnorderedEList">
+ <filter id="337686583">
+ <message_arguments>
+ <message_argument value="org.eclipse.emf.internal.cdo.CDOObjectImpl.CDOStoreUnorderedEList"/>
+ </message_arguments>
+ </filter>
+ </resource>
<resource path="src/org/eclipse/emf/internal/cdo/object/CDOObjectReferenceImpl.java" type="org.eclipse.emf.internal.cdo.object.CDOObjectReferenceImpl">
<filter id="574660632">
<message_arguments>
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 10dfc8c031..8e79a501a0 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
@@ -18,9 +18,7 @@ import org.eclipse.emf.cdo.CDOObjectHistory;
import org.eclipse.emf.cdo.CDOState;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.lock.CDOLockState;
-import org.eclipse.emf.cdo.common.model.CDOClassInfo;
import org.eclipse.emf.cdo.common.model.CDOModelUtil;
-import org.eclipse.emf.cdo.common.model.EMFUtil;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl;
@@ -42,9 +40,9 @@ import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
+import org.eclipse.emf.common.notify.Notifier;
import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.BasicEMap;
-import org.eclipse.emf.common.util.ECollections;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
@@ -55,11 +53,10 @@ import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.BasicEObjectImpl;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EStoreEObjectImpl;
+import org.eclipse.emf.ecore.impl.EStoreEObjectImpl.BasicEStoreFeatureMap;
import org.eclipse.emf.ecore.impl.MinimalEStoreEObjectImpl;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.Resource.Internal;
-import org.eclipse.emf.ecore.util.DelegatingFeatureMap;
-import org.eclipse.emf.ecore.util.EcoreEList;
import org.eclipse.emf.ecore.util.EcoreEMap;
import org.eclipse.emf.ecore.util.FeatureMap;
import org.eclipse.emf.ecore.util.FeatureMapUtil;
@@ -73,9 +70,6 @@ import org.eclipse.emf.spi.cdo.InternalCDOView.ViewAndState;
import java.util.Collection;
import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
/**
* The base class of all <em>native</em> {@link CDOObject objects}.
@@ -86,7 +80,20 @@ public class CDOObjectImpl extends MinimalEStoreEObjectImpl implements InternalC
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_OBJECT, CDOObjectImpl.class);
- private static final Object[] CDO_NO_SETTINGS = {};
+ private static final EObservableAdapterList.Listener ADAPTERS_LISTENER = new EObservableAdapterList.Listener()
+ {
+ public void added(Notifier notifier, Adapter adapter)
+ {
+ ((CDOObjectImpl)notifier).adapterAdded(adapter);
+ }
+
+ public void removed(Notifier notifier, Adapter adapter)
+ {
+ ((CDOObjectImpl)notifier).adapterRemoved(adapter);
+ }
+ };
+
+ private InternalCDOClassInfo classInfo;
/**
* Optimized storage of {@link CDOObject#cdoView()} and {@link CDOObject#cdoState()}.
@@ -102,17 +109,6 @@ public class CDOObjectImpl extends MinimalEStoreEObjectImpl implements InternalC
private Object idOrRevision;
/**
- * Used by CDO instead of eSettings for TRANSIENT objects.
- * <p>
- * EMF uses eSettings as a cache.
- * CDO {@link #eIsCaching() deactivates} this caching but EMF still uses eSettings to store list wrappers.
- * List wrappers are the lists returned from the getters of many-valued features. They need to be unique for an object during all CDOStates.
- * CDO needs another place to store the real list with the actual data (transient mode) and accessible through EStore.
- * This allows CDO to always use the same instance of the list wrapper.
- */
- private transient Object[] cdoSettings;
-
- /**
* Don't use the optional slot in MinimalEObject because a CDOObject always needs eSettings to store:
* <ul>
* <li>the values of all features of transient objects,
@@ -124,6 +120,15 @@ public class CDOObjectImpl extends MinimalEStoreEObjectImpl implements InternalC
public CDOObjectImpl()
{
+ initClassInfo(eStaticClass());
+ }
+
+ /**
+ * @since 4.2
+ */
+ public InternalCDOClassInfo cdoClassInfo()
+ {
+ return classInfo;
}
public final CDOState cdoState()
@@ -339,8 +344,6 @@ public class CDOObjectImpl extends MinimalEStoreEObjectImpl implements InternalC
// Only intended to be called by CDOTransactionImpl.removeObject(CDOID, CDOObject).
// See bug 383370.
- // TODO Rename this method to cdoInternalDetach()
-
if (resource != null)
{
throw new IllegalArgumentException(
@@ -367,15 +370,13 @@ public class CDOObjectImpl extends MinimalEStoreEObjectImpl implements InternalC
if (eSettings != null)
{
// Make sure transient features are kept but persisted values are not cached.
- CDOClassInfo classInfo = getClassInfo();
-
EClass eClass = eClass();
int featureCount = eClass.getFeatureCount();
for (int i = 0; i < featureCount; i++)
{
// We need to keep the existing list if possible.
int index = classInfo.getSettingsFeatureIndex(i);
- if (index != CDOClassInfo.NO_SETTING)
+ if (index != InternalCDOClassInfo.NO_SLOT)
{
Object value = eSettings[index];
if (value instanceof InternalCDOLoadable)
@@ -416,21 +417,30 @@ public class CDOObjectImpl extends MinimalEStoreEObjectImpl implements InternalC
revision.setResourceID(cdoResource.cdoID());
}
- if (cdoSettings != null)
+ if (eSettings != null)
{
EClass eClass = eClass();
- int featureCount = eClass.getFeatureCount();
- for (int i = 0; i < featureCount; i++)
+ EStructuralFeature[] allPersistentFeatures = classInfo.getAllPersistentFeatures();
+ int length = allPersistentFeatures.length;
+ for (int i = 0; i < length; i++)
{
- EStructuralFeature eFeature = eClass.getEStructuralFeature(i);
- if (EMFUtil.isPersistent(eFeature))
- {
- instanceToRevisionFeature(viewAndState.view, this, eFeature, cdoSettings[i]);
- }
+ EStructuralFeature eFeature = allPersistentFeatures[i];
+ int featureID = eClass.getFeatureID(eFeature);
+ int transientIndex = classInfo.getTransientFeatureIndex(featureID);
+ Object setting = eSettings[transientIndex]; // Can be safely accessed directly because we come from TRANSIENT
+
+ instanceToRevisionFeature(viewAndState.view, this, eFeature, setting);
}
cdoRevision().setUnchunked();
- cdoSettings = null;
+
+ int newSize = classInfo.getSettingsFeatureCount();
+ if (newSize != eSettings.length)
+ {
+ Object[] newSettings = new Object[newSize];
+ System.arraycopy(eSettings, 0, newSettings, 0, newSize);
+ eSettings = newSettings;
+ }
}
}
@@ -458,21 +468,23 @@ public class CDOObjectImpl extends MinimalEStoreEObjectImpl implements InternalC
eBasicSetContainer(store.getContainer(this));
eBasicSetContainerFeatureID(store.getContainingFeatureID(this));
- // Ensure that the internal cdoSettings array is initialized;
- cdoSettings = null;
- cdoSettings();
-
- InternalCDORevision revision = cdoRevision();
- EClass eClass = eClass();
- int featureCount = eClass.getFeatureCount();
- for (int i = 0; i < featureCount; i++)
+ if (eSettings != null)
{
- EStructuralFeature eFeature = eClass.getEStructuralFeature(i);
- if (EMFUtil.isPersistent(eFeature))
+ int newSize = classInfo.getSettingsFeatureCount() + classInfo.getTransientFeatureCount();
+ if (newSize != eSettings.length)
{
- revisionToInstanceFeature(this, revision, eFeature);
+ Object[] newSettings = new Object[newSize];
+ System.arraycopy(eSettings, 0, newSettings, 0, eSettings.length);
+ eSettings = newSettings;
}
}
+
+ InternalCDORevision revision = cdoRevision();
+ EStructuralFeature[] allPersistentFeatures = classInfo.getAllPersistentFeatures();
+ for (EStructuralFeature eFeature : allPersistentFeatures)
+ {
+ revisionToInstanceFeature(this, revision, eFeature);
+ }
}
/**
@@ -499,68 +511,47 @@ public class CDOObjectImpl extends MinimalEStoreEObjectImpl implements InternalC
throw new UnsupportedOperationException();
}
- /**
- * @since 4.2
- */
- @Override
- protected void eAdapterAdded(Adapter newAdapter)
+ private CDOStore cdoStore()
{
- if (!FSMUtil.isTransient(CDOObjectImpl.this))
- {
- viewAndState.view.handleAddAdapter(CDOObjectImpl.this, newAdapter);
- }
+ return viewAndState.view.getStore();
}
/**
- * @since 4.2
+ * @since 2.0
*/
@Override
- protected void eAdapterRemoved(Adapter oldAdapter)
+ public EStore eStore()
{
- if (!FSMUtil.isTransient(CDOObjectImpl.this))
+ if (FSMUtil.isTransient(this))
{
- viewAndState.view.handleRemoveAdapter(CDOObjectImpl.this, oldAdapter);
+ return TransientStore.INSTANCE;
}
+
+ return cdoStore();
}
- /**
- * @since 2.0
- */
- private Object[] cdoSettings()
+ @Override
+ protected EClass eDynamicClass()
{
- if (cdoSettings == null)
+ EClass eClass = eClass();
+ if (eClass == eStaticClass())
{
- int size = eClass().getFeatureCount();
- if (size == 0)
- {
- cdoSettings = CDO_NO_SETTINGS;
- }
- else
- {
- cdoSettings = new Object[size];
- }
+ return null;
}
- return cdoSettings;
+ return eClass;
}
- private CDOStore cdoStore()
+ @Override
+ public final EClass eClass()
{
- return viewAndState.view.getStore();
+ return classInfo.getEClass();
}
- /**
- * @since 2.0
- */
@Override
- public EStore eStore()
+ public void eSetClass(EClass eClass)
{
- if (FSMUtil.isTransient(this))
- {
- return TransientStore.INSTANCE;
- }
-
- return cdoStore();
+ initClassInfo(eClass);
}
/**
@@ -591,8 +582,8 @@ public class CDOObjectImpl extends MinimalEStoreEObjectImpl implements InternalC
@Override
public Object dynamicGet(int dynamicFeatureID)
{
- int index = getClassInfo().getSettingsFeatureIndex(dynamicFeatureID);
- if (index == CDOClassInfo.NO_SETTING)
+ int index = classInfo.getSettingsFeatureIndex(dynamicFeatureID);
+ if (index == InternalCDOClassInfo.NO_SLOT)
{
// The feature has no slot in eSettings, i.e., it's persistent or single-valued.
// Delegate to the store. TransientStore delegates back to eSettings.
@@ -607,7 +598,7 @@ public class CDOObjectImpl extends MinimalEStoreEObjectImpl implements InternalC
if (result == null)
{
EStructuralFeature eStructuralFeature = eDynamicFeature(dynamicFeatureID);
- if (EMFUtil.isPersistent(eStructuralFeature))
+ if (classInfo.isPersistent(dynamicFeatureID))
{
if (FeatureMapUtil.isFeatureMap(eStructuralFeature))
{
@@ -626,8 +617,8 @@ public class CDOObjectImpl extends MinimalEStoreEObjectImpl implements InternalC
@Override
public void dynamicSet(int dynamicFeatureID, Object value)
{
- int index = getClassInfo().getSettingsFeatureIndex(dynamicFeatureID);
- if (index == CDOClassInfo.NO_SETTING)
+ int index = classInfo.getSettingsFeatureIndex(dynamicFeatureID);
+ if (index == InternalCDOClassInfo.NO_SLOT)
{
// The feature has no slot in eSettings, i.e., it's persistent or single-valued.
// Delegate to the store. TransientStore delegates back to eSettings.
@@ -645,8 +636,8 @@ public class CDOObjectImpl extends MinimalEStoreEObjectImpl implements InternalC
@Override
public void dynamicUnset(int dynamicFeatureID)
{
- int index = getClassInfo().getSettingsFeatureIndex(dynamicFeatureID);
- if (index == CDOClassInfo.NO_SETTING)
+ int index = classInfo.getSettingsFeatureIndex(dynamicFeatureID);
+ if (index == InternalCDOClassInfo.NO_SLOT)
{
// The feature has no slot in eSettings, i.e., it's persistent or single-valued.
// Delegate to the store. TransientStore delegates back to eSettings.
@@ -657,9 +648,26 @@ public class CDOObjectImpl extends MinimalEStoreEObjectImpl implements InternalC
else
{
Object[] eSettings = eBasicSettings();
- eSettings[index] = null;
-
- // XXX Don't remove the list wrapper for many-valued features!!!
+ Object oldValue = eSettings[index];
+ if (oldValue != null)
+ {
+ if (oldValue instanceof InternalEList)
+ {
+ InternalEList<?> list = (InternalEList<?>)oldValue;
+ if (list instanceof InternalEList.Unsettable)
+ {
+ ((InternalEList.Unsettable<?>)list).unset();
+ }
+ else
+ {
+ list.clear();
+ }
+ }
+ else
+ {
+ eSettings[index] = null;
+ }
+ }
}
}
@@ -876,7 +884,7 @@ public class CDOObjectImpl extends MinimalEStoreEObjectImpl implements InternalC
return eOpenIsSet(eFeature);
}
- if (EMFUtil.isPersistent(eFeature))
+ if (classInfo.isPersistent(dynamicFeatureID))
{
return eStore().isSet(this, eFeature);
}
@@ -907,14 +915,16 @@ public class CDOObjectImpl extends MinimalEStoreEObjectImpl implements InternalC
protected int eDynamicFeatureID(EStructuralFeature eStructuralFeature)
{
// CDOObjectImpl has no static features, so don't subract their count here:
- return eClass().getFeatureID(eStructuralFeature);
+ EClass eClass = eClass();
+ return eClass.getFeatureID(eStructuralFeature);
}
@Override
protected EStructuralFeature eDynamicFeature(int dynamicFeatureID)
{
// CDOObjectImpl has no static features, so don't add their count here:
- return eClass().getEStructuralFeature(dynamicFeatureID);
+ EClass eClass = eClass();
+ return eClass.getEStructuralFeature(dynamicFeatureID);
}
@Override
@@ -922,7 +932,12 @@ public class CDOObjectImpl extends MinimalEStoreEObjectImpl implements InternalC
{
if (!eHasSettings())
{
- int size = getClassInfo().getSettingsFeatureCount();
+ int size = classInfo.getSettingsFeatureCount();
+ if (FSMUtil.isTransient(this))
+ {
+ size += classInfo.getTransientFeatureCount();
+ }
+
if (size != 0)
{
eBasicSetSettings(new Object[size]);
@@ -959,6 +974,45 @@ public class CDOObjectImpl extends MinimalEStoreEObjectImpl implements InternalC
return false;
}
+ @Override
+ protected void eBasicSetAdapterArray(Adapter[] adapters)
+ {
+ Adapter[] oldAdapters = eBasicAdapterArray();
+ if (ObjectUtil.isEmpty(adapters))
+ {
+ adapters = null;// Optimize possibly empty array
+ if (oldAdapters != null) // Can't be empty array because of the optimization above
+ {
+ ((EObservableAdapterList)eAdapters()).removeListener(ADAPTERS_LISTENER);
+ }
+ }
+ else
+ {
+ if (oldAdapters == null) // Can't be empty array because of the optimization above
+ {
+ ((EObservableAdapterList)eAdapters()).addListener(ADAPTERS_LISTENER);
+ }
+ }
+
+ super.eBasicSetAdapterArray(adapters);
+ }
+
+ private void adapterAdded(Adapter newAdapter)
+ {
+ if (!FSMUtil.isTransient(CDOObjectImpl.this))
+ {
+ viewAndState.view.handleAddAdapter(CDOObjectImpl.this, newAdapter);
+ }
+ }
+
+ private void adapterRemoved(Adapter oldAdapter)
+ {
+ if (!FSMUtil.isTransient(CDOObjectImpl.this))
+ {
+ viewAndState.view.handleRemoveAdapter(CDOObjectImpl.this, oldAdapter);
+ }
+ }
+
/**
* Specializing the behaviour of {@link #hashCode()} is not permitted as per {@link EObject} specification.
*/
@@ -980,13 +1034,16 @@ public class CDOObjectImpl extends MinimalEStoreEObjectImpl implements InternalC
@Override
public String toString()
{
+ EClass eClass = eClass();
+ String name = eClass.getName();
+
CDOID id = cdoID();
if (id == null)
{
- return eClass().getName() + "?"; //$NON-NLS-1$
+ return name + "?"; //$NON-NLS-1$
}
- return eClass().getName() + "@" + id; //$NON-NLS-1$
+ return name + "@" + id; //$NON-NLS-1$
}
@Override
@@ -1034,9 +1091,9 @@ public class CDOObjectImpl extends MinimalEStoreEObjectImpl implements InternalC
return eStructuralFeature.getEType().getInstanceClassName() == "java.util.Map$Entry"; //$NON-NLS-1$
}
- private CDOClassInfo getClassInfo()
+ private void initClassInfo(EClass eClass)
{
- return CDOModelUtil.getClassInfo(eClass());
+ classInfo = (InternalCDOClassInfo)CDOModelUtil.getClassInfo(eClass);
}
/**
@@ -1052,18 +1109,18 @@ public class CDOObjectImpl extends MinimalEStoreEObjectImpl implements InternalC
{
if (feature.isMany())
{
- int index = cdoObject.eStore().indexOf(cdoObject, feature, instance.cdoID());
+ EStore eStore = cdoObject.eStore();
+ int index = eStore.indexOf(cdoObject, feature, instance.cdoID());
- // TODO Simon Log an error in the new view.getErrors() in the case we are not able to find the object.
- // Cannot throw an exception, the detach process is too far.
if (index != -1)
{
- cdoObject.eStore().set(cdoObject, feature, index, instance);
+ eStore.set(cdoObject, feature, index, instance);
}
}
else
{
- cdoObject.eStore().set(cdoObject, feature, 0, instance);
+ EStore eStore = cdoObject.eStore();
+ eStore.set(cdoObject, feature, 0, instance);
}
}
else
@@ -1091,50 +1148,6 @@ public class CDOObjectImpl extends MinimalEStoreEObjectImpl implements InternalC
}
/**
- * @since 2.0
- */
- public static void revisionToInstanceFeature(InternalCDOObject instance, InternalCDORevision revision,
- EStructuralFeature eFeature)
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Depopulating feature {0}", eFeature); //$NON-NLS-1$
- }
-
- EStructuralFeature.Internal internalFeature = (EStructuralFeature.Internal)eFeature;
- InternalCDOView view = instance.cdoView();
- EReference oppositeReference = view.isObjectNew(instance.cdoID()) ? null : internalFeature.getEOpposite();
-
- CDOStore cdoStore = view.getStore();
- EStore eStore = instance.eStore();
-
- if (eFeature.isMany())
- {
- int size = cdoStore.size(instance, eFeature);
- for (int index = 0; index < size; index++)
- {
- // Do not trigger events
- // Do not trigger inverse updates
- Object object = cdoStore.get(instance, eFeature, index);
- eStore.add(instance, eFeature, index, object);
- if (oppositeReference != null)
- {
- adjustOppositeReference(instance, (InternalEObject)object, oppositeReference);
- }
- }
- }
- else
- {
- Object object = cdoStore.get(instance, eFeature, EStore.NO_INDEX);
- eStore.set(instance, eFeature, EStore.NO_INDEX, object);
- if (oppositeReference != null)
- {
- adjustOppositeReference(instance, (InternalEObject)object, oppositeReference);
- }
- }
- }
-
- /**
* @since 3.0
*/
public static void instanceToRevisionFeature(InternalCDOView view, InternalCDOObject object,
@@ -1181,6 +1194,50 @@ public class CDOObjectImpl extends MinimalEStoreEObjectImpl implements InternalC
}
/**
+ * @since 2.0
+ */
+ public static void revisionToInstanceFeature(InternalCDOObject instance, InternalCDORevision revision,
+ EStructuralFeature eFeature)
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Depopulating feature {0}", eFeature); //$NON-NLS-1$
+ }
+
+ EStructuralFeature.Internal internalFeature = (EStructuralFeature.Internal)eFeature;
+ InternalCDOView view = instance.cdoView();
+ EReference oppositeReference = view.isObjectNew(instance.cdoID()) ? null : internalFeature.getEOpposite();
+
+ CDOStore cdoStore = view.getStore();
+ EStore eStore = instance.eStore();
+
+ if (eFeature.isMany())
+ {
+ int size = cdoStore.size(instance, eFeature);
+ for (int index = 0; index < size; index++)
+ {
+ // Do not trigger events
+ // Do not trigger inverse updates
+ Object object = cdoStore.get(instance, eFeature, index);
+ eStore.add(instance, eFeature, index, object);
+ if (oppositeReference != null)
+ {
+ adjustOppositeReference(instance, (InternalEObject)object, oppositeReference);
+ }
+ }
+ }
+ else
+ {
+ Object object = cdoStore.get(instance, eFeature, EStore.NO_INDEX);
+ eStore.set(instance, eFeature, EStore.NO_INDEX, object);
+ if (oppositeReference != null)
+ {
+ adjustOppositeReference(instance, (InternalEObject)object, oppositeReference);
+ }
+ }
+ }
+
+ /**
* @since 4.1
*/
public static CDOLock createLock(InternalCDOObject object, LockType type)
@@ -1225,137 +1282,146 @@ public class CDOObjectImpl extends MinimalEStoreEObjectImpl implements InternalC
{
}
- private Object getValue(InternalEObject eObject, int dynamicFeatureID)
+ private Object getValue(InternalEObject eObject, int transientIndex)
{
- Object settings[] = ((CDOObjectImpl)eObject).cdoSettings();
- return settings[dynamicFeatureID];
+ Object[] settings = getSettings(eObject);
+ return settings[transientIndex];
}
- private EList<Object> getValueAsList(InternalEObject eObject, int dynamicFeatureID)
+ private EList<Object> getValueAsList(InternalEObject eObject, int transientIndex)
{
- Object settings[] = ((CDOObjectImpl)eObject).cdoSettings();
+ Object[] settings = getSettings(eObject);
@SuppressWarnings("unchecked")
- EList<Object> result = (EList<Object>)settings[dynamicFeatureID];
+ EList<Object> result = (EList<Object>)settings[transientIndex];
if (result == null)
{
result = new BasicEList<Object>();
- settings[dynamicFeatureID] = result;
+ settings[transientIndex] = result;
}
return result;
}
- private Object setValue(InternalEObject eObject, int dynamicFeatureID, Object newValue)
+ private Object setValue(InternalEObject eObject, int transientIndex, Object newValue)
{
- Object settings[] = ((CDOObjectImpl)eObject).cdoSettings();
- Object oldValue = settings[dynamicFeatureID];
- settings[dynamicFeatureID] = newValue;
+ Object[] settings = getSettings(eObject);
+ Object oldValue = settings[transientIndex];
+ settings[transientIndex] = newValue;
return oldValue;
}
- private int eDynamicFeatureID(InternalEObject eObject, EStructuralFeature feature)
+ private Object[] getSettings(InternalEObject eObject)
{
- return ((CDOObjectImpl)eObject).eDynamicFeatureID(feature);
+ CDOObjectImpl object = (CDOObjectImpl)eObject;
+ object.eSettings(); // Ensure that the array is created
+ return object.eSettings;
+ }
+
+ private int getTransientFeatureIndex(InternalEObject eObject, EStructuralFeature feature)
+ {
+ CDOObjectImpl object = (CDOObjectImpl)eObject;
+ int dynamicFeatureID = object.eDynamicFeatureID(feature);
+ return object.classInfo.getTransientFeatureIndex(dynamicFeatureID);
}
public Object get(InternalEObject eObject, EStructuralFeature feature, int index)
{
- int dynamicFeatureID = eDynamicFeatureID(eObject, feature);
+ int transientIndex = getTransientFeatureIndex(eObject, feature);
if (index != NO_INDEX)
{
- return getValueAsList(eObject, dynamicFeatureID).get(index);
+ return getValueAsList(eObject, transientIndex).get(index);
}
- return getValue(eObject, dynamicFeatureID);
+ return getValue(eObject, transientIndex);
}
public Object set(InternalEObject eObject, EStructuralFeature feature, int index, Object value)
{
- int dynamicFeatureID = eDynamicFeatureID(eObject, feature);
+ int transientIndex = getTransientFeatureIndex(eObject, feature);
if (index != NO_INDEX)
{
- return getValueAsList(eObject, dynamicFeatureID).set(index, value);
+ return getValueAsList(eObject, transientIndex).set(index, value);
}
- return setValue(eObject, dynamicFeatureID, value);
+ return setValue(eObject, transientIndex, value);
}
public void add(InternalEObject eObject, EStructuralFeature feature, int index, Object value)
{
- int dynamicFeatureID = eDynamicFeatureID(eObject, feature);
- getValueAsList(eObject, dynamicFeatureID).add(index, value);
+ int transientIndex = getTransientFeatureIndex(eObject, feature);
+ getValueAsList(eObject, transientIndex).add(index, value);
}
public Object remove(InternalEObject eObject, EStructuralFeature feature, int index)
{
- int dynamicFeatureID = eDynamicFeatureID(eObject, feature);
- return getValueAsList(eObject, dynamicFeatureID).remove(index);
+ int transientIndex = getTransientFeatureIndex(eObject, feature);
+ return getValueAsList(eObject, transientIndex).remove(index);
}
public Object move(InternalEObject eObject, EStructuralFeature feature, int targetIndex, int sourceIndex)
{
- int dynamicFeatureID = eDynamicFeatureID(eObject, feature);
- return getValueAsList(eObject, dynamicFeatureID).move(targetIndex, sourceIndex);
+ int transientIndex = getTransientFeatureIndex(eObject, feature);
+ return getValueAsList(eObject, transientIndex).move(targetIndex, sourceIndex);
}
public void clear(InternalEObject eObject, EStructuralFeature feature)
{
- int dynamicFeatureID = eDynamicFeatureID(eObject, feature);
+ int transientIndex = getTransientFeatureIndex(eObject, feature);
if (feature.isMany())
{
- getValueAsList(eObject, dynamicFeatureID).clear();
+ getValueAsList(eObject, transientIndex).clear();
}
- setValue(eObject, dynamicFeatureID, null);
+ setValue(eObject, transientIndex, null);
}
public int size(InternalEObject eObject, EStructuralFeature feature)
{
- int dynamicFeatureID = eDynamicFeatureID(eObject, feature);
- return getValueAsList(eObject, dynamicFeatureID).size();
+ int transientIndex = getTransientFeatureIndex(eObject, feature);
+ return getValueAsList(eObject, transientIndex).size();
}
public int indexOf(InternalEObject eObject, EStructuralFeature feature, Object value)
{
- int dynamicFeatureID = eDynamicFeatureID(eObject, feature);
- return getValueAsList(eObject, dynamicFeatureID).indexOf(value);
+ int transientIndex = getTransientFeatureIndex(eObject, feature);
+ return getValueAsList(eObject, transientIndex).indexOf(value);
}
public int lastIndexOf(InternalEObject eObject, EStructuralFeature feature, Object value)
{
- int dynamicFeatureID = eDynamicFeatureID(eObject, feature);
- return getValueAsList(eObject, dynamicFeatureID).lastIndexOf(value);
+ int transientIndex = getTransientFeatureIndex(eObject, feature);
+ return getValueAsList(eObject, transientIndex).lastIndexOf(value);
}
public Object[] toArray(InternalEObject eObject, EStructuralFeature feature)
{
- int dynamicFeatureID = eDynamicFeatureID(eObject, feature);
- return getValueAsList(eObject, dynamicFeatureID).toArray();
+ int transientIndex = getTransientFeatureIndex(eObject, feature);
+ return getValueAsList(eObject, transientIndex).toArray();
}
public <T> T[] toArray(InternalEObject eObject, EStructuralFeature feature, T[] array)
{
- int dynamicFeatureID = eDynamicFeatureID(eObject, feature);
- return getValueAsList(eObject, dynamicFeatureID).toArray(array);
+ int transientIndex = getTransientFeatureIndex(eObject, feature);
+ return getValueAsList(eObject, transientIndex).toArray(array);
}
public boolean isEmpty(InternalEObject eObject, EStructuralFeature feature)
{
- int dynamicFeatureID = eDynamicFeatureID(eObject, feature);
- return getValueAsList(eObject, dynamicFeatureID).isEmpty();
+ int transientIndex = getTransientFeatureIndex(eObject, feature);
+ return getValueAsList(eObject, transientIndex).isEmpty();
}
public boolean contains(InternalEObject eObject, EStructuralFeature feature, Object value)
{
- int dynamicFeatureID = eDynamicFeatureID(eObject, feature);
- return getValueAsList(eObject, dynamicFeatureID).contains(value);
+ int transientIndex = getTransientFeatureIndex(eObject, feature);
+ return getValueAsList(eObject, transientIndex).contains(value);
}
public int hashCode(InternalEObject eObject, EStructuralFeature feature)
{
- int dynamicFeatureID = eDynamicFeatureID(eObject, feature);
- return getValueAsList(eObject, dynamicFeatureID).hashCode();
+ int transientIndex = getTransientFeatureIndex(eObject, feature);
+ return getValueAsList(eObject, transientIndex).hashCode();
}
public InternalEObject getContainer(InternalEObject eObject)
@@ -1387,34 +1453,28 @@ public class CDOObjectImpl extends MinimalEStoreEObjectImpl implements InternalC
return !ObjectUtil.equals(eObject.eGet(feature), feature.getDefaultValue());
}
- Object[] settings = ((CDOObjectImpl)eObject).cdoSettings;
+ Object[] settings = ((CDOObjectImpl)eObject).eSettings;
if (settings == null)
{
return false;
}
- int dynamicFeatureID = eDynamicFeatureID(eObject, feature);
- return settings[dynamicFeatureID] != null;
+ int transientIndex = getTransientFeatureIndex(eObject, feature);
+ return settings[transientIndex] != null;
}
public void unset(InternalEObject eObject, EStructuralFeature feature)
{
- Object[] settings = ((CDOObjectImpl)eObject).cdoSettings;
+ CDOObjectImpl object = (CDOObjectImpl)eObject;
+ Object[] settings = object.eSettings;
if (settings == null)
{
// Is already unset
return;
}
- int dynamicFeatureID = eDynamicFeatureID(eObject, feature);
- if (feature.isUnsettable())
- {
- settings[dynamicFeatureID] = null;
- }
- else
- {
- settings[dynamicFeatureID] = feature.getDefaultValue();
- }
+ int transientIndex = getTransientFeatureIndex(eObject, feature);
+ settings[transientIndex] = null;
}
}
@@ -1424,7 +1484,7 @@ public class CDOObjectImpl extends MinimalEStoreEObjectImpl implements InternalC
* @author Eike Stepper
* @since 4.1
*/
- public class CDOStoreEcoreEMap extends EcoreEMap<Object, Object> implements InternalCDOLoadable
+ private final class CDOStoreEcoreEMap extends EcoreEMap<Object, Object> implements InternalCDOLoadable
{
private static final long serialVersionUID = 1L;
@@ -1539,14 +1599,14 @@ public class CDOObjectImpl extends MinimalEStoreEObjectImpl implements InternalC
return super.containsValue(value);
}
- public void cdoInternalPostLoad()
+ public void cdoInternalPreLoad()
{
- entryData = null;
- size = delegateEList.size();
}
- public void cdoInternalPreLoad()
+ public void cdoInternalPostLoad()
{
+ entryData = null;
+ size = delegateEList.size();
}
}
@@ -1556,7 +1616,7 @@ public class CDOObjectImpl extends MinimalEStoreEObjectImpl implements InternalC
* @author Andras Peteri
* @since 4.1
*/
- public class CDOStoreUnorderedEList<E> extends EStoreEObjectImpl.BasicEStoreEList<E>
+ private final class CDOStoreUnorderedEList<E> extends EStoreEObjectImpl.BasicEStoreEList<E>
{
private static final long serialVersionUID = 1L;
@@ -1581,11 +1641,11 @@ public class CDOObjectImpl extends MinimalEStoreEObjectImpl implements InternalC
}
/**
- * TODO Remove this when EMF has fixed bug 197487
+ * For internal use only.
*
* @author Eike Stepper
*/
- public class CDOStoreFeatureMap extends DelegatingFeatureMap
+ private final class CDOStoreFeatureMap extends BasicEStoreFeatureMap
{
private static final long serialVersionUID = 1L;
@@ -1593,165 +1653,5 @@ public class CDOObjectImpl extends MinimalEStoreEObjectImpl implements InternalC
{
super(CDOObjectImpl.this, eStructuralFeature);
}
-
- @Override
- protected List<FeatureMap.Entry> delegateList()
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public EStructuralFeature getEStructuralFeature()
- {
- return eStructuralFeature;
- }
-
- @Override
- protected void delegateAdd(int index, Entry object)
- {
- eStore().add(owner, eStructuralFeature, index, object);
- }
-
- @Override
- protected void delegateAdd(Entry object)
- {
- delegateAdd(delegateSize(), object);
- }
-
- @Override
- protected List<FeatureMap.Entry> delegateBasicList()
- {
- int size = delegateSize();
- if (size == 0)
- {
- return ECollections.emptyEList();
- }
-
- Object[] data = cdoStore().toArray(owner, eStructuralFeature);
- return new EcoreEList.UnmodifiableEList<FeatureMap.Entry>(owner, eStructuralFeature, data.length, data);
- }
-
- @Override
- protected void delegateClear()
- {
- eStore().clear(owner, eStructuralFeature);
- }
-
- @Override
- protected boolean delegateContains(Object object)
- {
- return eStore().contains(owner, eStructuralFeature, object);
- }
-
- @Override
- protected boolean delegateContainsAll(Collection<?> collection)
- {
- for (Object o : collection)
- {
- if (!delegateContains(o))
- {
- return false;
- }
- }
-
- return true;
- }
-
- @Override
- protected Entry delegateGet(int index)
- {
- return (Entry)eStore().get(owner, eStructuralFeature, index);
- }
-
- @Override
- protected int delegateHashCode()
- {
- return eStore().hashCode(owner, eStructuralFeature);
- }
-
- @Override
- protected int delegateIndexOf(Object object)
- {
- return eStore().indexOf(owner, eStructuralFeature, object);
- }
-
- @Override
- protected boolean delegateIsEmpty()
- {
- return eStore().isEmpty(owner, eStructuralFeature);
- }
-
- @Override
- protected Iterator<FeatureMap.Entry> delegateIterator()
- {
- return iterator();
- }
-
- @Override
- protected int delegateLastIndexOf(Object object)
- {
- return eStore().lastIndexOf(owner, eStructuralFeature, object);
- }
-
- @Override
- protected ListIterator<FeatureMap.Entry> delegateListIterator()
- {
- return listIterator();
- }
-
- @Override
- protected Entry delegateRemove(int index)
- {
- return (Entry)eStore().remove(owner, eStructuralFeature, index);
- }
-
- @Override
- protected Entry delegateSet(int index, Entry object)
- {
- return (Entry)eStore().set(owner, eStructuralFeature, index, object);
- }
-
- @Override
- protected int delegateSize()
- {
- return eStore().size(owner, eStructuralFeature);
- }
-
- @Override
- protected Object[] delegateToArray()
- {
- return eStore().toArray(owner, eStructuralFeature);
- }
-
- @Override
- protected <T> T[] delegateToArray(T[] array)
- {
- return eStore().toArray(owner, eStructuralFeature, array);
- }
-
- @Override
- protected Entry delegateMove(int targetIndex, int sourceIndex)
- {
- return (Entry)eStore().move(owner, eStructuralFeature, targetIndex, sourceIndex);
- }
-
- @Override
- protected String delegateToString()
- {
- StringBuffer stringBuffer = new StringBuffer();
- stringBuffer.append("["); //$NON-NLS-1$
- for (int i = 0, size = size(); i < size;)
- {
- Object value = delegateGet(i);
- stringBuffer.append(String.valueOf(value));
- if (++i < size)
- {
- stringBuffer.append(", "); //$NON-NLS-1$
- }
- }
-
- stringBuffer.append("]"); //$NON-NLS-1$
- return stringBuffer.toString();
- }
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyAdapter.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyAdapter.java
index 3e0666137f..c3ed1f748d 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyAdapter.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyAdapter.java
@@ -13,7 +13,6 @@
package org.eclipse.emf.internal.cdo.object;
import org.eclipse.emf.cdo.CDONotification;
-import org.eclipse.emf.cdo.common.model.EMFUtil;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.util.CDOUtil;
@@ -30,6 +29,7 @@ import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.spi.cdo.CDOStore;
import org.eclipse.emf.spi.cdo.FSMUtil;
+import org.eclipse.emf.spi.cdo.InternalCDOView;
import java.util.List;
@@ -89,7 +89,8 @@ public class CDOLegacyAdapter extends CDOLegacyWrapper implements Adapter.Intern
return;
}
- if (EMFUtil.isPersistent(feature))
+ int featureID = eClass().getFeatureID(feature);
+ if (cdoClassInfo().isPersistent(featureID))
{
int eventType = msg.getEventType();
int position = msg.getPosition();
@@ -334,7 +335,8 @@ public class CDOLegacyAdapter extends CDOLegacyWrapper implements Adapter.Intern
if (!FSMUtil.isTransient(CDOLegacyAdapter.this))
{
- cdoView().handleAddAdapter(CDOLegacyAdapter.this, adapter);
+ InternalCDOView view = cdoView();
+ view.handleAddAdapter(CDOLegacyAdapter.this, adapter);
}
}
@@ -347,7 +349,8 @@ public class CDOLegacyAdapter extends CDOLegacyWrapper implements Adapter.Intern
if (!FSMUtil.isTransient(CDOLegacyAdapter.this))
{
- cdoView().handleRemoveAdapter(CDOLegacyAdapter.this, adapter);
+ InternalCDOView view = cdoView();
+ view.handleRemoveAdapter(CDOLegacyAdapter.this, adapter);
}
}
}
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 05122d934e..f5604b13eb 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
@@ -27,6 +27,7 @@ import org.eclipse.emf.cdo.common.security.CDOPermission;
import org.eclipse.emf.cdo.common.util.CDOException;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl;
+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.view.CDOView;
@@ -43,7 +44,6 @@ import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
@@ -74,6 +74,8 @@ public abstract class CDOLegacyWrapper extends CDOObjectWrapper
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_OBJECT, CDOLegacyWrapper.class);
+ private final InternalCDOClassInfo classInfo;
+
/**
* This ThreadLocal map stores all pre-registered objects. This avoids a never-ending loop when setting the container
* of an object.
@@ -113,9 +115,15 @@ public abstract class CDOLegacyWrapper extends CDOObjectWrapper
public CDOLegacyWrapper(InternalEObject instance)
{
this.instance = instance;
+ classInfo = (InternalCDOClassInfo)CDOModelUtil.getClassInfo(instance.eClass());
viewAndState = ViewAndState.TRANSIENT;
}
+ public InternalCDOClassInfo cdoClassInfo()
+ {
+ return classInfo;
+ }
+
public CDOID cdoID()
{
if (idOrRevision == null)
@@ -263,9 +271,7 @@ public abstract class CDOLegacyWrapper extends CDOObjectWrapper
// This loop adjusts the opposite wrapper objects to support dangling references. See Bugzilla_251263_Test
InternalCDORevision revision = cdoRevision();
- EClass eClass = revision.getEClass();
- EStructuralFeature[] allPersistentFeatures = CDOModelUtil.getAllPersistentFeatures(eClass);
- for (EStructuralFeature feature : allPersistentFeatures)
+ for (EStructuralFeature feature : classInfo.getAllPersistentFeatures())
{
EReference oppositeReference = ((EStructuralFeature.Internal)feature).getEOpposite();
if (oppositeReference != null && !oppositeReference.isContainment() && EMFUtil.isPersistent(oppositeReference))
@@ -314,9 +320,7 @@ public abstract class CDOLegacyWrapper extends CDOObjectWrapper
instanceToRevisionContainment();
InternalCDORevision revision = cdoRevision();
- EClass eClass = revision.getEClass();
- EStructuralFeature[] allPersistentFeatures = CDOModelUtil.getAllPersistentFeatures(eClass);
- for (EStructuralFeature feature : allPersistentFeatures)
+ for (EStructuralFeature feature : classInfo.getAllPersistentFeatures())
{
if (feature.isUnsettable())
{
@@ -377,9 +381,7 @@ public abstract class CDOLegacyWrapper extends CDOObjectWrapper
instanceToRevisionContainment();
// Handle values
- EClass eClass = revision.getEClass();
- EStructuralFeature[] allPersistentFeatures = CDOModelUtil.getAllPersistentFeatures(eClass);
- for (EStructuralFeature feature : allPersistentFeatures)
+ for (EStructuralFeature feature : classInfo.getAllPersistentFeatures())
{
instanceToRevisionFeature(feature);
}
@@ -458,9 +460,7 @@ public abstract class CDOLegacyWrapper extends CDOObjectWrapper
resource.cdoInternalLoading(instance);
}
- EClass eClass = revision.getEClass();
- EStructuralFeature[] allPersistentFeatures = CDOModelUtil.getAllPersistentFeatures(eClass);
- for (EStructuralFeature feature : allPersistentFeatures)
+ for (EStructuralFeature feature : classInfo.getAllPersistentFeatures())
{
revisionToInstanceFeature(feature);
}
@@ -849,10 +849,7 @@ public abstract class CDOLegacyWrapper extends CDOObjectWrapper
*/
protected void resolveAllProxies()
{
- InternalCDORevision revision = cdoRevision();
- EClass eClass = revision.getEClass();
- EStructuralFeature[] allPersistentFeatures = CDOModelUtil.getAllPersistentFeatures(eClass);
- for (EStructuralFeature feature : allPersistentFeatures)
+ for (EStructuralFeature feature : classInfo.getAllPersistentFeatures())
{
if (feature instanceof EReference)
{
@@ -965,11 +962,15 @@ public abstract class CDOLegacyWrapper extends CDOObjectWrapper
public synchronized EList<Adapter> eAdapters()
{
EList<Adapter> adapters = instance.eAdapters();
- for (Adapter adapter : adapters)
+ if (!FSMUtil.isTransient(this))
{
- if (!FSMUtil.isTransient(this) && !(adapter instanceof CDOLegacyWrapper))
+ InternalCDOView view = cdoView();
+ for (Adapter adapter : adapters)
{
- cdoView().handleAddAdapter(this, adapter);
+ if (!(adapter instanceof CDOLegacyWrapper))
+ {
+ view.handleAddAdapter(this, adapter);
+ }
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOObjectWrapperBase.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOObjectWrapperBase.java
index ae02451a9b..c2d7897e01 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOObjectWrapperBase.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOObjectWrapperBase.java
@@ -115,7 +115,8 @@ public abstract class CDOObjectWrapperBase implements CDOObject, InternalEObject
*/
protected EStructuralFeature eDynamicFeature(int dynamicFeatureID)
{
- return eClass().getEStructuralFeature(dynamicFeatureID + eStaticFeatureCount());
+ EClass eClass = eClass();
+ return eClass.getEStructuralFeature(dynamicFeatureID + eStaticFeatureCount());
}
/**
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/DynamicCDOObjectImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/DynamicCDOObjectImpl.java
index 388becd11f..c8b3b17bcd 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/DynamicCDOObjectImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/DynamicCDOObjectImpl.java
@@ -22,29 +22,16 @@ import org.eclipse.emf.ecore.EStructuralFeature;
*/
public class DynamicCDOObjectImpl extends CDOObjectImpl
{
- private EClass eClass;
-
public DynamicCDOObjectImpl(EClass eClass)
{
eSetClass(eClass);
}
@Override
- public EClass eClass()
- {
- return eClass;
- }
-
- @Override
- public void eSetClass(EClass eClass)
- {
- this.eClass = eClass;
- }
-
- @Override
protected EClass eDynamicClass()
{
- return eClass;
+ // Bypass the eStaticClass() check in super.eDynamicClass()
+ return eClass();
}
/**
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java
index bf7ce48068..acc6d3d7ff 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java
@@ -30,7 +30,6 @@ import org.eclipse.emf.cdo.common.lob.CDOLobInfo;
import org.eclipse.emf.cdo.common.lob.CDOLobStore;
import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo;
import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
-import org.eclipse.emf.cdo.common.model.EMFUtil;
import org.eclipse.emf.cdo.common.revision.CDOElementProxy;
import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
import org.eclipse.emf.cdo.common.revision.CDOList;
@@ -812,31 +811,29 @@ public abstract class CDOSessionImpl extends CDOTransactionContainerImpl impleme
*/
public void resolveAllElementProxies(CDORevision revision)
{
- if (!((InternalCDORevision)revision).isUnchunked())
+ InternalCDORevision internalRevision = (InternalCDORevision)revision;
+ if (!internalRevision.isUnchunked())
{
CDOCollectionLoadingPolicy policy = options().getCollectionLoadingPolicy();
- for (EStructuralFeature feature : revision.getEClass().getEAllStructuralFeatures())
+
+ for (EReference reference : internalRevision.getClassInfo().getAllPersistentReferences())
{
- if (feature instanceof EReference)
+ if (reference.isMany())
{
- EReference reference = (EReference)feature;
- if (reference.isMany() && EMFUtil.isPersistent(reference))
+ CDOList list = internalRevision.getList(reference);
+ for (Iterator<Object> it = list.iterator(); it.hasNext();)
{
- CDOList list = ((InternalCDORevision)revision).getList(reference);
- for (Iterator<Object> it = list.iterator(); it.hasNext();)
+ Object element = it.next();
+ if (element instanceof CDOElementProxy)
{
- Object element = it.next();
- if (element instanceof CDOElementProxy)
- {
- policy.resolveAllProxies(revision, reference);
- break;
- }
+ policy.resolveAllProxies(internalRevision, reference);
+ break;
}
}
}
}
- ((InternalCDORevision)revision).setUnchunked();
+ internalRevision.setUnchunked();
}
}
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 93e02a670f..4a809527c6 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
@@ -387,25 +387,22 @@ public class CommitIntegrityCheck
private void checkCurrentRefTargetsIncluded(CDOObject referencer, String msgFrag) throws CommitIntegrityException
{
- for (EReference eRef : referencer.eClass().getEAllReferences())
+ for (EReference eRef : ((InternalCDOObject)referencer).cdoClassInfo().getAllPersistentReferences())
{
- if (EMFUtil.isPersistent(eRef))
+ if (eRef.isMany())
{
- if (eRef.isMany())
+ EList<?> list = (EList<?>)referencer.eGet(eRef);
+ for (Object refTarget : list)
{
- EList<?> list = (EList<?>)referencer.eGet(eRef);
- for (Object refTarget : list)
- {
- checkBidiRefTargetOrNewNonBidiTargetIncluded(referencer, eRef, refTarget, msgFrag);
- }
+ checkBidiRefTargetOrNewNonBidiTargetIncluded(referencer, eRef, refTarget, msgFrag);
}
- else
+ }
+ else
+ {
+ Object refTarget = referencer.eGet(eRef);
+ if (refTarget != null)
{
- Object refTarget = referencer.eGet(eRef);
- if (refTarget != null)
- {
- checkBidiRefTargetOrNewNonBidiTargetIncluded(referencer, eRef, refTarget, msgFrag);
- }
+ checkBidiRefTargetOrNewNonBidiTargetIncluded(referencer, eRef, refTarget, msgFrag);
}
}
}
@@ -435,9 +432,9 @@ public class CommitIntegrityCheck
InternalCDORevision cleanRev = transaction.getCleanRevisions().get(referencer);
CheckUtil.checkState(cleanRev, "cleanRev");
- for (EReference eRef : referencer.eClass().getEAllReferences())
+ for (EReference eRef : ((InternalCDOObject)referencer).cdoClassInfo().getAllPersistentReferences())
{
- if (EMFUtil.isPersistent(eRef) && hasPersistentOpposite(eRef))
+ if (hasPersistentOpposite(eRef))
{
Object value = cleanRev.get(eRef, EStore.NO_INDEX);
if (value != null)
@@ -498,7 +495,7 @@ public class CommitIntegrityCheck
/**
* Designates an exception style for a {@link CommitIntegrityCheck}
- *
+ *
* @author Caspar De Groot
*/
public static enum Style
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 730330c2d4..ba62937838 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
@@ -459,7 +459,6 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
}
process(object, CDOEvent.ROLLBACK, null);
- object.cdoInternalPostRollback();
}
}
@@ -909,8 +908,19 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
{
public void execute(InternalCDOObject object, CDOState state, CDOEvent event, Object NULL)
{
+ InternalCDOTransaction transaction = object.cdoView().toTransaction();
+ if (transaction.getLastSavepoint().isNewObject(object.cdoID()))
+ {
+ changeState(object, CDOState.TRANSIENT);
+ object.cdoInternalPostDetach(false);
+ }
+ else
+ {
+ changeState(object, CDOState.PROXY);
+ object.cdoInternalPostRollback();
+ }
+
object.cdoInternalSetRevision(null);
- changeState(object, CDOState.PROXY);
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOObject.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOObject.java
index b7ca2d3d67..7c0bd4af83 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOObject.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOObject.java
@@ -16,6 +16,7 @@ import org.eclipse.emf.cdo.CDOState;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.model.CDOPackageTypeRegistry.CDOObjectMarker;
import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.spi.common.model.InternalCDOClassInfo;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.emf.cdo.view.CDOView;
@@ -32,6 +33,11 @@ import org.eclipse.emf.ecore.InternalEObject;
*/
public interface InternalCDOObject extends CDOObject, InternalEObject, InternalCDOLoadable, CDOObjectMarker
{
+ /**
+ * @since 4.2
+ */
+ public InternalCDOClassInfo cdoClassInfo();
+
public InternalCDOView cdoView();
public InternalCDORevision cdoRevision();

Back to the top