Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-02-10 06:13:09 -0500
committerEike Stepper2013-02-13 14:58:08 -0500
commit554a4a177bd6a182a8fd8081969f9d3426732b6f (patch)
treea1353627cedf8bab930ba6ea1821b3d257fcebde
parentb5a193491935f7c23ddf1da34dc6ea0561290b65 (diff)
downloadcdo-554a4a177bd6a182a8fd8081969f9d3426732b6f.tar.gz
cdo-554a4a177bd6a182a8fd8081969f9d3426732b6f.tar.xz
cdo-554a4a177bd6a182a8fd8081969f9d3426732b6f.zip
[400388] Integrate the new MinimalEStoreEObjectImpl
https://bugs.eclipse.org/bugs/show_bug.cgi?id=400388
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOClassInfo.java19
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOClassInfoImpl.java75
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InitialTest.java18
-rw-r--r--plugins/org.eclipse.emf.cdo/.settings/.api_filters17
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java3
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java251
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyWrapper.java1
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOViewContainerImpl.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java11
9 files changed, 249 insertions, 148 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOClassInfo.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOClassInfo.java
index 75a3f31ded..5682b0dc81 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
@@ -4,7 +4,7 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Eike Stepper - initial API and implementation
*/
@@ -16,7 +16,7 @@ import org.eclipse.emf.ecore.EStructuralFeature;
/**
* An EMF {@link Adapter adapter} that encapsulates CDO specific information about an {@link EClass}.
- *
+ *
* @author Eike Stepper
* @since 2.0
* @noextend This interface is not intended to be extended by clients.
@@ -26,6 +26,11 @@ 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,4 +44,14 @@ public interface CDOClassInfo extends Adapter
public int getFeatureIndex(EStructuralFeature feature);
public int getFeatureIndex(int featureID);
+
+ /**
+ * @since 4.2
+ */
+ public int getSettingsFeatureCount();
+
+ /**
+ * @since 4.2
+ */
+ public int getSettingsFeatureIndex(int featureID);
}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOClassInfoImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOClassInfoImpl.java
index dd833a77a6..25e17dde3b 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
@@ -23,6 +23,7 @@ import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
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;
@@ -43,6 +44,10 @@ public class CDOClassInfoImpl extends AdapterImpl implements InternalCDOClassInf
private int[] featureIDMappings;
+ private int settingsFeatureCount;
+
+ private int[] settingsFeatureIndices;
+
public CDOClassInfoImpl()
{
}
@@ -102,6 +107,16 @@ public class CDOClassInfoImpl extends AdapterImpl implements InternalCDOClassInf
return index;
}
+ public int getSettingsFeatureCount()
+ {
+ return settingsFeatureCount;
+ }
+
+ public int getSettingsFeatureIndex(int featureID)
+ {
+ return settingsFeatureIndices[featureID];
+ }
+
public PersistenceFilter getPersistenceFilter(EStructuralFeature feature)
{
if (persistenceFilters == NO_FILTERS)
@@ -113,15 +128,52 @@ public class CDOClassInfoImpl extends AdapterImpl implements InternalCDOClassInf
return persistenceFilters[featureID];
}
+ private PersistenceFilter initPersistenceFilter(EStructuralFeature feature)
+ {
+ CDOPersistenceFilterImpl result = null;
+ String filter = EcoreUtil.getAnnotation(feature, EMFUtil.CDO_ANNOTATION_SOURCE, "filter");
+
+ if (filter != null)
+ {
+ EStructuralFeature dependency = feature.getEContainingClass().getEStructuralFeature(filter);
+ if (dependency != null)
+ {
+ result = new CDOPersistenceFilterImpl(dependency);
+ }
+ else
+ {
+ OM.LOG.warn("Persistence filter '" + filter + "' not found for " + feature);
+ }
+ }
+
+ return result;
+ }
+
private void init(EClass eClass)
{
List<EStructuralFeature> persistentFeatures = new ArrayList<EStructuralFeature>();
EList<EStructuralFeature> allFeatures = eClass.getEAllStructuralFeatures();
- for (EStructuralFeature feature : allFeatures)
+
+ int featureCount = eClass.getFeatureCount();
+ settingsFeatureIndices = new int[featureCount];
+ for (int i = 0; i < featureCount; i++)
{
+ EStructuralFeature feature = eClass.getEStructuralFeature(i);
if (EMFUtil.isPersistent(feature))
{
persistentFeatures.add(feature);
+ if (feature.isMany() || FeatureMapUtil.isFeatureMap(feature))
+ {
+ settingsFeatureIndices[i] = settingsFeatureCount++;
+ }
+ else
+ {
+ settingsFeatureIndices[i] = NO_SETTING;
+ }
+ }
+ else
+ {
+ settingsFeatureIndices[i] = settingsFeatureCount++;
}
}
@@ -148,27 +200,6 @@ public class CDOClassInfoImpl extends AdapterImpl implements InternalCDOClassInf
}
}
- private PersistenceFilter initPersistenceFilter(EStructuralFeature feature)
- {
- CDOPersistenceFilterImpl result = null;
- String filter = EcoreUtil.getAnnotation(feature, EMFUtil.CDO_ANNOTATION_SOURCE, "filter");
-
- if (filter != null)
- {
- EStructuralFeature dependency = feature.getEContainingClass().getEStructuralFeature(filter);
- if (dependency != null)
- {
- result = new CDOPersistenceFilterImpl(dependency);
- }
- else
- {
- OM.LOG.warn("Persistence filter '" + filter + "' not found for " + feature);
- }
- }
-
- return result;
- }
-
@Override
public String toString()
{
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 9755bf598e..0951389106 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
@@ -489,54 +489,36 @@ public class InitialTest extends AbstractCDOTest
public void testReadTransientValue() throws Exception
{
- msg("Opening session");
CDOSession session = openSession();
{
disableConsole();
- msg("Opening transaction");
CDOTransaction transaction = session.openTransaction();
-
- msg("Creating resource");
CDOResource resource = transaction.createResource(getResourcePath("/test1"));
- msg("Creating supplier");
Product1 product = getModel1Factory().createProduct1();
-
- msg("Setting name");
product.setDescription("DESCRIPTION");
product.setName("McDuff");
- msg("Adding supplier");
resource.getContents().add(product);
assertEquals("DESCRIPTION", product.getDescription());
- msg("Committing");
transaction.commit();
enableConsole();
}
- msg("Opening transaction");
CDOView view = session.openView();
-
- msg("Getting resource");
CDOResource resource = view.getResource(getResourcePath("/test1"));
- msg("Getting contents");
EList<EObject> contents = resource.getContents();
-
- msg("Getting supplier");
Product1 s = (Product1)contents.get(0);
assertNotNull(s);
- msg("Verifying name");
assertEquals("McDuff", s.getName());
-
assertNull(s.getDescription());
s.setDescription("HELLO");
-
assertEquals("HELLO", s.getDescription());
}
diff --git a/plugins/org.eclipse.emf.cdo/.settings/.api_filters b/plugins/org.eclipse.emf.cdo/.settings/.api_filters
index 09496439e7..47a98726d8 100644
--- a/plugins/org.eclipse.emf.cdo/.settings/.api_filters
+++ b/plugins/org.eclipse.emf.cdo/.settings/.api_filters
@@ -169,6 +169,17 @@
<message_argument value="cdoBasicSettings()"/>
</message_arguments>
</filter>
+ <filter id="338792546">
+ <message_arguments>
+ <message_argument value="org.eclipse.emf.internal.cdo.CDOObjectImpl"/>
+ <message_argument value="eInitializeContainer()"/>
+ </message_arguments>
+ </filter>
+ <filter id="338849923">
+ <message_arguments>
+ <message_argument value="org.eclipse.emf.internal.cdo.CDOObjectImpl"/>
+ </message_arguments>
+ </filter>
<filter id="338886760">
<message_arguments>
<message_argument value="org.eclipse.emf.internal.cdo.CDOObjectImpl.CDOStoreSettingsImpl"/>
@@ -205,6 +216,12 @@
<message_argument value="cdoView()"/>
</message_arguments>
</filter>
+ <filter id="421654647">
+ <message_arguments>
+ <message_argument value="org.eclipse.emf.internal.cdo.CDOObjectImpl"/>
+ <message_argument value="eIsCaching()"/>
+ </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">
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java
index 4277fe2b2d..5d546121be 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java
@@ -52,6 +52,7 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.InternalEObject;
+import org.eclipse.emf.ecore.impl.EStoreEObjectImpl;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.URIConverter;
@@ -1675,7 +1676,7 @@ public class CDOResourceImpl extends CDOResourceLeafImpl implements InternalCDOR
* @author Eike Stepper
* @since 2.0
*/
- protected class ContentsCDOList extends BasicEStoreEList<Object>
+ protected class ContentsCDOList extends EStoreEObjectImpl.BasicEStoreEList<Object>
{
private static final long serialVersionUID = 1L;
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 bfd0b90891..5722af5cca 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,6 +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;
@@ -49,10 +50,12 @@ import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.EStructuralFeature.Internal.DynamicValueHolder;
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.MinimalEStoreEObjectImpl;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.Resource.Internal;
import org.eclipse.emf.ecore.util.DelegatingFeatureMap;
@@ -79,10 +82,12 @@ import java.util.ListIterator;
*
* @author Eike Stepper
*/
-public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObject
+public class CDOObjectImpl extends MinimalEStoreEObjectImpl implements InternalCDOObject
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_OBJECT, CDOObjectImpl.class);
+ private static final Object[] CDO_NO_SETTINGS = {};
+
/**
* Optimized storage of {@link CDOObject#cdoView()} and {@link CDOObject#cdoState()}.
*
@@ -107,11 +112,18 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
*/
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,
+ * <li>the values of transient features of persistent objects and
+ * <li>the list wrappers of all many-valued features of all objects.
+ * </ul>
+ */
private Object[] eSettings;
public CDOObjectImpl()
{
- eContainer = null; // Overwrite base class initialization
}
public final CDOState cdoState()
@@ -286,15 +298,6 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
{
viewAndState = ViewAndState.TRANSIENT.getViewAndState(viewAndState.state);
}
-
- if (viewAndState.view != null)
- {
- eSetStore(viewAndState.view.getStore());
- }
- else
- {
- eSetStore(null);
- }
}
public void cdoInternalSetID(CDOID id)
@@ -345,8 +348,8 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
}
super.eSetDirectResource(null);
- eContainer = null;
- eContainerFeatureID = 0;
+ eBasicSetContainer(null);
+ eBasicSetContainerFeatureID(0);
}
/**
@@ -360,19 +363,37 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
public void cdoInternalPostLoad()
{
// Reset EMAP objects
+ Object[] eSettings = eBasicSettings();
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++)
{
- EStructuralFeature eFeature = eClass.getEStructuralFeature(i);
-
// We need to keep the existing list if possible.
- if (EMFUtil.isPersistent(eFeature) && eSettings[i] instanceof InternalCDOLoadable)
+ int index = classInfo.getSettingsFeatureIndex(i);
+ if (index != CDOClassInfo.NO_SETTING)
+ {
+ EStructuralFeature eFeature = eClass.getEStructuralFeature(i);
+ if (EMFUtil.isPersistent(eFeature))
+ {
+ Object value = eSettings[index];
+ if (value instanceof InternalCDOLoadable)
+ {
+ ((InternalCDOLoadable)value).cdoInternalPostLoad();
+ }
+ }
+ }
+ else
{
- ((InternalCDOLoadable)eSettings[i]).cdoInternalPostLoad();
+ EStructuralFeature eFeature = eClass.getEStructuralFeature(i);
+ if (EMFUtil.isPersistent(eFeature))
+ {
+ System.out.println(eFeature);
+ }
}
}
}
@@ -393,6 +414,9 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
TRACER.format("Populating revision for {0}", this); //$NON-NLS-1$
}
+ InternalEObject eContainer = eBasicInternalContainer();
+ int eContainerFeatureID = eBasicContainerFeatureID();
+
InternalCDORevision revision = cdoRevision();
revision.setContainerID(eContainer == null ? CDOID.NULL : viewAndState.view.convertObjectToID(eContainer, true));
revision.setContainingFeatureID(eContainerFeatureID);
@@ -443,8 +467,8 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
CDOStore store = cdoStore();
super.eSetDirectResource((Resource.Internal)store.getResource(this));
- eContainer = store.getContainer(this);
- eContainerFeatureID = store.getContainingFeatureID(this);
+ eBasicSetContainer(store.getContainer(this));
+ eBasicSetContainerFeatureID(store.getContainingFeatureID(this));
// Ensure that the internal cdoSettings array is initialized;
cdoSettings = null;
@@ -488,47 +512,27 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
}
/**
- * @since 2.0
+ * @since 4.2
*/
@Override
- public synchronized EList<Adapter> eAdapters()
+ protected void eAdapterAdded(Adapter newAdapter)
{
- if (eAdapters == null)
+ if (!FSMUtil.isTransient(CDOObjectImpl.this))
{
- // TODO Adjust for EObjectEAdapterList (see bug #247130)
- eAdapters = new EAdapterList<Adapter>(this)
- {
- private static final long serialVersionUID = 1L;
-
- @Override
- protected void didAdd(int index, Adapter newObject)
- {
- if (viewAndState.view == null || viewAndState.view.isActive())
- {
- super.didAdd(index, newObject);
- if (!FSMUtil.isTransient(CDOObjectImpl.this))
- {
- viewAndState.view.handleAddAdapter(CDOObjectImpl.this, newObject);
- }
- }
- }
-
- @Override
- protected void didRemove(int index, Adapter oldObject)
- {
- if (viewAndState.view == null || viewAndState.view.isActive())
- {
- super.didRemove(index, oldObject);
- if (!FSMUtil.isTransient(CDOObjectImpl.this))
- {
- viewAndState.view.handleRemoveAdapter(CDOObjectImpl.this, oldObject);
- }
- }
- }
- };
+ viewAndState.view.handleAddAdapter(CDOObjectImpl.this, newAdapter);
}
+ }
- return eAdapters;
+ /**
+ * @since 4.2
+ */
+ @Override
+ protected void eAdapterRemoved(Adapter oldAdapter)
+ {
+ if (!FSMUtil.isTransient(CDOObjectImpl.this))
+ {
+ viewAndState.view.handleRemoveAdapter(CDOObjectImpl.this, oldAdapter);
+ }
}
/**
@@ -541,7 +545,7 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
int size = eClass().getFeatureCount();
if (size == 0)
{
- cdoSettings = ENO_SETTINGS;
+ cdoSettings = CDO_NO_SETTINGS;
}
else
{
@@ -599,28 +603,29 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
@Override
public Object dynamicGet(int dynamicFeatureID)
{
- Object result = eSettings[dynamicFeatureID];
+ EStructuralFeature eStructuralFeature = eDynamicFeature(dynamicFeatureID);
+
+ int index = getClassInfo().getSettingsFeatureIndex(dynamicFeatureID);
+ if (index == CDOClassInfo.NO_SETTING)
+ {
+ // The feature has no slot in eSettings, i.e., it's persistent or single-valued.
+ // Delegate to the store. TransientStore delegates back to eSettings.
+ EStore eStore = eStore();
+ return eStore.get(this, eStructuralFeature, EStore.NO_INDEX);
+ }
+
+ // Here we know that the feature is transient or many-valued, hence it has a slot in eSettings.
+ Object[] eSettings = eBasicSettings();
+ Object result = eSettings[index];
if (result == null)
{
- EStructuralFeature eStructuralFeature = eDynamicFeature(dynamicFeatureID);
- if (EMFUtil.isPersistent(eStructuralFeature))
+ if (FeatureMapUtil.isFeatureMap(eStructuralFeature))
{
- if (FeatureMapUtil.isFeatureMap(eStructuralFeature))
- {
- eSettings[dynamicFeatureID] = result = createFeatureMap(eStructuralFeature);
- }
- else if (eStructuralFeature.isMany())
- {
- eSettings[dynamicFeatureID] = result = createList(eStructuralFeature);
- }
- else
- {
- result = eStore().get(this, eStructuralFeature, EStore.NO_INDEX);
- if (eIsCaching())
- {
- eSettings[dynamicFeatureID] = result;
- }
- }
+ eSettings[index] = result = createFeatureMap(eStructuralFeature);
+ }
+ else if (eStructuralFeature.isMany())
+ {
+ eSettings[index] = result = createList(eStructuralFeature);
}
}
@@ -631,17 +636,19 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
public void dynamicSet(int dynamicFeatureID, Object value)
{
EStructuralFeature eStructuralFeature = eDynamicFeature(dynamicFeatureID);
- if (!EMFUtil.isPersistent(eStructuralFeature))
+
+ int index = getClassInfo().getSettingsFeatureIndex(dynamicFeatureID);
+ if (index == CDOClassInfo.NO_SETTING)
{
- eSettings[dynamicFeatureID] = value;
+ // The feature has no slot in eSettings, i.e., it's persistent or single-valued.
+ // Delegate to the store. TransientStore delegates back to eSettings.
+ EStore eStore = eStore();
+ eStore.set(this, eStructuralFeature, EStore.NO_INDEX, value);
}
else
{
- eStore().set(this, eStructuralFeature, EStore.NO_INDEX, value);
- if (eIsCaching())
- {
- eSettings[dynamicFeatureID] = value;
- }
+ Object[] eSettings = eBasicSettings();
+ eSettings[index] = value;
}
}
@@ -649,34 +656,33 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
public void dynamicUnset(int dynamicFeatureID)
{
EStructuralFeature eStructuralFeature = eDynamicFeature(dynamicFeatureID);
- if (!EMFUtil.isPersistent(eStructuralFeature))
+
+ int index = getClassInfo().getSettingsFeatureIndex(dynamicFeatureID);
+ if (index == CDOClassInfo.NO_SETTING)
{
- eSettings[dynamicFeatureID] = null;
+ // The feature has no slot in eSettings, i.e., it's persistent or single-valued.
+ // Delegate to the store. TransientStore delegates back to eSettings.
+ EStore eStore = eStore();
+ eStore.unset(this, eStructuralFeature);
}
else
{
- eStore().unset(this, eDynamicFeature(dynamicFeatureID));
- if (eIsCaching())
- {
- eSettings[dynamicFeatureID] = null;
- }
+ Object[] eSettings = eBasicSettings();
+ eSettings[index] = null;
+
+ // XXX Don't remove the list wrapper for many-valued features!!!
}
}
@Override
public InternalEObject eInternalContainer()
{
- InternalEObject container;
if (FSMUtil.isTransient(this))
{
- container = eContainer;
- }
- else
- {
- container = cdoStore().getContainer(this);
+ return eBasicInternalContainer();
}
- return container;
+ return cdoStore().getContainer(this);
}
@Override
@@ -684,7 +690,7 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
{
if (FSMUtil.isTransient(this))
{
- return eContainerFeatureID;
+ return eBasicContainerFeatureID();
}
return cdoStore().getContainingFeatureID(this);
@@ -903,7 +909,8 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
}
else
{
- cdoStore().setContainer(this, cdoDirectResource(), newEContainer, newContainerFeatureID);
+ CDOStore cdoStore = cdoStore();
+ cdoStore.setContainer(this, cdoDirectResource(), newEContainer, newContainerFeatureID);
}
}
@@ -915,16 +922,50 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
}
@Override
- protected void eInitializeContainer()
+ protected EStructuralFeature eDynamicFeature(int dynamicFeatureID)
{
- throw new UnsupportedOperationException();
+ // CDOObjectImpl has no static features, so don't add their count here:
+ return eClass().getEStructuralFeature(dynamicFeatureID);
+ }
+
+ @Override
+ protected DynamicValueHolder eSettings()
+ {
+ if (!eHasSettings())
+ {
+ int size = getClassInfo().getSettingsFeatureCount();
+ if (size != 0)
+ {
+ eBasicSetSettings(new Object[size]);
+ }
+ }
+
+ return this;
+ }
+
+ @Override
+ protected final boolean eHasSettings()
+ {
+ return eSettings != null;
+ }
+
+ @Override
+ protected final Object[] eBasicSettings()
+ {
+ return eSettings;
+ }
+
+ @Override
+ protected final void eBasicSetSettings(Object[] settings)
+ {
+ eSettings = settings;
}
/**
* Don't cache non-transient features in this CDOObject's {@link #eSettings()}.
*/
@Override
- protected boolean eIsCaching()
+ protected final boolean eIsCaching()
{
return false;
}
@@ -1004,6 +1045,11 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
return eStructuralFeature.getEType().getInstanceClassName() == "java.util.Map$Entry"; //$NON-NLS-1$
}
+ private CDOClassInfo getClassInfo()
+ {
+ return CDOModelUtil.getClassInfo(eClass());
+ }
+
/**
* Adjust the reference ONLY if the opposite reference used CDOID. This is true ONLY if the state of <cdo>this</code>
* was not {@link CDOState#NEW}.
@@ -1396,7 +1442,8 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
public CDOStoreEcoreEMap(EStructuralFeature eStructuralFeature)
{
super((EClass)eStructuralFeature.getEType(), BasicEMap.Entry.class, null);
- delegateEList = new BasicEStoreEList<BasicEMap.Entry<Object, Object>>(CDOObjectImpl.this, eStructuralFeature)
+ delegateEList = new EStoreEObjectImpl.BasicEStoreEList<BasicEMap.Entry<Object, Object>>(CDOObjectImpl.this,
+ eStructuralFeature)
{
private static final long serialVersionUID = 1L;
@@ -1520,7 +1567,7 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
* @author Andras Peteri
* @since 4.1
*/
- public class CDOStoreUnorderedEList<E> extends BasicEStoreEList<E>
+ public class CDOStoreUnorderedEList<E> extends EStoreEObjectImpl.BasicEStoreEList<E>
{
private static final long serialVersionUID = 1L;
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 1b55487234..05122d934e 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
@@ -249,7 +249,6 @@ public abstract class CDOLegacyWrapper extends CDOObjectWrapper
if (!(adapter instanceof CDOObjectWrapper))
{
viewAndState.view.handleAddAdapter(this, adapter);
- viewAndState.view.subscribe(this, adapter);
}
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOViewContainerImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOViewContainerImpl.java
index f5a3ef03b9..5e40fe95e3 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOViewContainerImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOViewContainerImpl.java
@@ -180,8 +180,6 @@ public abstract class CDOViewContainerImpl extends Container<CDOView> implements
*/
public void viewDetached(InternalCDOView view)
{
- // Detach viewset from the view
- view.getViewSet().remove(view);
synchronized (views)
{
if (!views.remove(view))
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java
index 85a76eb0e7..8483446b59 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java
@@ -89,6 +89,7 @@ import org.eclipse.emf.spi.cdo.InternalCDOObject;
import org.eclipse.emf.spi.cdo.InternalCDOSession;
import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
import org.eclipse.emf.spi.cdo.InternalCDOView;
+import org.eclipse.emf.spi.cdo.InternalCDOViewSet;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -1129,6 +1130,16 @@ public class CDOViewImpl extends AbstractCDOView
CDOViewRegistryImpl.INSTANCE.register(this);
}
+ @Override
+ protected void doBeforeDeactivate() throws Exception
+ {
+ // Detach viewset from the view
+ InternalCDOViewSet viewSet = getViewSet();
+ viewSet.remove(this);
+
+ super.doBeforeDeactivate();
+ }
+
/**
* @since 2.0
*/

Back to the top