diff options
author | Eike Stepper | 2008-05-03 08:25:21 +0000 |
---|---|---|
committer | Eike Stepper | 2008-05-03 08:25:21 +0000 |
commit | 88292f9084a9b2e3b225ffd1f8ce612ad26b4222 (patch) | |
tree | 13c4e12737550dbeea8503d07f2b79a14b7adea9 /plugins | |
parent | e5f953d99a359f18fff54aaedaad3c4eaf598fc7 (diff) | |
download | cdo-88292f9084a9b2e3b225ffd1f8ce612ad26b4222.tar.gz cdo-88292f9084a9b2e3b225ffd1f8ce612ad26b4222.tar.xz cdo-88292f9084a9b2e3b225ffd1f8ce612ad26b4222.zip |
[227995] Implement a self-populating EPackageRegistry
https://bugs.eclipse.org/bugs/show_bug.cgi?id=227995
Diffstat (limited to 'plugins')
2 files changed, 41 insertions, 11 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java index d1d205393c..87b59c5757 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java @@ -232,6 +232,31 @@ public class PackageRegistryTest extends AbstractCDOTest } } + public void testSelfPopulating() throws Exception + { + { + // Create resource in session 1 + CDOSession session = CDOUtil.openSession(getConnector(), REPOSITORY_NAME, true, true); + CDOTransaction transaction = session.openTransaction(); + CDOResource res = transaction.createResource("/res"); + + Company company = Model1Factory.eINSTANCE.createCompany(); + company.setName("Eike"); + res.getContents().add(company); + transaction.commit(); + } + + { + // Load resource in session 2 + CDOSession session = CDOUtil.openSession(getConnector(), REPOSITORY_NAME); + CDOTransaction transaction = session.openTransaction(); + CDOResource res = transaction.getResource("/res"); + + Company company = (Company)res.getContents().get(0); + assertEquals("Eike", company.getName()); + } + } + /** * TODO Fix testDynamicPackage() */ 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 58fb786769..1ffba00fef 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 @@ -46,10 +46,17 @@ public final class CDOPackageTypeRegistryImpl extends HashMapRegistry<String, CD { public static final CDOPackageTypeRegistryImpl INSTANCE = new CDOPackageTypeRegistryImpl(); + private static final String ECORE_ID = "org.eclipse.emf.ecore"; + private Object extensionTracker; private CDOPackageTypeRegistryImpl() { + if (!OMPlatform.INSTANCE.isOSGiRunning()) + { + throw new IllegalStateException("OSGi is not running"); + } + initPackageTypes(); } @@ -57,16 +64,14 @@ public final class CDOPackageTypeRegistryImpl extends HashMapRegistry<String, CD protected void doActivate() throws Exception { super.doActivate(); - if (OMPlatform.INSTANCE.isOSGiRunning()) + + try { - try - { - connectExtensionTracker(); - } - catch (Throwable t) - { - OM.LOG.error(t); - } + connectExtensionTracker(); + } + catch (Throwable t) + { + OM.LOG.error(t); } } @@ -90,8 +95,8 @@ public final class CDOPackageTypeRegistryImpl extends HashMapRegistry<String, CD private void initPackageTypes() { - IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor( - EcorePlugin.getPlugin().getBundle().getSymbolicName(), EcorePlugin.GENERATED_PACKAGE_PPID); + IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(ECORE_ID, + EcorePlugin.GENERATED_PACKAGE_PPID); addPackageTypes(elements); } |