Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2009-07-11 06:09:52 -0400
committerEike Stepper2009-07-11 06:09:52 -0400
commit4c6ec329bfde3863529cc7d50a2fd3b0bf02e7e8 (patch)
tree1a3c4caab3f92a57359b6aa6aee42acec4f9b301 /plugins/org.eclipse.emf.cdo/src/org/eclipse
parentf23f820913cb091abf7c41dba649ae194f29b94a (diff)
downloadcdo-4c6ec329bfde3863529cc7d50a2fd3b0bf02e7e8.tar.gz
cdo-4c6ec329bfde3863529cc7d50a2fd3b0bf02e7e8.tar.xz
cdo-4c6ec329bfde3863529cc7d50a2fd3b0bf02e7e8.zip
[282481] Provide an EmbeddedSessionProtocol
https://bugs.eclipse.org/bugs/show_bug.cgi?id=282481
Diffstat (limited to 'plugins/org.eclipse.emf.cdo/src/org/eclipse')
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDORepositoryInfo.java53
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDOSession.java67
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDOSessionConfiguration.java12
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOURIUtil.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOURIHandler.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/messages/messages.properties5
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionConfigurationImpl.java73
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java313
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewSetImpl.java4
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/PluginContainerViewProvider.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOSessionProtocol.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOSession.java35
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOSessionConfiguration.java28
15 files changed, 264 insertions, 338 deletions
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDORepositoryInfo.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDORepositoryInfo.java
new file mode 100644
index 0000000000..5037a940ce
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDORepositoryInfo.java
@@ -0,0 +1,53 @@
+package org.eclipse.emf.cdo.session;
+
+/**
+ * Describes a model repository a {@link CDOSession session} is connected to.
+ *
+ * @author Eike Stepper
+ * @see CDOSession#getRepositoryInfo()
+ * @since 3.0
+ */
+public interface CDORepositoryInfo
+{
+ /**
+ * Returns the name of this repository.
+ *
+ * @see IRepository#getName()
+ */
+ public String getName();
+
+ /**
+ * Returns the UUID of this repository.
+ *
+ * @see IRepository#getUUID()
+ */
+ public String getUUID();
+
+ /**
+ * Returns the creation time of this repository.
+ *
+ * @see IRepository#getCreationTime()
+ */
+ public long getCreationTime();
+
+ /**
+ * Returns the approximate current time of this repository.
+ * <p>
+ * Same as calling <code>getCurrentTime(false)</code>.
+ *
+ * @see #getCurrentTime(boolean)
+ */
+ public long getCurrentTime();
+
+ /**
+ * Returns the approximate current time of this repository by optionally refreshing the approximation from the server.
+ */
+ public long getCurrentTime(boolean forceRefresh);
+
+ /**
+ * Returns <code>true</code> if this repository supports auditing, <code>false</code> otherwise.
+ *
+ * @see IRepository#isSupportingAudits()
+ */
+ public boolean isSupportingAudits();
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDOSession.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDOSession.java
index 17adb2b148..1b2d48d630 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDOSession.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDOSession.java
@@ -39,7 +39,7 @@ import java.util.Collection;
* <p>
* A session has the following responsibilities:
* <ul>
- * <li> {@link CDOSession#repository() Repository information}
+ * <li> {@link CDOSession#getRepositoryInfo() CDORepositoryInfo information}
* <li> {@link CDOSession#getPackageRegistry() Package registry}
* <li> {@link CDOSession#getPackageUnitManager() Package unit management}
* <li> {@link CDOSession#getRevisionManager() Data management}
@@ -55,6 +55,11 @@ import java.util.Collection;
public interface CDOSession extends CDOCommonSession, IContainer<CDOView>, IOptionsContainer
{
/**
+ * @since 3.0
+ */
+ public CDOSessionConfiguration getConfiguration();
+
+ /**
* Returns the EMF {@link EPackage.Registry package registry} that is used by all {@link EObject objects} of all
* {@link CDOView views} of this session.
* <p>
@@ -161,10 +166,12 @@ public interface CDOSession extends CDOCommonSession, IContainer<CDOView>, IOpti
public Options options();
/**
- * Returns an instance of {@link Repository} that describes the model repository this {@link CDOSession session} is
- * connected to.
+ * Returns an instance of {@link CDORepositoryInfo} that describes the model repository this {@link CDOSession
+ * session} is connected to.
+ *
+ * @since 3.0
*/
- public Repository repository();
+ public CDORepositoryInfo getRepositoryInfo();
/**
* @author Simon McDuff
@@ -215,58 +222,6 @@ public interface CDOSession extends CDOCommonSession, IContainer<CDOView>, IOpti
}
/**
- * Describes a model repository a {@link CDOSession session} is connected to.
- *
- * @author Eike Stepper
- * @see CDOSession#repository()
- */
- public interface Repository
- {
- /**
- * Returns the name of this repository.
- *
- * @see IRepository#getName()
- */
- public String getName();
-
- /**
- * Returns the UUID of this repository.
- *
- * @see IRepository#getUUID()
- */
- public String getUUID();
-
- /**
- * Returns the creation time of this repository.
- *
- * @see IRepository#getCreationTime()
- */
- public long getCreationTime();
-
- /**
- * Returns the approximate current time of this repository.
- * <p>
- * Same as calling <code>getCurrentTime(false)</code>.
- *
- * @see #getCurrentTime(boolean)
- */
- public long getCurrentTime();
-
- /**
- * Returns the approximate current time of this repository by optionally refreshing the approximation from the
- * server.
- */
- public long getCurrentTime(boolean forceRefresh);
-
- /**
- * Returns <code>true</code> if this repository supports auditing, <code>false</code> otherwise.
- *
- * @see IRepository#isSupportingAudits()
- */
- public boolean isSupportingAudits();
- }
-
- /**
* @author Eike Stepper
*/
public interface ExceptionHandler
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDOSessionConfiguration.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDOSessionConfiguration.java
index f3279797e3..450043a83a 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDOSessionConfiguration.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDOSessionConfiguration.java
@@ -19,6 +19,18 @@ import org.eclipse.emf.cdo.common.protocol.CDOAuthenticator;
public interface CDOSessionConfiguration
{
/**
+ * @see CDOSession.Options#isPassiveUpdateEnabled()
+ * @since 3.0
+ */
+ public boolean isPassiveUpdateEnabled();
+
+ /**
+ * @see CDOSession.Options#isPassiveUpdateEnabled()
+ * @since 3.0
+ */
+ public void setPassiveUpdateEnabled(boolean passiveUpdateEnabled);
+
+ /**
* @see CDOSession#getExceptionHandler()
*/
public CDOSession.ExceptionHandler getExceptionHandler();
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOURIUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOURIUtil.java
index cc04b194b0..0f3f913166 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOURIUtil.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOURIUtil.java
@@ -133,7 +133,7 @@ public class CDOURIUtil
public static URI createResourceURI(CDOSession session, String path)
{
- return createResourceURI(session == null ? null : session.repository().getUUID(), path);
+ return createResourceURI(session == null ? null : session.getRepositoryInfo().getUUID(), path);
}
/**
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 dd6a5e18fc..643121ed2c 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
@@ -235,7 +235,7 @@ public final class CDOUtil
if (revision.getVersion() != version)
{
CDOSession session = object.cdoView().getSession();
- if (!session.repository().isSupportingAudits())
+ if (!session.getRepositoryInfo().isSupportingAudits())
{
throw new IllegalStateException(Messages.getString("CDOUtil.0")); //$NON-NLS-1$
}
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 3aaba76e81..aab7a57d8d 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
@@ -535,7 +535,7 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
/**
* Code took from {@link BasicEObjectImpl#eBasicSetContainer} and modify it to detect when object are moved in the
- * same context. (E.g.: An object is moved from resA to resB. resA and resB belongs to the same Repository. Without
+ * same context. (E.g.: An object is moved from resA to resB. resA and resB belongs to the same CDORepositoryInfo. Without
* this special handling, a detach and newObject will be generated for the object moved)
*
* @since 2.0
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOURIHandler.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOURIHandler.java
index ab0ab3f6e9..7d14659d2d 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOURIHandler.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOURIHandler.java
@@ -56,7 +56,7 @@ public class CDOURIHandler implements URIHandler
public boolean canHandle(URI uri)
{
return CDO_URI_SCHEME.equals(uri.scheme())
- && view.getSession().repository().getUUID().equals(CDOURIUtil.extractRepositoryUUID(uri));
+ && view.getSession().getRepositoryInfo().getUUID().equals(CDOURIUtil.extractRepositoryUUID(uri));
}
public boolean exists(URI uri, Map<?, ?> options)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/messages/messages.properties b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/messages/messages.properties
index 6e9501a173..5dc3512bc7 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/messages/messages.properties
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/messages/messages.properties
@@ -3,7 +3,7 @@
# 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:
# Victor Roldan Betancort - initial API and implementation
# Eike Stepper - maintenance
@@ -19,6 +19,7 @@ CDOResourceNodeImpl.3=Null path is not allowed
CDOResourceNodeImpl.4=Root path is not allowed
CDOResourceNodeImpl.5=Duplicate path: {0}
CDOSessionConfigurationImpl.0=Session is already open
+CDOSessionConfigurationImpl.1=Session is not open
CDOSessionFactory.1=Query is empty: {0}
CDOSessionImpl.0=Generated packages locally not available: {0}
CDOSessionImpl.1=Commit notification arrived while session is inactive
@@ -80,7 +81,7 @@ FSMUtil.0=View closed
FSMUtil.1=object == null
FSMUtil.2=view == null
FSMUtil.3=Legacy models not supported
-FSMUtil.4=Use CDOFactory to create dynamic object:
+FSMUtil.4=Use CDOFactory to create dynamic object:
InvalidObjectException.0=Object {0} is not valid anymore
InvalidURIException.0=Invalid URI "{0}": {1}
ObjectNotFoundException.0=Object {0} not found (temporary = {1})
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionConfigurationImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionConfigurationImpl.java
index 6ac0a0db63..c13809fe3c 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionConfigurationImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionConfigurationImpl.java
@@ -13,42 +13,49 @@ package org.eclipse.emf.internal.cdo.session;
import org.eclipse.emf.cdo.common.protocol.CDOAuthenticationResult;
import org.eclipse.emf.cdo.common.protocol.CDOAuthenticator;
import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.session.CDOSessionConfiguration;
+import org.eclipse.emf.cdo.session.remote.CDORemoteSessionManager;
import org.eclipse.emf.internal.cdo.messages.Messages;
+import org.eclipse.emf.internal.cdo.session.remote.CDORemoteSessionManagerImpl;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import org.eclipse.net4j.util.security.IPasswordCredentials;
import org.eclipse.net4j.util.security.IPasswordCredentialsProvider;
import org.eclipse.net4j.util.security.SecurityUtil;
+import org.eclipse.emf.spi.cdo.CDOSessionProtocol;
+import org.eclipse.emf.spi.cdo.InternalCDORemoteSessionManager;
import org.eclipse.emf.spi.cdo.InternalCDOSession;
+import org.eclipse.emf.spi.cdo.InternalCDOSessionConfiguration;
/**
* @author Eike Stepper
*/
-public abstract class CDOSessionConfigurationImpl implements CDOSessionConfiguration
+public abstract class CDOSessionConfigurationImpl implements InternalCDOSessionConfiguration
{
- private InternalCDOSession session;
-
- private CDOSession.ExceptionHandler exceptionHandler;
+ private boolean passiveUpdateEnabled = true;
private CDOAuthenticator authenticator = new AuthenticatorImpl();
+ private CDOSession.ExceptionHandler exceptionHandler;
+
private boolean activateOnOpen = true;
+ private InternalCDOSession session;
+
public CDOSessionConfigurationImpl()
{
}
- public CDOSession.ExceptionHandler getExceptionHandler()
+ public boolean isPassiveUpdateEnabled()
{
- return exceptionHandler;
+ return passiveUpdateEnabled;
}
- public void setExceptionHandler(CDOSession.ExceptionHandler exceptionHandler)
+ public void setPassiveUpdateEnabled(boolean passiveUpdateEnabled)
{
checkNotOpen();
- this.exceptionHandler = exceptionHandler;
+ this.passiveUpdateEnabled = passiveUpdateEnabled;
}
public CDOAuthenticator getAuthenticator()
@@ -62,6 +69,17 @@ public abstract class CDOSessionConfigurationImpl implements CDOSessionConfigura
this.authenticator = authenticator;
}
+ public CDOSession.ExceptionHandler getExceptionHandler()
+ {
+ return exceptionHandler;
+ }
+
+ public void setExceptionHandler(CDOSession.ExceptionHandler exceptionHandler)
+ {
+ checkNotOpen();
+ this.exceptionHandler = exceptionHandler;
+ }
+
public boolean isActivateOnOpen()
{
return activateOnOpen;
@@ -98,8 +116,6 @@ public abstract class CDOSessionConfigurationImpl implements CDOSessionConfigura
{
session = createSession();
session.setExceptionHandler(exceptionHandler);
- session.setAuthenticator(authenticator);
-
if (activateOnOpen)
{
session.activate();
@@ -109,6 +125,39 @@ public abstract class CDOSessionConfigurationImpl implements CDOSessionConfigura
return session;
}
+ public InternalCDOSession getSession()
+ {
+ checkOpen();
+ return session;
+ }
+
+ public void activateSession(InternalCDOSession session) throws Exception
+ {
+ InternalCDORemoteSessionManager remoteSessionManager = new CDORemoteSessionManagerImpl(session);
+ session.setRemoteSessionManager(remoteSessionManager);
+ remoteSessionManager.activate();
+ }
+
+ public void deactivateSession(InternalCDOSession session) throws Exception
+ {
+ CDORemoteSessionManager remoteSessionManager = session.getRemoteSessionManager();
+ session.setRemoteSessionManager(null);
+ LifecycleUtil.deactivate(remoteSessionManager);
+
+ CDOSessionProtocol sessionProtocol = session.getSessionProtocol();
+ LifecycleUtil.deactivate(sessionProtocol);
+ session.setSessionProtocol(null);
+ session = null;
+ }
+
+ protected void checkOpen()
+ {
+ if (!isSessionOpen())
+ {
+ throw new IllegalStateException(Messages.getString("CDOSessionConfigurationImpl.1")); //$NON-NLS-1$
+ }
+ }
+
protected void checkNotOpen()
{
if (isSessionOpen())
@@ -117,8 +166,6 @@ public abstract class CDOSessionConfigurationImpl implements CDOSessionConfigura
}
}
- protected abstract InternalCDOSession createSession();
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java
index 6633698117..538f5df98e 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java
@@ -24,20 +24,15 @@ import org.eclipse.emf.cdo.common.id.CDOIDObject;
import org.eclipse.emf.cdo.common.id.CDOIDObjectFactory;
import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
-import org.eclipse.emf.cdo.common.model.EMFUtil;
import org.eclipse.emf.cdo.common.protocol.CDOAuthenticator;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
import org.eclipse.emf.cdo.common.util.CDOException;
-import org.eclipse.emf.cdo.eresource.EresourcePackage;
-import org.eclipse.emf.cdo.internal.common.model.CDOPackageRegistryImpl;
-import org.eclipse.emf.cdo.internal.common.revision.CDORevisionManagerImpl;
import org.eclipse.emf.cdo.session.CDOCollectionLoadingPolicy;
+import org.eclipse.emf.cdo.session.CDORepositoryInfo;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.session.CDOSessionInvalidationEvent;
import org.eclipse.emf.cdo.session.remote.CDORemoteSession;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
import org.eclipse.emf.cdo.transaction.CDOTimeStampContext;
@@ -48,7 +43,6 @@ import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.emf.internal.cdo.CDOFactoryImpl;
import org.eclipse.emf.internal.cdo.bundle.OM;
import org.eclipse.emf.internal.cdo.messages.Messages;
-import org.eclipse.emf.internal.cdo.session.remote.CDORemoteSessionManagerImpl;
import org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl;
import org.eclipse.emf.internal.cdo.view.CDOAuditImpl;
import org.eclipse.emf.internal.cdo.view.CDOViewImpl;
@@ -78,7 +72,6 @@ import org.eclipse.net4j.util.options.OptionsEvent;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.spi.cdo.AbstractQueryIterator;
@@ -86,11 +79,10 @@ import org.eclipse.emf.spi.cdo.CDOSessionProtocol;
import org.eclipse.emf.spi.cdo.InternalCDOObject;
import org.eclipse.emf.spi.cdo.InternalCDORemoteSessionManager;
import org.eclipse.emf.spi.cdo.InternalCDOSession;
+import org.eclipse.emf.spi.cdo.InternalCDOSessionConfiguration;
import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
import org.eclipse.emf.spi.cdo.InternalCDOView;
import org.eclipse.emf.spi.cdo.InternalCDOViewSet;
-import org.eclipse.emf.spi.cdo.CDOSessionProtocol.OpenSessionResult;
-import org.eclipse.emf.spi.cdo.CDOSessionProtocol.RepositoryTimeResult;
import org.eclipse.emf.spi.cdo.InternalCDOTransaction.InternalCDOCommitContext;
import org.eclipse.emf.spi.cdo.InternalCDOXATransaction.InternalCDOXACommitContext;
@@ -114,6 +106,8 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_SESSION, CDOSessionImpl.class);
+ private InternalCDOSessionConfiguration configuration;
+
private ExceptionHandler exceptionHandler;
private CDOSessionProtocol sessionProtocol;
@@ -132,13 +126,9 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter
private String userID;
- private CDOSession.Options options;
-
- private CDOSession.Repository repository;
-
- private InternalCDOPackageRegistry packageRegistry;
+ private CDOSession.Options options = createOptions();
- private InternalCDORevisionManager revisionManager;
+ private CDORepositoryInfo repositoryInfo;
private CDOFetchRuleManager ruleManager = CDOFetchRuleManager.NOOP;
@@ -165,10 +155,24 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter
@ExcludeFromDump
private transient int lastViewID;
- public CDOSessionImpl()
+ public CDOSessionImpl(InternalCDOSessionConfiguration configuration)
+ {
+ this.configuration = configuration;
+ }
+
+ public InternalCDOSessionConfiguration getConfiguration()
{
- remoteSessionManager = createRemoteSessionManager();
- options = createOptions();
+ return configuration;
+ }
+
+ public CDORepositoryInfo getRepositoryInfo()
+ {
+ return repositoryInfo;
+ }
+
+ public void setRepositoryInfo(CDORepositoryInfo repositoryInfo)
+ {
+ this.repositoryInfo = repositoryInfo;
}
public int getSessionID()
@@ -176,6 +180,11 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter
return sessionID;
}
+ public void setSessionID(int sessionID)
+ {
+ this.sessionID = sessionID;
+ }
+
public String getUserID()
{
return userID;
@@ -213,31 +222,14 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter
return new OptionsImpl();
}
- /**
- * @since 2.0
- */
- public CDOSession.Repository repository()
- {
- return repository;
- }
-
- public void setRepository(CDOSession.Repository repository)
+ public CDOSessionProtocol getSessionProtocol()
{
- this.repository = repository;
+ return sessionProtocol;
}
- /**
- * @param result
- * @since 2.0
- */
- protected CDOSession.Repository createRepository(OpenSessionResult result)
+ public void setSessionProtocol(CDOSessionProtocol sessionProtocol)
{
- return new RepositoryImpl(repository.getName(), result);
- }
-
- public CDOSessionProtocol getSessionProtocol()
- {
- return sessionProtocol;
+ this.sessionProtocol = sessionProtocol;
}
public CDOIDObject createCDOIDObject(ExtendedDataInput in)
@@ -266,19 +258,6 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter
return !isActive();
}
- /**
- * @since 2.0
- */
- public void setPackageRegistry(InternalCDOPackageRegistry packageRegistry)
- {
- this.packageRegistry = packageRegistry;
- }
-
- public InternalCDOPackageRegistry getPackageRegistry()
- {
- return packageRegistry;
- }
-
public Object processPackage(Object value)
{
CDOFactoryImpl.prepareDynamicEPackage(value);
@@ -291,7 +270,7 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter
{
if (!options().isGeneratedPackageEmulationEnabled())
{
- throw new CDOException(MessageFormat.format(Messages.getString("CDOSessionImpl.0"), packageUnit)); //$NON-NLS-1$
+ throw new CDOException(MessageFormat.format(Messages.getString("CDOSessionImpl.0"), packageUnit));
}
}
@@ -315,16 +294,6 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter
lockmanager.unlock(LockType.WRITE, key, singletonCollection);
}
- public InternalCDORevisionManager getRevisionManager()
- {
- return revisionManager;
- }
-
- public void setRevisionManager(InternalCDORevisionManager revisionManager)
- {
- this.revisionManager = revisionManager;
- }
-
/**
* @since 3.0
*/
@@ -356,6 +325,11 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter
return remoteSessionManager;
}
+ public void setRemoteSessionManager(InternalCDORemoteSessionManager remoteSessionManager)
+ {
+ this.remoteSessionManager = remoteSessionManager;
+ }
+
/**
* @since 2.0
*/
@@ -614,7 +588,7 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter
}
else
{
- OM.LOG.info(Messages.getString("CDOSessionImpl.1")); //$NON-NLS-1$
+ OM.LOG.info(Messages.getString("CDOSessionImpl.1"));
}
}
}
@@ -645,7 +619,7 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter
}
else
{
- OM.LOG.info(Messages.getString("CDOSessionImpl.2")); //$NON-NLS-1$
+ OM.LOG.info(Messages.getString("CDOSessionImpl.2"));
}
}
@@ -661,6 +635,7 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter
private void updateRevisionForRemoteChanges(final long timeStamp, Set<CDOIDAndVersion> dirtyOIDs,
Collection<CDOID> detachedObjects, InternalCDOView excludedView)
{
+ InternalCDORevisionManager revisionManager = getRevisionManager();
if (excludedView == null || timeStamp == CDORevision.UNSPECIFIED_DATE)
{
for (CDOIDAndVersion dirtyOID : dirtyOIDs)
@@ -704,26 +679,8 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter
@Override
public String toString()
{
- String name = repository == null ? "?" : repository.getName();
- return MessageFormat.format("CDOSession[{0}, {1}]", name, sessionID); //$NON-NLS-1$
- }
-
- /**
- * @since 2.0
- */
- protected InternalCDOPackageRegistry createPackageRegistry()
- {
- return new CDOPackageRegistryImpl();
- }
-
- protected InternalCDORevisionManager createRevisionManager()
- {
- return new CDORevisionManagerImpl();
- }
-
- protected InternalCDORemoteSessionManager createRemoteSessionManager()
- {
- return new CDORemoteSessionManagerImpl(this);
+ String name = repositoryInfo == null ? "?" : repositoryInfo.getName();
+ return MessageFormat.format("CDOSession[{0}, {1}]", name, sessionID);
}
protected ResourceSet createResourceSet()
@@ -766,67 +723,24 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter
}
@Override
+ protected void doBeforeActivate() throws Exception
+ {
+ super.doBeforeActivate();
+ }
+
+ @Override
protected void doActivate() throws Exception
{
super.doActivate();
- sessionProtocol = createSessionProtocol();
+ getConfiguration().activateSession(this);
+ checkState(sessionProtocol, "sessionProtocol");
+ checkState(remoteSessionManager, "remoteSessionManager");
if (exceptionHandler != null)
{
sessionProtocol = new DelegatingSessionProtocol(sessionProtocol);
}
EventUtil.addListener(sessionProtocol, sessionProtocolListener);
- if (revisionManager == null)
- {
- revisionManager = createRevisionManager();
- }
-
- activateRevisionManager();
- remoteSessionManager.activate();
- if (packageRegistry == null)
- {
- packageRegistry = createPackageRegistry();
- }
-
- activatePackageRegistry();
-
- String name = repository().getName();
- boolean passiveUpdateEnabled = options().isPassiveUpdateEnabled();
- OpenSessionResult result = getSessionProtocol().openSession(name, passiveUpdateEnabled);
-
- sessionID = result.getSessionID();
- repository = createRepository(result);
- handleLibraryDescriptor(result.getLibraryDescriptor());
-
- for (InternalCDOPackageUnit packageUnit : result.getPackageUnits())
- {
- if (EcorePackage.eINSTANCE.getNsURI().equals(packageUnit.getID()))
- {
- EMFUtil.addAdapter(EcorePackage.eINSTANCE, packageUnit.getTopLevelPackageInfo());
- packageUnit.setState(CDOPackageUnit.State.LOADED);
- }
- else if (EresourcePackage.eINSTANCE.getNsURI().equals(packageUnit.getID()))
- {
- EMFUtil.addAdapter(EresourcePackage.eINSTANCE, packageUnit.getTopLevelPackageInfo());
- packageUnit.setState(CDOPackageUnit.State.LOADED);
- }
-
- packageRegistry.putPackageUnit(packageUnit);
- }
- }
-
- protected void activatePackageRegistry()
- {
- packageRegistry.setPackageProcessor(this);
- packageRegistry.setPackageLoader(this);
- packageRegistry.activate();
- }
-
- protected void activateRevisionManager()
- {
- revisionManager.setRevisionLoader(sessionProtocol);
- revisionManager.setRevisionLocker(this);
- LifecycleUtil.activate(revisionManager);
}
@Override
@@ -844,7 +758,6 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter
}
views.clear();
- views = null;
if (invalidationRunner != null)
{
@@ -852,32 +765,12 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter
invalidationRunner = null;
}
- deactivateRevisionManager();
- revisionManager = null;
-
- deactivatePackageRegistry();
- packageRegistry = null;
-
EventUtil.removeListener(sessionProtocol, sessionProtocolListener);
- LifecycleUtil.deactivate(sessionProtocol);
- sessionProtocol = null;
-
+ getConfiguration().deactivateSession(this);
super.doDeactivate();
}
- protected void deactivatePackageRegistry()
- {
- packageRegistry.deactivate();
- }
-
- protected void deactivateRevisionManager()
- {
- LifecycleUtil.deactivate(revisionManager);
- }
-
- protected abstract CDOSessionProtocol createSessionProtocol();
-
- private void handleLibraryDescriptor(CDOIDLibraryDescriptor libraryDescriptor) throws Exception
+ public void setLibraryDescriptor(CDOIDLibraryDescriptor libraryDescriptor) throws Exception
{
if (libraryDescriptor == null)
{
@@ -887,7 +780,7 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter
String factoryName = libraryDescriptor.getFactoryName();
if (TRACER.isEnabled())
{
- TRACER.format("Using CDOID factory: {0}", factoryName); //$NON-NLS-1$
+ TRACER.format("Using CDOID factory: {0}", factoryName);
}
File cacheFolder = getCacheFolder();
@@ -913,10 +806,10 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter
File lib = new File(cacheFolder, neededLibrary);
if (TRACER.isEnabled())
{
- TRACER.format("Using CDOID library: {0}", lib.getAbsolutePath()); //$NON-NLS-1$
+ TRACER.format("Using CDOID library: {0}", lib.getAbsolutePath());
}
- urls[i++] = new URL("file:///" + lib.getAbsolutePath()); //$NON-NLS-1$
+ urls[i++] = new URL("file:///" + lib.getAbsolutePath());
}
classLoader = new URLClassLoader(urls, classLoader);
@@ -928,7 +821,7 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter
{
String stateLocation = OM.BUNDLE.getStateLocation();
File repos = new File(stateLocation, "repos"); //$NON-NLS-1$
- return new File(repos, repository().getUUID());
+ return new File(repos, getRepositoryInfo().getUUID());
}
private Set<String> createSet(String[] fileNames)
@@ -936,7 +829,7 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter
Set<String> set = new HashSet<String>();
for (String fileName : fileNames)
{
- if (fileName.endsWith(".jar")) //$NON-NLS-1$
+ if (fileName.endsWith(".jar"))
{
set.add(fileName);
}
@@ -1092,76 +985,6 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter
/**
* @author Eike Stepper
*/
- protected class RepositoryImpl implements CDOSession.Repository
- {
- private String name;
-
- private String uuid;
-
- private long creationTime;
-
- private RepositoryTimeResult timeResult;
-
- private boolean supportingAudits;
-
- public RepositoryImpl(String name, OpenSessionResult result)
- {
- this.name = name;
- uuid = result.getRepositoryUUID();
- creationTime = result.getRepositoryCreationTime();
- timeResult = result.getRepositoryTimeResult();
- supportingAudits = result.isRepositorySupportingAudits();
- }
-
- public String getName()
- {
- return name;
- }
-
- /**
- * Must be callable before session activation has finished!
- */
- public String getUUID()
- {
- return uuid;
- }
-
- public long getCreationTime()
- {
- checkActive();
- return creationTime;
- }
-
- public long getCurrentTime()
- {
- return getCurrentTime(false);
- }
-
- public long getCurrentTime(boolean forceRefresh)
- {
- checkActive();
- if (timeResult == null || forceRefresh)
- {
- timeResult = refreshTime();
- }
-
- return timeResult.getAproximateRepositoryTime();
- }
-
- public boolean isSupportingAudits()
- {
- return supportingAudits;
- }
-
- private RepositoryTimeResult refreshTime()
- {
- return getSessionProtocol().getRepositoryTime();
- }
- }
-
- /**
- * @author Eike Stepper
- */
private final class InvalidationEvent extends Event implements CDOSessionInvalidationEvent
{
private static final long serialVersionUID = 1L;
@@ -1226,7 +1049,7 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter
@Override
public String toString()
{
- return "CDOSessionInvalidationEvent: " + dirtyOIDs; //$NON-NLS-1$
+ return "CDOSessionInvalidationEvent: " + dirtyOIDs;
}
}
@@ -1621,22 +1444,6 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter
}
}
- public OpenSessionResult openSession(String repositoryName, boolean passiveUpdateEnabled)
- {
- int attempt = 0;
- for (;;)
- {
- try
- {
- return delegate.openSession(repositoryName, passiveUpdateEnabled);
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
- }
-
public void openView(int viewId, CDOCommonView.Type viewType, long timeStamp)
{
int attempt = 0;
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewSetImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewSetImpl.java
index f26e8f5264..3d17c4a269 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewSetImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewSetImpl.java
@@ -125,7 +125,7 @@ public class CDOViewSetImpl extends NotifierImpl implements InternalCDOViewSet
public void add(InternalCDOView view)
{
- String repositoryUUID = view.getSession().repository().getUUID();
+ String repositoryUUID = view.getSession().getRepositoryInfo().getUUID();
synchronized (views)
{
CDOView lookupView = mapOfViews.get(repositoryUUID);
@@ -147,7 +147,7 @@ public class CDOViewSetImpl extends NotifierImpl implements InternalCDOViewSet
public void remove(InternalCDOView view)
{
- String repositoryUUID = view.getSession().repository().getUUID();
+ String repositoryUUID = view.getSession().getRepositoryInfo().getUUID();
List<Resource> resToRemove = new ArrayList<Resource>();
synchronized (views)
{
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/PluginContainerViewProvider.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/PluginContainerViewProvider.java
index 832a9ee7d8..ba65fb3912 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/PluginContainerViewProvider.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/PluginContainerViewProvider.java
@@ -53,7 +53,7 @@ public class PluginContainerViewProvider extends ManagedContainerViewProvider im
for (Object element : container.getElements(CDOSessionFactory.PRODUCT_GROUP))
{
CDOSession session = (CDOSession)element;
- String uuid = session.repository().getUUID();
+ String uuid = session.getRepositoryInfo().getUUID();
if (repoUUID.equals(uuid))
{
CDOView view = openView(session, resourceSet);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOSessionProtocol.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOSessionProtocol.java
index 8b8f6d60c1..108796972e 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOSessionProtocol.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOSessionProtocol.java
@@ -51,8 +51,6 @@ import java.util.Set;
*/
public interface CDOSessionProtocol extends CDOProtocol, PackageLoader, RevisionLoader
{
- public OpenSessionResult openSession(String repositoryName, boolean passiveUpdateEnabled);
-
public void loadLibraries(Set<String> missingLibraries, File cacheFolder);
public void setPassiveUpdate(Map<CDOID, CDOIDAndVersion> idAndVersions, int initialChunkSize,
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOSession.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOSession.java
index 53ef541128..33e1b9a1cb 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOSession.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOSession.java
@@ -12,11 +12,12 @@ package org.eclipse.emf.spi.cdo;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDAndVersion;
+import org.eclipse.emf.cdo.common.id.CDOIDLibraryDescriptor;
import org.eclipse.emf.cdo.common.id.CDOIDObjectFactory;
import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
-import org.eclipse.emf.cdo.common.protocol.CDOAuthenticator;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
+import org.eclipse.emf.cdo.session.CDORepositoryInfo;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry;
import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry.PackageLoader;
@@ -39,11 +40,23 @@ import java.util.Set;
public interface InternalCDOSession extends CDOSession, CDOIDObjectFactory, PackageProcessor, PackageLoader,
RevisionLocker, ILifecycle
{
+ /**
+ * @since 3.0
+ */
+ public InternalCDOSessionConfiguration getConfiguration();
+
public CDOSessionProtocol getSessionProtocol();
/**
* @since 3.0
*/
+ public void setSessionProtocol(CDOSessionProtocol sessionProtocol);
+
+ public InternalCDOPackageRegistry getPackageRegistry();
+
+ /**
+ * @since 3.0
+ */
public InternalCDORevisionManager getRevisionManager();
public void setExceptionHandler(CDOSession.ExceptionHandler exceptionHandler);
@@ -53,13 +66,25 @@ public interface InternalCDOSession extends CDOSession, CDOIDObjectFactory, Pack
*/
public void setFetchRuleManager(CDOFetchRuleManager fetchRuleManager);
- public InternalCDOPackageRegistry getPackageRegistry();
+ /**
+ * @since 3.0
+ */
+ public void setRepositoryInfo(CDORepositoryInfo repositoryInfo);
- public void setPackageRegistry(InternalCDOPackageRegistry packageRegistry);
+ /**
+ * @since 3.0
+ */
+ public void setLibraryDescriptor(CDOIDLibraryDescriptor libraryDescriptor) throws Exception;
- public CDOAuthenticator getAuthenticator();
+ /**
+ * @since 3.0
+ */
+ public void setRemoteSessionManager(InternalCDORemoteSessionManager remoteSessionManager);
- public void setAuthenticator(CDOAuthenticator authenticator);
+ /**
+ * @since 3.0
+ */
+ public void setSessionID(int sessionID);
public void setUserID(String userID);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOSessionConfiguration.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOSessionConfiguration.java
new file mode 100644
index 0000000000..3397dba631
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOSessionConfiguration.java
@@ -0,0 +1,28 @@
+/**
+ * Copyright (c) 2004 - 2009 Eike Stepper (Berlin, Germany) and others.
+ * 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.spi.cdo;
+
+import org.eclipse.emf.cdo.session.CDOSessionConfiguration;
+
+/**
+ * @author Eike Stepper
+ * @since 3.0
+ */
+public interface InternalCDOSessionConfiguration extends CDOSessionConfiguration
+{
+ public InternalCDOSession getSession();
+
+ public InternalCDOSession createSession();
+
+ public void activateSession(InternalCDOSession session) throws Exception;
+
+ public void deactivateSession(InternalCDOSession session) throws Exception;
+}

Back to the top