summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-05-10 05:17:38 (EDT)
committerEike Stepper2008-05-10 05:17:38 (EDT)
commitf809c3205b043ae0ecef47fd82f10ca58ffe5f62 (patch)
tree32e05a3a0eeece30b9f89daf5625afce8981b495
parente9c80d5f548c8b901f1eda689b4ac71a173f516b (diff)
downloadcdo-f809c3205b043ae0ecef47fd82f10ca58ffe5f62.zip
cdo-f809c3205b043ae0ecef47fd82f10ca58ffe5f62.tar.gz
cdo-f809c3205b043ae0ecef47fd82f10ca58ffe5f62.tar.bz2
[230066] Implement a demand-populating EPackageRegistry
https://bugs.eclipse.org/bugs/show_bug.cgi?id=230066
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ImportXML.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/NoLegacyTest.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java39
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TransactionDeadLockTest.java10
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSessionConfiguration.java8
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java12
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionConfigurationImpl.java23
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageRegistryImpl.java3
9 files changed, 85 insertions, 16 deletions
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 ddff4cd..c2da540 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
@@ -84,7 +84,7 @@ public abstract class AbstractCDOTest extends AbstractTransportTest
CDOSessionConfiguration configuration = CDOUtil.createSessionConfiguration();
configuration.setConnector(getConnector());
configuration.setRepositoryName(REPOSITORY_NAME);
- configuration.setDisableLegacyObjects(true);
+ configuration.setLegacySupportEnabled(false);
return configuration.openSession();
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ImportXML.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ImportXML.java
index 5c62af1..71bcd3d 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ImportXML.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ImportXML.java
@@ -115,7 +115,7 @@ public class ImportXML
CDOSessionConfiguration configuration = CDOUtil.createSessionConfiguration();
configuration.setConnector(connector);
configuration.setRepositoryName(REPOSITORY_NAME);
- configuration.setDisableLegacyObjects(true);
+ configuration.setLegacySupportEnabled(false);
return configuration.openSession();
}
}
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
index d9cdf8f..8af2feb 100644
--- 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
@@ -35,7 +35,7 @@ public class NoLegacyTest extends AbstractCDOTest
CDOSessionConfiguration configuration = CDOUtil.createSessionConfiguration();
configuration.setConnector(getConnector());
configuration.setRepositoryName(REPOSITORY_NAME);
- configuration.setDisableLegacyObjects(false);
+ configuration.setLegacySupportEnabled(true);
session = configuration.openSession();
fail("LegacySystemNotAvailableException expected");
}
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 6b0a31f..905e1f8 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
@@ -35,8 +35,6 @@ import org.eclipse.emf.cdo.tests.model3.subpackage.SubpackagePackage;
import org.eclipse.emf.cdo.util.CDOPackageTypeRegistry;
import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.internal.cdo.util.CDOPackageRegistryImpl;
-
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EClass;
@@ -243,8 +241,41 @@ public class PackageRegistryTest extends AbstractCDOTest
CDOSessionConfiguration configuration = CDOUtil.createSessionConfiguration();
configuration.setConnector(getConnector());
configuration.setRepositoryName(REPOSITORY_NAME);
- configuration.setDisableLegacyObjects(true);
- configuration.setPackageRegistry(new CDOPackageRegistryImpl.SelfPopulating());
+ configuration.setLegacySupportEnabled(false);
+ configuration.setSelfPopulatingPackageRegistry();
+
+ CDOSession session = configuration.openSession();
+ 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 = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.getResource("/res");
+
+ Company company = (Company)res.getContents().get(0);
+ assertEquals("Eike", company.getName());
+ }
+ }
+
+ public void testDemandPopulating() throws Exception
+ {
+ CDOPackageTypeRegistry.INSTANCE.register(Model1Package.eINSTANCE);
+
+ {
+ // Create resource in session 1
+ CDOSessionConfiguration configuration = CDOUtil.createSessionConfiguration();
+ configuration.setConnector(getConnector());
+ configuration.setRepositoryName(REPOSITORY_NAME);
+ configuration.setLegacySupportEnabled(false);
+ configuration.setDemandPopulatingPackageRegistry();
CDOSession session = configuration.openSession();
CDOTransaction transaction = session.openTransaction();
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TransactionDeadLockTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TransactionDeadLockTest.java
index 0978163..be96533 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TransactionDeadLockTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/TransactionDeadLockTest.java
@@ -39,6 +39,16 @@ public class TransactionDeadLockTest extends AbstractCDOTest
return false;
}
+ public void _testHundredTimes() throws Exception
+ {
+ for (int i = 0; i < 100; i++)
+ {
+ testCreateManySession();
+ testCreateManyTransaction();
+ testCreateManySessionTransactionMultiThread();
+ }
+ }
+
public void testCreateManySession() throws Exception
{
{
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSessionConfiguration.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSessionConfiguration.java
index e123472..9355b46 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSessionConfiguration.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSessionConfiguration.java
@@ -28,9 +28,9 @@ public interface CDOSessionConfiguration
public void setRepositoryName(String repositoryName);
- public boolean isDisableLegacyObjects();
+ public boolean isLegacySupportEnabled();
- public void setDisableLegacyObjects(boolean disableLegacyObjects);
+ public void setLegacySupportEnabled(boolean enabled);
public IFailOverStrategy getFailOverStrategy();
@@ -40,6 +40,10 @@ public interface CDOSessionConfiguration
public void setPackageRegistry(CDOPackageRegistryImpl packageRegistry);
+ public void setSelfPopulatingPackageRegistry();
+
+ public void setDemandPopulatingPackageRegistry();
+
public CDOSession openSession();
public boolean isSessionOpen();
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 fb71873..87a7cd6 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
@@ -24,7 +24,9 @@ import org.eclipse.emf.internal.cdo.CDOViewImpl;
import org.eclipse.emf.internal.cdo.InternalCDOObject;
import org.eclipse.emf.internal.cdo.LegacyObjectDisabler;
import org.eclipse.emf.internal.cdo.protocol.CDOClientProtocolFactory;
+import org.eclipse.emf.internal.cdo.util.CDOPackageRegistryImpl;
import org.eclipse.emf.internal.cdo.util.FSMUtil;
+import org.eclipse.emf.internal.cdo.util.CDOPackageRegistryImpl.SelfPopulating;
import org.eclipse.net4j.connector.ConnectorException;
import org.eclipse.net4j.connector.IConnector;
@@ -63,6 +65,16 @@ public final class CDOUtil
return new CDOSessionConfigurationImpl();
}
+ public static SelfPopulating createSelfPopulatingPackageRegistry()
+ {
+ return new CDOPackageRegistryImpl.SelfPopulating();
+ }
+
+ public static CDOPackageRegistryImpl createDemandPopulatingPackageRegistry()
+ {
+ return new CDOPackageRegistryImpl.DemandPopulating();
+ }
+
/**
* @deprecated Use {@link #createSessionConfiguration()} instead.
*/
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionConfigurationImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionConfigurationImpl.java
index a94614a..82c3333 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionConfigurationImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionConfigurationImpl.java
@@ -12,6 +12,7 @@ package org.eclipse.emf.internal.cdo;
import org.eclipse.emf.cdo.CDOSession;
import org.eclipse.emf.cdo.CDOSessionConfiguration;
+import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.internal.cdo.util.CDOPackageRegistryImpl;
@@ -29,7 +30,7 @@ public class CDOSessionConfigurationImpl implements CDOSessionConfiguration
private String repositoryName;
- private boolean disableLegacyObjects;
+ private boolean legacySupportEnabled;
private IFailOverStrategy failOverStrategy;
@@ -59,14 +60,14 @@ public class CDOSessionConfigurationImpl implements CDOSessionConfiguration
this.repositoryName = repositoryName;
}
- public boolean isDisableLegacyObjects()
+ public boolean isLegacySupportEnabled()
{
- return disableLegacyObjects;
+ return legacySupportEnabled;
}
- public void setDisableLegacyObjects(boolean disableLegacyObjects)
+ public void setLegacySupportEnabled(boolean legacySupportEnabled)
{
- this.disableLegacyObjects = disableLegacyObjects;
+ this.legacySupportEnabled = legacySupportEnabled;
}
public IFailOverStrategy getFailOverStrategy()
@@ -89,6 +90,16 @@ public class CDOSessionConfigurationImpl implements CDOSessionConfiguration
this.packageRegistry = packageRegistry;
}
+ public void setSelfPopulatingPackageRegistry()
+ {
+ setPackageRegistry(CDOUtil.createSelfPopulatingPackageRegistry());
+ }
+
+ public void setDemandPopulatingPackageRegistry()
+ {
+ setPackageRegistry(CDOUtil.createDemandPopulatingPackageRegistry());
+ }
+
public CDOSession openSession()
{
if (!isSessionOpen())
@@ -96,7 +107,7 @@ public class CDOSessionConfigurationImpl implements CDOSessionConfiguration
session = new CDOSessionImpl();
session.setConnector(connector);
session.setRepositoryName(repositoryName);
- session.setDisableLegacyObjects(disableLegacyObjects);
+ session.setDisableLegacyObjects(!legacySupportEnabled);
session.setFailOverStrategy(failOverStrategy);
session.setPackageRegistry(packageRegistry);
session.activate();
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageRegistryImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageRegistryImpl.java
index 94e0dfa..f1c4ea0 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageRegistryImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageRegistryImpl.java
@@ -133,7 +133,8 @@ public class CDOPackageRegistryImpl extends EPackageRegistryImpl implements CDOP
EPackage ePackage = (EPackage)value;
CDOPackage cdoPackage = ModelUtil.getCDOPackage(ePackage, session.getPackageManager());
- ((InternalCDOPackage)cdoPackage).setPersistent(!cdoPackage.getTopLevelPackage().getMetaIDRange().isTemporary());
+ CDOIDMetaRange metaIDRange = cdoPackage.getTopLevelPackage().getMetaIDRange();
+ ((InternalCDOPackage)cdoPackage).setPersistent(metaIDRange != null && !metaIDRange.isTemporary());
}
return super.put(key, value);