summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaspar De Groot2011-04-05 01:05:21 (EDT)
committerCaspar De Groot2011-04-05 01:05:21 (EDT)
commitdbe376d135ed5ef29638902af0c75760f15b1fd8 (patch)
tree5120ea40469c793b67f04dac0a182e6feae3444e
parent5a0323152b0dc43c6028fdbb0d5a9911d477cefb (diff)
downloadcdo-dbe376d135ed5ef29638902af0c75760f15b1fd8.zip
cdo-dbe376d135ed5ef29638902af0c75760f15b1fd8.tar.gz
cdo-dbe376d135ed5ef29638902af0c75760f15b1fd8.tar.bz2
[Bug 337587] Illegal deltas are produced on compare
https://bugs.eclipse.org/bugs/show_bug.cgi?id=337587
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDOElementProxy.java (renamed from plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOElementProxy.java)14
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOElementProxyImpl.java (renamed from plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/revision/CDOElementProxyImpl.java)14
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOListWithElementProxiesImpl.java (renamed from plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/revision/CDOListWithElementProxiesImpl.java)5
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORevisionDeltaImpl.java20
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientIndication.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientRequest.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientRequestWithMonitoring.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ServerCDOView.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ViewTest.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_337587_Test.java92
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/AbstractCDORevisionCacheTest.java3
-rw-r--r--plugins/org.eclipse.emf.cdo/META-INF/MANIFEST.MF6
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDOCollectionLoadingPolicy.java40
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyWrapper.java5
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOCollectionLoadingPolicyImpl.java21
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java33
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java25
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStoreImpl.java6
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOSession.java5
20 files changed, 223 insertions, 83 deletions
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOElementProxy.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDOElementProxy.java
index 1d6ce53..0068576 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOElementProxy.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDOElementProxy.java
@@ -9,24 +9,14 @@
* Eike Stepper - initial API and implementation
* Simon McDuff - maintenance
*/
-package org.eclipse.emf.spi.cdo;
-
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.session.CDOSession;
-
-import org.eclipse.emf.ecore.EStructuralFeature;
+package org.eclipse.emf.cdo.common.revision;
/**
* @author Eike Stepper
* @noimplement This interface is not intended to be implemented by clients.
- * @since 2.0
+ * @since 4.0
*/
public interface CDOElementProxy
{
public int getIndex();
-
- /**
- * @since 3.0
- */
- public Object resolve(CDOSession session, CDORevision revision, EStructuralFeature feature, int index);
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/revision/CDOElementProxyImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOElementProxyImpl.java
index 9a927b3..74a1b84 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/revision/CDOElementProxyImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOElementProxyImpl.java
@@ -9,14 +9,9 @@
* Eike Stepper - initial API and implementation
* Simon McDuff - maintenance
*/
-package org.eclipse.emf.internal.cdo.revision;
+package org.eclipse.emf.cdo.internal.common.revision;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.session.CDOSession;
-
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.spi.cdo.CDOElementProxy;
-import org.eclipse.emf.spi.cdo.InternalCDOSession;
+import org.eclipse.emf.cdo.common.revision.CDOElementProxy;
import java.text.MessageFormat;
@@ -42,11 +37,6 @@ public final class CDOElementProxyImpl implements CDOElementProxy
this.index = index;
}
- public Object resolve(CDOSession session, CDORevision revision, EStructuralFeature feature, int index)
- {
- return ((InternalCDOSession)session).resolveElementProxy(revision, feature, index, getIndex());
- }
-
@Override
public String toString()
{
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/revision/CDOListWithElementProxiesImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOListWithElementProxiesImpl.java
index aad1c0d..dc7a1bb 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/revision/CDOListWithElementProxiesImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOListWithElementProxiesImpl.java
@@ -9,17 +9,16 @@
* Simon McDuff - initial API and implementation
* Eike Stepper - maintenance
*/
-package org.eclipse.emf.internal.cdo.revision;
+package org.eclipse.emf.cdo.internal.common.revision;
import org.eclipse.emf.cdo.common.model.CDOModelUtil;
import org.eclipse.emf.cdo.common.model.CDOType;
+import org.eclipse.emf.cdo.common.revision.CDOElementProxy;
import org.eclipse.emf.cdo.common.revision.CDOList;
import org.eclipse.emf.cdo.common.revision.CDOListFactory;
-import org.eclipse.emf.cdo.internal.common.revision.CDOListImpl;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDOList;
import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.spi.cdo.CDOElementProxy;
/**
* @author Simon McDuff
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 e7c9f61..f03e941 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
@@ -17,6 +17,7 @@ import org.eclipse.emf.cdo.common.id.CDOID;
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;
import org.eclipse.emf.cdo.common.revision.CDOList;
import org.eclipse.emf.cdo.common.revision.CDOReferenceAdjuster;
import org.eclipse.emf.cdo.common.revision.CDORevisable;
@@ -314,6 +315,14 @@ public class CDORevisionDeltaImpl implements InternalCDORevisionDelta
ListDifferenceAnalyzer analyzer = new ListDifferenceAnalyzer()
{
@Override
+ public void analyzeLists(EList<Object> oldList, EList<?> newList, EList<ListChange> listChanges)
+ {
+ checkNoProxies(oldList);
+ checkNoProxies(newList);
+ super.analyzeLists(oldList, newList, listChanges);
+ }
+
+ @Override
protected void createAddListChange(EList<Object> oldList, EList<ListChange> listChanges, Object value,
int index)
{
@@ -343,6 +352,17 @@ public class CDORevisionDeltaImpl implements InternalCDORevisionDelta
changes.add(delta);
oldList.move(toIndex, index);
}
+
+ private void checkNoProxies(EList<?> list)
+ {
+ for (Object element : list)
+ {
+ if (element instanceof CDOElementProxy)
+ {
+ throw new IllegalStateException("List contains proxy elements");
+ }
+ }
+ }
};
CDOList originList = ((InternalCDORevision)originRevision).getList(feature);
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientIndication.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientIndication.java
index 3529e50..4d95448 100644
--- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientIndication.java
+++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientIndication.java
@@ -19,8 +19,7 @@ import org.eclipse.emf.cdo.common.protocol.CDODataInput;
import org.eclipse.emf.cdo.common.revision.CDOListFactory;
import org.eclipse.emf.cdo.common.revision.CDORevisionFactory;
import org.eclipse.emf.cdo.internal.common.protocol.CDODataInputImpl;
-
-import org.eclipse.emf.internal.cdo.revision.CDOListWithElementProxiesImpl;
+import org.eclipse.emf.cdo.internal.common.revision.CDOListWithElementProxiesImpl;
import org.eclipse.net4j.signal.Indication;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientRequest.java
index bf89c59..b071a30 100644
--- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientRequest.java
+++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientRequest.java
@@ -22,8 +22,7 @@ import org.eclipse.emf.cdo.common.revision.CDOListFactory;
import org.eclipse.emf.cdo.common.revision.CDORevisionFactory;
import org.eclipse.emf.cdo.internal.common.protocol.CDODataInputImpl;
import org.eclipse.emf.cdo.internal.common.protocol.CDODataOutputImpl;
-
-import org.eclipse.emf.internal.cdo.revision.CDOListWithElementProxiesImpl;
+import org.eclipse.emf.cdo.internal.common.revision.CDOListWithElementProxiesImpl;
import org.eclipse.net4j.signal.RequestWithConfirmation;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientRequestWithMonitoring.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientRequestWithMonitoring.java
index 2a3d690..80249bf 100644
--- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientRequestWithMonitoring.java
+++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientRequestWithMonitoring.java
@@ -25,8 +25,7 @@ import org.eclipse.emf.cdo.common.revision.CDOListFactory;
import org.eclipse.emf.cdo.common.revision.CDORevisionFactory;
import org.eclipse.emf.cdo.internal.common.protocol.CDODataInputImpl;
import org.eclipse.emf.cdo.internal.common.protocol.CDODataOutputImpl;
-
-import org.eclipse.emf.internal.cdo.revision.CDOListWithElementProxiesImpl;
+import org.eclipse.emf.cdo.internal.common.revision.CDOListWithElementProxiesImpl;
import org.eclipse.net4j.signal.RequestWithMonitoring;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ServerCDOView.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ServerCDOView.java
index d0b5b27..b7c0e77 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ServerCDOView.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ServerCDOView.java
@@ -708,6 +708,11 @@ public class ServerCDOView extends AbstractCDOView implements org.eclipse.emf.cd
throw new UnsupportedOperationException();
}
+ public void resolveAllElementProxies(CDORevision revision)
+ {
+ throw new UnsupportedOperationException();
+ }
+
public void processRefreshSessionResult(RefreshSessionResult result, CDOBranch branch,
List<InternalCDOView> branchViews, Map<CDOBranch, Map<CDOID, InternalCDORevision>> viewedRevisions)
{
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java
index 9e0e5a8..a77ed7b 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java
@@ -211,6 +211,7 @@ public abstract class AllConfigs extends ConfigTestSuite
testClasses.add(Bugzilla_336382_Test.class);
testClasses.add(Bugzilla_336590_Test.class);
testClasses.add(Bugzilla_337523_Test.class);
+ testClasses.add(Bugzilla_337587_Test.class);
testClasses.add(Bugzilla_338884_Test.class);
testClasses.add(Bugzilla_338779_Test.class);
testClasses.add(Bugzilla_339461_Test.class);
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ViewTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ViewTest.java
index ac98ab7..6d1d855 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ViewTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ViewTest.java
@@ -10,6 +10,7 @@
*/
package org.eclipse.emf.cdo.tests;
+import org.eclipse.emf.cdo.common.revision.CDOElementProxy;
import org.eclipse.emf.cdo.common.revision.CDORevisionData;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.eresource.EresourcePackage;
@@ -29,7 +30,6 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.spi.cdo.CDOElementProxy;
/**
* @author Eike Stepper
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_337587_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_337587_Test.java
new file mode 100644
index 0000000..1ee0c0d
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_337587_Test.java
@@ -0,0 +1,92 @@
+/**
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * 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
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.delta.CDOListFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.model1.Customer;
+import org.eclipse.emf.cdo.tests.model1.SalesOrder;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.net4j.util.io.IOUtil;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
+
+/**
+ * @author Egidijus Vaisnora
+ */
+public class Bugzilla_337587_Test extends AbstractCDOTest
+{
+
+ public void testRevisionCompare() throws CommitException
+ {
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource("test1");
+
+ Customer customer = getModel1Factory().createCustomer();
+ customer.setName("customer");
+ resource.getContents().add(customer);
+
+ for (int i = 0; i < 10; i++)
+ {
+ SalesOrder salesOrder = getModel1Factory().createSalesOrder();
+ salesOrder.setId(i);
+ salesOrder.setCustomer(customer);
+ resource.getContents().add(salesOrder);
+ }
+
+ transaction.commit();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ // ************************************************************* //
+
+ CDOSession session = openSession();
+ session.options().setCollectionLoadingPolicy(CDOUtil.createCollectionLoadingPolicy(1, 2));
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource("test1");
+
+ Customer customer = (Customer)resource.getContents().get(0);
+ EList<SalesOrder> salesOrders = customer.getSalesOrders();
+ SalesOrder salesOrder = getModel1Factory().createSalesOrder();
+ resource.getContents().add(salesOrder);
+ salesOrders.set(5, salesOrder);
+
+ CDOObject cdoResource = CDOUtil.getCDOObject(resource);
+ CDORevision rev = cdoResource.cdoRevision();
+ IOUtil.OUT().println(rev);
+
+ for (EObject e : resource.getContents())
+ {
+ IOUtil.OUT().println(e);
+ }
+
+ InternalCDORevision cleanRevision = ((InternalCDOTransaction)transaction).getCleanRevisions().get(cdoResource);
+ CDORevisionDelta diff = cdoResource.cdoRevision().compare(cleanRevision);
+ assertEquals(1, ((CDOListFeatureDelta)diff.getFeatureDeltas().get(0)).getListChanges().size());
+
+ transaction.commit();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/AbstractCDORevisionCacheTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/AbstractCDORevisionCacheTest.java
index f434641..81fecc7 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/AbstractCDORevisionCacheTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/revisioncache/AbstractCDORevisionCacheTest.java
@@ -143,8 +143,7 @@ public abstract class AbstractCDORevisionCacheTest extends AbstractOMTest
// fetch older version and check version and ID equality
CDOID id = company.cdoID();
- CDORevision fetchedRevision = revisionCache.getRevisionByVersion(id,
- BRANCH.getVersion(firstRevision.getVersion()));
+ CDORevision fetchedRevision = revisionCache.getRevisionByVersion(id, BRANCH.getVersion(firstRevision.getVersion()));
assertNotNull(fetchedRevision);
assertEquals(true, firstRevision.getID().equals(fetchedRevision.getID()));
assertEquals(true, firstRevision.getVersion() == fetchedRevision.getVersion());
diff --git a/plugins/org.eclipse.emf.cdo/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo/META-INF/MANIFEST.MF
index 2d6dc74..c4b5051 100644
--- a/plugins/org.eclipse.emf.cdo/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo/META-INF/MANIFEST.MF
@@ -49,12 +49,6 @@ Export-Package: org.eclipse.emf.cdo;version="4.0.0",
org.eclipse.emf.cdo.defs,
org.eclipse.emf.cdo.ui,
org.eclipse.emf.cdo.tests.objectivity",
- org.eclipse.emf.internal.cdo.revision;version="4.0.0";
- x-friends:="org.eclipse.emf.cdo.net4j,
- org.eclipse.emf.cdo.server,
- org.eclipse.emf.cdo.tests,
- org.eclipse.emf.cdo.defs,
- org.eclipse.emf.cdo.ui",
org.eclipse.emf.internal.cdo.session;version="4.0.0";
x-friends:="org.eclipse.emf.cdo.net4j,
org.eclipse.emf.cdo.server,
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDOCollectionLoadingPolicy.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDOCollectionLoadingPolicy.java
index 6fd347e..b6bd0c0 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDOCollectionLoadingPolicy.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDOCollectionLoadingPolicy.java
@@ -12,13 +12,12 @@
package org.eclipse.emf.cdo.session;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.revision.CDOElementProxy;
import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+
+import org.eclipse.emf.internal.cdo.session.CDOCollectionLoadingPolicyImpl;
import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.spi.cdo.CDOElementProxy;
-import org.eclipse.emf.spi.cdo.CDOSessionProtocol;
-import org.eclipse.emf.spi.cdo.InternalCDOSession;
/**
* A strategy that specifies which list elememts must be present (loaded) in a {@link CDOID} list of a
@@ -34,32 +33,8 @@ public interface CDOCollectionLoadingPolicy
* A default collection loading strategy that leads to complete loading of {@link CDOID} lists <b>before</b> any of
* their elements is accessed.
*/
- public static final CDOCollectionLoadingPolicy DEFAULT = new CDOCollectionLoadingPolicy()
- {
- /**
- * Returns {@link CDORevision#UNCHUNKED}.
- */
- public int getInitialChunkSize()
- {
- return CDORevision.UNCHUNKED;
- }
-
- /**
- * Returns {@link CDORevision#UNCHUNKED}.
- */
- public int getResolveChunkSize()
- {
- return CDORevision.UNCHUNKED;
- }
-
- public Object resolveProxy(CDOSession session, CDORevision revision, EStructuralFeature feature, int accessIndex,
- int serverIndex)
- {
- CDOSessionProtocol protocol = ((InternalCDOSession)session).getSessionProtocol();
- return protocol.loadChunk((InternalCDORevision)revision, feature, accessIndex, serverIndex, accessIndex,
- accessIndex);
- }
- };
+ public static final CDOCollectionLoadingPolicy DEFAULT = new CDOCollectionLoadingPolicyImpl(CDORevision.UNCHUNKED,
+ CDORevision.UNCHUNKED);
/**
* Returns the maximum number of CDOIDs to be loaded for collections when the owning object is loaded initially, i.e.
@@ -83,4 +58,9 @@ public interface CDOCollectionLoadingPolicy
*/
public Object resolveProxy(CDOSession session, CDORevision revision, EStructuralFeature feature, int accessIndex,
int serverIndex);
+
+ /**
+ * @since 4.0
+ */
+ public void resolveAllProxies(CDOSession session, CDORevision revision, EStructuralFeature feature);
}
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 4b44ac2..663f356 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
@@ -19,6 +19,7 @@ import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
import org.eclipse.emf.cdo.common.model.CDOType;
import org.eclipse.emf.cdo.common.model.EMFUtil;
import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
+import org.eclipse.emf.cdo.common.revision.CDOElementProxy;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.CDORevisionData;
import org.eclipse.emf.cdo.common.util.CDOException;
@@ -48,7 +49,6 @@ import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.util.InternalEList;
-import org.eclipse.emf.spi.cdo.CDOElementProxy;
import org.eclipse.emf.spi.cdo.CDOStore;
import org.eclipse.emf.spi.cdo.FSMUtil;
import org.eclipse.emf.spi.cdo.InternalCDOObject;
@@ -597,7 +597,8 @@ public abstract class CDOLegacyWrapper extends CDOObjectWrapper
if (object instanceof CDOElementProxy)
{
// Resolve proxy
- object = ((CDOElementProxy)object).resolve(view.getSession(), revision, feature, index);
+ CDOElementProxy proxy = (CDOElementProxy)object;
+ object = view.getSession().resolveElementProxy(revision, feature, index, proxy.getIndex());
}
if (object instanceof CDOLegacyWrapper)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOCollectionLoadingPolicyImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOCollectionLoadingPolicyImpl.java
index 2fd2350..c383b33 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOCollectionLoadingPolicyImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOCollectionLoadingPolicyImpl.java
@@ -11,6 +11,7 @@
*/
package org.eclipse.emf.internal.cdo.session;
+import org.eclipse.emf.cdo.common.revision.CDOElementProxy;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.session.CDOCollectionLoadingPolicy;
import org.eclipse.emf.cdo.session.CDOSession;
@@ -19,7 +20,6 @@ import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.net4j.util.collection.MoveableList;
import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.spi.cdo.CDOElementProxy;
import org.eclipse.emf.spi.cdo.CDOSessionProtocol;
import org.eclipse.emf.spi.cdo.InternalCDOSession;
@@ -49,13 +49,14 @@ public class CDOCollectionLoadingPolicyImpl implements CDOCollectionLoadingPolic
return resolveChunkSize;
}
+ public void resolveAllProxies(CDOSession session, CDORevision revision, EStructuralFeature feature)
+ {
+ doResolveProxy(session, revision, feature, 0, 0, Integer.MAX_VALUE);
+ }
+
public Object resolveProxy(CDOSession session, CDORevision rev, EStructuralFeature feature, int accessIndex,
int serverIndex)
{
- // Get proxy values
- InternalCDORevision revision = (InternalCDORevision)rev;
- int fetchIndex = serverIndex;
-
int chunkSize = resolveChunkSize;
if (chunkSize == CDORevision.UNCHUNKED)
{
@@ -63,6 +64,16 @@ public class CDOCollectionLoadingPolicyImpl implements CDOCollectionLoadingPolic
chunkSize = Integer.MAX_VALUE;
}
+ return doResolveProxy(session, rev, feature, accessIndex, serverIndex, chunkSize);
+ }
+
+ private Object doResolveProxy(CDOSession session, CDORevision rev, EStructuralFeature feature, int accessIndex,
+ int serverIndex, int chunkSize)
+ {
+ // Get proxy values
+ InternalCDORevision revision = (InternalCDORevision)rev;
+ int fetchIndex = serverIndex;
+
MoveableList<Object> list = revision.getList(feature);
int size = list.size();
int fromIndex = accessIndex;
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 559fa47..b57f8e5 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
@@ -27,8 +27,11 @@ import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.lob.CDOLobInfo;
import org.eclipse.emf.cdo.common.lob.CDOLobStore;
import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
+import org.eclipse.emf.cdo.common.model.EMFUtil;
import org.eclipse.emf.cdo.common.protocol.CDOAuthenticator;
+import org.eclipse.emf.cdo.common.revision.CDOElementProxy;
import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
+import org.eclipse.emf.cdo.common.revision.CDOList;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
@@ -102,6 +105,7 @@ import org.eclipse.net4j.util.options.OptionsEvent;
import org.eclipse.emf.common.util.ECollections;
import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
@@ -125,6 +129,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -882,6 +887,34 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter
return policy.resolveProxy(this, revision, feature, accessIndex, serverIndex);
}
+ /**
+ * @since 4.0
+ */
+ public void resolveAllElementProxies(CDORevision revision)
+ {
+ CDOCollectionLoadingPolicy policy = options().getCollectionLoadingPolicy();
+ for (EStructuralFeature feature : revision.getEClass().getEAllStructuralFeatures())
+ {
+ if (feature instanceof EReference)
+ {
+ EReference reference = (EReference)feature;
+ if (reference.isMany() && EMFUtil.isPersistent(reference))
+ {
+ CDOList list = ((InternalCDORevision)revision).getList(reference);
+ for (Iterator<Object> it = list.iterator(); it.hasNext();)
+ {
+ Object element = it.next();
+ if (element instanceof CDOElementProxy)
+ {
+ policy.resolveAllProxies(this, revision, reference);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
public void handleRepositoryTypeChanged(CDOCommonRepository.Type oldType, CDOCommonRepository.Type newType)
{
fireEvent(new RepositoryTypeChangedEvent(this, oldType, newType));
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java
index d07d52e..e32020b 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java
@@ -60,6 +60,7 @@ import org.eclipse.emf.cdo.internal.common.commit.CDOCommitDataImpl;
import org.eclipse.emf.cdo.internal.common.commit.FailureCommitInfo;
import org.eclipse.emf.cdo.internal.common.protocol.CDODataInputImpl;
import org.eclipse.emf.cdo.internal.common.protocol.CDODataOutputImpl;
+import org.eclipse.emf.cdo.internal.common.revision.CDOListWithElementProxiesImpl;
import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil;
import org.eclipse.emf.cdo.spi.common.commit.CDORevisionAvailabilityInfo;
import org.eclipse.emf.cdo.spi.common.commit.InternalCDOCommitInfoManager;
@@ -94,7 +95,6 @@ import org.eclipse.emf.internal.cdo.object.CDONotificationBuilder;
import org.eclipse.emf.internal.cdo.object.CDOObjectMerger;
import org.eclipse.emf.internal.cdo.object.CDOObjectWrapper;
import org.eclipse.emf.internal.cdo.query.CDOQueryImpl;
-import org.eclipse.emf.internal.cdo.revision.CDOListWithElementProxiesImpl;
import org.eclipse.emf.internal.cdo.util.CommitIntegrityCheck;
import org.eclipse.emf.internal.cdo.util.CompletePackageClosure;
import org.eclipse.emf.internal.cdo.util.IPackageClosure;
@@ -215,7 +215,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
/**
* A map to hold a clean (i.e. unmodified) revision for objects that have been modified or detached.
*/
- private Map<InternalCDOObject, InternalCDORevision> cleanRevisions = new HashMap<InternalCDOObject, InternalCDORevision>();
+ private Map<InternalCDOObject, InternalCDORevision> cleanRevisions = new ResolvingRevisionMap();
public CDOTransactionImpl(CDOBranch branch)
{
@@ -2199,6 +2199,27 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
return rev;
}
+ private final class ResolvingRevisionMap extends HashMap<InternalCDOObject, InternalCDORevision>
+ {
+ private static final long serialVersionUID = 1L;
+
+ public ResolvingRevisionMap()
+ {
+ }
+
+ @Override
+ public InternalCDORevision get(Object cdoObject)
+ {
+ InternalCDORevision revision = super.get(cdoObject);
+ if (revision != null)
+ {
+ getSession().resolveAllElementProxies(revision);
+ }
+
+ return revision;
+ }
+ }
+
/**
* @author Simon McDuff
*/
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStoreImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStoreImpl.java
index 54f201b..ef1fe74 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStoreImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStoreImpl.java
@@ -17,6 +17,7 @@ package org.eclipse.emf.internal.cdo.view;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.model.CDOModelUtil;
import org.eclipse.emf.cdo.common.model.CDOType;
+import org.eclipse.emf.cdo.common.revision.CDOElementProxy;
import org.eclipse.emf.cdo.common.revision.CDOList;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
@@ -48,7 +49,6 @@ import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.InternalEObject.EStore;
import org.eclipse.emf.ecore.util.FeatureMap;
import org.eclipse.emf.ecore.util.FeatureMapUtil;
-import org.eclipse.emf.spi.cdo.CDOElementProxy;
import org.eclipse.emf.spi.cdo.CDOStore;
import org.eclipse.emf.spi.cdo.FSMUtil;
import org.eclipse.emf.spi.cdo.InternalCDOObject;
@@ -548,7 +548,9 @@ public final class CDOStoreImpl implements CDOStore
{
if (value instanceof CDOElementProxy)
{
- value = ((CDOElementProxy)value).resolve(getView().getSession(), revision, feature, index);
+ // Resolve proxy
+ CDOElementProxy proxy = (CDOElementProxy)value;
+ value = view.getSession().resolveElementProxy(revision, feature, index, proxy.getIndex());
}
return value;
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOSession.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOSession.java
index d799456..626d2a4 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOSession.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOSession.java
@@ -147,6 +147,11 @@ public interface InternalCDOSession extends CDOSession, PackageProcessor, Packag
public Object resolveElementProxy(CDORevision revision, EStructuralFeature feature, int accessIndex, int serverIndex);
/**
+ * @since 4.0
+ */
+ public void resolveAllElementProxies(CDORevision revision);
+
+ /**
* @since 3.0
*/
public void handleRepositoryTypeChanged(CDOCommonRepository.Type oldType, CDOCommonRepository.Type newType);