Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2011-07-20 11:50:52 +0000
committerEike Stepper2011-07-20 11:50:52 +0000
commitaf719ba16912427971a462cf41f6245cde962ab6 (patch)
tree8ea61c606d79b36652b1fdbcc7299aeac7ea0b9b /plugins/org.eclipse.emf.cdo.workspace/src
parentad46e775fa0f070dcb43eaea4e8b260e3e9bf443 (diff)
downloadcdo-af719ba16912427971a462cf41f6245cde962ab6.tar.gz
cdo-af719ba16912427971a462cf41f6245cde962ab6.tar.xz
cdo-af719ba16912427971a462cf41f6245cde962ab6.zip
[352561] Support client assigned CDOIDs (UUIDs)
https://bugs.eclipse.org/bugs/show_bug.cgi?id=352561
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.workspace/src')
-rw-r--r--plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/AbstractCDOWorkspaceBase.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/CDOWorkspaceConfigurationImpl.java140
-rw-r--r--plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/CDOWorkspaceImpl.java221
-rw-r--r--plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/spi/workspace/InternalCDOWorkspace.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspace.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceBase.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceConfiguration.java65
-rw-r--r--plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceUtil.java47
8 files changed, 408 insertions, 77 deletions
diff --git a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/AbstractCDOWorkspaceBase.java b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/AbstractCDOWorkspaceBase.java
index ff1cae21af..6d2d06fdb3 100644
--- a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/AbstractCDOWorkspaceBase.java
+++ b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/AbstractCDOWorkspaceBase.java
@@ -96,6 +96,7 @@ public abstract class AbstractCDOWorkspaceBase implements InternalCDOWorkspaceBa
protected boolean isAddedObject(CDOID id)
{
+ // throw new RuntimeException("Check whether CDOID.isLocal() is still valid with UUIDs");
return store.isLocal(id);
}
diff --git a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/CDOWorkspaceConfigurationImpl.java b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/CDOWorkspaceConfigurationImpl.java
new file mode 100644
index 0000000000..9ae4365363
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/CDOWorkspaceConfigurationImpl.java
@@ -0,0 +1,140 @@
+/**
+ * Copyright (c) 2004 - 2011 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.internal.workspace;
+
+import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.id.CDOIDGenerator;
+import org.eclipse.emf.cdo.server.IStore;
+import org.eclipse.emf.cdo.session.CDOSessionConfigurationFactory;
+import org.eclipse.emf.cdo.spi.workspace.InternalCDOWorkspaceBase;
+import org.eclipse.emf.cdo.workspace.CDOWorkspace;
+import org.eclipse.emf.cdo.workspace.CDOWorkspaceBase;
+import org.eclipse.emf.cdo.workspace.CDOWorkspaceConfiguration;
+
+/**
+ * @author Eike Stepper
+ * @since 4.1
+ */
+public class CDOWorkspaceConfigurationImpl implements CDOWorkspaceConfiguration
+{
+ private String localRepositoryName = DEFAULT_LOCAL_REPOSITORY_NAME;
+
+ private IStore store;
+
+ private CDOWorkspaceBase base;
+
+ private CDOSessionConfigurationFactory remote;
+
+ private String branchPath;
+
+ private long timeStamp = CDOBranchPoint.UNSPECIFIED_DATE;
+
+ private IDGenerationLocation idGenerationLocation = IDGenerationLocation.STORE;
+
+ private CDOIDGenerator idGenerator;
+
+ public CDOWorkspaceConfigurationImpl()
+ {
+ }
+
+ public String getLocalRepositoryName()
+ {
+ return localRepositoryName;
+ }
+
+ public void setLocalRepositoryName(String localRepositoryName)
+ {
+ this.localRepositoryName = localRepositoryName;
+ }
+
+ public IStore getStore()
+ {
+ return store;
+ }
+
+ public void setStore(IStore store)
+ {
+ this.store = store;
+ }
+
+ public CDOWorkspaceBase getBase()
+ {
+ return base;
+ }
+
+ public void setBase(CDOWorkspaceBase base)
+ {
+ this.base = base;
+ }
+
+ public CDOSessionConfigurationFactory getRemote()
+ {
+ return remote;
+ }
+
+ public void setRemote(CDOSessionConfigurationFactory remote)
+ {
+ this.remote = remote;
+ }
+
+ public String getBranchPath()
+ {
+ return branchPath;
+ }
+
+ public void setBranchPath(String branchPath)
+ {
+ this.branchPath = branchPath;
+ }
+
+ public long getTimeStamp()
+ {
+ return timeStamp;
+ }
+
+ public void setTimeStamp(long timeStamp)
+ {
+ this.timeStamp = timeStamp;
+ }
+
+ public IDGenerationLocation getIDGenerationLocation()
+ {
+ return idGenerationLocation;
+ }
+
+ public void setIDGenerationLocation(IDGenerationLocation idGenerationLocation)
+ {
+ this.idGenerationLocation = idGenerationLocation;
+ }
+
+ public CDOIDGenerator getIDGenerator()
+ {
+ return idGenerator;
+ }
+
+ public void setIDGenerator(CDOIDGenerator idGenerator)
+ {
+ this.idGenerator = idGenerator;
+ }
+
+ public CDOWorkspace open()
+ {
+ return new CDOWorkspaceImpl(localRepositoryName, store, idGenerationLocation, idGenerator,
+ (InternalCDOWorkspaceBase)base, remote);
+ }
+
+ public CDOWorkspace checkout()
+ {
+ return new CDOWorkspaceImpl(localRepositoryName, store, idGenerationLocation, idGenerator,
+ (InternalCDOWorkspaceBase)base, remote, branchPath, timeStamp);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/CDOWorkspaceImpl.java b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/CDOWorkspaceImpl.java
index 53c4be39d6..d80ab02ae1 100644
--- a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/CDOWorkspaceImpl.java
+++ b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/CDOWorkspaceImpl.java
@@ -10,6 +10,8 @@
*/
package org.eclipse.emf.cdo.internal.workspace;
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
import org.eclipse.emf.cdo.common.branch.CDOBranchPointRange;
@@ -17,6 +19,7 @@ import org.eclipse.emf.cdo.common.commit.CDOChangeSet;
import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDGenerator;
import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.CDORevisionCache;
@@ -27,13 +30,15 @@ import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
import org.eclipse.emf.cdo.internal.server.Repository;
import org.eclipse.emf.cdo.net4j.CDONet4jSessionConfiguration;
import org.eclipse.emf.cdo.net4j.CDONet4jUtil;
-import org.eclipse.emf.cdo.server.CDOServerBrowser;
import org.eclipse.emf.cdo.server.CDOServerUtil;
import org.eclipse.emf.cdo.server.IRepository.Props;
+import org.eclipse.emf.cdo.server.ISession;
import org.eclipse.emf.cdo.server.IStore;
import org.eclipse.emf.cdo.server.IStoreAccessor;
+import org.eclipse.emf.cdo.server.ITransaction;
import org.eclipse.emf.cdo.server.StoreThreadLocal;
import org.eclipse.emf.cdo.server.net4j.CDONet4jServerUtil;
+import org.eclipse.emf.cdo.session.CDORepositoryInfo;
import org.eclipse.emf.cdo.session.CDOSessionConfiguration;
import org.eclipse.emf.cdo.session.CDOSessionConfigurationFactory;
import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil;
@@ -47,6 +52,7 @@ import org.eclipse.emf.cdo.spi.server.InternalStore;
import org.eclipse.emf.cdo.spi.workspace.InternalCDOWorkspace;
import org.eclipse.emf.cdo.spi.workspace.InternalCDOWorkspaceBase;
import org.eclipse.emf.cdo.transaction.CDOCommitContext;
+import org.eclipse.emf.cdo.transaction.CDODefaultTransactionHandler1;
import org.eclipse.emf.cdo.transaction.CDODefaultTransactionHandler2;
import org.eclipse.emf.cdo.transaction.CDOMerger;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
@@ -59,8 +65,8 @@ import org.eclipse.net4j.Net4jUtil;
import org.eclipse.net4j.jvm.IJVMAcceptor;
import org.eclipse.net4j.jvm.IJVMConnector;
import org.eclipse.net4j.jvm.JVMUtil;
+import org.eclipse.net4j.signal.ISignalProtocol;
import org.eclipse.net4j.util.StringUtil;
-import org.eclipse.net4j.util.collection.Pair;
import org.eclipse.net4j.util.container.ContainerUtil;
import org.eclipse.net4j.util.container.IManagedContainer;
import org.eclipse.net4j.util.event.IEvent;
@@ -71,10 +77,12 @@ import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import org.eclipse.net4j.util.om.monitor.Monitor;
import org.eclipse.net4j.util.om.monitor.OMMonitor;
+import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.resource.ResourceSet;
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.InternalCDOTransaction.ApplyChangeSetResult;
import org.eclipse.emf.spi.cdo.InternalCDOView;
import java.util.Arrays;
@@ -100,6 +108,10 @@ public class CDOWorkspaceImpl implements InternalCDOWorkspace
private InternalCDOWorkspaceBase base;
+ private IDGenerationLocation idGenerationLocation;
+
+ private CDOIDGenerator idGenerator;
+
private InternalRepository localRepository;
private InternalCDOSession localSession;
@@ -116,13 +128,11 @@ public class CDOWorkspaceImpl implements InternalCDOWorkspace
private Set<InternalCDOView> views = new HashSet<InternalCDOView>();
- private CDOServerBrowser browser;
-
- public CDOWorkspaceImpl(IStore local, InternalCDOWorkspaceBase base, CDOSessionConfigurationFactory remote,
+ public CDOWorkspaceImpl(String localRepositoryName, IStore local, IDGenerationLocation idGenerationLocation,
+ CDOIDGenerator idGenerator, InternalCDOWorkspaceBase base, CDOSessionConfigurationFactory remote,
String branchPath, long timeStamp)
{
- init(local, base, remote);
- remoteSessionConfigurationFactory = remote;
+ init(localRepositoryName, local, idGenerationLocation, idGenerator, base, remote);
this.branchPath = StringUtil.isEmpty(branchPath) ? CDOBranch.MAIN_BRANCH_NAME : branchPath;
this.timeStamp = timeStamp;
@@ -132,24 +142,23 @@ public class CDOWorkspaceImpl implements InternalCDOWorkspace
saveProperties();
}
- public CDOWorkspaceImpl(IStore local, InternalCDOWorkspaceBase base, CDOSessionConfigurationFactory remote)
+ public CDOWorkspaceImpl(String localRepositoryName, IStore local, IDGenerationLocation idGenerationLocation,
+ CDOIDGenerator idGenerator, InternalCDOWorkspaceBase base, CDOSessionConfigurationFactory remote)
{
- init(local, base, remote);
+ init(localRepositoryName, local, idGenerationLocation, idGenerator, base, remote);
loadProperties();
}
- protected void init(IStore local, InternalCDOWorkspaceBase base, CDOSessionConfigurationFactory remote)
+ protected void init(String localRepositoryName, IStore local, IDGenerationLocation idGenerationLocation,
+ CDOIDGenerator idGenerator, InternalCDOWorkspaceBase base, CDOSessionConfigurationFactory remote)
{
+ this.idGenerationLocation = idGenerationLocation;
+ this.idGenerator = idGenerator;
+
container = createContainer(local);
remoteSessionConfigurationFactory = remote;
- localRepository = createLocalRepository(local);
-
- Map<String, InternalRepository> repositories = new HashMap<String, InternalRepository>();
- repositories.put(localRepository.getName(), localRepository);
- browser = new CDOServerBrowser(repositories);
- browser.setPort(7779);
- browser.activate();
+ localRepository = createLocalRepository(localRepositoryName, local);
this.base = base;
this.base.init(this);
@@ -222,6 +231,11 @@ public class CDOWorkspaceImpl implements InternalCDOWorkspace
return fixed;
}
+ public CDOIDGenerator getIDGenerator()
+ {
+ return idGenerator;
+ }
+
public InternalCDOWorkspaceBase getBase()
{
return base;
@@ -296,7 +310,7 @@ public class CDOWorkspaceImpl implements InternalCDOWorkspace
}
});
- transaction.applyChangeSetData(remoteData, new CDORevisionProvider()
+ transaction.applyChangeSet(remoteData, new CDORevisionProvider()
{
public CDORevision getRevision(CDOID id)
{
@@ -346,18 +360,23 @@ public class CDOWorkspaceImpl implements InternalCDOWorkspace
CDOChangeSetData changes = getLocalChanges();
- Pair<Map<CDOID, CDOID>, List<CDOID>> mappedLocalIDs = transaction.applyChangeSetData(changes, base, this, head)
- .getElement2();
+ ApplyChangeSetResult result = transaction.applyChangeSet(changes, base, this, head);
+ if (!result.getIDMappings().isEmpty())
+ {
+ throw new IllegalStateException("Attaching new objects is only supported for IDGenerationLocation.CLIENT");
+ }
- CDOIDMapper idMapper = getIDMapper(transaction, mappedLocalIDs);
+ // Attaching new objects is only supported for IDGenerationLocation.CLIENT
+ // CDOIDMapper idMapper = getIDMapper(transaction, result.getIDMappings());
transaction.setCommitComment(comment);
CDOCommitInfo info = transaction.commit();
- if (idMapper != null)
- {
- adjustLocally(idMapper, mappedLocalIDs.getElement2());
- }
+ // Attaching new objects is only supported for IDGenerationLocation.CLIENT
+ // if (idMapper != null)
+ // {
+ // adjustLocalIDs(idMapper, result.getAdjustedObjects());
+ // }
base.clear();
timeStamp = info.getTimeStamp();
@@ -371,15 +390,17 @@ public class CDOWorkspaceImpl implements InternalCDOWorkspace
}
}
- protected CDOIDMapper getIDMapper(InternalCDOTransaction transaction,
- Pair<Map<CDOID, CDOID>, List<CDOID>> mappedLocalIDs)
+ /**
+ * @deprecated Attaching new objects is only supported for IDGenerationLocation.CLIENT
+ */
+ @Deprecated
+ protected CDOIDMapper getIDMapper(InternalCDOTransaction transaction, final Map<CDOID, CDOID> idMappings)
{
- if (mappedLocalIDs == null)
+ if (idMappings.isEmpty())
{
return null;
}
- final Map<CDOID, CDOID> idMappings = mappedLocalIDs.getElement1();
transaction.addListener(new IListener()
{
public void notifyEvent(IEvent event)
@@ -401,50 +422,73 @@ public class CDOWorkspaceImpl implements InternalCDOWorkspace
return new CDOIDMapper(idMappings);
}
- protected void adjustLocally(CDOIDMapper idMapper, List<CDOID> adjustedObjects)
+ /**
+ * @deprecated Attaching new objects is only supported for IDGenerationLocation.CLIENT
+ */
+ @Deprecated
+ protected void adjustLocalIDs(CDOIDMapper idMapper, List<CDOID> adjustedObjects)
{
- IStoreAccessor.Raw accessor = (IStoreAccessor.Raw)localRepository.getStore().getReader(null);
- OMMonitor monitor = new Monitor();
-
- for (Entry<CDOID, CDOID> entry : idMapper.getIDMappings().entrySet())
+ Map<CDOID, CDOID> idMappings = idMapper.getIDMappings();
+ if (!idMappings.isEmpty())
{
- CDOID id = entry.getKey();
- InternalCDORevision revision = accessor.readRevision(id, head, CDORevision.UNCHUNKED, null);
- accessor.rawDelete(revision.getID(), revision.getVersion(), revision.getBranch(), revision.getEClass(), monitor);
+ CDOTransaction transaction = null;
+ OMMonitor monitor = new Monitor();
- CDOID newID = entry.getValue();
- revision.setID(newID);
- revision.setVersion(CDORevision.FIRST_VERSION);
+ try
+ {
+ transaction = localSession.openTransaction();
+ ISession repoSession = localRepository.getSessionManager().getSession(localSession.getSessionID());
+ ITransaction repoTransaction = (ITransaction)repoSession.getView(transaction.getViewID());
- revision.adjustReferences(idMapper);
- accessor.rawStore(revision, monitor);
- }
+ IStoreAccessor.Raw accessor = (IStoreAccessor.Raw)localRepository.getStore().getWriter(repoTransaction);
+ StoreThreadLocal.setAccessor(accessor);
- for (CDOID id : adjustedObjects)
- {
- InternalCDORevision revision = accessor.readRevision(id, head, CDORevision.UNCHUNKED, null);
- accessor.rawDelete(revision.getID(), revision.getVersion(), revision.getBranch(), revision.getEClass(), monitor);
+ monitor.begin(idMappings.size() * 2 + adjustedObjects.size() * 2 + 10);
- revision.adjustReferences(idMapper);
- accessor.rawStore(revision, monitor);
- }
+ for (Entry<CDOID, CDOID> entry : idMappings.entrySet())
+ {
+ CDOID id = entry.getKey();
- accessor.rawCommit(1, monitor);
- }
+ InternalCDORevision revision = accessor.readRevision(id, head, CDORevision.UNCHUNKED, null);
+ int version = revision.getVersion();
+ CDOBranch branch = revision.getBranch();
+ EClass eClass = revision.getEClass();
- protected InternalCDORevision adjustRevision(IStoreAccessor.Raw accessor, CDOID id, CDOIDMapper idMapper)
- {
- InternalCDORevision revision = accessor.readRevision(id, head, CDORevision.UNCHUNKED, null);
- CDOID newID = idMapper.getIDMappings().get(id);
- if (newID != null)
- {
- revision.setID(newID);
- revision.setVersion(CDORevision.FIRST_VERSION);
- }
+ CDOID newID = entry.getValue();
+ revision.setID(newID);
+ revision.setVersion(CDORevision.FIRST_VERSION);
- revision.adjustReferences(idMapper);
- accessor.rawStore(revision, new Monitor());
- return revision;
+ accessor.rawDelete(id, version, branch, eClass, monitor.fork());
+ revision.adjustReferences(idMapper);
+ accessor.rawStore(revision, monitor.fork());
+ }
+
+ for (CDOID id : adjustedObjects)
+ {
+ InternalCDORevision revision = accessor.readRevision(id, head, CDORevision.UNCHUNKED, null);
+ int version = revision.getVersion();
+ CDOBranch branch = revision.getBranch();
+ EClass eClass = revision.getEClass();
+
+ // TODO DBStoreAccessor.rawDelete() creates a new row with -(version+1)!!!
+ accessor.rawDelete(id, version, branch, eClass, monitor.fork());
+ revision.adjustReferences(idMapper);
+ accessor.rawStore(revision, monitor.fork());
+ }
+
+ accessor.rawCommit(1, monitor.fork(10));
+ }
+ finally
+ {
+ monitor.done();
+ StoreThreadLocal.release();
+
+ if (transaction != null)
+ {
+ transaction.close();
+ }
+ }
+ }
}
public CDOChangeSetData compare(String branchPath)
@@ -460,9 +504,6 @@ public class CDOWorkspaceImpl implements InternalCDOWorkspace
public synchronized void close()
{
- LifecycleUtil.deactivate(browser);
- browser = null;
-
LifecycleUtil.deactivate(localSession);
localSession = null;
@@ -538,20 +579,28 @@ public class CDOWorkspaceImpl implements InternalCDOWorkspace
return JVMUtil.getConnector(container, localAcceptorName);
}
- protected InternalRepository createLocalRepository(IStore store)
+ protected InternalRepository createLocalRepository(String localRepositoryName, IStore store)
{
Map<String, String> props = new HashMap<String, String>();
props.put(Props.OVERRIDE_UUID, ""); // UUID := name !!!
props.put(Props.SUPPORTING_AUDITS, "false");
props.put(Props.SUPPORTING_BRANCHES, "false");
+ props.put(Props.ID_GENERATION_LOCATION, idGenerationLocation.toString());
Repository repository = new Repository.Default()
{
@Override
public void initMainBranch(InternalCDOBranchManager branchManager, long timeStamp)
{
- // Mark the main branch local so that new objects get local IDs
- branchManager.initMainBranch(true, timeStamp);
+ if (idGenerationLocation == IDGenerationLocation.STORE)
+ {
+ // Mark the main branch local so that new objects get local IDs
+ branchManager.initMainBranch(true, timeStamp);
+ }
+ else
+ {
+ super.initMainBranch(branchManager, timeStamp);
+ }
}
@Override
@@ -562,7 +611,7 @@ public class CDOWorkspaceImpl implements InternalCDOWorkspace
}
};
- repository.setName("local");
+ repository.setName(localRepositoryName);
repository.setStore((InternalStore)store);
repository.setProperties(props);
@@ -580,10 +629,16 @@ public class CDOWorkspaceImpl implements InternalCDOWorkspace
CDONet4jSessionConfiguration configuration = CDONet4jUtil.createNet4jSessionConfiguration();
configuration.setConnector(connector);
configuration.setRepositoryName(repositoryName);
+ configuration.setIDGenerator(idGenerator);
configuration.setRevisionManager(CDORevisionUtil.createRevisionManager(CDORevisionCache.NOOP)); // Use repo's cache
- ((InternalCDOSessionConfiguration)configuration).setMainBranchLocal(true);
+
+ if (idGenerationLocation == IDGenerationLocation.STORE)
+ {
+ ((InternalCDOSessionConfiguration)configuration).setMainBranchLocal(true);
+ }
InternalCDOSession session = (InternalCDOSession)configuration.openNet4jSession();
+ ((ISignalProtocol<?>)session.getSessionProtocol()).setTimeout(ISignalProtocol.NO_TIMEOUT);
session.setPackageRegistry(localRepository.getPackageRegistry(false)); // Use repo's registry
head = session.getBranchManager().getMainBranch().getHead();
@@ -633,6 +688,18 @@ public class CDOWorkspaceImpl implements InternalCDOWorkspace
CDOWorkspaceImpl.this.committedTransaction(transaction, commitContext);
}
});
+
+ if (idGenerationLocation != IDGenerationLocation.CLIENT)
+ {
+ transaction.addTransactionHandler(new CDODefaultTransactionHandler1()
+ {
+ @Override
+ public void attachingObject(CDOTransaction transaction, CDOObject object)
+ {
+ throw new IllegalStateException("Attaching new objects is only supported for IDGenerationLocation.CLIENT");
+ }
+ });
+ }
}
}
@@ -651,12 +718,20 @@ public class CDOWorkspaceImpl implements InternalCDOWorkspace
CDOSessionConfiguration configuration = remoteSessionConfigurationFactory.createSessionConfiguration();
InternalCDOSession session = (InternalCDOSession)configuration.openSession();
- if (!session.getRepositoryInfo().isSupportingAudits())
+ CDORepositoryInfo repositoryInfo = session.getRepositoryInfo();
+ if (!repositoryInfo.isSupportingAudits())
{
session.close();
throw new IllegalStateException("Remote repository does not support auditing");
}
+ IDGenerationLocation remoteLocation = repositoryInfo.getIDGenerationLocation();
+ if (!remoteLocation.equals(idGenerationLocation))
+ {
+ session.close();
+ throw new IllegalStateException("Remote repository uses different ID generation location: " + remoteLocation);
+ }
+
return session;
}
diff --git a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/spi/workspace/InternalCDOWorkspace.java b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/spi/workspace/InternalCDOWorkspace.java
index bbdfd321ec..3f90cf59c3 100644
--- a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/spi/workspace/InternalCDOWorkspace.java
+++ b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/spi/workspace/InternalCDOWorkspace.java
@@ -17,6 +17,8 @@ import org.eclipse.emf.spi.cdo.InternalCDOSession;
/**
* @author Eike Stepper
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
*/
public interface InternalCDOWorkspace extends CDOWorkspace
{
diff --git a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspace.java b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspace.java
index d44c8f25a9..4604bfd62c 100644
--- a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspace.java
+++ b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspace.java
@@ -23,7 +23,11 @@ import org.eclipse.net4j.util.collection.Closeable;
import org.eclipse.emf.ecore.resource.ResourceSet;
/**
+ * Represents a local {@link CDOWorkspaceConfiguration#checkout() checkout} from a remote repository.
+ *
* @author Eike Stepper
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
*/
public interface CDOWorkspace extends CDORevisionProvider, Closeable
{
diff --git a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceBase.java b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceBase.java
index a31ce1a94a..f952e00cb5 100644
--- a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceBase.java
+++ b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceBase.java
@@ -16,6 +16,11 @@ import org.eclipse.emf.cdo.common.revision.CDORevisionProvider;
import java.util.Set;
/**
+ * Represents the local state of a {@link CDOWorkspace workspace} directly after the initial
+ * {@link CDOWorkspaceConfiguration#checkout() checkout} operation or any subsequent
+ * {@link CDOWorkspace#update(org.eclipse.emf.cdo.transaction.CDOMerger) update} and
+ * {@link CDOWorkspace#replace(String, long) replace} operations.
+ *
* @author Eike Stepper
*/
public interface CDOWorkspaceBase extends CDORevisionProvider
diff --git a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceConfiguration.java b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceConfiguration.java
new file mode 100644
index 0000000000..c971798f0e
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceConfiguration.java
@@ -0,0 +1,65 @@
+/**
+ * Copyright (c) 2004 - 2011 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.workspace;
+
+import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
+import org.eclipse.emf.cdo.common.id.CDOIDGenerator;
+import org.eclipse.emf.cdo.server.IStore;
+import org.eclipse.emf.cdo.session.CDOSessionConfigurationFactory;
+
+/**
+ * Checks out new {@link CDOWorkspace workspace} or opens existing ones.
+ *
+ * @author Eike Stepper
+ * @since 4.1
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface CDOWorkspaceConfiguration
+{
+ public static final String DEFAULT_LOCAL_REPOSITORY_NAME = "local";
+
+ public String getLocalRepositoryName();
+
+ public void setLocalRepositoryName(String localRepositoryName);
+
+ public IStore getStore();
+
+ public void setStore(IStore store);
+
+ public CDOWorkspaceBase getBase();
+
+ public void setBase(CDOWorkspaceBase base);
+
+ public CDOSessionConfigurationFactory getRemote();
+
+ public void setRemote(CDOSessionConfigurationFactory remote);
+
+ public String getBranchPath();
+
+ public void setBranchPath(String branchPath);
+
+ public long getTimeStamp();
+
+ public void setTimeStamp(long timeStamp);
+
+ public IDGenerationLocation getIDGenerationLocation();
+
+ public void setIDGenerationLocation(IDGenerationLocation idGenerationLocation);
+
+ public CDOIDGenerator getIDGenerator();
+
+ public void setIDGenerator(CDOIDGenerator idGenerator);
+
+ public CDOWorkspace open();
+
+ public CDOWorkspace checkout();
+}
diff --git a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceUtil.java b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceUtil.java
index 261ab02786..7552646962 100644
--- a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceUtil.java
+++ b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceUtil.java
@@ -11,15 +11,16 @@
package org.eclipse.emf.cdo.workspace;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.internal.workspace.CDOWorkspaceImpl;
+import org.eclipse.emf.cdo.internal.workspace.CDOWorkspaceConfigurationImpl;
import org.eclipse.emf.cdo.internal.workspace.FolderCDOWorkspaceBase;
import org.eclipse.emf.cdo.server.IStore;
import org.eclipse.emf.cdo.session.CDOSessionConfigurationFactory;
-import org.eclipse.emf.cdo.spi.workspace.InternalCDOWorkspaceBase;
import java.io.File;
/**
+ * Various static helper methods for dealing with {@link CDOWorkspace workspaces}.
+ *
* @author Eike Stepper
*/
public final class CDOWorkspaceUtil
@@ -33,31 +34,69 @@ public final class CDOWorkspaceUtil
return new FolderCDOWorkspaceBase(folder);
}
+ /**
+ * @since 4.1
+ */
+ public static CDOWorkspaceConfiguration createWorkspaceConfiguration()
+ {
+ return new CDOWorkspaceConfigurationImpl();
+ }
+
+ /**
+ * @deprecated Use {@link #createWorkspaceConfiguration()} and {@link CDOWorkspaceConfiguration#open()}
+ */
+ @Deprecated
public static CDOWorkspace open(IStore local, CDOWorkspaceBase base, CDOSessionConfigurationFactory remote)
{
- return new CDOWorkspaceImpl(local, (InternalCDOWorkspaceBase)base, remote);
+ CDOWorkspaceConfiguration config = createWorkspaceConfiguration();
+ config.setStore(local);
+ config.setBase(base);
+ config.setRemote(remote);
+ return config.open();
}
+ /**
+ * @deprecated Use {@link #createWorkspaceConfiguration()} and {@link CDOWorkspaceConfiguration#checkout()}
+ */
+ @Deprecated
public static CDOWorkspace checkout(IStore local, CDOWorkspaceBase base, CDOSessionConfigurationFactory remote)
{
return checkout(local, base, remote, null);
}
+ /**
+ * @deprecated Use {@link #createWorkspaceConfiguration()} and {@link CDOWorkspaceConfiguration#checkout()}
+ */
+ @Deprecated
public static CDOWorkspace checkout(IStore local, CDOWorkspaceBase base, CDOSessionConfigurationFactory remote,
String branchPath)
{
return checkout(local, base, remote, branchPath, CDOBranchPoint.UNSPECIFIED_DATE);
}
+ /**
+ * @deprecated Use {@link #createWorkspaceConfiguration()} and {@link CDOWorkspaceConfiguration#checkout()}
+ */
+ @Deprecated
public static CDOWorkspace checkout(IStore local, CDOWorkspaceBase base, CDOSessionConfigurationFactory remote,
long timeStamp)
{
return checkout(local, base, remote, null, timeStamp);
}
+ /**
+ * @deprecated Use {@link #createWorkspaceConfiguration()} and {@link CDOWorkspaceConfiguration#checkout()}
+ */
+ @Deprecated
public static CDOWorkspace checkout(IStore local, CDOWorkspaceBase base, CDOSessionConfigurationFactory remote,
String branchPath, long timeStamp)
{
- return new CDOWorkspaceImpl(local, (InternalCDOWorkspaceBase)base, remote, branchPath, timeStamp);
+ CDOWorkspaceConfiguration config = createWorkspaceConfiguration();
+ config.setStore(local);
+ config.setBase(base);
+ config.setRemote(remote);
+ config.setBranchPath(branchPath);
+ config.setTimeStamp(timeStamp);
+ return config.checkout();
}
}

Back to the top