Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 115764 Details for
Bug 251544
Instance of list are not the same for the following transition transient/new persisted/transient resulting strange behavior (NPE)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch v1
clipboard.txt (text/plain), 41.88 KB, created by
Simon Mc Duff
on 2008-10-21 19:37:35 EDT
(
hide
)
Description:
Patch v1
Filename:
MIME Type:
Creator:
Simon Mc Duff
Created:
2008-10-21 19:37:35 EDT
Size:
41.88 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.emf.cdo.tests >Index: src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf.cdo/tests/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java,v >retrieving revision 1.11 >diff -u -r1.11 AllTestsAllConfigs.java >--- src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java 19 Oct 2008 01:28:59 -0000 1.11 >+++ src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java 21 Oct 2008 23:36:45 -0000 >@@ -22,6 +22,7 @@ > import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_250757_Test; > import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_251087_Test; > import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_251263_Test; >+import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_251544_Test; > import org.eclipse.emf.cdo.tests.config.ConfigTest; > import org.eclipse.emf.cdo.tests.config.ConfigTestSuite; > >@@ -89,6 +90,7 @@ > testClasses.add(Bugzilla_250757_Test.class); > testClasses.add(Bugzilla_251087_Test.class); > testClasses.add(Bugzilla_251263_Test.class); >+ testClasses.add(Bugzilla_251544_Test.class); > > // TODO testClasses.add(NonCDOResourceTest.class); > // TODO testClasses.add(GeneratedEcoreTest.class); >Index: src/org/eclipse/emf/cdo/tests/TransactionTest.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf.cdo/tests/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TransactionTest.java,v >retrieving revision 1.3 >diff -u -r1.3 TransactionTest.java >--- src/org/eclipse/emf/cdo/tests/TransactionTest.java 28 Sep 2008 10:46:26 -0000 1.3 >+++ src/org/eclipse/emf/cdo/tests/TransactionTest.java 21 Oct 2008 23:36:45 -0000 >@@ -63,7 +63,6 @@ > } > } > >- @SuppressWarnings("deprecation") > public void testCreateManyTransactions() throws Exception > { > msg("Opening session"); >@@ -79,7 +78,6 @@ > msg("Transaction " + i + " (" + lastDuration + ")"); > lastDuration = System.currentTimeMillis(); > transaction = session.openTransaction(); >- transaction.setUniqueResourceContents(false); > resource = transaction.getResource("/test2"); > Category category = getModel1Factory().createCategory(); > resource.getContents().add(category); >Index: src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_246456_Test.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf.cdo/tests/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_246456_Test.java,v >retrieving revision 1.3 >diff -u -r1.3 Bugzilla_246456_Test.java >--- src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_246456_Test.java 22 Sep 2008 09:20:06 -0000 1.3 >+++ src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_246456_Test.java 21 Oct 2008 23:36:45 -0000 >@@ -24,7 +24,6 @@ > */ > public class Bugzilla_246456_Test extends AbstractCDOTest > { >- @SuppressWarnings("deprecation") > public void testBugzilla_246456() throws Exception > { > msg("Opening session"); >@@ -36,7 +35,6 @@ > .setCapacityRevised(10); > ((LRURevisionCache)((TwoLevelRevisionCache)transaction.getSession().getRevisionManager().getCache()).getLevel1()) > .setCapacityCurrent(10); >- transaction.setUniqueResourceContents(false); > > msg("Creating resource"); > CDOResource resource = transaction.createResource("/test1"); >Index: src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_251544_Test.java >=================================================================== >RCS file: src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_251544_Test.java >diff -N src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_251544_Test.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_251544_Test.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,64 @@ >+package org.eclipse.emf.cdo.tests.bugzilla; >+ >+import org.eclipse.emf.cdo.CDOSession; >+import org.eclipse.emf.cdo.CDOTransaction; >+import org.eclipse.emf.cdo.eresource.CDOResource; >+import org.eclipse.emf.cdo.tests.AbstractCDOTest; >+import org.eclipse.emf.cdo.tests.model1.Order; >+import org.eclipse.emf.cdo.tests.model1.OrderDetail; >+ >+import org.eclipse.emf.common.util.EList; >+import org.eclipse.emf.ecore.EObject; >+ >+/** >+ * Resources fetched using CDOViewImpl.getResource(CDOID) not added to ResourceSet >+ * <p> >+ * See https://bugs.eclipse.org/251544 >+ * >+ * @author Simon McDuff >+ */ >+public class Bugzilla_251544_Test extends AbstractCDOTest >+{ >+ public void testFromPersistedToTransient() throws Exception >+ { >+ CDOSession session = openModel1Session(); >+ CDOTransaction transaction = session.openTransaction(); >+ CDOResource resource = transaction.createResource("/my/resource"); >+ >+ Order order1 = getModel1Factory().createOrder(); >+ OrderDetail orderDetail = getModel1Factory().createOrderDetail(); >+ EList<EObject> contentList = resource.getContents(); >+ resource.getContents().add(order1); >+ order1.getOrderDetails().add(orderDetail); >+ EList<OrderDetail> list = order1.getOrderDetails(); >+ resource.getContents().remove(0); // remove object by index >+ list.remove(orderDetail); >+ >+ transaction.commit(); >+ >+ resource.delete(null); >+ >+ assertSame(contentList, resource.getContents()); >+ } >+ >+ public void testFromTransientToPersisted() throws Exception >+ { >+ CDOSession session = openModel1Session(); >+ CDOTransaction transaction = session.openTransaction(); >+ CDOResource resource = transaction.createResource("/my/resource"); >+ >+ Order order1 = getModel1Factory().createOrder(); >+ OrderDetail orderDetail = getModel1Factory().createOrderDetail(); >+ EList<OrderDetail> orderDetails = order1.getOrderDetails(); >+ order1.getOrderDetails().add(orderDetail); >+ >+ msg("Persist the graph"); >+ resource.getContents().add(order1); >+ assertSame(orderDetails, order1.getOrderDetails()); >+ resource.getContents().remove(0); // remove object by index >+ assertSame(orderDetails, order1.getOrderDetails()); >+ assertEquals(true, orderDetails.remove(orderDetail)); >+ transaction.commit(); >+ } >+ >+} >#P org.eclipse.emf.cdo >Index: src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf.cdo/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java,v >retrieving revision 1.45 >diff -u -r1.45 CDOResourceImpl.java >--- src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java 20 Oct 2008 22:47:22 -0000 1.45 >+++ src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java 21 Oct 2008 23:36:46 -0000 >@@ -48,12 +48,10 @@ > import org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl; > import org.eclipse.emf.ecore.resource.impl.ResourceImpl; > import org.eclipse.emf.ecore.util.InternalEList; >-import org.eclipse.emf.ecore.util.NotifyingInternalEListImpl; > > import java.io.IOException; > import java.io.InputStream; > import java.io.OutputStream; >-import java.util.Collection; > import java.util.Iterator; > import java.util.Map; > >@@ -257,18 +255,12 @@ > @SuppressWarnings("unchecked") > public EList<EObject> getContents() > { >- if (FSMUtil.isTransient(this)) >- { >- EList<EObject> transientContents = (EList<EObject>)eSettings[EresourcePackage.CDO_RESOURCE__CONTENTS]; >- if (transientContents == null) >- { >- transientContents = new TransientContents<EObject>(); >- eSettings[EresourcePackage.CDO_RESOURCE__CONTENTS] = transientContents; >- // throw new ImplementationError(); >- } >- >- return transientContents; >- } >+ /* >+ * if (FSMUtil.isTransient(this)) { EList<EObject> transientContents = >+ * (EList<EObject>)eSettings[EresourcePackage.CDO_RESOURCE__CONTENTS]; if (transientContents == null) { >+ * transientContents = new TransientContents<EObject>(); eSettings[EresourcePackage.CDO_RESOURCE__CONTENTS] = >+ * transientContents; // throw new ImplementationError(); } return transientContents; } >+ */ > > return (EList<EObject>)eGet(EresourcePackage.Literals.CDO_RESOURCE__CONTENTS, true); > } >@@ -846,7 +838,7 @@ > { > if (eStructuralFeature == EresourcePackage.eINSTANCE.getCDOResource_Contents()) > { >- return new PersistentContents(eStructuralFeature); >+ return new CDOContentEList(eStructuralFeature); > } > > return super.createList(eStructuralFeature); >@@ -857,19 +849,15 @@ > * > * @ADDED > * @author Eike Stepper >+ * @since 2.0 > */ >- protected class PersistentContents extends CDOStoreEList<Object> >+ protected class CDOContentEList extends BasicEStoreEList<Object> > { > private static final long serialVersionUID = 1L; > >- @SuppressWarnings("deprecation") >- public PersistentContents(EStructuralFeature eStructuralFeature) >+ public CDOContentEList(EStructuralFeature eStructuralFeature) > { >- super(eStructuralFeature); >- if (!cdoView().hasUniqueResourceContents()) >- { >- kind &= ~IS_UNIQUE; >- } >+ super(CDOResourceImpl.this, eStructuralFeature); > } > > /** >@@ -890,15 +878,22 @@ > @Override > public NotificationChain inverseAdd(Object object, NotificationChain notifications) > { >- CDOTransactionImpl transaction = cdoView().toTransaction(); >- InternalCDOObject cdoObject = FSMUtil.adapt(object, transaction); >- notifications = cdoObject.eSetResource(CDOResourceImpl.this, notifications); >- // Attach here instead of i CDOObjectImpl.eSetResource because EMF does it also here >- if (FSMUtil.isTransient(cdoObject)) >+ if (FSMUtil.isTransient(CDOResourceImpl.this)) > { >- attached(cdoObject, transaction); >+ InternalEObject eObject = (InternalEObject)object; >+ notifications = eObject.eSetResource(CDOResourceImpl.this, notifications); >+ } >+ else >+ { >+ CDOTransactionImpl transaction = cdoView().toTransaction(); >+ InternalCDOObject cdoObject = FSMUtil.adapt(object, transaction); >+ notifications = cdoObject.eSetResource(CDOResourceImpl.this, notifications); >+ // Attach here instead of i CDOObjectImpl.eSetResource because EMF does it also here >+ if (FSMUtil.isTransient(cdoObject)) >+ { >+ attached(cdoObject, transaction); >+ } > } >- > return notifications; > } > >@@ -908,147 +903,18 @@ > @Override > public NotificationChain inverseRemove(Object object, NotificationChain notifications) > { >- InternalEObject eObject = (InternalEObject)object; >- detached(eObject); >- return eObject.eSetResource(null, notifications); >- } >- } >- >- /** >- * TODO Change superclass to NotifyingInternalEListImpl when EMF 2.3 is out of maintenance >- * <p> >- * TODO Reuse {@link ResourceImpl.ContentsEList}!!! --> Bugzilla! >- * >- * @ADDED >- * @author Eike Stepper >- */ >- protected class TransientContents<E extends Object & EObject> extends NotifyingInternalEListImpl<E> >- { >- private static final long serialVersionUID = 1L; >- >- public TransientContents() >- { >- } >- >- public TransientContents(Collection<? extends E> collection) >- { >- super(collection); >- } >- >- public TransientContents(int initialCapacity) >- { >- super(initialCapacity); >- } >- >- /** >- * Optimization taken from ResourceImpl.EContentList.contains >- * >- * @since 2.0 >- */ >- @Override >- public boolean contains(Object object) >- { >- return size <= 4 ? super.contains(object) : object instanceof InternalEObject >- && ((InternalEObject)object).eDirectResource() == CDOResourceImpl.this; >- } >- >- @Override >- public Object getNotifier() >- { >- return CDOResourceImpl.this; >- } >- >- @Override >- public int getFeatureID() >- { >- return EresourcePackage.CDO_RESOURCE__CONTENTS; >- } >- >- @Override >- protected boolean isNotificationRequired() >- { >- return eNotificationRequired(); >- } >- >- @Override >- protected boolean useEquals() >- { >- return false; >- } >- >- @Override >- protected boolean hasInverse() >- { >- return true; >- } >- >- @Override >- protected boolean isUnique() >- { >- return true; >- } >- >- /** >- * @since 2.0 >- */ >- /* >- * IMPORTANT: Compile errors in this method might indicate an old version of EMF. Legacy support is only enabled for >- * EMF with fixed bug #247130. These compile errors do not affect native models! >- */ >- public InternalEList<E> readWriteFiringList() >- { >- return this; >- } >- >- @Override >- public NotificationChain inverseAdd(E object, NotificationChain notifications) >- { >- InternalEObject eObject = (InternalEObject)object; >- notifications = eObject.eSetResource(CDOResourceImpl.this, notifications); >- // CDOResourceImpl.this.attached(eObject); >- return notifications; >- } >- >- @Override >- public NotificationChain inverseRemove(E object, NotificationChain notifications) >- { >- InternalEObject eObject = (InternalEObject)object; >- // CDOResourceImpl.this.detached(eObject); >- return eObject.eSetResource(null, notifications); >- } >- >- @Override >- protected void didAdd(int index, E object) >- { >- super.didAdd(index, object); >- modified(); >- } >- >- @Override >- protected void didRemove(int index, E object) >- { >- super.didRemove(index, object); >- modified(); >- } >- >- @Override >- protected void didSet(int index, E newObject, E oldObject) >- { >- super.didSet(index, newObject, oldObject); >- modified(); >- } >- >- @Override >- protected void didClear(int oldSize, Object[] oldData) >- { >- if (oldSize == 0) >+ if (FSMUtil.isTransient(CDOResourceImpl.this)) > { >- loaded(); >+ InternalEObject eObject = (InternalEObject)object; >+ notifications = eObject.eSetResource(null, notifications); > } > else > { >- super.didClear(oldSize, oldData); >+ InternalEObject eObject = (InternalEObject)object; >+ detached(eObject); >+ notifications = eObject.eSetResource(null, notifications); > } >+ return notifications; > } > > /** >@@ -1066,6 +932,9 @@ > } > } > >+ /** >+ * @since 2.0 >+ */ > protected void modified() > { > if (isTrackingModification()) >@@ -1073,5 +942,33 @@ > setModified(true); > } > } >+ >+ /** >+ * @since 2.0 >+ */ >+ @Override >+ protected boolean useEquals() >+ { >+ return false; >+ } >+ >+ /** >+ * @since 2.0 >+ */ >+ @Override >+ protected boolean hasInverse() >+ { >+ return true; >+ } >+ >+ /** >+ * @since 2.0 >+ */ >+ @Override >+ protected boolean isUnique() >+ { >+ return true; >+ } > } >+ > } // CDOResourceImpl >Index: src/org/eclipse/emf/cdo/CDOView.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf.cdo/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java,v >retrieving revision 1.56 >diff -u -r1.56 CDOView.java >--- src/org/eclipse/emf/cdo/CDOView.java 19 Oct 2008 08:16:19 -0000 1.56 >+++ src/org/eclipse/emf/cdo/CDOView.java 21 Oct 2008 23:36:45 -0000 >@@ -165,32 +165,6 @@ > public boolean hasConflict(); > > /** >- * @see #setUniqueResourceContents(boolean) >- * @deprecated This performance tweak is not necessary with EMF 2.5 anymore and is likely to be removed when CDO >- * reaches 2.0. In the meantime it can be safely used. >- */ >- @Deprecated >- public boolean hasUniqueResourceContents(); >- >- /** >- * Specifies whether the contents list of resources will be unique or not. >- * <p> >- * This property is transient in that it does not stick with resources outside of the scope of this view. Especially >- * it will not be persisted with resources in the repository. Each new view will start with <code>true</code> as a >- * default value. Changing to <code>false</code> will subsequently apply to all resources being loaded or created. >- * <p> >- * Notice that the resource contents is a containment list and as such <b>must be</b> unique. Setting this property to >- * <code>false</code> is only recommended for performance optimization when uniqueness is granted by other means. >- * Violating the uniqueness constraint will result in unpredictable behaviour and possible corruption of the >- * repository! >- * >- * @deprecated This performance tweak is not necessary with EMF 2.5 anymore and is likely to be removed when CDO >- * reaches 2.0. In the meantime it can be safely used. >- */ >- @Deprecated >- public void setUniqueResourceContents(boolean uniqueResourceContents); >- >- /** > * Returns <code>true</code> if the {@link CDOObject objects} in this view will notify their > * {@link org.eclipse.emf.common.notify.Adapter adapters} about the fact that they are <em>invalidated</em> (due to > * remote changes), <code>false</code> otherwise. >Index: src/org/eclipse/emf/internal/cdo/CDOViewImpl.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf.cdo/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java,v >retrieving revision 1.155 >diff -u -r1.155 CDOViewImpl.java >--- src/org/eclipse/emf/internal/cdo/CDOViewImpl.java 19 Oct 2008 13:10:31 -0000 1.155 >+++ src/org/eclipse/emf/internal/cdo/CDOViewImpl.java 21 Oct 2008 23:36:47 -0000 >@@ -100,8 +100,6 @@ > > private CDOURIHandler uriHandler = new CDOURIHandler(this); > >- private boolean uniqueResourceContents = true; >- > private boolean invalidationNotificationEnabled; > > private CDORevisionPrefetchingPolicy revisionPrefetchingPolicy; >@@ -225,18 +223,6 @@ > return false; > } > >- @Deprecated >- public boolean hasUniqueResourceContents() >- { >- return uniqueResourceContents; >- } >- >- @Deprecated >- public void setUniqueResourceContents(boolean uniqueResourceContents) >- { >- this.uniqueResourceContents = uniqueResourceContents; >- } >- > /** > * @since 2.0 > */ >Index: src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf.cdo/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java,v >retrieving revision 1.76 >diff -u -r1.76 CDOObjectImpl.java >--- src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java 19 Oct 2008 01:28:52 -0000 1.76 >+++ src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java 21 Oct 2008 23:36:46 -0000 >@@ -34,6 +34,7 @@ > 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.util.BasicEList; > import org.eclipse.emf.common.util.BasicEMap; > import org.eclipse.emf.common.util.ECollections; > import org.eclipse.emf.common.util.EList; >@@ -49,7 +50,6 @@ > import org.eclipse.emf.ecore.impl.EStoreEObjectImpl; > import org.eclipse.emf.ecore.resource.Resource; > import org.eclipse.emf.ecore.resource.Resource.Internal; >-import org.eclipse.emf.ecore.util.DelegatingEcoreEList; > import org.eclipse.emf.ecore.util.DelegatingFeatureMap; > import org.eclipse.emf.ecore.util.EcoreEList; > import org.eclipse.emf.ecore.util.EcoreEMap; >@@ -77,10 +77,19 @@ > > private InternalCDORevision revision; > >+ /** >+ * CDO used this list instead of eSettings for transient objects. EMF used eSettings as cache. CDO deactivate the >+ * cache but EMF still use eSettings to store list wrapper. CDO needs another place to store the real list with the >+ * actual data (transient mode) and accessible through EStore. This allow CDO to always use the same instance of the >+ * list wrapper. >+ */ >+ private transient Object eTransientSettings[]; >+ > public CDOObjectImpl() > { > state = CDOState.TRANSIENT; > eContainer = null; >+ eTransientSettings = null; > } > > public CDOID cdoID() >@@ -98,6 +107,27 @@ > return revision; > } > >+ /** >+ * @since 2.0 >+ */ >+ protected Object[] eTransientSettings() >+ { >+ if (eTransientSettings == null) >+ { >+ int size = eClass().getFeatureCount() - eStaticFeatureCount(); >+ eTransientSettings = size == 0 ? ENO_SETTINGS : new Object[size]; >+ } >+ return eTransientSettings; >+ } >+ >+ /** >+ * @since 2.0 >+ */ >+ protected Object[] eBasicTransientSettings() >+ { >+ return eTransientSettings; >+ } >+ > public CDOClass cdoClass() > { > return getCDOClass(this); >@@ -201,6 +231,7 @@ > > public void cdoInternalPostLoad() > { >+ // Reset EMAP objects > if (eSettings != null) > { > // Make sure transient feature are kept but persisted value are not cached. >@@ -230,20 +261,7 @@ > */ > public void cdoInternalCleanup() > { >- if (eSettings != null) >- { >- // Make sure transient feature are kept but persisted value are not cached. >- EClass eClass = eClass(); >- for (int i = 0; i < eClass.getFeatureCount(); i++) >- { >- EStructuralFeature eFeature = cdoInternalDynamicFeature(i); >- // We need to keep the existing list if possible. >- if (!eFeature.isTransient()) >- { >- eSettings[i] = null; >- } >- } >- } >+ > } > > public void cdoInternalPostAttach() >@@ -263,8 +281,6 @@ > revision.setResourceID(cdoResource.cdoID()); > } > >- eSettings(); >- > EClass eClass = eClass(); > for (int i = 0; i < eClass.getFeatureCount(); i++) > { >@@ -274,6 +290,7 @@ > populateRevisionFeature(view, revision, eFeature, eSettings, i); > } > } >+ eTransientSettings = null; > } > > @SuppressWarnings("unchecked") >@@ -287,12 +304,11 @@ > TRACER.format("Populating feature {0}", cdoFeature); > } > >- Object setting = eSettings[i]; >+ Object setting = eBasicTransientSettings() != null ? eTransientSettings()[i] : null; > if (setting == null) > { > setting = eFeature.getDefaultValue(); > } >- > if (cdoFeature.isMany()) > { > if (setting != null) >@@ -330,13 +346,11 @@ > > revision.set(cdoFeature, 0, setting); > } >- >- if (eSettings != null) >- { >- eSettings[i] = null; >- } > } > >+ /** >+ * It is really important to access the data to go through getStore. eStore will redirect you to the transient data. >+ */ > public void cdoInternalPostDetach() > { > if (TRACER.isEnabled()) >@@ -346,7 +360,7 @@ > > CDOViewImpl view = cdoView(); > super.eSetDirectResource(cdoDirectResource()); >- eContainer = eStore().getContainer(this); >+ eContainer = getStore().getContainer(this); > eContainerFeatureID = getStore().getContainingFeatureID(this); > if (eContainer != null && eContainmentFeature().isResolveProxies()) > { >@@ -354,7 +368,8 @@ > } > > // Ensure that the internal eSettings array is initialized; >- eSettings(); >+ eTransientSettings = null; >+ eTransientSettings(); > > EClass eClass = eClass(); > for (int i = 0; i < eClass.getFeatureCount(); i++) >@@ -367,7 +382,6 @@ > } > } > >- @SuppressWarnings("unchecked") > private void depopulateRevisionFeature(CDOViewImpl view, InternalCDORevision revision, EStructuralFeature eFeature, > Object[] eSettings, int i) > { >@@ -379,17 +393,18 @@ > EStructuralFeature.Internal internalFeature = (EStructuralFeature.Internal)eFeature; > EReference oppositeReference = cdoID().isTemporary() ? null : internalFeature.getEOpposite(); > >+ CDOStore cdoStore = getStore(); >+ EStore transientStore = eStore(); > if (eFeature.isMany()) > { >- eSettings[i] = null; >- InternalEList<Object> setting = (InternalEList<Object>)eGet(eFeature, true); >- int size = eStore().size(this, eFeature); >+ >+ int size = cdoStore.size(this, eFeature); > for (int index = 0; index < size; index++) > { > // Do not trigger events > // Do not trigger inverse updates >- Object object = eStore().get(this, eFeature, index); >- setting.basicAdd(object, null); >+ Object object = cdoStore.get(this, eFeature, index); >+ transientStore.add(this, eFeature, index, object); > if (oppositeReference != null) > { > adjustOppositeReference((InternalEObject)object, oppositeReference); >@@ -398,10 +413,11 @@ > } > else > { >- eSettings[i] = eStore().get(this, eFeature, 0); >+ Object object = cdoStore.get(this, eFeature, EStore.NO_INDEX); >+ transientStore.set(this, eFeature, EStore.NO_INDEX, object); > if (oppositeReference != null) > { >- adjustOppositeReference((InternalEObject)eSettings[i], oppositeReference); >+ adjustOppositeReference((InternalEObject)object, oppositeReference); > } > } > } >@@ -534,7 +550,7 @@ > public EStoreEcoreEMap() > { > super((EClass)eType, eType.getInstanceClass(), null); >- delegateEList = new CDOStoreEList<BasicEMap.Entry<Object, Object>>(eStructuralFeature) >+ delegateEList = new BasicEStoreEList<BasicEMap.Entry<Object, Object>>(CDOObjectImpl.this, eStructuralFeature) > { > private static final long serialVersionUID = 1L; > >@@ -576,7 +592,10 @@ > > private void checkListForReading() > { >- CDOStateMachine.INSTANCE.read(CDOObjectImpl.this); >+ if (!FSMUtil.isTransient(CDOObjectImpl.this)) >+ { >+ CDOStateMachine.INSTANCE.read(CDOObjectImpl.this); >+ } > } > > /** >@@ -641,7 +660,7 @@ > return new EStoreEcoreEMap(); > } > >- return new CDOStoreEList<Object>(eStructuralFeature); >+ return super.createList(eStructuralFeature); > } > > @Override >@@ -682,79 +701,25 @@ > } > > /** >- * Don't cache non-transient features in this CDOObject's {@link #eSettings()}. >+ * @since 2.0 > */ > @Override >- protected boolean eIsCaching() >- { >- return false; >- } >- >- @Override >- public Object dynamicGet(int dynamicFeatureID) >+ public InternalEObject.EStore eStore() > { > if (FSMUtil.isTransient(this)) > { >- if (eSettings == null) >- { >- return null; >- } >- >- return eSettings[dynamicFeatureID]; >- } >- >- // Delegate to CDOStore >- return super.dynamicGet(dynamicFeatureID); >- } >- >- @Override >- public boolean eIsSet(EStructuralFeature feature) >- { >- if (FSMUtil.isTransient(this)) >- { >- // TODO What about defaultValues != null? >- if (eSettings == null) >- { >- return false; >- } >- >- return eSettings[eDynamicFeatureID(feature)] != null; >- } >- >- // Delegate to CDOStore >- return super.eIsSet(feature); >- } >- >- @Override >- public void dynamicSet(int dynamicFeatureID, Object value) >- { >- if (FSMUtil.isTransient(this)) >- { >- eSettings(); // Important to create eSettings array if necessary >- eSettings[dynamicFeatureID] = value; >- } >- else >- { >- // Delegate to CDOStore >- super.dynamicSet(dynamicFeatureID, value); >+ return CDOStoreSettingsImpl.TRANSIENT_STORE; > } >+ return getStore(); > } > >+ /** >+ * Don't cache non-transient features in this CDOObject's {@link #eSettings()}. >+ */ > @Override >- public void dynamicUnset(int dynamicFeatureID) >+ protected boolean eIsCaching() > { >- if (FSMUtil.isTransient(this)) >- { >- if (eSettings != null) >- { >- eSettings[dynamicFeatureID] = null; >- } >- } >- else >- { >- // Delegate to CDOStore >- super.dynamicUnset(dynamicFeatureID); >- } >+ return false; > } > > @Override >@@ -993,214 +958,178 @@ > > private CDOStore getStore() > { >- return (CDOStore)eStore(); >+ return cdoView().getStore(); > } > > /** >- * TODO Remove this when EMF has fixed http://bugs.eclipse.org/197487 >- * >- * @author Eike Stepper >+ * @since 2.0 > */ >- public class CDOStoreEList<E> extends DelegatingEcoreEList.Dynamic<E> >+ public static class CDOStoreSettingsImpl implements InternalEObject.EStore > { >- private static final long serialVersionUID = 1L; >+ protected static CDOStoreSettingsImpl TRANSIENT_STORE = new CDOStoreSettingsImpl(); > >- public CDOStoreEList(EStructuralFeature eStructuralFeature) >+ protected Object getValue(InternalEObject eObject, int dynamicFeatureID) > { >- super(CDOObjectImpl.this, eStructuralFeature); >- } >+ return ((CDOObjectImpl)eObject).eTransientSettings()[dynamicFeatureID]; > >- @Override >- protected List<E> delegateList() >- { >- throw new UnsupportedOperationException(); > } > >- @Override >- public EStructuralFeature getEStructuralFeature() >+ protected EList<Object> getValueAsList(InternalEObject eObject, int dynamicFeatureID) > { >- return eStructuralFeature; >+ @SuppressWarnings("unchecked") >+ EList<Object> result = (EList<Object>)getValue(eObject, dynamicFeatureID); >+ if (result == null) >+ { >+ result = new BasicEList<Object>(); >+ ((CDOObjectImpl)eObject).eTransientSettings()[dynamicFeatureID] = result; >+ } >+ return result; > } > >- @Override >- protected void delegateAdd(int index, Object object) >+ protected Object setValue(InternalEObject eObject, int dynamicFeatureID, Object newValue) > { >- getStore().add(owner, eStructuralFeature, index, object); >+ Object eSettings[] = ((CDOObjectImpl)eObject).eTransientSettings(); >+ try >+ { >+ return eSettings[dynamicFeatureID]; >+ } >+ finally >+ { >+ eSettings[dynamicFeatureID] = newValue; >+ } > } > >- @Override >- protected void delegateAdd(Object object) >+ protected int eDynamicFeatureID(InternalEObject eObject, EStructuralFeature feature) > { >- delegateAdd(delegateSize(), object); >+ return ((CDOObjectImpl)eObject).eDynamicFeatureID(feature); > } > >- @Override >- protected List<E> delegateBasicList() >+ public Object get(InternalEObject eObject, EStructuralFeature feature, int index) > { >- int size = delegateSize(); >- if (size == 0) >+ int dynamicFeatureID = eDynamicFeatureID(eObject, feature); >+ if (feature.isMany()) > { >- return ECollections.emptyEList(); >+ return getValueAsList(eObject, dynamicFeatureID).get(index); > } >- >- Object[] data = getStore().toArray(owner, eStructuralFeature); >- return new EcoreEList.UnmodifiableEList<E>(owner, eStructuralFeature, data.length, data); >+ return getValue(eObject, dynamicFeatureID); > } > >- @Override >- protected void delegateClear() >+ public Object set(InternalEObject eObject, EStructuralFeature feature, int index, Object value) > { >- getStore().clear(owner, eStructuralFeature); >+ int dynamicFeatureID = eDynamicFeatureID(eObject, feature); >+ if (feature.isMany()) >+ { >+ return getValueAsList(eObject, dynamicFeatureID).set(index, value); >+ } >+ return setValue(eObject, dynamicFeatureID, value); > } > >- @Override >- protected boolean delegateContains(Object object) >+ public void add(InternalEObject eObject, EStructuralFeature feature, int index, Object value) > { >- return getStore().contains(owner, eStructuralFeature, object); >+ int dynamicFeatureID = eDynamicFeatureID(eObject, feature); >+ getValueAsList(eObject, dynamicFeatureID).add(index, value); > } > >- @Override >- protected boolean delegateContainsAll(Collection<?> collection) >+ public Object remove(InternalEObject eObject, EStructuralFeature feature, int index) > { >- for (Object o : collection) >- { >- if (!delegateContains(o)) >- { >- return false; >- } >- } >- return true; >+ int dynamicFeatureID = eDynamicFeatureID(eObject, feature); >+ return getValueAsList(eObject, dynamicFeatureID).remove(index); > } > >- @SuppressWarnings("unchecked") >- @Override >- protected E delegateGet(int index) >+ public Object move(InternalEObject eObject, EStructuralFeature feature, int targetIndex, int sourceIndex) > { >- return (E)getStore().get(owner, eStructuralFeature, index); >+ int dynamicFeatureID = eDynamicFeatureID(eObject, feature); >+ return getValueAsList(eObject, dynamicFeatureID).move(targetIndex, sourceIndex); > } > >- @Override >- protected int delegateHashCode() >+ public void clear(InternalEObject eObject, EStructuralFeature feature) > { >- return getStore().hashCode(owner, eStructuralFeature); >+ int dynamicFeatureID = eDynamicFeatureID(eObject, feature); >+ if (feature.isMany()) >+ { >+ getValueAsList(eObject, dynamicFeatureID).clear(); >+ } >+ setValue(eObject, dynamicFeatureID, null); > } > >- @Override >- protected int delegateIndexOf(Object object) >+ public int size(InternalEObject eObject, EStructuralFeature feature) > { >- return getStore().indexOf(owner, eStructuralFeature, object); >+ int dynamicFeatureID = eDynamicFeatureID(eObject, feature); >+ return getValueAsList(eObject, dynamicFeatureID).size(); > } > >- @Override >- protected boolean delegateIsEmpty() >+ public int indexOf(InternalEObject eObject, EStructuralFeature feature, Object value) > { >- return getStore().isEmpty(owner, eStructuralFeature); >+ int dynamicFeatureID = eDynamicFeatureID(eObject, feature); >+ return getValueAsList(eObject, dynamicFeatureID).indexOf(value); > } > >- @Override >- protected Iterator<E> delegateIterator() >+ public int lastIndexOf(InternalEObject eObject, EStructuralFeature feature, Object value) > { >- return iterator(); >+ int dynamicFeatureID = eDynamicFeatureID(eObject, feature); >+ return getValueAsList(eObject, dynamicFeatureID).lastIndexOf(value); > } > >- @Override >- protected int delegateLastIndexOf(Object object) >+ public Object[] toArray(InternalEObject eObject, EStructuralFeature feature) > { >- return getStore().lastIndexOf(owner, eStructuralFeature, object); >+ int dynamicFeatureID = eDynamicFeatureID(eObject, feature); >+ return getValueAsList(eObject, dynamicFeatureID).toArray(); > } > >- @Override >- protected ListIterator<E> delegateListIterator() >+ public <T> T[] toArray(InternalEObject eObject, EStructuralFeature feature, T[] array) > { >- return listIterator(); >+ int dynamicFeatureID = eDynamicFeatureID(eObject, feature); >+ return getValueAsList(eObject, dynamicFeatureID).toArray(array); > } > >- @SuppressWarnings("unchecked") >- @Override >- protected E delegateRemove(int index) >+ public boolean isEmpty(InternalEObject eObject, EStructuralFeature feature) > { >- return (E)getStore().remove(owner, eStructuralFeature, index); >+ int dynamicFeatureID = eDynamicFeatureID(eObject, feature); >+ return getValueAsList(eObject, dynamicFeatureID).isEmpty(); > } > >- @SuppressWarnings("unchecked") >- @Override >- protected E delegateSet(int index, E object) >+ public boolean contains(InternalEObject eObject, EStructuralFeature feature, Object value) > { >- return (E)getStore().set(owner, eStructuralFeature, index, object); >+ int dynamicFeatureID = eDynamicFeatureID(eObject, feature); >+ return getValueAsList(eObject, dynamicFeatureID).contains(value); > } > >- @Override >- protected int delegateSize() >+ public int hashCode(InternalEObject eObject, EStructuralFeature feature) > { >- return getStore().size(owner, eStructuralFeature); >+ int dynamicFeatureID = eDynamicFeatureID(eObject, feature); >+ return getValueAsList(eObject, dynamicFeatureID).hashCode(); > } > >- @Override >- protected Object[] delegateToArray() >+ public InternalEObject getContainer(InternalEObject eObject) > { >- return getStore().toArray(owner, eStructuralFeature); >+ return null; > } > >- @Override >- protected <T> T[] delegateToArray(T[] array) >+ public EStructuralFeature getContainingFeature(InternalEObject eObject) > { >- return getStore().toArray(owner, eStructuralFeature, array); >+ // This should never be called. >+ // >+ throw new UnsupportedOperationException(); >+ // Entry entry = new Entry(eObject, CONTAINING_FEATURE); >+ // return (EStructuralFeature)map.get(entry); > } > >- @SuppressWarnings("unchecked") >- @Override >- protected E delegateMove(int targetIndex, int sourceIndex) >+ public EObject create(EClass eClass) > { >- return (E)getStore().move(owner, eStructuralFeature, targetIndex, sourceIndex); >+ InternalEObject result = new EStoreEObjectImpl(eClass, this); >+ return result; > } > >- @Override >- protected boolean delegateEquals(Object object) >+ public boolean isSet(InternalEObject eObject, EStructuralFeature feature) > { >- if (object == this) >- { >- return true; >- } >- >- if (!(object instanceof List)) >- { >- return false; >- } >- >- List<?> list = (List<?>)object; >- if (list.size() != delegateSize()) >- { >- return false; >- } >- >- for (ListIterator<?> i = list.listIterator(); i.hasNext();) >- { >- Object element = i.next(); >- if (element == null ? get(i.previousIndex()) != null : !element.equals(get(i.previousIndex()))) >- { >- return false; >- } >- } >- >- return true; >+ int dynamicFeatureID = eDynamicFeatureID(eObject, feature); >+ return getValue(eObject, dynamicFeatureID) != null; > } > >- @Override >- protected String delegateToString() >+ public void unset(InternalEObject eObject, EStructuralFeature feature) > { >- StringBuffer stringBuffer = new StringBuffer(); >- stringBuffer.append("["); >- for (int i = 0, size = size(); i < size;) >- { >- Object value = delegateGet(i); >- stringBuffer.append(String.valueOf(value)); >- if (++i < size) >- { >- stringBuffer.append(", "); >- } >- } >- stringBuffer.append("]"); >- return stringBuffer.toString(); >+ int dynamicFeatureID = eDynamicFeatureID(eObject, feature); >+ setValue(eObject, dynamicFeatureID, null); > } > } > >@@ -1233,7 +1162,7 @@ > @Override > protected void delegateAdd(int index, Entry object) > { >- getStore().add(owner, eStructuralFeature, index, object); >+ eStore().add(owner, eStructuralFeature, index, object); > } > > @Override >@@ -1258,13 +1187,13 @@ > @Override > protected void delegateClear() > { >- getStore().clear(owner, eStructuralFeature); >+ eStore().clear(owner, eStructuralFeature); > } > > @Override > protected boolean delegateContains(Object object) > { >- return getStore().contains(owner, eStructuralFeature, object); >+ return eStore().contains(owner, eStructuralFeature, object); > } > > @Override >@@ -1283,25 +1212,25 @@ > @Override > protected Entry delegateGet(int index) > { >- return (Entry)getStore().get(owner, eStructuralFeature, index); >+ return (Entry)eStore().get(owner, eStructuralFeature, index); > } > > @Override > protected int delegateHashCode() > { >- return getStore().hashCode(owner, eStructuralFeature); >+ return eStore().hashCode(owner, eStructuralFeature); > } > > @Override > protected int delegateIndexOf(Object object) > { >- return getStore().indexOf(owner, eStructuralFeature, object); >+ return eStore().indexOf(owner, eStructuralFeature, object); > } > > @Override > protected boolean delegateIsEmpty() > { >- return getStore().isEmpty(owner, eStructuralFeature); >+ return eStore().isEmpty(owner, eStructuralFeature); > } > > @Override >@@ -1313,7 +1242,7 @@ > @Override > protected int delegateLastIndexOf(Object object) > { >- return getStore().lastIndexOf(owner, eStructuralFeature, object); >+ return eStore().lastIndexOf(owner, eStructuralFeature, object); > } > > @Override >@@ -1325,37 +1254,37 @@ > @Override > protected Entry delegateRemove(int index) > { >- return (Entry)getStore().remove(owner, eStructuralFeature, index); >+ return (Entry)eStore().remove(owner, eStructuralFeature, index); > } > > @Override > protected Entry delegateSet(int index, Entry object) > { >- return (Entry)getStore().set(owner, eStructuralFeature, index, object); >+ return (Entry)eStore().set(owner, eStructuralFeature, index, object); > } > > @Override > protected int delegateSize() > { >- return getStore().size(owner, eStructuralFeature); >+ return eStore().size(owner, eStructuralFeature); > } > > @Override > protected Object[] delegateToArray() > { >- return getStore().toArray(owner, eStructuralFeature); >+ return eStore().toArray(owner, eStructuralFeature); > } > > @Override > protected <T> T[] delegateToArray(T[] array) > { >- return getStore().toArray(owner, eStructuralFeature, array); >+ return eStore().toArray(owner, eStructuralFeature, array); > } > > @Override > protected Entry delegateMove(int targetIndex, int sourceIndex) > { >- return (Entry)getStore().move(owner, eStructuralFeature, targetIndex, sourceIndex); >+ return (Entry)eStore().move(owner, eStructuralFeature, targetIndex, sourceIndex); > } > > @Override
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 251544
:
115764
|
115825
|
115828
|
116162