Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-09-15 17:15:47 +0000
committerEike Stepper2008-09-15 17:15:47 +0000
commitaffb17ca5db9e84ac0726523703ddb607dab5374 (patch)
treeaa212a58ffe90d5b569fc555549f69dfdee1654a
parent6526a7baf401c3905025df4def89b9abba22fc5a (diff)
downloadcdo-affb17ca5db9e84ac0726523703ddb607dab5374.tar.gz
cdo-affb17ca5db9e84ac0726523703ddb607dab5374.tar.xz
cdo-affb17ca5db9e84ac0726523703ddb607dab5374.zip
[247226] Transparently support legacy models
https://bugs.eclipse.org/bugs/show_bug.cgi?id=247226
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionImpl.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/InternalCDORevision.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/AllTests.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HbNoLegacyTest.java26
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF5
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java16
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LegacyTest.java121
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MangoTest.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/NoLegacyTest.java83
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterSinglePackageAction.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenSessionDialog.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/SelectPackageDialog.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java4
-rw-r--r--plugins/org.eclipse.emf.cdo/.classpath1
-rw-r--r--plugins/org.eclipse.emf.cdo/build.properties8
-rw-r--r--plugins/org.eclipse.emf.cdo/mixin/org/eclipse/emf/ecore/impl/CDOAware.java21
-rw-r--r--plugins/org.eclipse.emf.cdo/mixin/org/eclipse/emf/ecore/impl/CDOCallback.java25
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java47
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOPackageType.java10
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOPackageTypeRegistry.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java42
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/LegacySystemNotAvailableException.java26
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAdapterImpl.java59
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOCallbackImpl.java174
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOLegacyWrapper.java (renamed from plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOLegacyImpl.java)260
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOMetaWrapper.java (renamed from plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOMetaImpl.java)5
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java6
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectWrapper.java (renamed from plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOWrapperImpl.java)39
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java14
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java4
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java8
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java40
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageTypeRegistryImpl.java45
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java137
35 files changed, 482 insertions, 774 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionImpl.java
index 3150e34230..dd68d31637 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionImpl.java
@@ -512,7 +512,7 @@ public class CDORevisionImpl implements InternalCDORevision
{
int i = cdoClass.getFeatureID(feature);
MoveableList<Object> list = (MoveableList<Object>)values[i];
- if (list == null)
+ if (list == null && size != -1)
{
list = new MoveableArrayList<Object>(size);
values[i] = list;
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/InternalCDORevision.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/InternalCDORevision.java
index b2153833d3..1d1cf49785 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/InternalCDORevision.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/InternalCDORevision.java
@@ -66,6 +66,11 @@ public interface InternalCDORevision extends CDORevision, CDORevisionData
public MoveableList<Object> getList(CDOFeature feature);
+ /**
+ * @param size
+ * the size of a new list to be created if this revision has no list so far, or -1 to skip list creation and
+ * return <code>null</code> in this case.
+ */
public MoveableList<Object> getList(CDOFeature feature, int size);
public void setListSize(CDOFeature feature, int size);
diff --git a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/AllTests.java b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/AllTests.java
index d81660ccdd..dcfc30e675 100644
--- a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/AllTests.java
+++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/AllTests.java
@@ -39,7 +39,6 @@ public class AllTests
suite.addTestSuite(HbCrossReferenceTest.class);
suite.addTestSuite(HbMangoTest.class);
suite.addTestSuite(HbEnumTest.class);
- suite.addTestSuite(HbNoLegacyTest.class);
suite.addTestSuite(HbNonCDOResourceTest.class);
suite.addTestSuite(HbInvalidationTest.class);
suite.addTestSuite(HbIndexReconstructionTest.class);
diff --git a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HbNoLegacyTest.java b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HbNoLegacyTest.java
deleted file mode 100644
index a573a64b37..0000000000
--- a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HbNoLegacyTest.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
- * 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:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- **************************************************************************/
-package org.eclipse.emf.cdo.tests.hibernate;
-
-import org.eclipse.emf.cdo.tests.NoLegacyTest;
-import org.eclipse.emf.cdo.tests.StoreRepositoryProvider;
-
-/**
- * @author Martin Taal
- */
-public class HbNoLegacyTest extends NoLegacyTest
-{
- public HbNoLegacyTest()
- {
- StoreRepositoryProvider.setInstance(HbStoreRepositoryProvider.getInstance());
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF
index 4e60eb3358..39df5bfabe 100644
--- a/plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF
@@ -17,12 +17,13 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)",
org.eclipse.emf.cdo.server;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
org.eclipse.emf.cdo.server.db;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
org.eclipse.emf.cdo;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
+ org.eclipse.emf.cdo.tests.legacy;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
org.eclipse.emf.cdo.tests.mango;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
org.eclipse.emf.cdo.tests.model1;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
org.eclipse.emf.cdo.tests.model2;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
org.eclipse.emf.cdo.tests.model3;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
- org.eclipse.emf.cdo.tests.model4;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.emf.cdo.tests.model4interfaces;bundle-version="[2.0.0,3.0.0)",
+ org.eclipse.emf.cdo.tests.model4;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
+ org.eclipse.emf.cdo.tests.model4interfaces;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
org.junit;bundle-version="[3.8.0,4.0.0)";visibility:=reexport
Export-Package: base;version="2.0.0",
base.impl;version="2.0.0",
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java
index 9ba8ebd20e..2c78c1f4f7 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java
@@ -19,6 +19,8 @@ import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.server.CDOServerUtil;
import org.eclipse.emf.cdo.server.IRepository;
import org.eclipse.emf.cdo.server.IStore;
+import org.eclipse.emf.cdo.tests.legacy.LegacyPackage;
+import org.eclipse.emf.cdo.tests.mango.MangoPackage;
import org.eclipse.emf.cdo.tests.model1.Model1Package;
import org.eclipse.emf.cdo.tests.model2.Model2Package;
import org.eclipse.emf.cdo.tests.model3.Model3Package;
@@ -135,6 +137,20 @@ public abstract class AbstractCDOTest extends AbstractTransportTest
session.getPackageRegistry().putEPackage(Model3Package.eINSTANCE);
return session;
}
+ protected CDOSession openMangoSession()
+ {
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(MangoPackage.eINSTANCE);
+ return session;
+ }
+
+ protected CDOSession openLegacySession()
+ {
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(LegacyPackage.eINSTANCE);
+ return session;
+ }
+
protected static void assertTransient(CDOObject object)
{
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java
index 8d07149108..47d46b900b 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java
@@ -50,7 +50,6 @@ public class AllTests
suite.addTestSuite(RevisionDeltaWithDeltaSupportTest.class);
suite.addTestSuite(RevisionDeltaWithoutDeltaSupportTest.class);
suite.addTestSuite(IndexReconstructionTest.class);
- suite.addTestSuite(NoLegacyTest.class);
suite.addTestSuite(AutoAttacherTest.class);
suite.addTestSuite(SavepointTest.class);
suite.addTestSuite(ChangeSubscriptionTest.class);
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LegacyTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LegacyTest.java
new file mode 100644
index 0000000000..53625403df
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LegacyTest.java
@@ -0,0 +1,121 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
+ * 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;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.CDOSession;
+import org.eclipse.emf.cdo.CDOState;
+import org.eclipse.emf.cdo.CDOTransaction;
+import org.eclipse.emf.cdo.CDOView;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.tests.legacy.Hook;
+import org.eclipse.emf.cdo.tests.legacy.LegacyFactory;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * @author Eike Stepper
+ */
+public class LegacyTest extends AbstractCDOTest
+{
+ public void _testCommit() throws Exception
+ {
+ Hook hook = createHook("Mr. Hook");
+
+ CDOSession session = openLegacySession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource("/test1");
+ resource.getContents().add(hook);
+ transaction.commit();
+
+ CDOObject cdoHook = CDOUtil.adaptLegacy(hook);
+ assertEquals(CDOState.CLEAN, cdoHook.cdoState());
+ assertEquals(CDOState.CLEAN, resource.cdoState());
+ session.close();
+ }
+
+ public void _testLoad() throws Exception
+ {
+ {
+ CDOSession session = openLegacySession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource("/test1");
+ resource.getContents().add(createHook("Mr. Hook"));
+ transaction.commit();
+ session.close();
+ }
+
+ CDOSession session = openLegacySession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource("/test1");
+ EList<EObject> contents = resource.getContents();
+
+ Hook hook = (Hook)contents.get(0);
+ CDOObject cdoHook = CDOUtil.adaptLegacy(hook);
+ assertEquals(CDOState.PROXY, cdoHook.cdoState());
+ assertEquals(CDOState.CLEAN, resource.cdoState());
+
+ String name = hook.getName();
+ assertEquals("Mr. Hook", name);
+ assertEquals(CDOState.CLEAN, cdoHook.cdoState());
+ session.close();
+ }
+
+ public void testReferences() throws Exception
+ {
+ {
+ Hook hook = createHook("Mr. Hook");
+ EList<Hook> children = hook.getChildren();
+ children.add(createHook("Hook 1"));
+ children.add(createHook("Hook 2"));
+ children.add(createHook("Hook 3"));
+
+ CDOSession session = openLegacySession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource("/test1");
+ resource.getContents().add(hook);
+ transaction.commit();
+
+ CDOObject cdoHook = CDOUtil.adaptLegacy(hook);
+ assertEquals(CDOState.CLEAN, cdoHook.cdoState());
+ assertEquals(CDOState.CLEAN, resource.cdoState());
+ session.close();
+ }
+
+ CDOSession session = openLegacySession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.getResource("/test1");
+ EList<EObject> contents = resource.getContents();
+
+ Hook hook = (Hook)contents.get(0);
+ CDOObject cdoHook = CDOUtil.adaptLegacy(hook);
+ assertEquals(CDOState.PROXY, cdoHook.cdoState());
+
+ EList<Hook> children = hook.getChildren();
+ assertEquals(CDOState.PROXY, cdoHook.cdoState());
+ assertEquals(CDOState.CLEAN, resource.cdoState());
+
+ int size = children.size();
+ assertEquals(3, size);
+
+ assertEquals(CDOState.CLEAN, cdoHook.cdoState());
+ session.close();
+ }
+
+ private Hook createHook(String name)
+ {
+ Hook hook = LegacyFactory.eINSTANCE.createHook();
+ hook.setName(name);
+ return hook;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MangoTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MangoTest.java
index 5ea0ae70cb..5eea14988d 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MangoTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/MangoTest.java
@@ -15,7 +15,6 @@ import org.eclipse.emf.cdo.CDOState;
import org.eclipse.emf.cdo.CDOTransaction;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.tests.mango.MangoFactory;
-import org.eclipse.emf.cdo.tests.mango.MangoPackage;
import org.eclipse.emf.cdo.tests.mango.Value;
import org.eclipse.emf.cdo.tests.mango.ValueList;
@@ -24,13 +23,6 @@ import org.eclipse.emf.cdo.tests.mango.ValueList;
*/
public class MangoTest extends AbstractCDOTest
{
- private CDOSession openMangoSession()
- {
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(MangoPackage.eINSTANCE);
- return session;
- }
-
public void testCommitNew() throws Exception
{
CDOSession session = openMangoSession();
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/NoLegacyTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/NoLegacyTest.java
deleted file mode 100644
index d6a0b8c7e5..0000000000
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/NoLegacyTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
- * 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;
-
-import org.eclipse.emf.cdo.CDOSession;
-import org.eclipse.emf.cdo.CDOSessionConfiguration;
-import org.eclipse.emf.cdo.CDOTransaction;
-import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.LegacySystemNotAvailableException;
-
-import org.eclipse.net4j.util.io.IOUtil;
-
-import org.eclipse.emf.ecore.xml.type.ProcessingInstruction;
-import org.eclipse.emf.ecore.xml.type.XMLTypeFactory;
-import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
-
-/**
- * @author Eike Stepper
- */
-public class NoLegacyTest extends AbstractCDOTest
-{
- public void testOpenLegacySession() throws Exception
- {
- CDOSession session = null;
-
- try
- {
- CDOSessionConfiguration configuration = CDOUtil.createSessionConfiguration();
- configuration.setConnector(getConnector());
- configuration.setRepositoryName(REPOSITORY_NAME);
- configuration.setLegacySupportEnabled(true);
- session = configuration.openSession();
- fail("LegacySystemNotAvailableException expected");
- }
- catch (LegacySystemNotAvailableException ex)
- {
- IOUtil.print(ex);
- }
- finally
- {
- if (session != null)
- {
- session.close();
- }
- }
- }
-
- public void testAttachLegacyObject() throws Exception
- {
- CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(XMLTypePackage.eINSTANCE);
-
- CDOTransaction transaction = session.openTransaction();
- CDOResource resource = transaction.createResource("/test1");
-
- ProcessingInstruction pi = XMLTypeFactory.eINSTANCE.createProcessingInstruction();
- pi.setData("data");
- pi.setTarget("target");
-
- try
- {
- resource.getContents().add(pi);
- fail("LegacySystemNotAvailableException expected");
- }
- catch (LegacySystemNotAvailableException ex)
- {
- IOUtil.print(ex);
- }
- finally
- {
- session.close();
- }
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterSinglePackageAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterSinglePackageAction.java
index fa3d5db48c..6bb8ca4404 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterSinglePackageAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RegisterSinglePackageAction.java
@@ -54,9 +54,6 @@ public class RegisterSinglePackageAction extends RegisterPackagesAction
{
switch (packageType)
{
- case CONVERTED:
- return SharedIcons.getDescriptor(SharedIcons.OBJ_EPACKAGE_CONVERTED);
-
case LEGACY:
return SharedIcons.getDescriptor(SharedIcons.OBJ_EPACKAGE_LEGACY);
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenSessionDialog.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenSessionDialog.java
index a92c1166e4..5b8a8bf6d1 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenSessionDialog.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenSessionDialog.java
@@ -13,8 +13,6 @@ package org.eclipse.emf.cdo.internal.ui.dialogs;
import org.eclipse.emf.cdo.internal.ui.SharedIcons;
import org.eclipse.emf.cdo.internal.ui.bundle.OM;
-import org.eclipse.emf.internal.cdo.util.FSMUtil;
-
import org.eclipse.net4j.util.collection.IHistory;
import org.eclipse.net4j.util.collection.PreferenceHistory;
import org.eclipse.net4j.util.ui.UIUtil;
@@ -66,7 +64,7 @@ public class OpenSessionDialog extends TitleAreaDialog
static
{
- OM.PREF_LEGACY_MODEL_SUPPORT.setValue(FSMUtil.isLegacySystemAvailable());
+ OM.PREF_LEGACY_MODEL_SUPPORT.setValue(true);
}
public OpenSessionDialog(IWorkbenchPage page)
@@ -140,7 +138,6 @@ public class OpenSessionDialog extends TitleAreaDialog
new Label(composite, SWT.NONE);
legacyButton = new PreferenceButton(composite, SWT.CHECK, "Legacy Model Support", OM.PREF_LEGACY_MODEL_SUPPORT);
- legacyButton.getButton().setEnabled(FSMUtil.isLegacySystemAvailable());
connectorText.setFocus();
connectorText.getCombo().addFocusListener(new FocusListener()
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/SelectPackageDialog.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/SelectPackageDialog.java
index a79be83ee0..2f7e5b4c6e 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/SelectPackageDialog.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/SelectPackageDialog.java
@@ -150,9 +150,6 @@ public class SelectPackageDialog extends BaseDialog<CheckboxTableViewer>
CDOPackageType packageType = CDOPackageTypeRegistry.INSTANCE.get(element);
switch (packageType)
{
- case CONVERTED:
- return SharedIcons.getImage(SharedIcons.OBJ_EPACKAGE_CONVERTED);
-
case LEGACY:
return SharedIcons.getImage(SharedIcons.OBJ_EPACKAGE_LEGACY);
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
index 920c02dcea..cbe3632e5c 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
@@ -24,7 +24,7 @@ import org.eclipse.emf.cdo.ui.CDOEventHandler;
import org.eclipse.emf.cdo.ui.CDOLabelProvider;
import org.eclipse.emf.cdo.util.CDOURIUtil;
-import org.eclipse.emf.internal.cdo.CDOLegacyImpl;
+import org.eclipse.emf.internal.cdo.CDOLegacyWrapper;
import org.eclipse.emf.internal.cdo.CDOStateMachine;
import org.eclipse.emf.internal.cdo.CDOTransactionImpl;
import org.eclipse.emf.internal.cdo.InternalCDOObject;
@@ -1203,7 +1203,7 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
@Override
protected void objectInvalidated(InternalCDOObject cdoObject)
{
- if (cdoObject instanceof CDOLegacyImpl)
+ if (cdoObject instanceof CDOLegacyWrapper)
{
CDOStateMachine.INSTANCE.read(cdoObject);
}
diff --git a/plugins/org.eclipse.emf.cdo/.classpath b/plugins/org.eclipse.emf.cdo/.classpath
index ec2f73708f..64c5e31b7a 100644
--- a/plugins/org.eclipse.emf.cdo/.classpath
+++ b/plugins/org.eclipse.emf.cdo/.classpath
@@ -3,6 +3,5 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
- <classpathentry kind="src" output="mixin-bin" path="mixin"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/plugins/org.eclipse.emf.cdo/build.properties b/plugins/org.eclipse.emf.cdo/build.properties
index 3bf59e0b72..4e461b69c1 100644
--- a/plugins/org.eclipse.emf.cdo/build.properties
+++ b/plugins/org.eclipse.emf.cdo/build.properties
@@ -23,11 +23,7 @@ bin.includes = .,\
about.ini,\
about.mappings,\
about.properties,\
- modeling32.png,\
- mixin.jar
-jars.compile.order = mixin.jar,\
- .
+ modeling32.png
+jars.compile.order = .
source.. = src/
output.. = bin/
-source.mixin.jar = mixin/
-output.mixin.jar = mixin-bin/
diff --git a/plugins/org.eclipse.emf.cdo/mixin/org/eclipse/emf/ecore/impl/CDOAware.java b/plugins/org.eclipse.emf.cdo/mixin/org/eclipse/emf/ecore/impl/CDOAware.java
deleted file mode 100644
index df9c55bd87..0000000000
--- a/plugins/org.eclipse.emf.cdo/mixin/org/eclipse/emf/ecore/impl/CDOAware.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
- * 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.ecore.impl;
-
-/**
- * @author Eike Stepper
- */
-public interface CDOAware
-{
- public CDOCallback getCDOCallback();
-
- public void setCDOCallback(CDOCallback callback);
-}
diff --git a/plugins/org.eclipse.emf.cdo/mixin/org/eclipse/emf/ecore/impl/CDOCallback.java b/plugins/org.eclipse.emf.cdo/mixin/org/eclipse/emf/ecore/impl/CDOCallback.java
deleted file mode 100644
index 46fb408d02..0000000000
--- a/plugins/org.eclipse.emf.cdo/mixin/org/eclipse/emf/ecore/impl/CDOCallback.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
- * 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.ecore.impl;
-
-// import org.eclipse.emf.ecore.resource.Resource;
-
-/**
- * @author Eike Stepper
- */
-public interface CDOCallback
-{
- public void beforeRead(EObjectImpl eObject);
-
- public void beforeWrite(EObjectImpl eObject);
-
- // public Resource callbackResource(BasicEObjectImpl eObject);
-}
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 3035f40b6b..6398fa8099 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
@@ -19,10 +19,10 @@ import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.eresource.EresourcePackage;
import org.eclipse.emf.cdo.util.CDOURIUtil;
-import org.eclipse.emf.cdo.util.LegacySystemNotAvailableException;
import org.eclipse.emf.internal.cdo.CDOObjectImpl;
import org.eclipse.emf.internal.cdo.CDOStateMachine;
+import org.eclipse.emf.internal.cdo.CDOTransactionImpl;
import org.eclipse.emf.internal.cdo.InternalCDOObject;
import org.eclipse.emf.internal.cdo.util.FSMUtil;
@@ -431,7 +431,15 @@ public class CDOResourceImpl extends CDOObjectImpl implements CDOResource
public void attached(EObject object)
{
InternalCDOObject cdoObject = FSMUtil.adapt(object, cdoView());
- CDOStateMachine.INSTANCE.attach(cdoObject, cdoView().toTransaction());
+ attached(cdoObject, cdoView().toTransaction());
+ }
+
+ /**
+ * @ADDED
+ */
+ private void attached(InternalCDOObject cdoObject, CDOTransactionImpl transaction)
+ {
+ CDOStateMachine.INSTANCE.attach(cdoObject, transaction);
}
/**
@@ -552,20 +560,27 @@ public class CDOResourceImpl extends CDOObjectImpl implements CDOResource
@Override
public NotificationChain inverseAdd(Object object, NotificationChain notifications)
{
- if (object instanceof InternalCDOObject)
- {
- InternalCDOObject eObject = (InternalCDOObject)object;
- notifications = eObject.eSetResource(CDOResourceImpl.this, notifications);
- // It is possible that a attached objects gets add to the resource.
- if (FSMUtil.isTransient(eObject))
- {
- attached(eObject);
- }
- }
- else
- {
- throw new LegacySystemNotAvailableException();
- }
+ CDOTransactionImpl transaction = cdoView().toTransaction();
+ InternalCDOObject cdoObject = FSMUtil.adapt(object, transaction);
+ notifications = cdoObject.eSetResource(CDOResourceImpl.this, notifications);
+ attached(cdoObject, transaction);
+
+ // if (object instanceof InternalCDOObject)
+ // {
+ // InternalCDOObject eObject = (InternalCDOObject)object;
+ // notifications = eObject.eSetResource(CDOResourceImpl.this, notifications);
+ // // It is possible that a attached objects gets add to the resource.
+ // if (FSMUtil.isTransient(eObject))
+ // {
+ // attached(eObject);
+ // }
+ // }
+ // else
+ // {
+ // // throw new LegacySystemNotAvailableException();
+ // throw new IllegalArgumentException();
+ // }
+
return notifications;
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOPackageType.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOPackageType.java
index 51aad57b49..2497f0253b 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOPackageType.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOPackageType.java
@@ -10,7 +10,6 @@
**************************************************************************/
package org.eclipse.emf.cdo.util;
-import org.eclipse.emf.internal.cdo.CDOAdapterImpl;
import org.eclipse.emf.internal.cdo.CDOObjectImpl;
import org.eclipse.emf.internal.cdo.CDOStateMachine;
@@ -29,12 +28,5 @@ public enum CDOPackageType
* The type of <code>EPackages</code> that have been normally generated for EMF. Instances of <code>EClasses</code> of
* these packages are represented by {@link CDOAdapterImpl} to the {@link CDOStateMachine}.
*/
- LEGACY,
-
- /**
- * The type of <code>EPackages</code> that have been normally generated for EMF and later converted to CDO. Instances
- * of <code>EClasses</code> of these packages are represented by {@link org.eclipse.emf.internal.cdo.CDOCallbackImpl}
- * to the {@link CDOStateMachine}.
- */
- CONVERTED
+ LEGACY
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOPackageTypeRegistry.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOPackageTypeRegistry.java
index 4db7071c28..76cf50bbda 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOPackageTypeRegistry.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOPackageTypeRegistry.java
@@ -31,6 +31,4 @@ public interface CDOPackageTypeRegistry extends IRegistry<String, CDOPackageType
public void registerLegacy(String uri);
public void registerNative(String uri);
-
- public void registerConverted(String uri);
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java
index c1a6284b7e..3eea7ef3b1 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java
@@ -11,6 +11,7 @@
**************************************************************************/
package org.eclipse.emf.cdo.util;
+import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.CDOSessionConfiguration;
import org.eclipse.emf.cdo.CDOView;
import org.eclipse.emf.cdo.CDOViewSet;
@@ -37,10 +38,14 @@ import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EGenericType;
+import org.eclipse.emf.ecore.EModelElement;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.InternalEObject;
+import org.eclipse.emf.ecore.impl.EStringToStringMapEntryImpl;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
@@ -222,4 +227,41 @@ public final class CDOUtil
load(content, view);
}
}
+
+ /**
+ * @since 2.0
+ */
+ public static CDOObject adaptLegacy(EObject object)
+ {
+ if (object instanceof CDOObject)
+ {
+ return (CDOObject)object;
+ }
+
+ return FSMUtil.adaptLegacy((InternalEObject)object);
+ }
+
+ /**
+ * @since 2.0
+ */
+ public static CDOObject adaptMeta(EModelElement object, CDOView view)
+ {
+ return FSMUtil.adaptMeta((InternalEObject)object, view);
+ }
+
+ /**
+ * @since 2.0
+ */
+ public static CDOObject adaptMeta(EGenericType object, CDOView view)
+ {
+ return FSMUtil.adaptMeta((InternalEObject)object, view);
+ }
+
+ /**
+ * @since 2.0
+ */
+ public static CDOObject adaptMeta(EStringToStringMapEntryImpl object, CDOView view)
+ {
+ return FSMUtil.adaptMeta(object, view);
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/LegacySystemNotAvailableException.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/LegacySystemNotAvailableException.java
deleted file mode 100644
index c9583104d1..0000000000
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/LegacySystemNotAvailableException.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
- * 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.util;
-
-/**
- * @author Eike Stepper
- */
-public class LegacySystemNotAvailableException extends RuntimeException
-{
- public static final String LEGACY_SYSTEM_NOT_AVAILABLE = "Legacy system not available";
-
- private static final long serialVersionUID = 1L;
-
- public LegacySystemNotAvailableException()
- {
- super(LEGACY_SYSTEM_NOT_AVAILABLE);
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAdapterImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAdapterImpl.java
deleted file mode 100644
index 0fe204ed93..0000000000
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAdapterImpl.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
- * 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.internal.cdo;
-
-import org.eclipse.emf.internal.cdo.bundle.OM;
-
-import org.eclipse.emf.common.notify.Notification;
-
-/**
- * @author Eike Stepper
- */
-public class CDOAdapterImpl extends CDOLegacyImpl
-{
- public CDOAdapterImpl()
- {
- }
-
- @Override
- public boolean isAdapterForType(Object type)
- {
- return type == CDOAdapterImpl.class;
- }
-
- public void notifyChanged(Notification msg)
- {
- try
- {
- if (msg.getNotifier() == instance)
- {
- switch (msg.getEventType())
- {
- case Notification.ADD:
- case Notification.ADD_MANY:
- case Notification.REMOVE:
- case Notification.REMOVE_MANY:
- case Notification.MOVE:
- case Notification.SET:
- case Notification.UNSET:
- if (!instance.eIsProxy())
- {
- CDOStateMachine.INSTANCE.write(this);
- }
- }
- }
- }
- catch (RuntimeException ex)
- {
- OM.LOG.error(ex);
- }
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOCallbackImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOCallbackImpl.java
deleted file mode 100644
index fe83b1433f..0000000000
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOCallbackImpl.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
- * 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.internal.cdo;
-
-import org.eclipse.emf.cdo.CDOView;
-
-import org.eclipse.emf.internal.cdo.bundle.OM;
-import org.eclipse.emf.internal.cdo.util.FSMUtil;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.InternalEObject;
-import org.eclipse.emf.ecore.impl.CDOAware;
-import org.eclipse.emf.ecore.impl.CDOCallback;
-import org.eclipse.emf.ecore.impl.EObjectImpl;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public class CDOCallbackImpl extends CDOLegacyImpl implements CDOCallback
-{
- public CDOCallbackImpl(InternalEObject instance)
- {
- this.instance = instance;
- }
-
- public void beforeRead(EObjectImpl instance)
- {
- CDOStateMachine.INSTANCE.read(this);
- }
-
- public void beforeWrite(EObjectImpl instance)
- {
- CDOStateMachine.INSTANCE.write(this);
- }
-
- @Override
- public boolean isAdapterForType(Object type)
- {
- return type == CDOCallbackImpl.class;
- }
-
- public void notifyChanged(Notification msg)
- {
- try
- {
- if (msg.getNotifier() == instance)
- {
- Object feature = msg.getFeature();
- if (feature instanceof EReference)
- {
- EReference reference = (EReference)feature;
- if (reference.isContainment() && !reference.isTransient())
- {
- switch (msg.getEventType())
- {
- case Notification.ADD:
- notifyAdd(msg.getNewValue());
- break;
-
- case Notification.ADD_MANY:
- notifyAddMany(msg);
- break;
-
- case Notification.REMOVE:
- notifyRemove(msg.getOldValue());
- break;
-
- case Notification.REMOVE_MANY:
- notifyRemoveMany(msg);
- break;
- }
- }
- }
- }
- }
- catch (RuntimeException ex)
- {
- OM.LOG.error(ex);
- }
- }
-
- @Override
- protected void adjustEProxy()
- {
- // Do nothing
- }
-
- private void notifyAddMany(Notification msg)
- {
- List<?> newValues = (List<?>)msg.getNewValue();
- List<?> oldValues = (List<?>)msg.getOldValue();
- for (Object newValue : newValues)
- {
- if (!oldValues.contains(newValue))
- {
- notifyAdd(newValue);
- }
- }
- }
-
- private void notifyAdd(Object instance)
- {
- if (instance instanceof InternalEObject)
- {
- if (((InternalEObject)instance).eDeliver())
- {
- InternalCDOObject object = FSMUtil.adapt(instance, view);
- CDOStateMachine.INSTANCE.attach(object, view.toTransaction());
- }
- }
- }
-
- private void notifyRemoveMany(Notification msg)
- {
- List<?> newValues = (List<?>)msg.getNewValue();
- List<?> oldValues = (List<?>)msg.getOldValue();
- for (Object oldValue : oldValues)
- {
- if (!newValues.contains(oldValue))
- {
- notifyRemove(oldValue);
- }
- }
- }
-
- private void notifyRemove(Object instance)
- {
- if (instance instanceof InternalEObject)
- {
- if (((InternalEObject)instance).eDeliver())
- {
- InternalCDOObject object = FSMUtil.adapt(instance, view);
- CDOStateMachine.INSTANCE.detach(object);
- }
- }
- }
-
- public static InternalCDOObject adapt(Object object, CDOView view) throws Throwable
- {
- if (object instanceof CDOAware)
- {
- CDOAware aware = (CDOAware)object;
- CDOCallbackImpl callback = (CDOCallbackImpl)aware.getCDOCallback();
- if (callback == null)
- {
- InternalEObject instance = (InternalEObject)aware;
- if (instance.eIsProxy())
- {
- instance = (InternalEObject)EcoreUtil.resolve(instance, view.getResourceSet());
- }
-
- callback = new CDOCallbackImpl(instance);
- aware.setCDOCallback(callback);
- instance.eAdapters().add(callback);
- }
-
- return callback;
- }
-
- return null;
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOLegacyImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOLegacyWrapper.java
index e13f8fade3..574047be28 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOLegacyImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOLegacyWrapper.java
@@ -7,7 +7,6 @@
*
* Contributors:
* Eike Stepper - initial API and implementation
- * Simon McDuff - http://bugs.eclipse.org/201266
**************************************************************************/
package org.eclipse.emf.internal.cdo;
@@ -18,9 +17,11 @@ import org.eclipse.emf.cdo.common.model.CDOClass;
import org.eclipse.emf.cdo.common.model.CDOFeature;
import org.eclipse.emf.cdo.common.model.CDOType;
import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl;
import org.eclipse.emf.cdo.spi.common.InternalCDORevision;
+import org.eclipse.emf.cdo.util.CDOPackageRegistry;
import org.eclipse.emf.internal.cdo.bundle.OM;
import org.eclipse.emf.internal.cdo.util.GenUtil;
@@ -28,16 +29,14 @@ import org.eclipse.emf.internal.cdo.util.ModelUtil;
import org.eclipse.net4j.util.ImplementationError;
import org.eclipse.net4j.util.ReflectUtil;
-import org.eclipse.net4j.util.WrappedException;
import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.InternalEObject;
-import org.eclipse.emf.ecore.impl.BasicEObjectImpl;
import org.eclipse.emf.ecore.impl.EAttributeImpl;
import org.eclipse.emf.ecore.impl.EClassImpl;
import org.eclipse.emf.ecore.impl.EDataTypeImpl;
@@ -48,17 +47,17 @@ import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.util.InternalEList;
import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.List;
/**
* @author Eike Stepper
+ * @since 2.0
*/
-public abstract class CDOLegacyImpl extends CDOWrapperImpl implements Adapter.Internal
+public final class CDOLegacyWrapper extends CDOObjectWrapper implements InternalEObject.EReadListener,
+ InternalEObject.EWriteListener
{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_OBJECT, CDOLegacyImpl.class);
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_OBJECT, CDOLegacyWrapper.class);
private CDOState state;
@@ -66,11 +65,17 @@ public abstract class CDOLegacyImpl extends CDOWrapperImpl implements Adapter.In
private InternalCDORevision revision;
- public CDOLegacyImpl()
+ public CDOLegacyWrapper(InternalEObject instance)
{
+ this.instance = instance;
state = CDOState.TRANSIENT;
}
+ public CDOClass cdoClass()
+ {
+ return CDOObjectImpl.getCDOClass(this);
+ }
+
public CDOState cdoState()
{
return state;
@@ -86,21 +91,11 @@ public abstract class CDOLegacyImpl extends CDOWrapperImpl implements Adapter.In
return resource;
}
- public CDOClass cdoClass()
- {
- return CDOObjectImpl.getCDOClass(this);
- }
-
public void cdoReload()
{
CDOStateMachine.INSTANCE.reload(this);
}
- public boolean isAdapterForType(Object type)
- {
- return false;
- }
-
public CDOState cdoInternalSetState(CDOState state)
{
if (this.state != state)
@@ -146,7 +141,11 @@ public abstract class CDOLegacyImpl extends CDOWrapperImpl implements Adapter.In
public void cdoInternalPostAttach()
{
- // Do nothing
+ // TODO Avoid if no adapters in list (eBasicAdapters?)
+ for (Adapter adapter : eAdapters())
+ {
+ view.subscribe(this, adapter);
+ }
}
public void cdoInternalPostDetach()
@@ -156,66 +155,44 @@ public abstract class CDOLegacyImpl extends CDOWrapperImpl implements Adapter.In
public void cdoInternalPreCommit()
{
- transferInstanceToRevision();
-
- CDORevisionManagerImpl revisionManager = view.getSession().getRevisionManager();
- InternalCDORevision revision = cdoRevision();
- InternalCDORevision originRevision = revisionManager.getRevisionByVersion(revision.getID(), CDORevision.UNCHUNKED,
- revision.getVersion() - 1, false);
-
- CDOTransactionImpl transaction = cdoView().toTransaction();
- transaction.registerRevisionDelta(cdoRevision().compare(originRevision));
+ instanceToRevision();
+ if (cdoState() == CDOState.DIRTY) // NEW is handled in PrepareTransition
+ {
+ CDORevisionManagerImpl revisionManager = (CDORevisionManagerImpl)revision.getRevisionResolver();
+ InternalCDORevision originRevision = revisionManager.getRevisionByVersion(revision.getID(),
+ CDORevision.UNCHUNKED, revision.getVersion() - 1, false);
+ CDORevisionDelta delta = revision.compare(originRevision);
+ cdoView().toTransaction().registerRevisionDelta(delta);
+ }
}
public void cdoInternalPostLoad()
{
- transferRevisionToInstance();
+ revisionToInstance();
}
- @Override
- public String toString()
+ public void handleRead(InternalEObject object, int featureID)
{
- if (id == null)
- {
- return eClass().getName() + "?";
- }
-
- return eClass().getName() + "@" + id;
+ CDOStateMachine.INSTANCE.read(this);
}
- public InternalEObject getTarget()
+ public void handleWrite(InternalEObject object, int featureID)
{
- return instance;
+ CDOStateMachine.INSTANCE.write(this);
}
- public void setTarget(Notifier newTarget)
+ @Override
+ public NotificationChain eSetResource(Resource.Internal resource, NotificationChain notifications)
{
- if (newTarget instanceof InternalEObject)
- {
- instance = (InternalEObject)newTarget;
- }
- else
+ if (resource.getClass() == CDOResourceImpl.class)
{
- throw new IllegalArgumentException("Not an InternalEObject: " + newTarget.getClass().getName());
+ this.resource = (CDOResourceImpl)resource;
}
- }
- public void unsetTarget(Notifier oldTarget)
- {
- if (oldTarget instanceof InternalEObject)
- {
- if (instance == oldTarget)
- {
- instance = null;
- }
- }
- else
- {
- throw new IllegalArgumentException("Not an InternalEObject: " + oldTarget.getClass().getName());
- }
+ return super.eSetResource(resource, notifications);
}
- protected void transferInstanceToRevision()
+ private void instanceToRevision()
{
if (TRACER.isEnabled())
{
@@ -229,6 +206,19 @@ public abstract class CDOLegacyImpl extends CDOWrapperImpl implements Adapter.In
}
// Handle containment
+ instanceToRevisionContainment(view);
+
+ // Handle values
+ CDOPackageRegistry packageRegistry = cdoView().getSession().getPackageRegistry();
+ CDOClass cdoClass = revision.getCDOClass();
+ for (CDOFeature feature : cdoClass.getAllFeatures())
+ {
+ instanceToRevisionFeature(view, feature, packageRegistry);
+ }
+ }
+
+ private void instanceToRevisionContainment(CDOViewImpl view) throws ImplementationError
+ {
EObject container = instance.eContainer();
if (container != null)
{
@@ -248,62 +238,59 @@ public abstract class CDOLegacyImpl extends CDOWrapperImpl implements Adapter.In
throw new ImplementationError("containerID.isNull()");
}
- int containerFeatureID = instance.eContainerFeatureID();// containER???
+ int containerFeatureID = instance.eContainerFeatureID();// container???
revision.setContainerID(containerID);
revision.setContainingFeatureID(containerFeatureID);
}
}
+ }
- // Handle values
- CDOClass cdoClass = revision.getCDOClass();
- CDOFeature[] features = cdoClass.getAllFeatures();
- for (int i = 0; i < features.length; i++)
+ private void instanceToRevisionFeature(CDOViewImpl view, CDOFeature feature, CDOPackageRegistry packageRegistry)
+ throws ImplementationError
+ {
+ Object instanceValue = getInstanceValue(instance, feature, packageRegistry);
+ if (feature.isMany())
{
- CDOFeature feature = features[i];
- Object instanceValue = getInstanceValue(instance, feature);
- if (feature.isMany())
- {
- List<Object> revisionList = revision.getList(feature); // TODO lazy?
- revisionList.clear();
+ List<Object> revisionList = revision.getList(feature); // TODO lazy?
+ revisionList.clear();
- if (instanceValue != null)
+ if (instanceValue != null)
+ {
+ if (instanceValue instanceof InternalEList)
{
- if (instanceValue instanceof InternalEList)
+ InternalEList<?> instanceList = (InternalEList<?>)instanceValue;
+ if (!instanceList.isEmpty())
{
- InternalEList<?> instanceList = (InternalEList<?>)instanceValue;
- if (instanceList != null)
+ for (Iterator<?> it = instanceList.basicIterator(); it.hasNext();)
{
- for (Iterator<?> it = instanceList.basicIterator(); it.hasNext();)
+ Object instanceElement = it.next();
+ if (instanceElement != null && feature.isReference())
{
- Object instanceElement = it.next();
- if (instanceElement != null && feature.isReference())
- {
- instanceElement = view.convertObjectToID(instanceElement);
- }
-
- revisionList.add(instanceElement);
+ instanceElement = view.convertObjectToID(instanceElement);
}
+
+ revisionList.add(instanceElement);
}
}
- else
- {
- throw new ImplementationError("Not an InternalEList: " + instanceValue.getClass().getName());
- }
}
- }
- else
- {
- if (instanceValue != null && feature.isReference())
+ else
{
- instanceValue = view.convertObjectToID(instanceValue);
+ throw new ImplementationError("Not an InternalEList: " + instanceValue.getClass().getName());
}
-
- revision.setValue(feature, instanceValue);
}
}
+ else
+ {
+ if (instanceValue != null && feature.isReference())
+ {
+ instanceValue = view.convertObjectToID(instanceValue);
+ }
+
+ revision.setValue(feature, instanceValue);
+ }
}
- protected void transferRevisionToInstance()
+ private void revisionToInstance()
{
if (TRACER.isEnabled())
{
@@ -325,14 +312,14 @@ public abstract class CDOLegacyImpl extends CDOWrapperImpl implements Adapter.In
try
{
// Handle containment
- transferContainmentToInstance(view);
+ revisionToInstanceContainment(view);
// Handle values
+ CDOPackageRegistry packageRegistry = cdoView().getSession().getPackageRegistry();
CDOClass cdoClass = revision.getCDOClass();
- CDOFeature[] features = cdoClass.getAllFeatures();
- for (CDOFeature feature : features)
+ for (CDOFeature feature : cdoClass.getAllFeatures())
{
- transferFeatureToInstance(view, feature);
+ revisionToInstanceFeature(view, feature, packageRegistry);
}
}
finally
@@ -344,7 +331,7 @@ public abstract class CDOLegacyImpl extends CDOWrapperImpl implements Adapter.In
}
}
- protected void transferContainmentToInstance(CDOViewImpl view)
+ private void revisionToInstanceContainment(CDOViewImpl view)
{
// Not supported anymore
// Object containerID = revision.getContainerID();
@@ -362,41 +349,47 @@ public abstract class CDOLegacyImpl extends CDOWrapperImpl implements Adapter.In
// }
}
- public void transferResourceToInstance(Resource.Internal resource)
- {
- Method method = ReflectUtil.getMethod(BasicEObjectImpl.class, "eSetDirectResource", Resource.Internal.class);
-
- try
- {
- ReflectUtil.invokeMethod(method, instance, resource);
- }
- catch (InvocationTargetException ex)
- {
- throw WrappedException.wrap(ex);
- }
- }
+ // private void transferRevisionToInstanceResource(Resource.Internal resource)
+ // {
+ // Method method = ReflectUtil.getMethod(BasicEObjectImpl.class, "eSetDirectResource", Resource.Internal.class);
+ //
+ // try
+ // {
+ // ReflectUtil.invokeMethod(method, instance, resource);
+ // }
+ // catch (InvocationTargetException ex)
+ // {
+ // throw WrappedException.wrap(ex);
+ // }
+ // }
@SuppressWarnings("unchecked")
- protected void transferFeatureToInstance(CDOViewImpl view, CDOFeature feature)
+ private void revisionToInstanceFeature(CDOViewImpl view, CDOFeature feature, CDOPackageRegistry packageRegistry)
{
Object value = revision.getValue(feature);
if (feature.isMany())
{
- InternalEList<Object> instanceList = (InternalEList<Object>)getInstanceValue(instance, feature);
+ InternalEList<Object> instanceList = (InternalEList<Object>)getInstanceValue(instance, feature, packageRegistry);
if (instanceList != null)
{
clearEList(instanceList);
if (value != null)
{
List<?> revisionList = (List<?>)value;
- for (Object element : revisionList)
+ if (feature.isReference())
{
- if (feature.isReference())
+ for (Object element : revisionList)
{
- element = convertPotentialID(view, element);
+ element = getEObjectFromPotentialID(view, element);
+ instanceList.basicAdd(element, null);
+ }
+ }
+ else
+ {
+ for (Object element : revisionList)
+ {
+ instanceList.basicAdd(element, null);
}
-
- instanceList.basicAdd(element, null);
}
}
}
@@ -405,14 +398,14 @@ public abstract class CDOLegacyImpl extends CDOWrapperImpl implements Adapter.In
{
if (feature.isReference())
{
- value = convertPotentialID(view, value);
+ value = getEObjectFromPotentialID(view, value);
}
setInstanceValue(instance, feature, value);
}
}
- protected InternalEObject convertPotentialID(CDOViewImpl view, Object potentialID)
+ private InternalEObject getEObjectFromPotentialID(CDOViewImpl view, Object potentialID)
{
if (potentialID instanceof CDOID)
{
@@ -422,7 +415,7 @@ public abstract class CDOLegacyImpl extends CDOWrapperImpl implements Adapter.In
return null;
}
- potentialID = view.getObject(id, false);
+ potentialID = createProxy(view, id);
}
if (potentialID instanceof InternalCDOObject)
@@ -438,13 +431,18 @@ public abstract class CDOLegacyImpl extends CDOWrapperImpl implements Adapter.In
throw new ImplementationError();
}
- protected Object getInstanceValue(InternalEObject instance, CDOFeature feature)
+ private InternalCDOObject createProxy(CDOViewImpl view, CDOID id)
+ {
+ return view.getObject(id, false);
+ }
+
+ private Object getInstanceValue(InternalEObject instance, CDOFeature feature, CDOPackageRegistry packageRegistry)
{
- EStructuralFeature eFeature = ModelUtil.getEFeature(feature, cdoView().getSession().getPackageRegistry());
+ EStructuralFeature eFeature = ModelUtil.getEFeature(feature, packageRegistry);
return instance.eGet(eFeature);
}
- protected void setInstanceValue(InternalEObject instance, CDOFeature feature, Object value)
+ private void setInstanceValue(InternalEObject instance, CDOFeature feature, Object value)
{
// TODO Don't use Java reflection
Class<?> instanceClass = instance.getClass();
@@ -508,7 +506,7 @@ public abstract class CDOLegacyImpl extends CDOWrapperImpl implements Adapter.In
ReflectUtil.setValue(field, instance, value);
}
- protected void adjustEProxy()
+ private void adjustEProxy()
{
// Setting eProxyURI is necessary to prevent content adapters from
// loading the whole content tree.
@@ -540,7 +538,7 @@ public abstract class CDOLegacyImpl extends CDOWrapperImpl implements Adapter.In
}
}
- protected void clearEList(InternalEList<Object> list)
+ private void clearEList(InternalEList<Object> list)
{
while (!list.isEmpty())
{
@@ -549,7 +547,7 @@ public abstract class CDOLegacyImpl extends CDOWrapperImpl implements Adapter.In
}
}
- protected static int getEFlagMask(Class<?> instanceClass, String flagName)
+ private static int getEFlagMask(Class<?> instanceClass, String flagName)
{
Field field = ReflectUtil.getField(instanceClass, flagName);
if (!field.isAccessible())
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOMetaImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOMetaWrapper.java
index 4cef61cd57..228bcc93d6 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOMetaImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOMetaWrapper.java
@@ -20,10 +20,11 @@ import org.eclipse.emf.ecore.InternalEObject;
/**
* @author Eike Stepper
+ * @since 2.0
*/
-public class CDOMetaImpl extends CDOWrapperImpl
+public class CDOMetaWrapper extends CDOObjectWrapper
{
- public CDOMetaImpl(CDOViewImpl view, InternalEObject instance, CDOID id)
+ public CDOMetaWrapper(CDOViewImpl view, InternalEObject instance, CDOID id)
{
this.view = view;
this.instance = instance;
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 71fa09a4ab..257c0bbcd2 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
@@ -36,6 +36,7 @@ import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
+import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.BasicEMap;
import org.eclipse.emf.common.util.ECollections;
import org.eclipse.emf.common.util.EList;
@@ -231,9 +232,10 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
}
}
- if (eBasicAdapters() != null)
+ BasicEList<Adapter> adapters = eBasicAdapters();
+ if (adapters != null)
{
- for (Adapter adapter : eBasicAdapters())
+ for (Adapter adapter : adapters)
{
view.subscribe(this, adapter);
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOWrapperImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectWrapper.java
index 3c324a14e0..2f962b1ae2 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOWrapperImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectWrapper.java
@@ -33,10 +33,11 @@ import org.eclipse.emf.ecore.resource.Resource;
/**
* @author Eike Stepper
+ * @since 2.0
*/
-public abstract class CDOWrapperImpl implements InternalCDOObject
+public abstract class CDOObjectWrapper implements InternalCDOObject
{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_OBJECT, CDOWrapperImpl.class);
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_OBJECT, CDOObjectWrapper.class);
protected CDOID id;
@@ -44,7 +45,7 @@ public abstract class CDOWrapperImpl implements InternalCDOObject
protected InternalEObject instance;
- public CDOWrapperImpl()
+ public CDOObjectWrapper()
{
super();
}
@@ -95,6 +96,38 @@ public abstract class CDOWrapperImpl implements InternalCDOObject
throw new UnsupportedOperationException("Not yet implemented");
}
+ /**
+ * @since 2.0
+ */
+ public void eFireRead(int featureID)
+ {
+ // Do nothing
+ }
+
+ /**
+ * @since 2.0
+ */
+ public void eFireWrite(int featureID)
+ {
+ // Do nothing
+ }
+
+ /**
+ * @since 2.0
+ */
+ public EList<EReadListener> eReadListeners()
+ {
+ return instance.eReadListeners();
+ }
+
+ /**
+ * @since 2.0
+ */
+ public EList<EWriteListener> eWriteListeners()
+ {
+ return instance.eWriteListeners();
+ }
+
public EList<Adapter> eAdapters()
{
return instance.eAdapters();
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
index df5941873e..684a3b6180 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
@@ -38,7 +38,6 @@ import org.eclipse.emf.cdo.common.util.TransportException;
import org.eclipse.emf.cdo.spi.common.InternalCDORevision;
import org.eclipse.emf.cdo.util.CDOPackageRegistry;
import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.cdo.util.LegacySystemNotAvailableException;
import org.eclipse.emf.internal.cdo.bundle.OM;
import org.eclipse.emf.internal.cdo.protocol.LoadLibrariesRequest;
@@ -49,7 +48,6 @@ import org.eclipse.emf.internal.cdo.protocol.QueryObjectTypesRequest;
import org.eclipse.emf.internal.cdo.protocol.SyncRevisionRequest;
import org.eclipse.emf.internal.cdo.protocol.ViewsChangedRequest;
import org.eclipse.emf.internal.cdo.util.CDOPackageRegistryImpl;
-import org.eclipse.emf.internal.cdo.util.FSMUtil;
import org.eclipse.emf.internal.cdo.util.ModelUtil;
import org.eclipse.net4j.channel.IChannel;
@@ -205,13 +203,6 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD
public void setLegacySupportEnabled(boolean legacySupportEnabled)
{
checkInactive();
- // TODO Adjust this when legacy system is working again:
- // if (legacySupportEnabled && !FSMUtil.isLegacySystemAvailable())
- if (legacySupportEnabled)
- {
- throw new LegacySystemNotAvailableException();
- }
-
this.legacySupportEnabled = legacySupportEnabled;
}
@@ -734,11 +725,6 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD
protected void doBeforeActivate() throws Exception
{
super.doBeforeActivate();
- if (legacySupportEnabled && !FSMUtil.isLegacySystemAvailable())
- {
- throw new LegacySystemNotAvailableException();
- }
-
if (channel == null && connector == null)
{
throw new IllegalStateException("channel == null && connector == null");
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java
index c9f4d856aa..97abdaa6a1 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java
@@ -446,11 +446,11 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
object.cdoInternalPostAttach();
changeState(object, CDOState.NEW);
- List<InternalCDOObject> contents = mapOfContents.get(object);
-
// Prepare content tree
+ List<InternalCDOObject> contents = mapOfContents.get(object);
for (InternalCDOObject content : contents)
{
+ // TODO Just call execute()?!
INSTANCE.process(content, CDOEvent.ATTACH, mapOfContents);
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java
index 434592b23f..4bccdd934d 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java
@@ -636,11 +636,11 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
if (object instanceof CDOResourceImpl)
{
- register(lastSavepoint.getNewResources(), object);
+ registerNew(lastSavepoint.getNewResources(), object);
}
else
{
- register(lastSavepoint.getNewObjects(), object);
+ registerNew(lastSavepoint.getNewObjects(), object);
}
}
@@ -696,11 +696,11 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
}
registerFeatureDelta(object, featureDelta);
- register(lastSavepoint.getDirtyObjects(), object);
+ registerNew(lastSavepoint.getDirtyObjects(), object);
}
@SuppressWarnings("unchecked")
- private void register(Map map, InternalCDOObject object)
+ private void registerNew(Map map, InternalCDOObject object)
{
Object old = map.put(object.cdoID(), object);
if (old != null)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
index 1720de7c9b..e28445a148 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
@@ -419,7 +419,7 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement
}
else
{
- if (loadOnDemand)
+ if (!loadOnDemand)
{
localLookupObject = createObject(id);
}
@@ -501,7 +501,7 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement
throw new ImplementationError("No metaInstance for " + id);
}
- return new CDOMetaImpl(this, metaInstance, id);
+ return new CDOMetaWrapper(this, metaInstance, id);
}
/**
@@ -524,18 +524,6 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement
/**
* @since 2.0
*/
- public void registerProxyResource(CDOResourceImpl resource)
- {
- resource.cdoInternalSetResource(resource);
- resource.cdoInternalSetView(this);
- resource.cdoInternalSetID(getResourceID(resource.getPath()));
- resource.cdoInternalSetState(CDOState.PROXY);
- registerObject(resource);
- }
-
- /**
- * @since 2.0
- */
protected void cleanObject(InternalCDOObject object, InternalCDORevision revision)
{
if (object instanceof CDOResourceImpl)
@@ -647,16 +635,10 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement
if (potentialObject instanceof InternalEObject && !(potentialObject instanceof InternalCDOObject))
{
InternalEObject eObject = (InternalEObject)potentialObject;
-
- // Only adapt object that are already adapted.
- // We do not want to create a attach without goign through the normal process.
- if (EcoreUtil.getAdapter(eObject.eAdapters(), CDOAdapterImpl.class) != null)
+ CDOLegacyWrapper legacyListener = FSMUtil.getLegacyWrapper(eObject.eReadListeners());
+ if (legacyListener != null)
{
- InternalCDOObject adapter = FSMUtil.adapt(eObject, this);
- if (adapter != null)
- {
- potentialObject = adapter;
- }
+ potentialObject = legacyListener;
}
}
@@ -700,6 +682,18 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement
return potentialID;
}
+ /**
+ * @since 2.0
+ */
+ public void registerProxyResource(CDOResourceImpl resource)
+ {
+ resource.cdoInternalSetResource(resource);
+ resource.cdoInternalSetView(this);
+ resource.cdoInternalSetID(getResourceID(resource.getPath()));
+ resource.cdoInternalSetState(CDOState.PROXY);
+ registerObject(resource);
+ }
+
public void registerObject(InternalCDOObject object)
{
if (TRACER.isEnabled())
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageTypeRegistryImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageTypeRegistryImpl.java
index ebf97c3f1e..cc452c6b79 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageTypeRegistryImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageTypeRegistryImpl.java
@@ -14,8 +14,8 @@ import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.eresource.EresourcePackage;
import org.eclipse.emf.cdo.util.CDOPackageType;
import org.eclipse.emf.cdo.util.CDOPackageTypeRegistry;
-import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.internal.cdo.CDOObjectImpl;
import org.eclipse.emf.internal.cdo.bundle.OM;
import org.eclipse.net4j.util.StringUtil;
@@ -38,7 +38,6 @@ import org.eclipse.core.runtime.dynamichelpers.IExtensionTracker;
import org.eclipse.core.runtime.dynamichelpers.IFilter;
import org.osgi.framework.Bundle;
-import org.osgi.framework.Constants;
import java.util.HashMap;
import java.util.Map;
@@ -68,6 +67,7 @@ public final class CDOPackageTypeRegistryImpl extends HashMapRegistry<String, CD
if (ePackage.getClass() == EPackageImpl.class)
{
// Dynamic packages can be considered native
+ // TODO Check EFactory type!
return CDOPackageType.NATIVE;
}
@@ -78,21 +78,13 @@ public final class CDOPackageTypeRegistryImpl extends HashMapRegistry<String, CD
throw new IllegalArgumentException("ePackage does not contain classes");
}
- try
- {
- if (isConverted(eClass))
- {
- return CDOPackageType.CONVERTED;
- }
- }
- catch (Throwable ignore)
+ Class<?> instanceClass = eClass.getInstanceClass();
+ if (CDOObject.class.isAssignableFrom(instanceClass))
{
- // Legacy system might not be available
+ return CDOPackageType.NATIVE;
}
- // TODO This might not work if the model interface don't extend CDOObject
- Class<?> instanceClass = eClass.getInstanceClass();
- if (CDOObject.class.isAssignableFrom(instanceClass))
+ if (CDOObjectImpl.class.isAssignableFrom(instanceClass))
{
return CDOPackageType.NATIVE;
}
@@ -115,11 +107,6 @@ public final class CDOPackageTypeRegistryImpl extends HashMapRegistry<String, CD
put(uri, CDOPackageType.NATIVE);
}
- public void registerConverted(String uri)
- {
- put(uri, CDOPackageType.CONVERTED);
- }
-
@Override
protected void doActivate() throws Exception
{
@@ -191,18 +178,8 @@ public final class CDOPackageTypeRegistryImpl extends HashMapRegistry<String, CD
{
return CDOPackageType.NATIVE;
}
- else
- {
- String version = (String)bundle.getHeaders().get(Constants.BUNDLE_VERSION);
- if (version.endsWith(CDOUtil.CDO_VERSION_SUFFIX))
- {
- return CDOPackageType.CONVERTED;
- }
- else
- {
- return CDOPackageType.LEGACY;
- }
- }
+
+ return CDOPackageType.LEGACY;
}
private EClass getAnyEClass(EPackage ePackage)
@@ -227,12 +204,6 @@ public final class CDOPackageTypeRegistryImpl extends HashMapRegistry<String, CD
return null;
}
- private boolean isConverted(EClass eClass)
- {
- Class<?> instanceClass = eClass.getInstanceClass();
- return org.eclipse.emf.ecore.impl.CDOAware.class.isAssignableFrom(instanceClass);
- }
-
private void connectExtensionTracker()
{
ExtensionTracker extensionTracker = new ExtensionTracker();
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java
index b55a0a6215..beb0440480 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java
@@ -12,20 +12,15 @@
package org.eclipse.emf.internal.cdo.util;
import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.CDOSession;
import org.eclipse.emf.cdo.CDOState;
import org.eclipse.emf.cdo.CDOView;
import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.util.LegacySystemNotAvailableException;
-import org.eclipse.emf.internal.cdo.CDOAdapterImpl;
-import org.eclipse.emf.internal.cdo.CDOLegacyImpl;
-import org.eclipse.emf.internal.cdo.CDOMetaImpl;
+import org.eclipse.emf.internal.cdo.CDOLegacyWrapper;
+import org.eclipse.emf.internal.cdo.CDOMetaWrapper;
import org.eclipse.emf.internal.cdo.CDOViewImpl;
import org.eclipse.emf.internal.cdo.InternalCDOObject;
-import org.eclipse.emf.internal.cdo.bundle.OM;
-import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EGenericType;
import org.eclipse.emf.ecore.EModelElement;
@@ -34,7 +29,6 @@ import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.util.EcoreUtil;
-import java.lang.reflect.Method;
import java.util.Collection;
import java.util.Iterator;
@@ -43,52 +37,10 @@ import java.util.Iterator;
*/
public final class FSMUtil
{
- private static Method adaptLegacyMethod = initAdaptLegacyMethod();
-
private FSMUtil()
{
}
- private static Method initAdaptLegacyMethod()
- {
- // TODO Fix when legacy mode is supported again...
- // try
- // {
- // Class<?> c = Class.forName("org.eclipse.emf.internal.cdo.CDOCallbackImpl");
- // if (c != null)
- // {
- // final Class<?>[] params = { Object.class, CDOView.class };
- // Method method = c.getDeclaredMethod("adapt", params);
- // if (method != null)
- // {
- // return method;
- // }
- // }
- // }
- // catch (Throwable ignore)
- // {
- // // Only for testing:
- // // ignore.printStackTrace();
- // }
- //
- // OM.LOG.info(LegacySystemNotAvailableException.LEGACY_SYSTEM_NOT_AVAILABLE);
- return null;
- }
-
- public static boolean isLegacySystemAvailable()
- {
- return adaptLegacyMethod != null;
- }
-
- public static void checkLegacySystemAvailability(CDOSession session, CDOObject object)
- throws LegacySystemNotAvailableException
- {
- if (!session.isLegacySupportEnabled() && object instanceof CDOLegacyImpl)
- {
- throw new LegacySystemNotAvailableException();
- }
- }
-
public static boolean isTransient(CDOObject object)
{
CDOState state = object.cdoState();
@@ -101,6 +53,12 @@ public final class FSMUtil
return state == CDOState.NEW;
}
+ public static boolean isMeta(Object object)
+ {
+ return object instanceof EModelElement || object instanceof EGenericType
+ || object instanceof org.eclipse.emf.ecore.impl.EStringToStringMapEntryImpl;
+ }
+
/**
* @param view
* Only needed if object is a meta instance.
@@ -117,50 +75,63 @@ public final class FSMUtil
throw new IllegalArgumentException("object == null");
}
- if (object instanceof EModelElement || object instanceof EGenericType
- || object instanceof org.eclipse.emf.ecore.impl.EStringToStringMapEntryImpl)
+ if (isMeta(object))
{
- InternalEObject eObject = (InternalEObject)object;
- if (view == null)
- {
- throw new IllegalArgumentException("view == null");
- }
+ return adaptMeta((InternalEObject)object, view);
+ }
- if (eObject.eIsProxy())
- {
- eObject = (InternalEObject)EcoreUtil.resolve(eObject, view.getResourceSet());
- }
+ if (object instanceof InternalEObject)
+ {
+ return adaptLegacy((InternalEObject)object);
+ }
- CDOID id = ((CDOViewImpl)view).getSession().lookupMetaInstanceID(eObject);
- if (id != null)
- {
- return new CDOMetaImpl((CDOViewImpl)view, eObject, id);
- }
+ return null;
+ }
+
+ public static InternalCDOObject adaptMeta(InternalEObject object, CDOView view)
+ {
+ if (view == null)
+ {
+ throw new IllegalArgumentException("view == null");
}
- if (isLegacySystemAvailable())
+ if (object.eIsProxy())
{
- try
- {
- return (InternalCDOObject)adaptLegacyMethod.invoke(null, object, view);
- }
- catch (Throwable t)
- {
- OM.LOG.info(t);
- }
+ object = (InternalEObject)EcoreUtil.resolve(object, view.getResourceSet());
}
- if (object instanceof InternalEObject)
+ CDOID id = ((CDOViewImpl)view).getSession().lookupMetaInstanceID(object);
+ if (id != null)
{
- EList<Adapter> adapters = ((InternalEObject)object).eAdapters();
- CDOAdapterImpl adapter = (CDOAdapterImpl)EcoreUtil.getAdapter(adapters, CDOAdapterImpl.class);
- if (adapter == null)
+ return new CDOMetaWrapper((CDOViewImpl)view, object, id);
+ }
+
+ return null;
+ }
+
+ public static InternalCDOObject adaptLegacy(InternalEObject object)
+ {
+ EList<InternalEObject.EReadListener> readListeners = object.eReadListeners();
+ CDOLegacyWrapper wrapper = getLegacyWrapper(readListeners);
+ if (wrapper == null)
+ {
+ wrapper = new CDOLegacyWrapper(object);
+ // TODO Only Load/Attach transitions should actually *add* the wrappers!
+ readListeners.add(0, wrapper);
+ object.eWriteListeners().add(0, wrapper);
+ }
+
+ return wrapper;
+ }
+
+ public static CDOLegacyWrapper getLegacyWrapper(EList<?> listeners)
+ {
+ for (Object listener : listeners)
+ {
+ if (listener.getClass() == CDOLegacyWrapper.class)
{
- adapter = new CDOAdapterImpl();
- adapters.add(adapter);
+ return (CDOLegacyWrapper)listener;
}
-
- return adapter;
}
return null;

Back to the top