Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionManagerImpl.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.server.embedded/.settings/.api_filters24
-rw-r--r--plugins/org.eclipse.emf.cdo.server.embedded/META-INF/MANIFEST.MF2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/embedded/CDOEmbeddedRepositoryConfig.java87
-rw-r--r--plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/internal/embedded/AbstractClientManager.java94
-rw-r--r--plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/internal/embedded/ClientBranchManager.java133
-rw-r--r--plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/internal/embedded/ClientRevisionManager.java297
-rw-r--r--plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/internal/embedded/EmbeddedRepository.java494
-rw-r--r--plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/internal/embedded/ServerBranchLoader.java157
-rw-r--r--plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/internal/embedded/ServerRevisionLoader.java123
-rw-r--r--plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/internal/embedded/ServerSession.java40
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java77
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/mem/MEMStore.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/launches/CDO AllTests (MEM embedded).launch2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMEmbedded.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IConstants.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ISessionConfig.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java55
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/SessionConfig.java113
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestRevisionManager.java7
21 files changed, 1146 insertions, 584 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionManagerImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionManagerImpl.java
index 4323d1871d..71cc783d5d 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionManagerImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionManagerImpl.java
@@ -473,8 +473,10 @@ public class CDORevisionManagerImpl extends Lifecycle implements InternalCDORevi
int oldVersion = revision.getVersion() - 1;
if (oldVersion >= CDORevision.UNSPECIFIED_VERSION)
{
+ CDOID id = revision.getID();
CDOBranchVersion old = revision.getBranch().getVersion(oldVersion);
- InternalCDORevision oldRevision = getCachedRevisionByVersion(revision.getID(), old);
+
+ InternalCDORevision oldRevision = getCachedRevisionByVersion(id, old);
if (!revision.isHistorical())
{
if (oldRevision != null)
@@ -484,12 +486,12 @@ public class CDORevisionManagerImpl extends Lifecycle implements InternalCDORevi
else
{
// Remove last revision from cache, which is not revised
- InternalCDORevision cachedLatestRevision = getCachedRevision(revision.getID(), revision);
+ InternalCDORevision cachedLatestRevision = getCachedRevision(id, revision);
if (cachedLatestRevision != null && !cachedLatestRevision.isHistorical())
{
// Found revision is stale.
// We cannot revise it now because of lack information, thus remove it from the cache
- cache.removeRevision(cachedLatestRevision.getID(), cachedLatestRevision);
+ cache.removeRevision(id, cachedLatestRevision);
}
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server.embedded/.settings/.api_filters b/plugins/org.eclipse.emf.cdo.server.embedded/.settings/.api_filters
index 1246807b0e..eb8bc080dc 100644
--- a/plugins/org.eclipse.emf.cdo.server.embedded/.settings/.api_filters
+++ b/plugins/org.eclipse.emf.cdo.server.embedded/.settings/.api_filters
@@ -1,18 +1,32 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<component id="org.eclipse.emf.cdo.server.embedded" version="2">
- <resource path="src/org/eclipse/emf/cdo/server/internal/embedded/EmbeddedRepository.java" type="org.eclipse.emf.cdo.server.internal.embedded.EmbeddedRepository$ClientAwareRevisionLoader">
+ <resource path="src/org/eclipse/emf/cdo/server/internal/embedded/ClientBranchManager.java" type="org.eclipse.emf.cdo.server.internal.embedded.ClientBranchManager">
<filter id="574619656">
<message_arguments>
- <message_argument value="RevisionLoader"/>
- <message_argument value="ClientAwareRevisionLoader"/>
+ <message_argument value="InternalCDOBranchManager"/>
+ <message_argument value="ClientBranchManager"/>
</message_arguments>
</filter>
</resource>
- <resource path="src/org/eclipse/emf/cdo/server/internal/embedded/EmbeddedRepository.java" type="org.eclipse.emf.cdo.server.internal.embedded.EmbeddedRepository$DelegatingRevisionManager">
+ <resource path="src/org/eclipse/emf/cdo/server/internal/embedded/ClientRevisionManager.java" type="org.eclipse.emf.cdo.server.internal.embedded.ClientRevisionManager">
<filter id="574619656">
<message_arguments>
<message_argument value="InternalCDORevisionManager"/>
- <message_argument value="DelegatingRevisionManager"/>
+ <message_argument value="ClientRevisionManager"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src/org/eclipse/emf/cdo/server/internal/embedded/ServerRevisionLoader.java" type="org.eclipse.emf.cdo.server.internal.embedded.ServerRevisionLoader">
+ <filter id="574619656">
+ <message_arguments>
+ <message_argument value="RevisionLoader"/>
+ <message_argument value="ServerRevisionLoader"/>
+ </message_arguments>
+ </filter>
+ <filter id="574619656">
+ <message_arguments>
+ <message_argument value="RevisionLoader2"/>
+ <message_argument value="ServerRevisionLoader"/>
</message_arguments>
</filter>
</resource>
diff --git a/plugins/org.eclipse.emf.cdo.server.embedded/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.server.embedded/META-INF/MANIFEST.MF
index 9a44dff2c3..d63f001f49 100644
--- a/plugins/org.eclipse.emf.cdo.server.embedded/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.server.embedded/META-INF/MANIFEST.MF
@@ -14,5 +14,5 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)";resoluti
org.eclipse.emf.cdo.server.net4j;bundle-version="[4.0.0,5.0.0)";visibility:=reexport,
org.eclipse.net4j.jvm;bundle-version="[4.0.0,5.0.0)";visibility:=reexport
Export-Package: org.eclipse.emf.cdo.server.embedded;version="4.6.0",
- org.eclipse.emf.cdo.server.internal.embedded;version="4.6.0";x-internal:=true,
+ org.eclipse.emf.cdo.server.internal.embedded;version="4.6.0";x-friends:="org.eclipse.emf.cdo.tests",
org.eclipse.emf.cdo.server.internal.embedded.bundle;version="4.6.0";x-internal:=true
diff --git a/plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/embedded/CDOEmbeddedRepositoryConfig.java b/plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/embedded/CDOEmbeddedRepositoryConfig.java
index 68cef3cfe4..208d2e2933 100644
--- a/plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/embedded/CDOEmbeddedRepositoryConfig.java
+++ b/plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/embedded/CDOEmbeddedRepositoryConfig.java
@@ -1,17 +1,34 @@
+/*
+ * Copyright (c) 2016 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.cdo.server.embedded;
+import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
+import org.eclipse.emf.cdo.common.revision.CDORevisionManager;
import org.eclipse.emf.cdo.net4j.CDONet4jSession;
import org.eclipse.emf.cdo.net4j.CDONet4jSessionConfiguration;
+import org.eclipse.emf.cdo.net4j.CDONet4jUtil;
import org.eclipse.emf.cdo.server.IRepository;
import org.eclipse.emf.cdo.server.IStore;
import org.eclipse.emf.cdo.server.internal.embedded.EmbeddedRepository;
-import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.spi.server.InternalRepository;
import org.eclipse.emf.cdo.spi.server.InternalStore;
+import org.eclipse.net4j.acceptor.IAcceptor;
+import org.eclipse.net4j.connector.IConnector;
+import org.eclipse.net4j.jvm.JVMUtil;
import org.eclipse.net4j.util.container.IManagedContainer;
import org.eclipse.net4j.util.container.IPluginContainer;
+import org.eclipse.net4j.util.lifecycle.ILifecycle;
import org.eclipse.net4j.util.lifecycle.Lifecycle;
+import org.eclipse.net4j.util.lifecycle.LifecycleEventAdapter;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import org.eclipse.emf.ecore.EPackage;
@@ -27,6 +44,8 @@ import java.util.Map;
*/
public abstract class CDOEmbeddedRepositoryConfig extends Lifecycle
{
+ private static final String JVM_ACCEPTOR_PREFIX = "cdo_embedded_repo_";
+
private final String repositoryName;
private EmbeddedRepository repository;
@@ -41,7 +60,7 @@ public abstract class CDOEmbeddedRepositoryConfig extends Lifecycle
return repository;
}
- public final CDOSession openClientSession()
+ public final CDONet4jSession openClientSession()
{
return repository.openClientSession();
}
@@ -96,22 +115,55 @@ public abstract class CDOEmbeddedRepositoryConfig extends Lifecycle
/**
* Subclasses may override.
*/
- public void modifySessionConfiguration(IRepository repository, CDONet4jSessionConfiguration config)
+ public void modifySession(IRepository repository, CDONet4jSession session)
{
- // Do nothing.
+ session.options().setCommitTimeout(Integer.MAX_VALUE);
}
/**
* Subclasses may override.
*/
- public void modifySession(IRepository repository, CDONet4jSession session)
+ public CDONet4jSessionConfiguration createSessionConfiguration(IConnector connector, CDOBranchManager branchManager, CDORevisionManager revisionManager)
{
- // Do nothing.
+ CDONet4jSessionConfiguration configuration = CDONet4jUtil.createNet4jSessionConfiguration();
+ configuration.setConnector(connector);
+ configuration.setRepositoryName(repositoryName);
+ configuration.setSignalTimeout(Integer.MAX_VALUE);
+ configuration.setBranchManager(branchManager);
+ configuration.setRevisionManager(revisionManager);
+ return configuration;
+ }
+
+ /**
+ * Subclasses may override.
+ */
+ public IAcceptor createAcceptor(IManagedContainer container)
+ {
+ return JVMUtil.getAcceptor(container, JVM_ACCEPTOR_PREFIX + repositoryName);
+ }
+
+ /**
+ * Subclasses may override.
+ */
+ public IConnector createConnector(IManagedContainer container)
+ {
+ return JVMUtil.getConnector(container, JVM_ACCEPTOR_PREFIX + repositoryName);
}
- public abstract IStore createStore();
+ public abstract IStore createStore(IManagedContainer container);
- public abstract void initProperties(Map<String, String> properties);
+ public abstract void initProperties(IManagedContainer container, Map<String, String> properties);
+
+ protected void activateRepository(IRepository repository)
+ {
+ LifecycleUtil.activate(repository);
+ }
+
+ protected void deactivateRepository()
+ {
+ LifecycleUtil.deactivate(repository);
+ repository = null;
+ }
@Override
protected void doActivate() throws Exception
@@ -120,25 +172,34 @@ public abstract class CDOEmbeddedRepositoryConfig extends Lifecycle
IManagedContainer container = getContainer();
// Initialize store.
- IStore store = createStore();
+ IStore store = createStore(container);
// Initialize properties.
Map<String, String> properties = new HashMap<String, String>();
properties.put(IRepository.Props.OVERRIDE_UUID, "");
- initProperties(properties);
+ initProperties(container, properties);
repository = new EmbeddedRepository(this);
((InternalRepository)repository).setContainer(container);
((InternalRepository)repository).setName(repositoryName);
((InternalRepository)repository).setStore((InternalStore)store);
((InternalRepository)repository).setProperties(properties);
- LifecycleUtil.activate(repository);
+
+ activateRepository(repository);
+
+ repository.addListener(new LifecycleEventAdapter()
+ {
+ @Override
+ protected void onDeactivated(ILifecycle lifecycle)
+ {
+ CDOEmbeddedRepositoryConfig.this.deactivate();
+ }
+ });
}
@Override
protected void doDeactivate() throws Exception
{
- LifecycleUtil.deactivate(repository);
- repository = null;
+ deactivateRepository();
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/internal/embedded/AbstractClientManager.java b/plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/internal/embedded/AbstractClientManager.java
new file mode 100644
index 0000000000..a5bf5a5648
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/internal/embedded/AbstractClientManager.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2016 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.cdo.server.internal.embedded;
+
+import org.eclipse.emf.cdo.net4j.CDONet4jSession;
+import org.eclipse.emf.cdo.spi.server.InternalRepository;
+import org.eclipse.emf.cdo.spi.server.InternalSession;
+import org.eclipse.emf.cdo.spi.server.InternalSessionManager;
+
+import org.eclipse.net4j.util.event.IListener;
+import org.eclipse.net4j.util.lifecycle.ILifecycle;
+import org.eclipse.net4j.util.lifecycle.LifecycleException;
+import org.eclipse.net4j.util.lifecycle.LifecycleState;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class AbstractClientManager<T extends ILifecycle> implements ILifecycle
+{
+ protected final T delegate;
+
+ protected CDONet4jSession clientSession;
+
+ protected InternalSession serverSession;
+
+ private LifecycleState lifecycleState = LifecycleState.INACTIVE;
+
+ public AbstractClientManager(T delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ public boolean hasListeners()
+ {
+ return delegate.hasListeners();
+ }
+
+ public IListener[] getListeners()
+ {
+ return delegate.getListeners();
+ }
+
+ public void addListener(IListener listener)
+ {
+ delegate.addListener(listener);
+ }
+
+ public void removeListener(IListener listener)
+ {
+ delegate.removeListener(listener);
+ }
+
+ public LifecycleState getLifecycleState()
+ {
+ return lifecycleState;
+ }
+
+ public boolean isActive()
+ {
+ return lifecycleState == LifecycleState.ACTIVE;
+ }
+
+ public void activate() throws LifecycleException
+ {
+ lifecycleState = LifecycleState.ACTIVE;
+ }
+
+ public Exception deactivate()
+ {
+ lifecycleState = LifecycleState.INACTIVE;
+ clientSession = null;
+ serverSession = null;
+ return null;
+ }
+
+ protected final void initServerSession(CDONet4jSession clientSession)
+ {
+ this.clientSession = clientSession;
+
+ InternalRepository repository = getRepository(delegate);
+ InternalSessionManager sessionManager = repository.getSessionManager();
+ serverSession = sessionManager.getSession(clientSession.getSessionID());
+ }
+
+ protected abstract InternalRepository getRepository(T delegate);
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/internal/embedded/ClientBranchManager.java b/plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/internal/embedded/ClientBranchManager.java
new file mode 100644
index 0000000000..d2df1a40ae
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/internal/embedded/ClientBranchManager.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2016 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.cdo.server.internal.embedded;
+
+import org.eclipse.emf.cdo.common.CDOCommonRepository;
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchChangedEvent.ChangeKind;
+import org.eclipse.emf.cdo.common.branch.CDOBranchHandler;
+import org.eclipse.emf.cdo.common.util.CDOTimeProvider;
+import org.eclipse.emf.cdo.net4j.CDONet4jSession;
+import org.eclipse.emf.cdo.session.CDORepositoryInfo;
+import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranch;
+import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager;
+import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader.BranchInfo;
+import org.eclipse.emf.cdo.spi.server.InternalRepository;
+
+/**
+ * @author Eike Stepper
+ */
+public class ClientBranchManager extends AbstractClientManager<InternalCDOBranchManager> implements InternalCDOBranchManager
+{
+ public ClientBranchManager(InternalCDOBranchManager delegate)
+ {
+ super(delegate);
+ }
+
+ public void initMainBranch(boolean local, long timestamp)
+ {
+ // Do nothing.
+ }
+
+ public CDOCommonRepository getRepository()
+ {
+ if (clientSession == null)
+ {
+ return null;
+ }
+
+ return clientSession.getRepositoryInfo();
+ }
+
+ public void setRepository(CDOCommonRepository repository)
+ {
+ initServerSession((CDONet4jSession)((CDORepositoryInfo)repository).getSession());
+ }
+
+ public BranchLoader getBranchLoader()
+ {
+ return delegate.getBranchLoader();
+ }
+
+ public void setBranchLoader(BranchLoader branchLoader)
+ {
+ // Do nothing.
+ }
+
+ public CDOTimeProvider getTimeProvider()
+ {
+ return delegate.getTimeProvider();
+ }
+
+ public InternalCDOBranch getMainBranch()
+ {
+ return delegate.getMainBranch();
+ }
+
+ public InternalCDOBranch getBranch(int branchID)
+ {
+ return delegate.getBranch(branchID);
+ }
+
+ public InternalCDOBranch getBranch(int id, String name, InternalCDOBranch baseBranch, long baseTimeStamp)
+ {
+ return delegate.getBranch(id, name, baseBranch, baseTimeStamp);
+ }
+
+ public InternalCDOBranch getBranch(int id, BranchInfo branchInfo)
+ {
+ return delegate.getBranch(id, branchInfo);
+ }
+
+ public InternalCDOBranch getBranch(String path)
+ {
+ return delegate.getBranch(path);
+ }
+
+ public InternalCDOBranch createBranch(int id, String name, InternalCDOBranch baseBranch, long baseTimeStamp)
+ {
+ return delegate.createBranch(id, name, baseBranch, baseTimeStamp);
+ }
+
+ public void handleBranchChanged(InternalCDOBranch branch, ChangeKind changeKind)
+ {
+ delegate.handleBranchChanged(branch, changeKind);
+ }
+
+ public int getBranches(int startID, int endID, CDOBranchHandler handler)
+ {
+ return delegate.getBranches(startID, endID, handler);
+ }
+
+ @Deprecated
+ public void setTimeProvider(CDOTimeProvider timeProvider)
+ {
+ // Do nothing.
+ }
+
+ @Deprecated
+ public void renameBranch(CDOBranch branch, String newName)
+ {
+ // Do nothing.
+ }
+
+ @Deprecated
+ public void handleBranchCreated(InternalCDOBranch branch)
+ {
+ // Do nothing.
+ }
+
+ @Override
+ protected InternalRepository getRepository(InternalCDOBranchManager delegate)
+ {
+ return (InternalRepository)delegate.getRepository();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/internal/embedded/ClientRevisionManager.java b/plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/internal/embedded/ClientRevisionManager.java
new file mode 100644
index 0000000000..49899cf76a
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/internal/embedded/ClientRevisionManager.java
@@ -0,0 +1,297 @@
+/*
+ * Copyright (c) 2016 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.cdo.server.internal.embedded;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPointRange;
+import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.CDORevisionCache;
+import org.eclipse.emf.cdo.common.revision.CDORevisionFactory;
+import org.eclipse.emf.cdo.common.revision.CDORevisionHandler;
+import org.eclipse.emf.cdo.net4j.CDONet4jSession;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionCache;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
+import org.eclipse.emf.cdo.spi.common.revision.SyntheticCDORevision;
+import org.eclipse.emf.cdo.spi.server.InternalRepository;
+
+import org.eclipse.emf.ecore.EClass;
+
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public final class ClientRevisionManager extends AbstractClientManager<InternalCDORevisionManager> implements InternalCDORevisionManager
+{
+ public ClientRevisionManager(InternalCDORevisionManager delegate)
+ {
+ super(delegate);
+ }
+
+ public RevisionLocker getRevisionLocker()
+ {
+ return delegate.getRevisionLocker();
+ }
+
+ public void setRevisionLocker(RevisionLocker revisionLocker)
+ {
+ if (revisionLocker instanceof CDONet4jSession)
+ {
+ initServerSession((CDONet4jSession)revisionLocker);
+ }
+ }
+
+ public RevisionLoader getRevisionLoader()
+ {
+ return delegate.getRevisionLoader();
+ }
+
+ public void setRevisionLoader(RevisionLoader revisionLoader)
+ {
+ // Do nothing.
+ }
+
+ public CDORevisionFactory getFactory()
+ {
+ return delegate.getFactory();
+ }
+
+ public void setFactory(CDORevisionFactory factory)
+ {
+ // Do nothing.
+ }
+
+ public InternalCDORevisionCache getCache()
+ {
+ return delegate.getCache();
+ }
+
+ public void setCache(CDORevisionCache cache)
+ {
+ // Do nothing.
+ }
+
+ public boolean isSupportingAudits()
+ {
+ return delegate.isSupportingAudits();
+ }
+
+ public void setSupportingAudits(boolean on)
+ {
+ // Do nothing.
+ }
+
+ public boolean isSupportingBranches()
+ {
+ return delegate.isSupportingBranches();
+ }
+
+ public void setSupportingBranches(boolean on)
+ {
+ // Do nothing.
+ }
+
+ public EClass getObjectType(CDOID id)
+ {
+ try
+ {
+ ServerSession.set(serverSession);
+ return delegate.getObjectType(id);
+ }
+ finally
+ {
+ ServerSession.unset();
+ }
+ }
+
+ public EClass getObjectType(CDOID id, CDOBranchManager branchManagerForLoadOnDemand)
+ {
+ try
+ {
+ ServerSession.set(serverSession);
+ return delegate.getObjectType(id, branchManagerForLoadOnDemand);
+ }
+ finally
+ {
+ ServerSession.unset();
+ }
+ }
+
+ public CDOBranchPointRange getObjectLifetime(CDOID id, CDOBranchPoint branchPoint)
+ {
+ try
+ {
+ ServerSession.set(serverSession);
+ return delegate.getObjectLifetime(id, branchPoint);
+ }
+ finally
+ {
+ ServerSession.unset();
+ }
+ }
+
+ public boolean containsRevision(CDOID id, CDOBranchPoint branchPoint)
+ {
+ try
+ {
+ ServerSession.set(serverSession);
+ return delegate.containsRevision(id, branchPoint);
+ }
+ finally
+ {
+ ServerSession.unset();
+ }
+ }
+
+ public boolean containsRevisionByVersion(CDOID id, CDOBranchVersion branchVersion)
+ {
+ try
+ {
+ ServerSession.set(serverSession);
+ return delegate.containsRevisionByVersion(id, branchVersion);
+ }
+ finally
+ {
+ ServerSession.unset();
+ }
+ }
+
+ public InternalCDORevision getRevision(CDOID id, CDOBranchPoint branchPoint, int referenceChunk, int prefetchDepth, boolean loadOnDemand,
+ SyntheticCDORevision[] synthetics)
+ {
+ try
+ {
+ ServerSession.set(serverSession);
+ return delegate.getRevision(id, branchPoint, referenceChunk, prefetchDepth, loadOnDemand, synthetics);
+ }
+ finally
+ {
+ ServerSession.unset();
+ }
+ }
+
+ public List<CDORevision> getRevisions(List<CDOID> ids, CDOBranchPoint branchPoint, int referenceChunk, int prefetchDepth, boolean loadOnDemand,
+ SyntheticCDORevision[] synthetics)
+ {
+ try
+ {
+ ServerSession.set(serverSession);
+ return delegate.getRevisions(ids, branchPoint, referenceChunk, prefetchDepth, loadOnDemand, synthetics);
+ }
+ finally
+ {
+ ServerSession.unset();
+ }
+ }
+
+ public InternalCDORevision getRevision(CDOID id, CDOBranchPoint branchPoint, int referenceChunk, int prefetchDepth, boolean loadOnDemand)
+ {
+ try
+ {
+ ServerSession.set(serverSession);
+ return delegate.getRevision(id, branchPoint, referenceChunk, prefetchDepth, loadOnDemand);
+ }
+ finally
+ {
+ ServerSession.unset();
+ }
+ }
+
+ public InternalCDORevision getRevisionByVersion(CDOID id, CDOBranchVersion branchVersion, int referenceChunk, boolean loadOnDemand)
+ {
+ try
+ {
+ ServerSession.set(serverSession);
+ return delegate.getRevisionByVersion(id, branchVersion, referenceChunk, loadOnDemand);
+ }
+ finally
+ {
+ ServerSession.unset();
+ }
+ }
+
+ public List<CDORevision> getRevisions(List<CDOID> ids, CDOBranchPoint branchPoint, int referenceChunk, int prefetchDepth, boolean loadOnDemand)
+ {
+ try
+ {
+ ServerSession.set(serverSession);
+ return delegate.getRevisions(ids, branchPoint, referenceChunk, prefetchDepth, loadOnDemand);
+ }
+ finally
+ {
+ ServerSession.unset();
+ }
+ }
+
+ public void handleRevisions(EClass eClass, CDOBranch branch, boolean exactBranch, long timeStamp, boolean exactTime, CDORevisionHandler handler)
+ {
+ try
+ {
+ ServerSession.set(serverSession);
+ delegate.handleRevisions(eClass, branch, exactBranch, timeStamp, exactTime, handler);
+ }
+ finally
+ {
+ ServerSession.unset();
+ }
+ }
+
+ public void addRevision(CDORevision revision)
+ {
+ try
+ {
+ ServerSession.set(serverSession);
+ delegate.addRevision(revision);
+ }
+ finally
+ {
+ ServerSession.unset();
+ }
+ }
+
+ public void reviseLatest(CDOID id, CDOBranch branch)
+ {
+ try
+ {
+ ServerSession.set(serverSession);
+ delegate.reviseLatest(id, branch);
+ }
+ finally
+ {
+ ServerSession.unset();
+ }
+ }
+
+ public void reviseVersion(CDOID id, CDOBranchVersion branchVersion, long timeStamp)
+ {
+ try
+ {
+ ServerSession.set(serverSession);
+ delegate.reviseVersion(id, branchVersion, timeStamp);
+ }
+ finally
+ {
+ ServerSession.unset();
+ }
+ }
+
+ @Override
+ protected InternalRepository getRepository(InternalCDORevisionManager delegate)
+ {
+ ServerRevisionLoader revisionLoader = (ServerRevisionLoader)delegate.getRevisionLoader();
+ return (InternalRepository)revisionLoader.getDelegate();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/internal/embedded/EmbeddedRepository.java b/plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/internal/embedded/EmbeddedRepository.java
index 8437f99345..9bf6c7d73d 100644
--- a/plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/internal/embedded/EmbeddedRepository.java
+++ b/plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/internal/embedded/EmbeddedRepository.java
@@ -1,32 +1,24 @@
+/*
+ * Copyright (c) 2016 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.cdo.server.internal.embedded;
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPointRange;
-import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.CDORevisionCache;
-import org.eclipse.emf.cdo.common.revision.CDORevisionFactory;
-import org.eclipse.emf.cdo.common.revision.CDORevisionHandler;
import org.eclipse.emf.cdo.common.revision.CDORevisionManager;
import org.eclipse.emf.cdo.internal.server.Repository;
import org.eclipse.emf.cdo.net4j.CDONet4jSession;
import org.eclipse.emf.cdo.net4j.CDONet4jSessionConfiguration;
-import org.eclipse.emf.cdo.net4j.CDONet4jUtil;
-import org.eclipse.emf.cdo.server.StoreThreadLocal;
import org.eclipse.emf.cdo.server.embedded.CDOEmbeddedRepositoryConfig;
import org.eclipse.emf.cdo.server.net4j.CDONet4jServerUtil;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionCache;
+import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager.RevisionLoader;
-import org.eclipse.emf.cdo.spi.common.revision.RevisionInfo;
-import org.eclipse.emf.cdo.spi.common.revision.SyntheticCDORevision;
-import org.eclipse.emf.cdo.spi.server.InternalRepository;
-import org.eclipse.emf.cdo.spi.server.InternalSession;
-import org.eclipse.emf.cdo.spi.server.InternalSessionManager;
import org.eclipse.emf.cdo.spi.server.InternalStore;
import org.eclipse.emf.cdo.spi.server.RepositoryFactory;
@@ -35,13 +27,9 @@ import org.eclipse.net4j.acceptor.IAcceptor;
import org.eclipse.net4j.connector.IConnector;
import org.eclipse.net4j.jvm.JVMUtil;
import org.eclipse.net4j.util.container.IManagedContainer;
-import org.eclipse.net4j.util.event.IListener;
-import org.eclipse.net4j.util.lifecycle.LifecycleException;
-import org.eclipse.net4j.util.lifecycle.LifecycleState;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import org.eclipse.net4j.util.om.OMPlatform;
-import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EPackage;
import java.util.ArrayList;
@@ -52,8 +40,6 @@ import java.util.List;
*/
public class EmbeddedRepository extends Repository.Default
{
- private static final String JVM_ACCEPTOR_PREFIX = "cdo_embedded_repo_";
-
private CDOEmbeddedRepositoryConfig config;
private IAcceptor acceptor;
@@ -67,12 +53,13 @@ public class EmbeddedRepository extends Repository.Default
public CDONet4jSession openClientSession()
{
- CDORevisionManager revisionManager = new DelegatingRevisionManager(getRevisionManager());
- CDONet4jSessionConfiguration configuration = createSessionConfiguration(connector, revisionManager);
+ CDOBranchManager branchManager = new ClientBranchManager(getBranchManager());
+ CDORevisionManager revisionManager = new ClientRevisionManager(getRevisionManager());
+
+ CDONet4jSessionConfiguration configuration = config.createSessionConfiguration(connector, branchManager, revisionManager);
CDONet4jSession session = configuration.openNet4jSession();
- session.options().setCommitTimeout(Integer.MAX_VALUE);
- config.modifySessionConfiguration(this, configuration);
+ config.modifySession(this, session);
return session;
}
@@ -106,8 +93,11 @@ public class EmbeddedRepository extends Repository.Default
super.doBeforeActivate();
+ InternalCDOBranchManager branchManager = getBranchManager();
+ branchManager.setBranchLoader(new ServerBranchLoader(this));
+
InternalCDORevisionManager revisionManager = getRevisionManager();
- revisionManager.setRevisionLoader(new ClientAwareRevisionLoader(this));
+ revisionManager.setRevisionLoader(new ServerRevisionLoader(this));
}
@Override
@@ -118,8 +108,8 @@ public class EmbeddedRepository extends Repository.Default
IManagedContainer container = getContainer();
container.putElement(RepositoryFactory.PRODUCT_GROUP, RepositoryFactory.TYPE, getName(), this);
- acceptor = createAcceptor(container);
- connector = createConnector(container);
+ acceptor = config.createAcceptor(container);
+ connector = config.createConnector(container);
InternalStore store = getStore();
if (store.isFirstStart())
@@ -132,22 +122,6 @@ public class EmbeddedRepository extends Repository.Default
}
}
- protected void doAfterFirstStart()
- {
- // Subclasses may override.
- }
-
- protected void doAfterReStart()
- {
- // Subclasses may override.
- }
-
- @Override
- protected void doBeforeDeactivate() throws Exception
- {
- super.doBeforeDeactivate();
- }
-
@Override
protected void doDeactivate() throws Exception
{
@@ -159,428 +133,4 @@ public class EmbeddedRepository extends Repository.Default
super.doDeactivate();
}
-
- protected IAcceptor createAcceptor(IManagedContainer container)
- {
- return JVMUtil.getAcceptor(container, JVM_ACCEPTOR_PREFIX + getName());
- }
-
- protected IConnector createConnector(IManagedContainer container)
- {
- return JVMUtil.getConnector(container, JVM_ACCEPTOR_PREFIX + getName());
- }
-
- protected CDONet4jSessionConfiguration createSessionConfiguration(IConnector connector, CDORevisionManager revisionManager)
- {
- CDONet4jSessionConfiguration configuration = CDONet4jUtil.createNet4jSessionConfiguration();
- configuration.setConnector(connector);
- configuration.setRepositoryName(getName());
- configuration.setSignalTimeout(Integer.MAX_VALUE);
- configuration.setRevisionManager(revisionManager);
- config.modifySessionConfiguration(this, configuration);
- return configuration;
- }
-
- /**
- * @author Eike Stepper
- */
- private static final class ClientAwareRevisionLoader implements RevisionLoader
- {
- private static final ThreadLocal<InternalSession> SERVER_SESSION = new ThreadLocal<InternalSession>();
-
- private final RevisionLoader delegate;
-
- private ClientAwareRevisionLoader(RevisionLoader delegate)
- {
- this.delegate = delegate;
- }
-
- public RevisionLoader getDelegate()
- {
- return delegate;
- }
-
- public List<RevisionInfo> loadRevisions(List<RevisionInfo> infos, CDOBranchPoint branchPoint, int referenceChunk, int prefetchDepth)
- {
- InternalSession serverSession = SERVER_SESSION.get();
- if (serverSession != null)
- {
- try
- {
- StoreThreadLocal.setSession(serverSession);
- return delegate.loadRevisions(infos, branchPoint, referenceChunk, prefetchDepth);
- }
- finally
- {
- StoreThreadLocal.release();
- }
- }
-
- return delegate.loadRevisions(infos, branchPoint, referenceChunk, prefetchDepth);
- }
-
- public InternalCDORevision loadRevisionByVersion(CDOID id, CDOBranchVersion branchVersion, int referenceChunk)
- {
- InternalSession serverSession = SERVER_SESSION.get();
- if (serverSession != null)
- {
- try
- {
- StoreThreadLocal.setSession(serverSession);
- return delegate.loadRevisionByVersion(id, branchVersion, referenceChunk);
- }
- finally
- {
- StoreThreadLocal.release();
- }
- }
-
- return delegate.loadRevisionByVersion(id, branchVersion, referenceChunk);
- }
-
- public void handleRevisions(EClass eClass, CDOBranch branch, boolean exactBranch, long timeStamp, boolean exactTime, CDORevisionHandler handler)
- {
- InternalSession serverSession = SERVER_SESSION.get();
- if (serverSession != null)
- {
- try
- {
- StoreThreadLocal.setSession(serverSession);
- delegate.handleRevisions(eClass, branch, exactBranch, timeStamp, exactTime, handler);
- }
- finally
- {
- StoreThreadLocal.release();
- }
- }
- else
- {
- delegate.handleRevisions(eClass, branch, exactBranch, timeStamp, exactTime, handler);
- }
- }
- }
-
- /**
- * @author Eike Stepper
- */
- private static final class DelegatingRevisionManager implements InternalCDORevisionManager
- {
- private final InternalCDORevisionManager delegate;
-
- private LifecycleState lifecycleState = LifecycleState.INACTIVE;
-
- private CDONet4jSession clientSession;
-
- private InternalSession serverSession;
-
- public DelegatingRevisionManager(InternalCDORevisionManager delegate)
- {
- this.delegate = delegate;
- }
-
- public boolean hasListeners()
- {
- return delegate.hasListeners();
- }
-
- public IListener[] getListeners()
- {
- return delegate.getListeners();
- }
-
- public void addListener(IListener listener)
- {
- delegate.addListener(listener);
- }
-
- public void removeListener(IListener listener)
- {
- delegate.removeListener(listener);
- }
-
- public LifecycleState getLifecycleState()
- {
- return lifecycleState;
- }
-
- public boolean isActive()
- {
- return lifecycleState == LifecycleState.ACTIVE;
- }
-
- public void activate() throws LifecycleException
- {
- lifecycleState = LifecycleState.ACTIVE;
- }
-
- public Exception deactivate()
- {
- lifecycleState = LifecycleState.INACTIVE;
- serverSession = null;
- clientSession = null;
- return null;
- }
-
- public RevisionLocker getRevisionLocker()
- {
- return delegate.getRevisionLocker();
- }
-
- public void setRevisionLocker(RevisionLocker revisionLocker)
- {
- if (revisionLocker instanceof CDONet4jSession)
- {
- clientSession = (CDONet4jSession)revisionLocker;
-
- ClientAwareRevisionLoader revisionLoader = (ClientAwareRevisionLoader)delegate.getRevisionLoader();
- InternalRepository repository = (InternalRepository)revisionLoader.getDelegate();
- InternalSessionManager sessionManager = repository.getSessionManager();
- serverSession = sessionManager.getSession(clientSession.getSessionID());
- }
- }
-
- public RevisionLoader getRevisionLoader()
- {
- return delegate.getRevisionLoader();
- }
-
- public void setRevisionLoader(RevisionLoader revisionLoader)
- {
- // Do nothing.
- }
-
- public CDORevisionFactory getFactory()
- {
- return delegate.getFactory();
- }
-
- public void setFactory(CDORevisionFactory factory)
- {
- // Do nothing.
- }
-
- public InternalCDORevisionCache getCache()
- {
- return delegate.getCache();
- }
-
- public void setCache(CDORevisionCache cache)
- {
- // Do nothing.
- }
-
- public boolean isSupportingAudits()
- {
- return delegate.isSupportingAudits();
- }
-
- public void setSupportingAudits(boolean on)
- {
- // Do nothing.
- }
-
- public boolean isSupportingBranches()
- {
- return delegate.isSupportingBranches();
- }
-
- public void setSupportingBranches(boolean on)
- {
- // Do nothing.
- }
-
- public EClass getObjectType(CDOID id)
- {
- try
- {
- setServerSession(serverSession);
- return delegate.getObjectType(id);
- }
- finally
- {
- unsetServerSession();
- }
- }
-
- public EClass getObjectType(CDOID id, CDOBranchManager branchManagerForLoadOnDemand)
- {
- try
- {
- setServerSession(serverSession);
- return delegate.getObjectType(id, branchManagerForLoadOnDemand);
- }
- finally
- {
- unsetServerSession();
- }
- }
-
- public CDOBranchPointRange getObjectLifetime(CDOID id, CDOBranchPoint branchPoint)
- {
- try
- {
- setServerSession(serverSession);
- return delegate.getObjectLifetime(id, branchPoint);
- }
- finally
- {
- unsetServerSession();
- }
- }
-
- public boolean containsRevision(CDOID id, CDOBranchPoint branchPoint)
- {
- try
- {
- setServerSession(serverSession);
- return delegate.containsRevision(id, branchPoint);
- }
- finally
- {
- unsetServerSession();
- }
- }
-
- public boolean containsRevisionByVersion(CDOID id, CDOBranchVersion branchVersion)
- {
- try
- {
- setServerSession(serverSession);
- return delegate.containsRevisionByVersion(id, branchVersion);
- }
- finally
- {
- unsetServerSession();
- }
- }
-
- public InternalCDORevision getRevision(CDOID id, CDOBranchPoint branchPoint, int referenceChunk, int prefetchDepth, boolean loadOnDemand,
- SyntheticCDORevision[] synthetics)
- {
- try
- {
- setServerSession(serverSession);
- return delegate.getRevision(id, branchPoint, referenceChunk, prefetchDepth, loadOnDemand, synthetics);
- }
- finally
- {
- unsetServerSession();
- }
- }
-
- public List<CDORevision> getRevisions(List<CDOID> ids, CDOBranchPoint branchPoint, int referenceChunk, int prefetchDepth, boolean loadOnDemand,
- SyntheticCDORevision[] synthetics)
- {
- try
- {
- setServerSession(serverSession);
- return delegate.getRevisions(ids, branchPoint, referenceChunk, prefetchDepth, loadOnDemand, synthetics);
- }
- finally
- {
- unsetServerSession();
- }
- }
-
- public InternalCDORevision getRevision(CDOID id, CDOBranchPoint branchPoint, int referenceChunk, int prefetchDepth, boolean loadOnDemand)
- {
- try
- {
- setServerSession(serverSession);
- return delegate.getRevision(id, branchPoint, referenceChunk, prefetchDepth, loadOnDemand);
- }
- finally
- {
- unsetServerSession();
- }
- }
-
- public InternalCDORevision getRevisionByVersion(CDOID id, CDOBranchVersion branchVersion, int referenceChunk, boolean loadOnDemand)
- {
- try
- {
- setServerSession(serverSession);
- return delegate.getRevisionByVersion(id, branchVersion, referenceChunk, loadOnDemand);
- }
- finally
- {
- unsetServerSession();
- }
- }
-
- public List<CDORevision> getRevisions(List<CDOID> ids, CDOBranchPoint branchPoint, int referenceChunk, int prefetchDepth, boolean loadOnDemand)
- {
- try
- {
- setServerSession(serverSession);
- return delegate.getRevisions(ids, branchPoint, referenceChunk, prefetchDepth, loadOnDemand);
- }
- finally
- {
- unsetServerSession();
- }
- }
-
- public void handleRevisions(EClass eClass, CDOBranch branch, boolean exactBranch, long timeStamp, boolean exactTime, CDORevisionHandler handler)
- {
- try
- {
- setServerSession(serverSession);
- delegate.handleRevisions(eClass, branch, exactBranch, timeStamp, exactTime, handler);
- }
- finally
- {
- unsetServerSession();
- }
- }
-
- public void addRevision(CDORevision revision)
- {
- try
- {
- setServerSession(serverSession);
- delegate.addRevision(revision);
- }
- finally
- {
- unsetServerSession();
- }
- }
-
- public void reviseLatest(CDOID id, CDOBranch branch)
- {
- try
- {
- setServerSession(serverSession);
- delegate.reviseLatest(id, branch);
- }
- finally
- {
- unsetServerSession();
- }
- }
-
- public void reviseVersion(CDOID id, CDOBranchVersion branchVersion, long timeStamp)
- {
- try
- {
- setServerSession(serverSession);
- delegate.reviseVersion(id, branchVersion, timeStamp);
- }
- finally
- {
- unsetServerSession();
- }
- }
-
- private static void setServerSession(InternalSession serverSession)
- {
- ClientAwareRevisionLoader.SERVER_SESSION.set(serverSession);
- }
-
- private static void unsetServerSession()
- {
- ClientAwareRevisionLoader.SERVER_SESSION.remove();
- }
- }
}
diff --git a/plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/internal/embedded/ServerBranchLoader.java b/plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/internal/embedded/ServerBranchLoader.java
new file mode 100644
index 0000000000..d5a213ba97
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/internal/embedded/ServerBranchLoader.java
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2016 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.cdo.server.internal.embedded;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranchHandler;
+import org.eclipse.emf.cdo.server.IRepository;
+import org.eclipse.emf.cdo.server.ISessionManager;
+import org.eclipse.emf.cdo.server.StoreThreadLocal;
+import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader3;
+import org.eclipse.emf.cdo.spi.server.InternalSession;
+
+import org.eclipse.net4j.util.collection.Pair;
+
+/**
+ * @author Eike Stepper
+ */
+public final class ServerBranchLoader implements BranchLoader3
+{
+ private final BranchLoader3 delegate;
+
+ private final ISessionManager sessionManager;
+
+ public ServerBranchLoader(BranchLoader3 delegate)
+ {
+ this.delegate = delegate;
+ sessionManager = ((IRepository)delegate).getSessionManager();
+ }
+
+ public BranchLoader3 getDelegate()
+ {
+ return delegate;
+ }
+
+ public Pair<Integer, Long> createBranch(int branchID, BranchInfo branchInfo)
+ {
+ if (!StoreThreadLocal.hasSession())
+ {
+ try
+ {
+ StoreThreadLocal.setSession(getServerSession());
+ return delegate.createBranch(branchID, branchInfo);
+ }
+ finally
+ {
+ StoreThreadLocal.release();
+ }
+ }
+
+ return delegate.createBranch(branchID, branchInfo);
+ }
+
+ public BranchInfo loadBranch(int branchID)
+ {
+ if (!StoreThreadLocal.hasSession())
+ {
+ try
+ {
+ StoreThreadLocal.setSession(getServerSession());
+ return delegate.loadBranch(branchID);
+ }
+ finally
+ {
+ StoreThreadLocal.release();
+ }
+ }
+
+ return delegate.loadBranch(branchID);
+ }
+
+ public SubBranchInfo[] loadSubBranches(int branchID)
+ {
+ if (!StoreThreadLocal.hasSession())
+ {
+ try
+ {
+ StoreThreadLocal.setSession(getServerSession());
+ return delegate.loadSubBranches(branchID);
+ }
+ finally
+ {
+ StoreThreadLocal.release();
+ }
+ }
+
+ return delegate.loadSubBranches(branchID);
+ }
+
+ public int loadBranches(int startID, int endID, CDOBranchHandler branchHandler)
+ {
+ if (!StoreThreadLocal.hasSession())
+ {
+ try
+ {
+ StoreThreadLocal.setSession(getServerSession());
+ return delegate.loadBranches(startID, endID, branchHandler);
+ }
+ finally
+ {
+ StoreThreadLocal.release();
+ }
+ }
+
+ return delegate.loadBranches(startID, endID, branchHandler);
+ }
+
+ public void renameBranch(int branchID, String oldName, String newName)
+ {
+ if (!StoreThreadLocal.hasSession())
+ {
+ try
+ {
+ StoreThreadLocal.setSession(getServerSession());
+ delegate.renameBranch(branchID, oldName, newName);
+ }
+ finally
+ {
+ StoreThreadLocal.release();
+ }
+ }
+ else
+ {
+ delegate.renameBranch(branchID, oldName, newName);
+ }
+ }
+
+ @Deprecated
+ public void deleteBranch(int branchID)
+ {
+ }
+
+ @Deprecated
+ public void renameBranch(int branchID, String newName)
+ {
+ }
+
+ private InternalSession getServerSession()
+ {
+ InternalSession serverSession = ServerSession.get();
+ if (serverSession == null)
+ {
+ // In contrast to revision loading the branch loading can happen through
+ // parent branches and not explicitly through the delegating client branch manager.
+ // In these cases the server session is not set, so use any open session.
+ serverSession = (InternalSession)sessionManager.getSessions()[0];
+ }
+
+ return serverSession;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/internal/embedded/ServerRevisionLoader.java b/plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/internal/embedded/ServerRevisionLoader.java
new file mode 100644
index 0000000000..55040d393e
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/internal/embedded/ServerRevisionLoader.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2016 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.cdo.server.internal.embedded;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPointRange;
+import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.revision.CDORevisionHandler;
+import org.eclipse.emf.cdo.server.StoreThreadLocal;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager.RevisionLoader2;
+import org.eclipse.emf.cdo.spi.common.revision.RevisionInfo;
+import org.eclipse.emf.cdo.spi.server.InternalSession;
+
+import org.eclipse.emf.ecore.EClass;
+
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public final class ServerRevisionLoader implements RevisionLoader2
+{
+ private final RevisionLoader2 delegate;
+
+ public ServerRevisionLoader(RevisionLoader2 delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ public RevisionLoader2 getDelegate()
+ {
+ return delegate;
+ }
+
+ public List<RevisionInfo> loadRevisions(List<RevisionInfo> infos, CDOBranchPoint branchPoint, int referenceChunk, int prefetchDepth)
+ {
+ InternalSession serverSession = ServerSession.get();
+ if (serverSession != null)
+ {
+ try
+ {
+ StoreThreadLocal.setSession(serverSession);
+ return delegate.loadRevisions(infos, branchPoint, referenceChunk, prefetchDepth);
+ }
+ finally
+ {
+ StoreThreadLocal.release();
+ }
+ }
+
+ return delegate.loadRevisions(infos, branchPoint, referenceChunk, prefetchDepth);
+ }
+
+ public InternalCDORevision loadRevisionByVersion(CDOID id, CDOBranchVersion branchVersion, int referenceChunk)
+ {
+ InternalSession serverSession = ServerSession.get();
+ if (serverSession != null)
+ {
+ try
+ {
+ StoreThreadLocal.setSession(serverSession);
+ return delegate.loadRevisionByVersion(id, branchVersion, referenceChunk);
+ }
+ finally
+ {
+ StoreThreadLocal.release();
+ }
+ }
+
+ return delegate.loadRevisionByVersion(id, branchVersion, referenceChunk);
+ }
+
+ public void handleRevisions(EClass eClass, CDOBranch branch, boolean exactBranch, long timeStamp, boolean exactTime, CDORevisionHandler handler)
+ {
+ InternalSession serverSession = ServerSession.get();
+ if (serverSession != null)
+ {
+ try
+ {
+ StoreThreadLocal.setSession(serverSession);
+ delegate.handleRevisions(eClass, branch, exactBranch, timeStamp, exactTime, handler);
+ }
+ finally
+ {
+ StoreThreadLocal.release();
+ }
+ }
+ else
+ {
+ delegate.handleRevisions(eClass, branch, exactBranch, timeStamp, exactTime, handler);
+ }
+ }
+
+ public CDOBranchPointRange loadObjectLifetime(CDOID id, CDOBranchPoint branchPoint)
+ {
+ InternalSession serverSession = ServerSession.get();
+ if (serverSession != null)
+ {
+ try
+ {
+ StoreThreadLocal.setSession(serverSession);
+ return delegate.loadObjectLifetime(id, branchPoint);
+ }
+ finally
+ {
+ StoreThreadLocal.release();
+ }
+ }
+
+ return delegate.loadObjectLifetime(id, branchPoint);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/internal/embedded/ServerSession.java b/plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/internal/embedded/ServerSession.java
new file mode 100644
index 0000000000..d1ad10838b
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server.embedded/src/org/eclipse/emf/cdo/server/internal/embedded/ServerSession.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2016 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.cdo.server.internal.embedded;
+
+import org.eclipse.emf.cdo.spi.server.InternalSession;
+
+/**
+ * @author Eike Stepper
+ */
+public final class ServerSession
+{
+ private static final ThreadLocal<InternalSession> THREAD_LOCAL = new ThreadLocal<InternalSession>();
+
+ private ServerSession()
+ {
+ }
+
+ public static InternalSession get()
+ {
+ return THREAD_LOCAL.get();
+ }
+
+ static void set(InternalSession serverSession)
+ {
+ THREAD_LOCAL.set(serverSession);
+ }
+
+ static void unset()
+ {
+ THREAD_LOCAL.remove();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java
index 53d1a8c4de..e2f88189ed 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java
@@ -2296,8 +2296,9 @@ public class Repository extends Container<Object> implements InternalRepository,
protected void doBeforeActivate() throws Exception
{
super.doBeforeActivate();
- checkState(store, "store"); //$NON-NLS-1$
+
checkState(!StringUtil.isEmpty(name), "name is empty"); //$NON-NLS-1$
+ checkState(store, "store"); //$NON-NLS-1$
checkState(packageRegistry, "packageRegistry"); //$NON-NLS-1$
checkState(sessionManager, "sessionManager"); //$NON-NLS-1$
checkState(branchManager, "branchManager"); //$NON-NLS-1$
@@ -2308,20 +2309,66 @@ public class Repository extends Container<Object> implements InternalRepository,
checkState(lockingManager, "lockingManager"); //$NON-NLS-1$
packageRegistry.setReplacingDescriptors(true);
- packageRegistry.setPackageProcessor(this);
- packageRegistry.setPackageLoader(this);
-
- branchManager.setRepository(this);
- branchManager.setBranchLoader(this);
-
- revisionManager.setRevisionLoader(this);
- sessionManager.setRepository(this);
- queryManager.setRepository(this);
- commitInfoManager.setRepository(this);
- commitInfoManager.setCommitInfoLoader(this);
- commitManager.setRepository(this);
- lockingManager.setRepository(this);
- store.setRepository(this);
+
+ if (packageRegistry.getPackageProcessor() == null)
+ {
+ packageRegistry.setPackageProcessor(this);
+ }
+
+ if (packageRegistry.getPackageLoader() == null)
+ {
+ packageRegistry.setPackageLoader(this);
+ }
+
+ if (branchManager.getRepository() == null)
+ {
+ branchManager.setRepository(this);
+ }
+
+ if (branchManager.getBranchLoader() == null)
+ {
+ branchManager.setBranchLoader(this);
+ }
+
+ if (revisionManager.getRevisionLoader() == null)
+ {
+ revisionManager.setRevisionLoader(this);
+ }
+
+ if (sessionManager.getRepository() == null)
+ {
+ sessionManager.setRepository(this);
+ }
+
+ if (queryManager.getRepository() == null)
+ {
+ queryManager.setRepository(this);
+ }
+
+ if (commitInfoManager.getRepository() == null)
+ {
+ commitInfoManager.setRepository(this);
+ }
+
+ if (commitInfoManager.getCommitInfoLoader() == null)
+ {
+ commitInfoManager.setCommitInfoLoader(this);
+ }
+
+ if (commitManager.getRepository() == null)
+ {
+ commitManager.setRepository(this);
+ }
+
+ if (lockingManager.getRepository() == null)
+ {
+ lockingManager.setRepository(this);
+ }
+
+ if (store.getRepository() == null)
+ {
+ store.setRepository(this);
+ }
}
@Override
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/mem/MEMStore.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/mem/MEMStore.java
index f4b4dabef0..4d21fb8fcf 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/mem/MEMStore.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/mem/MEMStore.java
@@ -544,7 +544,7 @@ public class MEMStore extends LongIDStore implements IMEMStore, BranchLoader3, D
public synchronized void addRevision(InternalCDORevision revision, boolean raw)
{
InternalCDOBranch branch = revision.getBranch();
- if (branch.getBranchManager().getBranchLoader() != getRepository())
+ if (branch.getBranchManager().getRepository() != getRepository())
{
throw new IllegalArgumentException("Branch does not belong to this repository: " + branch);
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF
index 87bf6dd349..23738fe630 100644
--- a/plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF
@@ -28,6 +28,7 @@ Require-Bundle: org.eclipse.net4j.tests;bundle-version="[4.0.0,5.0.0)";visibilit
org.eclipse.emf.cdo.tests.model5;bundle-version="[3.0.0,4.0.0)";visibility:=reexport,
org.eclipse.emf.cdo.tests.model6;bundle-version="[4.0.0,5.0.0)";visibility:=reexport,
org.eclipse.emf.cdo.server.ocl;bundle-version="[4.0.0,5.0.0)";visibility:=reexport,
+ org.eclipse.emf.cdo.server.embedded;bundle-version="[4.1.0,5.0.0)";visibility:=reexport,
org.eclipse.emf.cdo.server.security;bundle-version="[4.1.0,5.0.0)";visibility:=reexport,
org.eclipse.emf.cdo.security;bundle-version="[4.1.0,5.0.0)";visibility:=reexport,
org.eclipse.emf.cdo.workspace;bundle-version="[4.0.0,5.0.0)";visibility:=reexport,
diff --git a/plugins/org.eclipse.emf.cdo.tests/launches/CDO AllTests (MEM embedded).launch b/plugins/org.eclipse.emf.cdo.tests/launches/CDO AllTests (MEM embedded).launch
index a4ae627679..3d6babf4f8 100644
--- a/plugins/org.eclipse.emf.cdo.tests/launches/CDO AllTests (MEM embedded).launch
+++ b/plugins/org.eclipse.emf.cdo.tests/launches/CDO AllTests (MEM embedded).launch
@@ -12,6 +12,6 @@
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.cdo.tests.AllTestsMEMEmbedded"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.emf.cdo.tests"/>
-<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m&#13;&#10;-Xmx512m"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m&#13;&#10;-Xmx1024m&#13;&#10;-Dorg.eclipse.net4j.util.om.trace.disable=true"/>
<stringAttribute key="yk-options" value="&#13;&#10;additional-options=&#13;&#10;snapshots-dir=&#13;&#10;"/>
</launchConfiguration>
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMEmbedded.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMEmbedded.java
index 609d634dfb..a88b0bcaae 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMEmbedded.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsMEMEmbedded.java
@@ -15,9 +15,7 @@ import junit.framework.TestSuite;
/**
* @author Eike Stepper
- * @deprecated Not yet supported.
*/
-@Deprecated
public class AllTestsMEMEmbedded extends AllConfigs
{
public static Test suite()
@@ -28,6 +26,6 @@ public class AllTestsMEMEmbedded extends AllConfigs
@Override
protected void initConfigSuites(TestSuite parent)
{
- addScenario(parent, MEM, EMBEDDED, NATIVE);
+ addScenario(parent, MEM_EMBEDDED_BRANCHES, EMBEDDED, NATIVE);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IConstants.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IConstants.java
index 754df5d5e7..d3ad3ce1ca 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IConstants.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IConstants.java
@@ -33,11 +33,9 @@ public interface IConstants
public static final RepositoryConfig MEM_OFFLINE = new MEMOfflineConfig(IDGenerationLocation.CLIENT);
- /**
- * @deprecated Not yet supported.
- */
- @Deprecated
- public static final SessionConfig EMBEDDED = SessionConfig.Embedded.INSTANCE;
+ public static final RepositoryConfig MEM_EMBEDDED_BRANCHES = new MEMConfig.Embedded(true, true, IDGenerationLocation.STORE);
+
+ public static final SessionConfig EMBEDDED = Net4j.JVM.Embedded.INSTANCE;
public static final SessionConfig JVM = Net4j.JVM.INSTANCE;
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ISessionConfig.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ISessionConfig.java
index a62ea8a6f8..f8bc572c5c 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ISessionConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ISessionConfig.java
@@ -30,6 +30,8 @@ public interface ISessionConfig extends IConfig
public static final String CAPABILITY_NET4J_SSL = "session.net4j.ssl";
+ public static final String CAPABILITY_NET4J_EMBEDDED = "session.net4j.embedded";
+
public IManagedContainer getClientContainer();
public boolean hasClientContainer();
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java
index be7e359a55..ad9f618b85 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java
@@ -39,12 +39,16 @@ import org.eclipse.emf.cdo.server.IStoreAccessor.CommitContext;
import org.eclipse.emf.cdo.server.ITransaction;
import org.eclipse.emf.cdo.server.StoreThreadLocal;
import org.eclipse.emf.cdo.server.admin.CDOAdminServerUtil;
+import org.eclipse.emf.cdo.server.internal.embedded.ServerBranchLoader;
+import org.eclipse.emf.cdo.server.internal.embedded.ServerRevisionLoader;
import org.eclipse.emf.cdo.server.mem.MEMStoreUtil;
import org.eclipse.emf.cdo.server.net4j.CDONet4jServerUtil;
import org.eclipse.emf.cdo.server.ocl.OCLQueryHandler;
import org.eclipse.emf.cdo.server.security.ISecurityManager;
import org.eclipse.emf.cdo.server.spi.security.InternalSecurityManager;
import org.eclipse.emf.cdo.session.CDOSessionConfigurationFactory;
+import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil;
+import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
import org.eclipse.emf.cdo.spi.server.InternalRepository;
@@ -71,6 +75,7 @@ import org.eclipse.net4j.util.concurrent.DelegatingExecutorService;
import org.eclipse.net4j.util.concurrent.ExecutorServiceFactory;
import org.eclipse.net4j.util.container.ContainerUtil;
import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.container.IPluginContainer;
import org.eclipse.net4j.util.event.IEvent;
import org.eclipse.net4j.util.event.IListener;
import org.eclipse.net4j.util.event.ThrowableEvent;
@@ -355,8 +360,12 @@ public abstract class RepositoryConfig extends Config implements IRepositoryConf
}
}
- IManagedContainer serverContainer = getServerContainer();
- repository.setContainer(serverContainer);
+ if (repository.getContainer() == IPluginContainer.INSTANCE)
+ {
+ IManagedContainer serverContainer = getServerContainer();
+ repository.setContainer(serverContainer);
+ }
+
registerRepository(repository);
if (activate)
@@ -596,7 +605,7 @@ public abstract class RepositoryConfig extends Config implements IRepositoryConf
IStore store = createStore(name);
Map<String, String> repoProps = getRepositoryProperties();
- InternalRepository repository = (InternalRepository)CDOServerUtil.createRepository(name, store, repoProps);
+ InternalRepository repository = createRepository(name, store, repoProps);
if (hasAnnotation(CountedTime.class))
{
@@ -655,6 +664,11 @@ public abstract class RepositoryConfig extends Config implements IRepositoryConf
return repository;
}
+ protected InternalRepository createRepository(String name, IStore store, Map<String, String> props)
+ {
+ return (InternalRepository)CDOServerUtil.createRepository(name, store, props);
+ }
+
protected InternalRepository getTestRepository()
{
return (InternalRepository)getTestProperty(PROP_TEST_REPOSITORY);
@@ -1075,9 +1089,14 @@ public abstract class RepositoryConfig extends Config implements IRepositoryConf
private static final long serialVersionUID = 1L;
+ public MEMConfig(String name, boolean supportingAudits, boolean supportingBranches, IDGenerationLocation idGenerationLocation)
+ {
+ super(name, supportingAudits, supportingBranches, idGenerationLocation);
+ }
+
public MEMConfig(boolean supportingAudits, boolean supportingBranches, IDGenerationLocation idGenerationLocation)
{
- super(STORE_NAME, supportingAudits, supportingBranches, idGenerationLocation);
+ this(STORE_NAME, supportingAudits, supportingBranches, idGenerationLocation);
}
@Override
@@ -1096,6 +1115,34 @@ public abstract class RepositoryConfig extends Config implements IRepositoryConf
{
return MEMStoreUtil.createMEMStore();
}
+
+ /**
+ * @author Eike Stepper
+ */
+ public static class Embedded extends MEMConfig
+ {
+ private static final long serialVersionUID = 1L;
+
+ public Embedded(boolean supportingAudits, boolean supportingBranches, IDGenerationLocation idGenerationLocation)
+ {
+ super(STORE_NAME + "Embedded", supportingAudits, supportingBranches, idGenerationLocation);
+ }
+
+ @Override
+ protected InternalRepository createRepository(String name)
+ {
+ InternalRepository repository = super.createRepository(name);
+
+ InternalCDORevisionManager revisionManager = repository.getRevisionManager();
+ revisionManager.setRevisionLoader(new ServerRevisionLoader(repository));
+
+ InternalCDOBranchManager branchManager = CDOBranchUtil.createBranchManager();
+ branchManager.setBranchLoader(new ServerBranchLoader(repository));
+ repository.setBranchManager(branchManager);
+
+ return repository;
+ }
+ }
}
/**
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/SessionConfig.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/SessionConfig.java
index 573a0f9e80..be01b4d04f 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/SessionConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/SessionConfig.java
@@ -11,14 +11,18 @@
*/
package org.eclipse.emf.cdo.tests.config.impl;
+import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
+import org.eclipse.emf.cdo.common.revision.CDORevisionManager;
+import org.eclipse.emf.cdo.net4j.CDONet4jSession;
import org.eclipse.emf.cdo.net4j.CDONet4jSessionConfiguration;
import org.eclipse.emf.cdo.net4j.CDONet4jUtil;
import org.eclipse.emf.cdo.net4j.CDONet4jViewProvider;
-import org.eclipse.emf.cdo.server.CDOServerUtil;
-import org.eclipse.emf.cdo.server.IRepository;
+import org.eclipse.emf.cdo.server.internal.embedded.ClientBranchManager;
+import org.eclipse.emf.cdo.server.internal.embedded.ClientRevisionManager;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.session.CDOSessionConfiguration;
import org.eclipse.emf.cdo.spi.common.CDOLobStoreImpl;
+import org.eclipse.emf.cdo.spi.server.InternalRepository;
import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
import org.eclipse.emf.cdo.tests.config.ISessionConfig;
import org.eclipse.emf.cdo.tests.util.TestRevisionManager;
@@ -315,56 +319,6 @@ public abstract class SessionConfig extends Config implements ISessionConfig
/**
* @author Eike Stepper
- * @deprecated Not yet supported.
- */
- @Deprecated
- public static final class Embedded extends SessionConfig
- {
- public static final String NAME = "Embedded";
-
- public static final Embedded INSTANCE = new Embedded();
-
- private static final long serialVersionUID = 1L;
-
- public Embedded()
- {
- super(NAME);
- }
-
- public void initCapabilities(Set<String> capabilities)
- {
- capabilities.add(CAPABILITY_EMBEDDED);
- }
-
- public String getURIProtocol()
- {
- throw new UnsupportedOperationException();
- }
-
- public String getURIPrefix()
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public CDOSessionConfiguration createSessionConfiguration(String repositoryName)
- {
- IRepository repository = getCurrentTest().getRepository(repositoryName);
-
- org.eclipse.emf.cdo.server.embedded.CDOSessionConfiguration configuration = CDOServerUtil.createSessionConfiguration();
- configuration.setRepository(repository);
- return configuration;
- }
-
- @Override
- protected boolean usesServerContainer()
- {
- return true;
- }
- }
-
- /**
- * @author Eike Stepper
*/
public static abstract class Net4j extends SessionConfig
{
@@ -620,7 +574,7 @@ public abstract class SessionConfig extends Config implements ISessionConfig
/**
* @author Eike Stepper
*/
- public static final class JVM extends SessionConfig.Net4j
+ public static class JVM extends SessionConfig.Net4j
{
public static final String NAME = "JVM";
@@ -630,9 +584,14 @@ public abstract class SessionConfig extends Config implements ISessionConfig
private static final long serialVersionUID = 1L;
+ public JVM(String name)
+ {
+ super(name);
+ }
+
public JVM()
{
- super(NAME);
+ this(NAME);
}
@Override
@@ -684,6 +643,52 @@ public abstract class SessionConfig extends Config implements ISessionConfig
}
};
}
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class Embedded extends SessionConfig.Net4j.JVM
+ {
+ public static final String NAME = "JVMEmbedded";
+
+ public static final Embedded INSTANCE = new Embedded();
+
+ private static final long serialVersionUID = 1L;
+
+ public Embedded()
+ {
+ super(NAME);
+ }
+
+ @Override
+ public void initCapabilities(Set<String> capabilities)
+ {
+ super.initCapabilities(capabilities);
+ capabilities.add(CAPABILITY_NET4J_EMBEDDED);
+ }
+
+ @Override
+ public CDOSessionConfiguration createSessionConfiguration(String repositoryName)
+ {
+ InternalRepository repository = getCurrentTest().getRepository(repositoryName);
+ CDOBranchManager branchManager = new ClientBranchManager(repository.getBranchManager());
+ CDORevisionManager revisionManager = new ClientRevisionManager(repository.getRevisionManager());
+
+ CDONet4jSessionConfiguration configuration = (CDONet4jSessionConfiguration)super.createSessionConfiguration(repositoryName);
+ configuration.setBranchManager(branchManager);
+ configuration.setRevisionManager(revisionManager);
+ configuration.setSignalTimeout(Integer.MAX_VALUE);
+
+ return configuration;
+ }
+
+ @Override
+ public void configureSession(CDOSession session)
+ {
+ super.configureSession(session);
+ ((CDONet4jSession)session).options().setCommitTimeout(Integer.MAX_VALUE);
+ }
+ }
}
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestRevisionManager.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestRevisionManager.java
index 942106285a..f1ec3372e8 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestRevisionManager.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestRevisionManager.java
@@ -19,7 +19,6 @@ import org.eclipse.emf.cdo.spi.common.revision.RevisionInfo;
import org.eclipse.emf.cdo.spi.common.revision.SyntheticCDORevision;
import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
-import org.eclipse.net4j.util.event.IListener;
import java.util.List;
@@ -71,12 +70,6 @@ public class TestRevisionManager extends CDORevisionManagerImpl
return super.getRevisions(ids, branchPoint, referenceChunk, prefetchDepth, loadOnDemand, synthetics);
}
- @Override
- public void addListener(IListener listener)
- {
- super.addListener(listener);
- }
-
public void resetLoadCounter()
{
synchronized (lock)

Back to the top