summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-05-03 04:25:21 (EDT)
committerEike Stepper2008-05-03 04:25:21 (EDT)
commit88292f9084a9b2e3b225ffd1f8ce612ad26b4222 (patch)
tree13c4e12737550dbeea8503d07f2b79a14b7adea9
parente5f953d99a359f18fff54aaedaad3c4eaf598fc7 (diff)
downloadcdo-88292f9084a9b2e3b225ffd1f8ce612ad26b4222.zip
cdo-88292f9084a9b2e3b225ffd1f8ce612ad26b4222.tar.gz
cdo-88292f9084a9b2e3b225ffd1f8ce612ad26b4222.tar.bz2
[227995] Implement a self-populating EPackageRegistry
https://bugs.eclipse.org/bugs/show_bug.cgi?id=227995
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java25
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageTypeRegistryImpl.java27
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 d1d2053..87b59c5 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 58fb786..1ffba00 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);
}