summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-05-10 05:26:28 (EDT)
committerEike Stepper2008-05-10 05:26:28 (EDT)
commit33a6cefe68cbf1478594dadce83ff527c55bc530 (patch)
tree3d2f4b30fbd76246db72bb6b54759e095d023831
parentf809c3205b043ae0ecef47fd82f10ca58ffe5f62 (diff)
downloadcdo-33a6cefe68cbf1478594dadce83ff527c55bc530.zip
cdo-33a6cefe68cbf1478594dadce83ff527c55bc530.tar.gz
cdo-33a6cefe68cbf1478594dadce83ff527c55bc530.tar.bz2
[231419] Provide more flexible creation of CDOSession
https://bugs.eclipse.org/bugs/show_bug.cgi?id=231419
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java58
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionConfigurationImpl.java32
2 files changed, 31 insertions, 59 deletions
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 87a7cd6..f482fdd 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
@@ -10,15 +10,12 @@
**************************************************************************/
package org.eclipse.emf.cdo.util;
-import org.eclipse.emf.cdo.CDOSession;
import org.eclipse.emf.cdo.CDOSessionConfiguration;
import org.eclipse.emf.cdo.CDOView;
import org.eclipse.emf.cdo.eresource.CDOResourceFactory;
import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
import org.eclipse.emf.internal.cdo.CDOSessionConfigurationImpl;
-import org.eclipse.emf.internal.cdo.CDOSessionFactory;
-import org.eclipse.emf.internal.cdo.CDOSessionImpl;
import org.eclipse.emf.internal.cdo.CDOStateMachine;
import org.eclipse.emf.internal.cdo.CDOViewImpl;
import org.eclipse.emf.internal.cdo.InternalCDOObject;
@@ -28,9 +25,6 @@ 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;
-import org.eclipse.net4j.signal.failover.IFailOverStrategy;
import org.eclipse.net4j.util.container.IManagedContainer;
import org.eclipse.emf.common.notify.Adapter;
@@ -75,58 +69,6 @@ public final class CDOUtil
return new CDOPackageRegistryImpl.DemandPopulating();
}
- /**
- * @deprecated Use {@link #createSessionConfiguration()} instead.
- */
- @Deprecated
- public static CDOSession openSession(IConnector connector, String repositoryName, boolean disableLegacyObjects,
- boolean automaticPackageRegistry, IFailOverStrategy failOverStrategy) throws ConnectorException
- {
- CDOSessionImpl session = CDOSessionFactory.createSession(repositoryName, disableLegacyObjects,
- automaticPackageRegistry, failOverStrategy);
- session.setConnector(connector);
- session.activate();
- return session;
- }
-
- /**
- * @deprecated Use {@link #createSessionConfiguration()} instead.
- */
- @Deprecated
- public static CDOSession openSession(IConnector connector, String repositoryName, boolean disableLegacyObjects,
- boolean automaticPackageRegistry) throws ConnectorException
- {
- return openSession(connector, repositoryName, disableLegacyObjects, automaticPackageRegistry, null);
- }
-
- /**
- * @deprecated Use {@link #createSessionConfiguration()} instead.
- */
- @Deprecated
- public static CDOSession openSession(IConnector connector, String repositoryName, boolean disableLegacyObjects)
- throws ConnectorException
- {
- return openSession(connector, repositoryName, disableLegacyObjects, false, null);
- }
-
- /**
- * @deprecated Use {@link #createSessionConfiguration()} instead.
- */
- @Deprecated
- public static CDOSession openSession(IConnector connector, String repositoryName) throws ConnectorException
- {
- return openSession(connector, repositoryName, true);
- }
-
- /**
- * @deprecated Use {@link #createSessionConfiguration()} instead.
- */
- @Deprecated
- public static CDOSession openSession(IManagedContainer container, String description) throws ConnectorException
- {
- return CDOSessionFactory.get(container, description);
- }
-
public static CDOView getView(ResourceSet resourceSet)
{
EList<Adapter> adapters = resourceSet.eAdapters();
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 82c3333..fb43580 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
@@ -36,6 +36,8 @@ public class CDOSessionConfigurationImpl implements CDOSessionConfiguration
private CDOPackageRegistryImpl packageRegistry;
+ private boolean activateOnOpen = true;
+
public CDOSessionConfigurationImpl()
{
}
@@ -47,6 +49,7 @@ public class CDOSessionConfigurationImpl implements CDOSessionConfiguration
public void setConnector(IConnector connector)
{
+ checkNotOpen();
this.connector = connector;
}
@@ -57,6 +60,7 @@ public class CDOSessionConfigurationImpl implements CDOSessionConfiguration
public void setRepositoryName(String repositoryName)
{
+ checkNotOpen();
this.repositoryName = repositoryName;
}
@@ -67,6 +71,7 @@ public class CDOSessionConfigurationImpl implements CDOSessionConfiguration
public void setLegacySupportEnabled(boolean legacySupportEnabled)
{
+ checkNotOpen();
this.legacySupportEnabled = legacySupportEnabled;
}
@@ -77,6 +82,7 @@ public class CDOSessionConfigurationImpl implements CDOSessionConfiguration
public void setFailOverStrategy(IFailOverStrategy failOverStrategy)
{
+ checkNotOpen();
this.failOverStrategy = failOverStrategy;
}
@@ -87,6 +93,7 @@ public class CDOSessionConfigurationImpl implements CDOSessionConfiguration
public void setPackageRegistry(CDOPackageRegistryImpl packageRegistry)
{
+ checkNotOpen();
this.packageRegistry = packageRegistry;
}
@@ -100,6 +107,17 @@ public class CDOSessionConfigurationImpl implements CDOSessionConfiguration
setPackageRegistry(CDOUtil.createDemandPopulatingPackageRegistry());
}
+ public boolean isActivateOnOpen()
+ {
+ return activateOnOpen;
+ }
+
+ public void setActivateOnOpen(boolean activateOnOpen)
+ {
+ checkNotOpen();
+ this.activateOnOpen = activateOnOpen;
+ }
+
public CDOSession openSession()
{
if (!isSessionOpen())
@@ -110,7 +128,11 @@ public class CDOSessionConfigurationImpl implements CDOSessionConfiguration
session.setDisableLegacyObjects(!legacySupportEnabled);
session.setFailOverStrategy(failOverStrategy);
session.setPackageRegistry(packageRegistry);
- session.activate();
+
+ if (activateOnOpen)
+ {
+ session.activate();
+ }
}
return session;
@@ -131,4 +153,12 @@ public class CDOSessionConfigurationImpl implements CDOSessionConfiguration
session = null;
return false;
}
+
+ private void checkNotOpen()
+ {
+ if (isSessionOpen())
+ {
+ throw new IllegalStateException("Session is already open");
+ }
+ }
}