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
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
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/CDOCommonRepository.java19
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDGenerator.java86
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDUtil.java58
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOIDByteArray.java9
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/CDONet4jSessionConfigurationImpl.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitXATransactionPhase2Request.java30
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/OpenSessionRequest.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/META-INF/MANIFEST.MF18
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStore.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IIDHandler.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IClassMapping.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java41
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java76
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/LongIDHandler.java18
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/StringIDHandler.java16
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/UUIDHandler.java243
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditFeatureMapTableMappingWithRanges.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingFeatureMapTableMappingWithRanges.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db4o/src/org/eclipse/emf/cdo/server/internal/db4o/DB4OStoreAccessor.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.mongodb/META-INF/MANIFEST.MF8
-rw-r--r--plugins/org.eclipse.emf.cdo.server.mongodb/src/org/eclipse/emf/cdo/server/internal/mongodb/Commits.java14
-rw-r--r--plugins/org.eclipse.emf.cdo.server.net4j/META-INF/MANIFEST.MF8
-rw-r--r--plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/OpenSessionIndication.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/META-INF/MANIFEST.MF18
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreAccessor.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server/META-INF/MANIFEST.MF22
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java43
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ServerCDOView.java18
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSessionConfiguration.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/mem/MEMStoreAccessor.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepository.java9
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStore.java13
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreAccessor.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/StoreAccessor.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Offline.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBStoreRepositoryConfig.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/SQLQueryTest.java54
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db4o/src/org/eclipse/emf/cdo/tests/db4o/AllTestsDB4O.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db4o/src/org/eclipse/emf/cdo/tests/db4o/AllTestsMEMDB4O.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateConfig.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.mongodb/src/org/eclipse/emf/cdo/tests/mongodb/MongoDBStoreRepositoryConfig.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.objectivity/src/org/eclipse/emf/cdo/tests/objectivity/ObjyStoreRepositoryConfig.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InitialTest.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/WorkspaceTest.java40
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_327604_Test.java11
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IRepositoryConfig.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java18
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestSessionConfiguration.java11
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/messages/messages.properties2
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/properties/CDOSessionPropertySource.java16
-rw-r--r--plugins/org.eclipse.emf.cdo.workspace.efs/src/org/eclipse/emf/cdo/workspace/efs/CDOFS.java18
-rw-r--r--plugins/org.eclipse.emf.cdo.workspace/META-INF/MANIFEST.MF10
-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
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java5
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDOSession.java6
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDOSessionConfiguration.java16
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java5
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOQueryImpl.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionConfigurationImpl.java16
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java18
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOSavepointImpl.java42
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java151
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CommitIntegrityCheck.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java21
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStateMachine.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/AbstractObjectConflictResolver.java4
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOSessionProtocol.java16
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOSavepoint.java5
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOSession.java6
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOTransaction.java56
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOView.java5
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AllTests.java2
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/UUIDGeneratorTest.java59
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/HexUtil.java2
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/UUIDGenerator.java372
84 files changed, 2010 insertions, 343 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/CDOCommonRepository.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/CDOCommonRepository.java
index d509b32431..eebcc6a17e 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/CDOCommonRepository.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/CDOCommonRepository.java
@@ -63,6 +63,11 @@ public interface CDOCommonRepository extends CDOTimeProvider
public Set<CDOID.ObjectType> getObjectIDTypes();
/**
+ * @since 4.1
+ */
+ public IDGenerationLocation getIDGenerationLocation();
+
+ /**
* Returns the ID of the root resource of this repository.
*/
public CDOID getRootResourceID();
@@ -92,10 +97,21 @@ public interface CDOCommonRepository extends CDOTimeProvider
public boolean isEnsuringReferentialIntegrity();
/**
+ * Enumerates the possible {@link CDOCommonRepository#getIDGenerationLocation() ID generation locations} of a CDO
+ * repository.
+ *
+ * @author Eike Stepper
+ * @since 4.1
+ */
+ public enum IDGenerationLocation
+ {
+ STORE, CLIENT
+ }
+
+ /**
* Enumerates the possible {@link CDOCommonRepository#getType() types} of a CDO repository.
*
* @author Eike Stepper
- * @noextend This interface is not intended to be extended by clients.
*/
public enum Type
{
@@ -106,7 +122,6 @@ public interface CDOCommonRepository extends CDOTimeProvider
* Enumerates the possible {@link CDOCommonRepository#getState() states} of a CDO repository.
*
* @author Eike Stepper
- * @noextend This interface is not intended to be extended by clients.
*/
public static enum State
{
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDGenerator.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDGenerator.java
new file mode 100644
index 0000000000..10135fb92d
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDGenerator.java
@@ -0,0 +1,86 @@
+/**
+ * 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.common.id;
+
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * Generates {@link CDOID IDs}.
+ *
+ * @author Eike Stepper
+ * @since 4.1
+ */
+public interface CDOIDGenerator
+{
+ /**
+ * Generates {@link CDOID#NULL NULL} values.
+ */
+ public static final CDOIDGenerator NULL = new CDOIDGenerator()
+ {
+ public CDOID generateCDOID()
+ {
+ return CDOID.NULL;
+ }
+
+ public void reset()
+ {
+ // Do nothing
+ }
+ };
+
+ /**
+ * Generates {@link EcoreUtil#generateUUID(byte[]) UUID} values.
+ */
+ public static final CDOIDGenerator UUID = new CDOIDGenerator()
+ {
+ public CDOID generateCDOID()
+ {
+ byte[] bytes = new byte[16];
+ EcoreUtil.generateUUID(bytes);
+ return CDOIDUtil.createUUID(bytes);
+ }
+
+ public void reset()
+ {
+ // Do nothing
+ }
+ };
+
+ public CDOID generateCDOID();
+
+ public void reset();
+
+ /**
+ * Generates {@link CDOIDTemp temporary} ID values.
+ *
+ * @author Eike Stepper
+ */
+ public static final class TempID implements CDOIDGenerator
+ {
+ private AtomicInteger lastTemporaryID = new AtomicInteger();
+
+ public TempID()
+ {
+ }
+
+ public CDOID generateCDOID()
+ {
+ return CDOIDUtil.createTempObject(lastTemporaryID.incrementAndGet());
+ }
+
+ public void reset()
+ {
+ lastTemporaryID.set(0);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDUtil.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDUtil.java
index 66cfd1caae..1cd89a7643 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDUtil.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDUtil.java
@@ -31,11 +31,13 @@ import org.eclipse.emf.cdo.internal.common.messages.Messages;
import org.eclipse.emf.cdo.internal.common.revision.CDOIDAndBranchImpl;
import org.eclipse.emf.cdo.internal.common.revision.CDOIDAndVersionImpl;
import org.eclipse.emf.cdo.spi.common.id.AbstractCDOID;
+import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDByteArray;
import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDLong;
import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDString;
import org.eclipse.emf.cdo.spi.common.id.InternalCDOIDObject;
import org.eclipse.net4j.util.ObjectUtil;
+import org.eclipse.net4j.util.UUIDGenerator;
import java.text.MessageFormat;
@@ -137,6 +139,36 @@ public final class CDOIDUtil
}
/**
+ * @since 4.1
+ */
+ public static byte[] getByteArray(CDOID id)
+ {
+ if (id == null)
+ {
+ return null;
+ }
+
+ switch (id.getType())
+ {
+ case NULL:
+ return null;
+
+ case OBJECT:
+ if (id instanceof AbstractCDOIDByteArray)
+ {
+ return ((AbstractCDOIDByteArray)id).getByteArrayValue();
+ }
+
+ throw new IllegalArgumentException(MessageFormat.format(
+ Messages.getString("CDOIDUtil.0"), id.getClass().getName())); //$NON-NLS-1$
+
+ default:
+ throw new IllegalArgumentException(MessageFormat.format(
+ Messages.getString("CDOIDUtil.3"), id.getClass().getName())); //$NON-NLS-1$
+ }
+ }
+
+ /**
* @since 3.0
*/
public static CDOClassifierRef getClassifierRef(CDOID id)
@@ -205,6 +237,32 @@ public final class CDOIDUtil
}
/**
+ * @since 4.1
+ */
+ public static CDOID createUUID()
+ {
+ byte[] value = new byte[16];
+ UUIDGenerator.DEFAULT.generate(value);
+ return createUUID(value);
+ }
+
+ /**
+ * @since 4.1
+ */
+ public static String encodeUUID(byte[] bytes)
+ {
+ return UUIDGenerator.DEFAULT.encode(bytes);
+ }
+
+ /**
+ * @since 4.1
+ */
+ public static byte[] decodeUUID(String string)
+ {
+ return UUIDGenerator.DEFAULT.decode(string);
+ }
+
+ /**
* @since 2.0
*/
public static CDOIDExternal createExternal(String uri)
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOIDByteArray.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOIDByteArray.java
index d2f0086101..7d0e3af479 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOIDByteArray.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOIDByteArray.java
@@ -10,7 +10,9 @@
*/
package org.eclipse.emf.cdo.spi.common.id;
-import org.eclipse.net4j.util.HexUtil;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
+
+import org.eclipse.net4j.util.CheckUtil;
import org.eclipse.net4j.util.io.ExtendedDataInput;
import org.eclipse.net4j.util.io.ExtendedDataOutput;
@@ -36,6 +38,7 @@ public abstract class AbstractCDOIDByteArray extends AbstractCDOID
public AbstractCDOIDByteArray(byte[] value)
{
+ CheckUtil.checkArg(value != null && value.length == 16, "Illegal UUID value");
this.value = value;
}
@@ -46,13 +49,13 @@ public abstract class AbstractCDOIDByteArray extends AbstractCDOID
public String toURIFragment()
{
- return HexUtil.bytesToHex(value);
+ return CDOIDUtil.encodeUUID(value);
}
@Override
public void read(String fragmentPart)
{
- value = HexUtil.hexToBytes(fragmentPart);
+ value = CDOIDUtil.decodeUUID(fragmentPart);
}
@Override
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/CDONet4jSessionConfigurationImpl.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/CDONet4jSessionConfigurationImpl.java
index 7ba8d31561..ec77a73c52 100644
--- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/CDONet4jSessionConfigurationImpl.java
+++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/CDONet4jSessionConfigurationImpl.java
@@ -159,6 +159,8 @@ public class CDONet4jSessionConfigurationImpl extends CDOSessionConfigurationImp
private boolean ensuringReferentialIntegrity;
+ private IDGenerationLocation idGenerationLocation;
+
private InternalCDOSession session;
public RepositoryInfo(String name, OpenSessionResult result, InternalCDOSession session)
@@ -176,6 +178,7 @@ public class CDONet4jSessionConfigurationImpl extends CDOSessionConfigurationImp
supportingBranches = result.isRepositorySupportingBranches();
supportingEcore = result.isRepositorySupportingEcore();
ensuringReferentialIntegrity = result.isRepositoryEnsuringReferentialIntegrity();
+ idGenerationLocation = result.getRepositoryIDGenerationLocation();
this.session = session;
}
@@ -267,6 +270,11 @@ public class CDONet4jSessionConfigurationImpl extends CDOSessionConfigurationImp
return ensuringReferentialIntegrity;
}
+ public IDGenerationLocation getIDGenerationLocation()
+ {
+ return idGenerationLocation;
+ }
+
private RepositoryTimeResult refreshTime()
{
return session.getSessionProtocol().getRepositoryTime();
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitXATransactionPhase2Request.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitXATransactionPhase2Request.java
index d66602bd3d..75279e6125 100644
--- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitXATransactionPhase2Request.java
+++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitXATransactionPhase2Request.java
@@ -55,19 +55,13 @@ public class CommitXATransactionPhase2Request extends CommitXATransactionRequest
protected void requesting(CDODataOutput out, OMMonitor monitor) throws IOException
{
requestingTransactionInfo(out);
- requestingIdMapping(out);
- }
-
- @Override
- protected CommitTransactionResult confirming(CDODataInput in, OMMonitor monitor) throws IOException
- {
- return confirmingCheckError(in);
+ requestingIDMapping(out);
}
/**
- * Write ids that are needed. only If it needs to
+ * Write IDs that are needed. only If it needs to
*/
- protected void requestingIdMapping(CDODataOutput out) throws IOException
+ protected void requestingIDMapping(CDODataOutput out) throws IOException
{
InternalCDOXACommitContext context = getCommitContext();
Map<CDOIDTempObjectExternalImpl, InternalCDOTransaction> requestedIDs = context.getRequestedIDs();
@@ -77,13 +71,13 @@ public class CommitXATransactionPhase2Request extends CommitXATransactionRequest
{
PROTOCOL.format("Number of ids requested: {0}", size); //$NON-NLS-1$
}
-
+
for (Entry<CDOIDTempObjectExternalImpl, InternalCDOTransaction> entry : requestedIDs.entrySet())
{
CDOIDTempObjectExternalImpl tempID = entry.getKey();
URI oldURIExternal = URI.createURI(tempID.toURIFragment());
CDOID oldCDOID = CDOIDUtil.read(oldURIExternal.fragment());
-
+
InternalCDOXACommitContext commitContext = context.getTransactionManager().getCommitContext(entry.getValue());
if (commitContext == null)
{
@@ -91,7 +85,7 @@ public class CommitXATransactionPhase2Request extends CommitXATransactionRequest
Messages.getString("CommitTransactionPhase2Request.1"), entry //$NON-NLS-1$
.getValue()));
}
-
+
CDOID newID = commitContext.getResult().getIDMappings().get(oldCDOID);
if (newID == null)
{
@@ -99,17 +93,23 @@ public class CommitXATransactionPhase2Request extends CommitXATransactionRequest
Messages.getString("CommitTransactionPhase2Request.2"), oldCDOID //$NON-NLS-1$
.toURIFragment()));
}
-
+
CDOID newIDExternal = CDOURIUtil.convertExternalCDOID(oldURIExternal, newID);
if (PROTOCOL.isEnabled())
{
PROTOCOL.format("ID mapping: {0} --> {1}", tempID.toURIFragment(), newIDExternal.toURIFragment()); //$NON-NLS-1$
}
-
+
out.writeCDOID(tempID);
out.writeCDOID(newIDExternal);
-
+
context.getResult().addIDMapping(tempID, newIDExternal);
}
}
+
+ @Override
+ protected CommitTransactionResult confirming(CDODataInput in, OMMonitor monitor) throws IOException
+ {
+ return confirmingCheckError(in);
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/OpenSessionRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/OpenSessionRequest.java
index eb6f74b4b3..601496df3f 100644
--- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/OpenSessionRequest.java
+++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/OpenSessionRequest.java
@@ -12,6 +12,7 @@
package org.eclipse.emf.cdo.internal.net4j.protocol;
import org.eclipse.emf.cdo.common.CDOCommonRepository;
+import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOID.ObjectType;
@@ -175,9 +176,16 @@ public class OpenSessionRequest extends CDOClientRequestWithMonitoring<OpenSessi
TRACER.format("Read repositoryEnsuringReferentialIntegrity: {0}", repositoryEnsuringReferentialIntegrity); //$NON-NLS-1$
}
+ IDGenerationLocation repositoryIDGenerationLocation = in.readEnum(IDGenerationLocation.class);
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Read repositoryIDGenerationLocation: {0}", repositoryIDGenerationLocation); //$NON-NLS-1$
+ }
+
result = new OpenSessionResult(sessionID, userID, repositoryUUID, repositoryType, repositoryState, storeType,
objectIDTypes, repositoryCreationTime, lastUpdateTime, rootResourceID, repositorySupportingAudits,
- repositorySupportingBranches, repositorySupportingEcore, repositoryEnsuringReferentialIntegrity);
+ repositorySupportingBranches, repositorySupportingEcore, repositoryEnsuringReferentialIntegrity,
+ repositoryIDGenerationLocation);
CDOPackageUnit[] packageUnits = in.readCDOPackageUnits(null);
for (int i = 0; i < packageUnits.length; i++)
diff --git a/plugins/org.eclipse.emf.cdo.server.db/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.server.db/META-INF/MANIFEST.MF
index e456321a1a..b3af04016e 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.server.db/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.emf.cdo.server.db;singleton:=true
-Bundle-Version: 4.0.100.qualifier
+Bundle-Version: 4.1.0.qualifier
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -12,11 +12,11 @@ Bundle-ClassPath: .
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)",
org.eclipse.net4j.db;bundle-version="[4.0.0,5.0.0)";visibility:=reexport,
org.eclipse.emf.cdo.server;bundle-version="[4.0.0,5.0.0)";visibility:=reexport
-Export-Package: org.eclipse.emf.cdo.server.db;version="4.0.100",
- org.eclipse.emf.cdo.server.db.mapping;version="4.0.100",
- org.eclipse.emf.cdo.server.internal.db;version="4.0.100";x-friends:="org.eclipse.emf.cdo.tests,org.eclipse.emf.cdo.tests.db",
- org.eclipse.emf.cdo.server.internal.db.bundle;version="4.0.100";x-internal:=true,
- org.eclipse.emf.cdo.server.internal.db.jdbc;version="4.0.100";x-friends:="org.eclipse.emf.cdo.tests,org.eclipse.emf.cdo.tests.db",
- org.eclipse.emf.cdo.server.internal.db.mapping;version="4.0.100";x-friends:="org.eclipse.emf.cdo.tests,org.eclipse.emf.cdo.tests.db",
- org.eclipse.emf.cdo.server.internal.db.mapping.horizontal;version="4.0.100";x-friends:="org.eclipse.emf.cdo.tests,org.eclipse.emf.cdo.tests.db",
- org.eclipse.emf.cdo.server.internal.db.messages;version="4.0.100";x-internal:=true
+Export-Package: org.eclipse.emf.cdo.server.db;version="4.1.0",
+ org.eclipse.emf.cdo.server.db.mapping;version="4.1.0",
+ org.eclipse.emf.cdo.server.internal.db;version="4.1.0";x-friends:="org.eclipse.emf.cdo.tests,org.eclipse.emf.cdo.tests.db",
+ org.eclipse.emf.cdo.server.internal.db.bundle;version="4.1.0";x-internal:=true,
+ org.eclipse.emf.cdo.server.internal.db.jdbc;version="4.1.0";x-friends:="org.eclipse.emf.cdo.tests,org.eclipse.emf.cdo.tests.db",
+ org.eclipse.emf.cdo.server.internal.db.mapping;version="4.1.0";x-friends:="org.eclipse.emf.cdo.tests,org.eclipse.emf.cdo.tests.db",
+ org.eclipse.emf.cdo.server.internal.db.mapping.horizontal;version="4.1.0";x-friends:="org.eclipse.emf.cdo.tests,org.eclipse.emf.cdo.tests.db",
+ org.eclipse.emf.cdo.server.internal.db.messages;version="4.1.0";x-internal:=true
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStore.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStore.java
index 6d05f288ad..c1c6d23498 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStore.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStore.java
@@ -14,6 +14,7 @@ package org.eclipse.emf.cdo.server.db;
import org.eclipse.emf.cdo.server.ISession;
import org.eclipse.emf.cdo.server.IStore;
+import org.eclipse.emf.cdo.server.IStore.CanHandleClientAssignedIDs;
import org.eclipse.emf.cdo.server.ITransaction;
import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
@@ -26,7 +27,7 @@ import org.eclipse.net4j.db.ddl.IDBSchema;
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/
-public interface IDBStore extends IStore, IDBConnectionProvider
+public interface IDBStore extends IStore, IDBConnectionProvider, CanHandleClientAssignedIDs
{
/**
* @since 2.0
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IIDHandler.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IIDHandler.java
index 34e8ed7283..0bbee5d23a 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IIDHandler.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IIDHandler.java
@@ -52,6 +52,11 @@ public interface IIDHandler extends Comparator<CDOID>
public void setLastObjectID(CDOID lastObjectID);
+ /**
+ * @since 4.1
+ */
+ public void adjustLastObjectID(CDOID maxID);
+
public CDOID getNextLocalObjectID();
public void setNextLocalObjectID(CDOID nextLocalObjectID);
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IClassMapping.java
index bfdef4a6aa..9775d42fd5 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IClassMapping.java
@@ -117,11 +117,11 @@ public interface IClassMapping
* @param accessor
* the accessor to use.
* @param id
- * the id to revise
+ * the id to revise.
* @param version
- * the last valid version plus one (needed as marker)
+ * the last valid version.
* @param timeStamp
- * the timestamp of detach
+ * the timestamp of detach.
* @param monitor
* the monitor to indicate progress.
* @since 3.0
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
index 53b7496fdc..f99471a8b7 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
@@ -14,6 +14,7 @@
*/
package org.eclipse.emf.cdo.server.internal.db;
+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.id.CDOID;
@@ -94,8 +95,7 @@ public class DBStore extends Store implements IDBStore, CDOAllRevisionsProvider
private Map<String, String> properties;
- // private IIDHandler idHandler = new StringIDHandler(this);
- private IIDHandler idHandler = new LongIDHandler(this);
+ private IIDHandler idHandler;
private IMetaDataManager metaDataManager = new MetaDataManager(this);
@@ -492,7 +492,6 @@ public class DBStore extends Store implements IDBStore, CDOAllRevisionsProvider
protected void doBeforeActivate() throws Exception
{
super.doBeforeActivate();
- checkNull(idHandler, Messages.getString("DBStore.3")); //$NON-NLS-1$
checkNull(mappingStrategy, Messages.getString("DBStore.2")); //$NON-NLS-1$
checkNull(dbAdapter, Messages.getString("DBStore.1")); //$NON-NLS-1$
checkNull(dbConnectionProvider, Messages.getString("DBStore.0")); //$NON-NLS-1$
@@ -503,6 +502,15 @@ public class DBStore extends Store implements IDBStore, CDOAllRevisionsProvider
{
super.doActivate();
+ if (getRepository().getIDGenerationLocation() == IDGenerationLocation.CLIENT)
+ {
+ idHandler = new UUIDHandler(this);
+ }
+ else
+ {
+ idHandler = new LongIDHandler(this);
+ }
+
setObjectIDTypes(idHandler.getObjectIDTypes());
connectionKeepAliveTimer = new Timer("Connection-Keep-Alive-" + this); //$NON-NLS-1$
@@ -558,8 +566,13 @@ public class DBStore extends Store implements IDBStore, CDOAllRevisionsProvider
Map<String, String> map = new HashMap<String, String>();
map.put(PROP_GRACEFULLY_SHUT_DOWN, Boolean.TRUE.toString());
map.put(PROP_REPOSITORY_STOPPED, Long.toString(getRepository().getTimeStamp()));
- map.put(PROP_NEXT_LOCAL_CDOID, Store.idToString(idHandler.getNextLocalObjectID()));
- map.put(PROP_LAST_CDOID, Store.idToString(idHandler.getLastObjectID()));
+
+ if (getRepository().getIDGenerationLocation() == IDGenerationLocation.STORE)
+ {
+ map.put(PROP_NEXT_LOCAL_CDOID, Store.idToString(idHandler.getNextLocalObjectID()));
+ map.put(PROP_LAST_CDOID, Store.idToString(idHandler.getLastObjectID()));
+ }
+
map.put(PROP_LAST_BRANCHID, Integer.toString(getLastBranchID()));
map.put(PROP_LAST_LOCAL_BRANCHID, Integer.toString(getLastLocalBranchID()));
map.put(PROP_LAST_COMMITTIME, Long.toString(getLastCommitTime()));
@@ -616,16 +629,26 @@ public class DBStore extends Store implements IDBStore, CDOAllRevisionsProvider
if (map.containsKey(PROP_GRACEFULLY_SHUT_DOWN))
{
names.clear();
- names.add(PROP_NEXT_LOCAL_CDOID);
- names.add(PROP_LAST_CDOID);
+
+ boolean generatingIDs = getRepository().getIDGenerationLocation() == IDGenerationLocation.STORE;
+ if (generatingIDs)
+ {
+ names.add(PROP_NEXT_LOCAL_CDOID);
+ names.add(PROP_LAST_CDOID);
+ }
+
names.add(PROP_LAST_BRANCHID);
names.add(PROP_LAST_LOCAL_BRANCHID);
names.add(PROP_LAST_COMMITTIME);
names.add(PROP_LAST_NONLOCAL_COMMITTIME);
map = getPersistentProperties(names);
- idHandler.setNextLocalObjectID(Store.stringToID(map.get(PROP_NEXT_LOCAL_CDOID)));
- idHandler.setLastObjectID(Store.stringToID(map.get(PROP_LAST_CDOID)));
+ if (generatingIDs)
+ {
+ idHandler.setNextLocalObjectID(Store.stringToID(map.get(PROP_NEXT_LOCAL_CDOID)));
+ idHandler.setLastObjectID(Store.stringToID(map.get(PROP_LAST_CDOID)));
+ }
+
setLastBranchID(Integer.valueOf(map.get(PROP_LAST_BRANCHID)));
setLastLocalBranchID(Integer.valueOf(map.get(PROP_LAST_LOCAL_BRANCHID)));
setLastCommitTime(Long.valueOf(map.get(PROP_LAST_COMMITTIME)));
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
index c058e5ef8e..52c6ebc90e 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
@@ -14,6 +14,7 @@
*/
package org.eclipse.emf.cdo.server.internal.db;
+import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.branch.CDOBranchHandler;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
@@ -197,7 +198,7 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor,
return (EClass)type.resolve(packageRegistry);
}
- throw new IllegalStateException("No type found for " + id);
+ return null;
}
public InternalCDORevision readRevision(CDOID id, CDOBranchPoint branchPoint, int listChunk,
@@ -211,20 +212,23 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor,
IMappingStrategy mappingStrategy = getStore().getMappingStrategy();
EClass eClass = getObjectType(id);
- InternalCDORevision revision = getStore().createRevision(eClass, id);
- revision.setBranchPoint(branchPoint);
-
- IClassMapping mapping = mappingStrategy.getClassMapping(eClass);
- if (mapping.readRevision(this, revision, listChunk))
+ if (eClass != null)
{
- int version = revision.getVersion();
- if (version < CDOBranchVersion.FIRST_VERSION - 1)
+ InternalCDORevision revision = getStore().createRevision(eClass, id);
+ revision.setBranchPoint(branchPoint);
+
+ IClassMapping mapping = mappingStrategy.getClassMapping(eClass);
+ if (mapping.readRevision(this, revision, listChunk))
{
- return new DetachedCDORevision(eClass, id, revision.getBranch(), -version, revision.getTimeStamp(),
- revision.getRevised());
- }
+ int version = revision.getVersion();
+ if (version < CDOBranchVersion.FIRST_VERSION - 1)
+ {
+ return new DetachedCDORevision(eClass, id, revision.getBranch(), -version, revision.getTimeStamp(),
+ revision.getRevised());
+ }
- return revision;
+ return revision;
+ }
}
// Reading failed - revision does not exist.
@@ -468,6 +472,10 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor,
{
super.applyIDMappings(context, monitor);
+ // Remember maxID because it may have to be adjusted if the repository is BACKUP or CLONE. See bug 325097.
+ boolean adjustMaxID = !context.getBranchPoint().getBranch().isLocal()
+ && getStore().getRepository().getIDGenerationLocation() == IDGenerationLocation.STORE;
+
IIDHandler idHandler = getStore().getIDHandler();
// Remember CDOIDs of new objects. They are cleared after writeRevisions()
@@ -476,13 +484,9 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor,
CDOID id = revision.getID();
newObjects.add(id);
- // Remember maxID because it may have to be adjusted if the repository is BACKUP or CLONE. See bug 325097.
- if (!context.getBranchPoint().getBranch().isLocal())
+ if (adjustMaxID && idHandler.compare(id, maxID) > 0)
{
- if (idHandler.compare(id, maxID) > 0)
- {
- maxID = id;
- }
+ maxID = id;
}
}
}
@@ -697,14 +701,12 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor,
async = monitor.forkAsync();
getConnection().commit();
- IIDHandler idHandler = getStore().getIDHandler();
- if (idHandler.compare(maxID, idHandler.getLastObjectID()) > 0)
+ if (maxID != CDOID.NULL)
{
// See bug 325097
- idHandler.setLastObjectID(maxID);
+ getStore().getIDHandler().adjustLastObjectID(maxID);
+ maxID = CDOID.NULL;
}
-
- maxID = CDOID.NULL;
}
finally
{
@@ -1226,12 +1228,7 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor,
}
writeRevision(revision, isFirstRevision, false, monitor);
-
- IIDHandler idHandler = getStore().getIDHandler();
- if (idHandler.compare(id, idHandler.getLastObjectID()) > 0)
- {
- idHandler.setLastObjectID(id);
- }
+ getStore().getIDHandler().adjustLastObjectID(id);
}
public void rawStore(byte[] id, long size, InputStream inputStream) throws IOException
@@ -1250,20 +1247,24 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor,
writeCommitInfo(branch, timeStamp, previousTimeStamp, userID, comment, monitor);
}
+ @Deprecated
public void rawDelete(CDOID id, int version, CDOBranch branch, EClass eClass, OMMonitor monitor)
{
- IMappingStrategy mappingStrategy = getStore().getMappingStrategy();
- if (eClass == null)
- {
- eClass = getObjectType(id);
- }
-
- IClassMapping mapping = mappingStrategy.getClassMapping(eClass);
- mapping.detachObject(this, id, version, branch, CDOBranchPoint.UNSPECIFIED_DATE, monitor.fork());
+ throw new UnsupportedOperationException();
+
+ // IMappingStrategy mappingStrategy = getStore().getMappingStrategy();
+ // if (eClass == null)
+ // {
+ // eClass = getObjectType(id);
+ // }
+ //
+ // IClassMapping mapping = mappingStrategy.getClassMapping(eClass);
+ // mapping.detachObject(this, id, version, branch, CDOBranchPoint.UNSPECIFIED_DATE, monitor);
}
public void rawCommit(double commitWork, OMMonitor monitor)
{
+ monitor.begin();
Async async = monitor.forkAsync();
try
@@ -1277,6 +1278,7 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor,
finally
{
async.stop();
+ monitor.done();
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/LongIDHandler.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/LongIDHandler.java
index 948ba1d9ca..79d06158c7 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/LongIDHandler.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/LongIDHandler.java
@@ -1,3 +1,13 @@
+/**
+ * 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.server.internal.db;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
@@ -91,6 +101,14 @@ public class LongIDHandler extends Lifecycle implements IIDHandler
this.lastObjectID = lastObjectID;
}
+ public synchronized void adjustLastObjectID(CDOID maxID)
+ {
+ if (compare(maxID, lastObjectID) > 0)
+ {
+ lastObjectID = maxID;
+ }
+ }
+
public synchronized CDOID getNextLocalObjectID()
{
return nextLocalObjectID;
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/StringIDHandler.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/StringIDHandler.java
index dc944553d8..803958428d 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/StringIDHandler.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/StringIDHandler.java
@@ -1,3 +1,13 @@
+/**
+ * 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.server.internal.db;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
@@ -86,6 +96,12 @@ public class StringIDHandler extends Lifecycle implements IIDHandler
this.lastObjectID = Long.parseLong(value(lastObjectID));
}
+ public void adjustLastObjectID(CDOID maxID)
+ {
+ // TODO: implement StringIDHandler.adjustLastObjectID(maxID)
+ throw new UnsupportedOperationException();
+ }
+
public synchronized CDOID getNextLocalObjectID()
{
return CDOIDUtil.createString("" + nextLocalObjectID);
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/UUIDHandler.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/UUIDHandler.java
new file mode 100644
index 0000000000..29c1ea1612
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/UUIDHandler.java
@@ -0,0 +1,243 @@
+/**
+ * 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.server.internal.db;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOID.ObjectType;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
+import org.eclipse.emf.cdo.server.db.IIDHandler;
+import org.eclipse.emf.cdo.server.db.mapping.ITypeMapping;
+import org.eclipse.emf.cdo.server.internal.db.mapping.CoreTypeMappings;
+
+import org.eclipse.net4j.db.DBType;
+import org.eclipse.net4j.util.lifecycle.Lifecycle;
+import org.eclipse.net4j.util.om.monitor.OMMonitor;
+
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Collections;
+import java.util.Set;
+
+/**
+ * @author Eike Stepper
+ */
+public class UUIDHandler extends Lifecycle implements IIDHandler
+{
+ public static final Set<ObjectType> OBJECT_ID_TYPES = Collections.singleton(ObjectType.UUID);
+
+ private static final char NULL_CHAR = '0';
+
+ private static final String NULL_STRING = Character.toString(NULL_CHAR);
+
+ private static final char INTERNAL_CHAR = '@';
+
+ private static final String INTERNAL_STRING = Character.toString(INTERNAL_CHAR);
+
+ private DBStore store;
+
+ public UUIDHandler(DBStore store)
+ {
+ this.store = store;
+ }
+
+ public DBStore getStore()
+ {
+ return store;
+ }
+
+ public int compare(CDOID id1, CDOID id2)
+ {
+ // if (id1.getType() == CDOID.Type.OBJECT && id2.getType() == CDOID.Type.OBJECT)
+ // {
+ // return Long.valueOf(value(id1)).compareTo(Long.valueOf(value(id2)));
+ // }
+ //
+ // return id1.compareTo(id2);
+ throw new UnsupportedOperationException();
+ }
+
+ public DBType getDBType()
+ {
+ return DBType.VARCHAR;
+ }
+
+ public Set<ObjectType> getObjectIDTypes()
+ {
+ return OBJECT_ID_TYPES;
+ }
+
+ public CDOID createCDOID(String val)
+ {
+ return create(INTERNAL_STRING + val);
+ }
+
+ public synchronized CDOID getLastObjectID()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public synchronized void setLastObjectID(CDOID lastObjectID)
+ {
+ // Do nothing
+ }
+
+ public void adjustLastObjectID(CDOID maxID)
+ {
+ // Do nothing
+ }
+
+ public synchronized CDOID getNextLocalObjectID()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public synchronized void setNextLocalObjectID(CDOID nextLocalObjectID)
+ {
+ // Do nothing
+ }
+
+ public synchronized CDOID getNextCDOID(CDORevision revision)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isLocalCDOID(CDOID id)
+ {
+ return false;
+ }
+
+ public ITypeMapping getObjectTypeMapping()
+ {
+ return new CoreTypeMappings.TMObject();
+ }
+
+ public void appendCDOID(StringBuilder builder, CDOID id)
+ {
+ builder.append("'");
+ builder.append(value(id));
+ builder.append("'");
+ }
+
+ public void setCDOID(PreparedStatement stmt, int column, CDOID id) throws SQLException
+ {
+ setCDOID(stmt, column, id, CDOBranchPoint.INVALID_DATE);
+ }
+
+ public void setCDOID(PreparedStatement stmt, int column, CDOID id, long commitTime) throws SQLException
+ {
+ stmt.setString(column, value(id));
+ }
+
+ public CDOID getCDOID(ResultSet resultSet, int column) throws SQLException
+ {
+ String id = resultSet.getString(column);
+ if (resultSet.wasNull())
+ {
+ return null;
+ }
+
+ return create(id);
+ }
+
+ public CDOID getCDOID(ResultSet resultSet, String name) throws SQLException
+ {
+ String id = resultSet.getString(name);
+ if (resultSet.wasNull())
+ {
+ return null;
+ }
+
+ return create(id);
+ }
+
+ public CDOID getMinCDOID()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public CDOID getMaxCDOID()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public CDOID mapURI(IDBStoreAccessor accessor, String uri, long commitTime)
+ {
+ return CDOIDUtil.createExternal(uri);
+ }
+
+ public String unmapURI(IDBStoreAccessor accessor, CDOID id)
+ {
+ return CDOIDUtil.getString(id);
+ }
+
+ public void rawExport(Connection connection, CDODataOutput out, long fromCommitTime, long toCommitTime)
+ throws IOException
+ {
+ // Do nothing
+ }
+
+ public void rawImport(Connection connection, CDODataInput in, long fromCommitTime, long toCommitTime,
+ OMMonitor monitor) throws IOException
+ {
+ // Do nothing
+ }
+
+ private static CDOID create(String id)
+ {
+ if (id == null)
+ {
+ return null;
+ }
+
+ int length = id.length();
+ if (length == 0)
+ {
+ return null;
+ }
+
+ char firstChar = id.charAt(0);
+ if (length == 1 && firstChar == NULL_CHAR)
+ {
+ return null;
+ }
+
+ if (firstChar == INTERNAL_CHAR)
+ {
+ byte[] bytes = CDOIDUtil.decodeUUID(id.substring(1));
+ return CDOIDUtil.createUUID(bytes);
+ }
+
+ return CDOIDUtil.createExternal(id);
+ }
+
+ private static String value(CDOID id)
+ {
+ if (CDOIDUtil.isNull(id))
+ {
+ return NULL_STRING;
+ }
+
+ if (id.isExternal())
+ {
+ return CDOIDUtil.getString(id);
+ }
+
+ return INTERNAL_STRING + id.toURIFragment();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditFeatureMapTableMappingWithRanges.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditFeatureMapTableMappingWithRanges.java
index 9e8f090439..150fc06e63 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditFeatureMapTableMappingWithRanges.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditFeatureMapTableMappingWithRanges.java
@@ -162,7 +162,7 @@ public class AuditFeatureMapTableMappingWithRanges extends BasicAbstractListTabl
table = store.getDBSchema().addTable(tableName);
// add fields for CDOID
- IDBField idField = table.addField(CDODBSchema.FEATUREMAP_REVISION_ID, DBType.INTEGER);
+ IDBField idField = table.addField(CDODBSchema.FEATUREMAP_REVISION_ID, store.getIDHandler().getDBType());
// add fields for version range
IDBField versionAddedField = table.addField(CDODBSchema.FEATUREMAP_VERSION_ADDED, DBType.INTEGER);
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingFeatureMapTableMappingWithRanges.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingFeatureMapTableMappingWithRanges.java
index 86bb8abe09..b1458ae679 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingFeatureMapTableMappingWithRanges.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingFeatureMapTableMappingWithRanges.java
@@ -112,14 +112,14 @@ public class BranchingFeatureMapTableMappingWithRanges extends BasicAbstractList
*/
private Map<CDOID, ITypeMapping> typeMappings;
+ private List<DBType> dbTypes;
+
// --------- SQL strings - see initSQLStrings() -----------------
private String sqlSelectChunksPrefix;
private String sqlOrderByIndex;
- protected String sqlInsert;
-
- private List<DBType> dbTypes;
+ private String sqlInsert;
private String sqlRemoveEntry;
@@ -154,7 +154,7 @@ public class BranchingFeatureMapTableMappingWithRanges extends BasicAbstractList
table = store.getDBSchema().addTable(tableName);
// add fields for CDOID
- IDBField idField = table.addField(CDODBSchema.FEATUREMAP_REVISION_ID, DBType.INTEGER);
+ IDBField idField = table.addField(CDODBSchema.FEATUREMAP_REVISION_ID, store.getIDHandler().getDBType());
IDBField branchField = table.addField(CDODBSchema.LIST_REVISION_BRANCH, DBType.INTEGER);
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java
index 0906104bb4..cd534ce307 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java
@@ -31,6 +31,7 @@ import org.eclipse.emf.cdo.server.IRepository;
import org.eclipse.emf.cdo.server.IStoreAccessor.QueryXRefsContext;
import org.eclipse.emf.cdo.server.IStoreChunkReader;
import org.eclipse.emf.cdo.server.IStoreChunkReader.Chunk;
+import org.eclipse.emf.cdo.server.ITransaction;
import org.eclipse.emf.cdo.server.db.IDBStore;
import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
import org.eclipse.emf.cdo.server.db.IDBStoreChunkReader;
@@ -675,15 +676,16 @@ public class BranchingListTableMappingWithRanges extends BasicAbstractListTableM
public void objectDetached(IDBStoreAccessor accessor, CDOID id, long revised)
{
- InternalCDORevision revision = (InternalCDORevision)accessor.getTransaction().getRevision(id);
- int branchId = accessor.getTransaction().getBranch().getID();
+ ITransaction transaction = accessor.getTransaction();
+ InternalCDORevision revision = (InternalCDORevision)transaction.getRevision(id);
+ int branchID = transaction.getBranch().getID();
if (TRACER.isEnabled())
{
TRACER.format("objectDetached {1}", revision); //$NON-NLS-1$
}
- clearList(accessor, id, branchId, revision.getVersion(), FINAL_VERSION, revision.getList(getFeature()).size() - 1);
+ clearList(accessor, id, branchID, revision.getVersion(), FINAL_VERSION, revision.getList(getFeature()).size() - 1);
}
public void processDelta(final IDBStoreAccessor accessor, final CDOID id, final int branchId, final int oldVersion,
diff --git a/plugins/org.eclipse.emf.cdo.server.db4o/src/org/eclipse/emf/cdo/server/internal/db4o/DB4OStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.db4o/src/org/eclipse/emf/cdo/server/internal/db4o/DB4OStoreAccessor.java
index 91b9ab59d8..4f6642a099 100644
--- a/plugins/org.eclipse.emf.cdo.server.db4o/src/org/eclipse/emf/cdo/server/internal/db4o/DB4OStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server.db4o/src/org/eclipse/emf/cdo/server/internal/db4o/DB4OStoreAccessor.java
@@ -820,9 +820,9 @@ public class DB4OStoreAccessor extends LongIDStoreAccessor implements Raw, Durab
writeCommitInfo(branch, timeStamp, previousTimeStamp, userID, comment, monitor);
}
+ @Deprecated
public void rawDelete(CDOID id, int version, CDOBranch branch, EClass eClass, OMMonitor monitor)
{
- // TODO: Implement DB4OStoreAccessor.rawDelete(CDOID, int, CDOBranch, EClass, OMMonitor)
throw new UnsupportedOperationException();
}
diff --git a/plugins/org.eclipse.emf.cdo.server.mongodb/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.server.mongodb/META-INF/MANIFEST.MF
index b7c044b7df..452de96c78 100644
--- a/plugins/org.eclipse.emf.cdo.server.mongodb/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.server.mongodb/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.emf.cdo.server.mongodb;singleton:=true
-Bundle-Version: 4.0.0.qualifier
+Bundle-Version: 4.0.100.qualifier
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -11,9 +11,9 @@ Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ClassPath: .
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)",
org.eclipse.emf.cdo.server;bundle-version="[4.0.0,5.0.0)";visibility:=reexport
-Export-Package: org.eclipse.emf.cdo.server.internal.mongodb;version="4.0.0";x-friends:="org.eclipse.emf.cdo.tests,org.eclipse.emf.cdo.tests.mongodb",
- org.eclipse.emf.cdo.server.internal.mongodb.bundle;version="4.0.0";x-internal:=true,
- org.eclipse.emf.cdo.server.mongodb;version="4.0.0"
+Export-Package: org.eclipse.emf.cdo.server.internal.mongodb;version="4.0.100";x-friends:="org.eclipse.emf.cdo.tests,org.eclipse.emf.cdo.tests.mongodb",
+ org.eclipse.emf.cdo.server.internal.mongodb.bundle;version="4.0.100";x-internal:=true,
+ org.eclipse.emf.cdo.server.mongodb;version="4.0.100"
Import-Package: com.mongodb;version="[2.0.0,3.0.0)",
com.mongodb.gridfs;version="[2.0.0,3.0.0)",
com.mongodb.io;version="[2.0.0,3.0.0)",
diff --git a/plugins/org.eclipse.emf.cdo.server.mongodb/src/org/eclipse/emf/cdo/server/internal/mongodb/Commits.java b/plugins/org.eclipse.emf.cdo.server.mongodb/src/org/eclipse/emf/cdo/server/internal/mongodb/Commits.java
index b6b148353c..aba114743f 100644
--- a/plugins/org.eclipse.emf.cdo.server.mongodb/src/org/eclipse/emf/cdo/server/internal/mongodb/Commits.java
+++ b/plugins/org.eclipse.emf.cdo.server.mongodb/src/org/eclipse/emf/cdo/server/internal/mongodb/Commits.java
@@ -154,6 +154,20 @@ public class Commits extends Coll
{
// This must be the first commit into the repo.
systemPackageUnits = packageUnits;
+
+ for (int i = 0; i < packageUnits.length; i++)
+ {
+ InternalCDOPackageUnit packageUnit = packageUnits[i];
+ InternalCDOPackageInfo[] packageInfos = packageUnit.getPackageInfos();
+ for (int j = 0; j < packageInfos.length; j++)
+ {
+ InternalCDOPackageInfo packageInfo = packageInfos[j];
+ for (EClassifier classifier : packageInfo.getEPackage().getEClassifiers())
+ {
+ store.getClasses().mapNewClassifier(classifier);
+ }
+ }
+ }
}
private DBObject[] marshallUnits(InternalCDOPackageUnit[] packageUnits)
diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.server.net4j/META-INF/MANIFEST.MF
index 97b482a578..0edf40d5a5 100644
--- a/plugins/org.eclipse.emf.cdo.server.net4j/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.server.net4j/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.emf.cdo.server.net4j;singleton:=true
-Bundle-Version: 4.0.0.qualifier
+Bundle-Version: 4.0.100.qualifier
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -12,6 +12,6 @@ Bundle-ClassPath: .
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)";resolution:=optional,
org.eclipse.emf.cdo.server;bundle-version="[4.0.0,5.0.0)";visibility:=reexport,
org.eclipse.net4j;bundle-version="[4.0.0,5.0.0)";visibility:=reexport
-Export-Package: org.eclipse.emf.cdo.server.internal.net4j.bundle;version="4.0.0";x-internal:=true,
- org.eclipse.emf.cdo.server.internal.net4j.protocol;version="4.0.0";x-friends:="org.eclipse.emf.cdo.tests",
- org.eclipse.emf.cdo.server.net4j;version="4.0.0"
+Export-Package: org.eclipse.emf.cdo.server.internal.net4j.bundle;version="4.0.100";x-internal:=true,
+ org.eclipse.emf.cdo.server.internal.net4j.protocol;version="4.0.100";x-friends:="org.eclipse.emf.cdo.tests",
+ org.eclipse.emf.cdo.server.net4j;version="4.0.100"
diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/OpenSessionIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/OpenSessionIndication.java
index 179c6a89b6..7d8a9962d4 100644
--- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/OpenSessionIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/OpenSessionIndication.java
@@ -144,6 +144,7 @@ public class OpenSessionIndication extends CDOServerIndicationWithMonitoring
out.writeBoolean(repository.isSupportingBranches());
out.writeBoolean(repository.isSupportingEcore());
out.writeBoolean(repository.isEnsuringReferentialIntegrity());
+ out.writeEnum(repository.getIDGenerationLocation());
CDOPackageUnit[] packageUnits = repository.getPackageRegistry().getPackageUnits();
out.writeCDOPackageUnits(packageUnits);
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.server.objectivity/META-INF/MANIFEST.MF
index e761f036b6..67de440a2b 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.emf.cdo.server.objectivity;singleton:=true
-Bundle-Version: 4.0.0.qualifier
+Bundle-Version: 4.0.100.qualifier
Bundle-Activator: org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM$Activator
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)",
org.eclipse.emf.cdo.server;bundle-version="[4.0.0,5.0.0)";visibility:=reexport
@@ -11,14 +11,14 @@ Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-ClassPath: .
-Export-Package: org.eclipse.emf.cdo.server.internal.objectivity;version="4.0.0";x-friends:="org.eclipse.emf.cdo.tests.objectivity",
- org.eclipse.emf.cdo.server.internal.objectivity.bundle;version="4.0.0";x-friends:="org.eclipse.emf.cdo.tests.objectivity",
- org.eclipse.emf.cdo.server.internal.objectivity.clustering;version="4.0.0";x-friends:="org.eclipse.emf.cdo.tests.objectivity",
- org.eclipse.emf.cdo.server.internal.objectivity.db;version="4.0.0";x-friends:="org.eclipse.emf.cdo.tests.objectivity",
- org.eclipse.emf.cdo.server.internal.objectivity.mapper;version="4.0.0";x-friends:="org.eclipse.emf.cdo.tests.objectivity",
- org.eclipse.emf.cdo.server.internal.objectivity.schema;version="4.0.0";x-friends:="org.eclipse.emf.cdo.tests.objectivity",
- org.eclipse.emf.cdo.server.internal.objectivity.utils;version="4.0.0";x-friends:="org.eclipse.emf.cdo.tests.objectivity",
- org.eclipse.emf.cdo.server.objectivity;version="4.0.0"
+Export-Package: org.eclipse.emf.cdo.server.internal.objectivity;version="4.0.100";x-friends:="org.eclipse.emf.cdo.tests.objectivity",
+ org.eclipse.emf.cdo.server.internal.objectivity.bundle;version="4.0.100";x-friends:="org.eclipse.emf.cdo.tests.objectivity",
+ org.eclipse.emf.cdo.server.internal.objectivity.clustering;version="4.0.100";x-friends:="org.eclipse.emf.cdo.tests.objectivity",
+ org.eclipse.emf.cdo.server.internal.objectivity.db;version="4.0.100";x-friends:="org.eclipse.emf.cdo.tests.objectivity",
+ org.eclipse.emf.cdo.server.internal.objectivity.mapper;version="4.0.100";x-friends:="org.eclipse.emf.cdo.tests.objectivity",
+ org.eclipse.emf.cdo.server.internal.objectivity.schema;version="4.0.100";x-friends:="org.eclipse.emf.cdo.tests.objectivity",
+ org.eclipse.emf.cdo.server.internal.objectivity.utils;version="4.0.100";x-friends:="org.eclipse.emf.cdo.tests.objectivity",
+ org.eclipse.emf.cdo.server.objectivity;version="4.0.100"
Import-Package: com.objy.as;version="[4.0.0,5.0.0)",
com.objy.as.app;version="[4.0.0,5.0.0)",
com.objy.db;version="[4.0.0,5.0.0)",
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreAccessor.java
index 1016399512..187e7d3f04 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreAccessor.java
@@ -1928,9 +1928,9 @@ public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectiv
throw new UnsupportedOperationException();
}
+ @Deprecated
public void rawDelete(CDOID id, int version, CDOBranch branch, EClass eClass, OMMonitor monitor)
{
- // TODO: implement ObjectivityStoreAccessor.rawDelete
throw new UnsupportedOperationException();
}
diff --git a/plugins/org.eclipse.emf.cdo.server/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.server/META-INF/MANIFEST.MF
index 261e11f404..b35cecd3ec 100644
--- a/plugins/org.eclipse.emf.cdo.server/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.server/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.emf.cdo.server;singleton:=true
-Bundle-Version: 4.0.100.qualifier
+Bundle-Version: 4.1.0.qualifier
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -12,18 +12,18 @@ Bundle-ClassPath: .
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)";resolution:=optional,
org.eclipse.emf.cdo;bundle-version="[4.0.0,5.0.0)";visibility:=reexport,
org.eclipse.net4j.util;bundle-version="[3.1.0,4.0.0)";visibility:=reexport
-Export-Package: org.eclipse.emf.cdo.internal.server;version="4.0.100";
+Export-Package: org.eclipse.emf.cdo.internal.server;version="4.1.0";
x-friends:="org.eclipse.emf.cdo.server.db,
org.eclipse.emf.cdo.server.net4j,
org.eclipse.emf.cdo.tests,
org.eclipse.emf.cdo.workspace,
org.eclipse.emf.cdo.server.hibernate",
- org.eclipse.emf.cdo.internal.server.bundle;version="4.0.100";x-internal:=true,
- org.eclipse.emf.cdo.internal.server.embedded;version="4.0.100";x-friends:="org.eclipse.emf.cdo.tests",
- org.eclipse.emf.cdo.internal.server.mem;version="4.0.100";x-friends:="org.eclipse.emf.cdo.tests",
- org.eclipse.emf.cdo.internal.server.messages;version="4.0.100";x-internal:=true,
- org.eclipse.emf.cdo.internal.server.syncing;version="4.0.100";x-friends:="org.eclipse.emf.cdo.tests",
- org.eclipse.emf.cdo.server;version="4.0.100",
- org.eclipse.emf.cdo.server.embedded;version="4.0.100",
- org.eclipse.emf.cdo.server.mem;version="4.0.100",
- org.eclipse.emf.cdo.spi.server;version="4.0.100"
+ org.eclipse.emf.cdo.internal.server.bundle;version="4.1.0";x-internal:=true,
+ org.eclipse.emf.cdo.internal.server.embedded;version="4.1.0";x-friends:="org.eclipse.emf.cdo.tests",
+ org.eclipse.emf.cdo.internal.server.mem;version="4.1.0";x-friends:="org.eclipse.emf.cdo.tests",
+ org.eclipse.emf.cdo.internal.server.messages;version="4.1.0";x-internal:=true,
+ org.eclipse.emf.cdo.internal.server.syncing;version="4.1.0";x-friends:="org.eclipse.emf.cdo.tests",
+ org.eclipse.emf.cdo.server;version="4.1.0",
+ org.eclipse.emf.cdo.server.embedded;version="4.1.0",
+ org.eclipse.emf.cdo.server.mem;version="4.1.0",
+ org.eclipse.emf.cdo.spi.server;version="4.1.0"
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 404b516040..95e3d3ad47 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
@@ -24,6 +24,7 @@ import org.eclipse.emf.cdo.common.commit.CDOCommitData;
import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDGenerator;
import org.eclipse.emf.cdo.common.id.CDOIDTemp;
import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.lob.CDOLobHandler;
@@ -47,6 +48,7 @@ import org.eclipse.emf.cdo.internal.server.bundle.OM;
import org.eclipse.emf.cdo.server.IQueryHandler;
import org.eclipse.emf.cdo.server.IQueryHandlerProvider;
import org.eclipse.emf.cdo.server.IStore;
+import org.eclipse.emf.cdo.server.IStore.CanHandleClientAssignedIDs;
import org.eclipse.emf.cdo.server.IStoreAccessor;
import org.eclipse.emf.cdo.server.IStoreChunkReader;
import org.eclipse.emf.cdo.server.IStoreChunkReader.Chunk;
@@ -136,6 +138,8 @@ public class Repository extends Container<Object> implements InternalRepository
private boolean ensuringReferentialIntegrity;
+ private IDGenerationLocation idGenerationLocation;
+
private InternalCDOPackageRegistry packageRegistry;
private InternalCDOBranchManager branchManager;
@@ -299,6 +303,11 @@ public class Repository extends Container<Object> implements InternalRepository
return ensuringReferentialIntegrity;
}
+ public IDGenerationLocation getIDGenerationLocation()
+ {
+ return idGenerationLocation;
+ }
+
public String getStoreType()
{
return store.getType();
@@ -1353,6 +1362,17 @@ public class Repository extends Container<Object> implements InternalRepository
{
ensuringReferentialIntegrity = Boolean.valueOf(valueIntegrity);
}
+
+ String valueIDLocation = properties.get(Props.ID_GENERATION_LOCATION);
+ if (valueIDLocation != null)
+ {
+ idGenerationLocation = IDGenerationLocation.valueOf(valueIDLocation);
+ }
+
+ if (idGenerationLocation == null)
+ {
+ idGenerationLocation = IDGenerationLocation.STORE;
+ }
}
public void initSystemPackages()
@@ -1407,7 +1427,7 @@ public class Repository extends Container<Object> implements InternalRepository
protected void initRootResource()
{
CDOBranchPoint head = branchManager.getMainBranch().getHead();
- CDOIDTemp tempID = CDOIDUtil.createTempObject(1);
+ CDOID id = createRootResourceID();
CDORevisionFactory factory = getRevisionManager().getFactory();
InternalCDORevision rootResource = (InternalCDORevision)factory
@@ -1416,8 +1436,8 @@ public class Repository extends Container<Object> implements InternalRepository
rootResource.setBranchPoint(head);
rootResource.setContainerID(CDOID.NULL);
rootResource.setContainingFeatureID(0);
- rootResource.setID(tempID);
- rootResource.setResourceID(tempID);
+ rootResource.setID(id);
+ rootResource.setResourceID(id);
InternalSession session = getSessionManager().openSession(null);
InternalTransaction transaction = session.openTransaction(1, head);
@@ -1455,12 +1475,22 @@ public class Repository extends Container<Object> implements InternalRepository
throw new TransactionException(rollbackMessage);
}
- rootResourceID = commitContext.getIDMappings().get(tempID);
+ rootResourceID = id instanceof CDOIDTemp ? commitContext.getIDMappings().get(id) : id;
commitContext.postCommit(true);
session.close();
}
+ protected CDOID createRootResourceID()
+ {
+ if (getIDGenerationLocation() == IDGenerationLocation.STORE)
+ {
+ return CDOIDUtil.createTempObject(1);
+ }
+
+ return CDOIDGenerator.UUID.generateCDOID();
+ }
+
protected void readRootResource()
{
IStoreAccessor reader = store.getReader(null);
@@ -1533,6 +1563,11 @@ public class Repository extends Container<Object> implements InternalRepository
super.doActivate();
initProperties();
+ if (idGenerationLocation == IDGenerationLocation.CLIENT && !(store instanceof CanHandleClientAssignedIDs))
+ {
+ throw new IllegalStateException("Store can not handle client assigned IDs: " + store);
+ }
+
store.setRevisionTemporality(supportingAudits ? IStore.RevisionTemporality.AUDITING
: IStore.RevisionTemporality.NONE);
store.setRevisionParallelism(supportingBranches ? IStore.RevisionParallelism.BRANCHING
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ServerCDOView.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ServerCDOView.java
index 917eb5f067..10868ef70f 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ServerCDOView.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/ServerCDOView.java
@@ -17,6 +17,7 @@ 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.CDOID.ObjectType;
+import org.eclipse.emf.cdo.common.id.CDOIDGenerator;
import org.eclipse.emf.cdo.common.lob.CDOLobStore;
import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
import org.eclipse.emf.cdo.common.protocol.CDOAuthenticator;
@@ -131,7 +132,7 @@ public class ServerCDOView extends AbstractCDOView implements org.eclipse.emf.cd
}
@Override
- protected synchronized void excludeTempIDs(CDOID id)
+ protected synchronized void excludeNewObject(CDOID id)
{
// Do nothing
}
@@ -529,6 +530,11 @@ public class ServerCDOView extends AbstractCDOView implements org.eclipse.emf.cd
return repository.isEnsuringReferentialIntegrity();
}
+ public IDGenerationLocation getIDGenerationLocation()
+ {
+ return repository.getIDGenerationLocation();
+ }
+
public void handleRepositoryTypeChanged(Type oldType, Type newType)
{
}
@@ -697,6 +703,11 @@ public class ServerCDOView extends AbstractCDOView implements org.eclipse.emf.cd
return null;
}
+ public CDOIDGenerator getIDGenerator()
+ {
+ return null;
+ }
+
public void viewDetached(InternalCDOView view)
{
// Do nothing
@@ -742,6 +753,11 @@ public class ServerCDOView extends AbstractCDOView implements org.eclipse.emf.cd
throw new UnsupportedOperationException();
}
+ public void setIDGenerator(CDOIDGenerator idGenerator)
+ {
+ throw new UnsupportedOperationException();
+ }
+
public Object resolveElementProxy(CDORevision revision, EStructuralFeature feature, int accessIndex, int serverIndex)
{
throw new UnsupportedOperationException();
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java
index 3cef064445..ed52b2753a 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java
@@ -321,6 +321,11 @@ public class TransactionCommitContext implements InternalCommitContext
public void applyIDMappings(OMMonitor monitor)
{
+ if (idMappings.isEmpty())
+ {
+ return;
+ }
+
try
{
monitor.begin(newObjects.length + dirtyObjects.length + dirtyObjectDeltas.length);
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSessionConfiguration.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSessionConfiguration.java
index d34917ecdc..38706105b2 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSessionConfiguration.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSessionConfiguration.java
@@ -135,6 +135,11 @@ public class EmbeddedClientSessionConfiguration extends CDOSessionConfigurationI
return session.getRepository().isEnsuringReferentialIntegrity();
}
+ public IDGenerationLocation getIDGenerationLocation()
+ {
+ return session.getRepository().getIDGenerationLocation();
+ }
+
public String getStoreType()
{
return session.getRepository().getStoreType();
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/mem/MEMStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/mem/MEMStoreAccessor.java
index 25d2feb90e..2e071a7ecd 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/mem/MEMStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/mem/MEMStoreAccessor.java
@@ -389,9 +389,12 @@ public class MEMStoreAccessor extends LongIDStoreAccessor implements Raw, Durabl
writeCommitInfo(branch, timeStamp, previousTimeStamp, userID, comment, monitor);
}
+ @Deprecated
public void rawDelete(CDOID id, int version, CDOBranch branch, EClass eClass, OMMonitor monitor)
{
- getStore().rawDelete(id, version, branch);
+ throw new UnsupportedOperationException();
+
+ // getStore().rawDelete(id, version, branch);
}
public void rawCommit(double commitWork, OMMonitor monitor)
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepository.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepository.java
index 09adc8289e..e930089523 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepository.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepository.java
@@ -207,10 +207,14 @@ public interface IRepository extends CDOCommonRepository, IQueryHandlerProvider,
/**
* @author Eike Stepper
* @noimplement This interface is not intended to be implemented by clients.
+ * @noextend This interface is not intended to be extended by clients.
*/
public interface Props
{
/**
+ * Used to override the automatic UUID generation during first startup of a repository. Passing the empty string
+ * causes the UUID of the repository to be set to its {@link IRepository#getName() name}.
+ *
* @since 2.0
*/
public static final String OVERRIDE_UUID = "overrideUUID"; //$NON-NLS-1$
@@ -239,5 +243,10 @@ public interface IRepository extends CDOCommonRepository, IQueryHandlerProvider,
* @since 4.0
*/
public static final String ALLOW_INTERRUPT_RUNNING_QUERIES = "allowInterruptRunningQueries"; //$NON-NLS-1$
+
+ /**
+ * @since 4.1
+ */
+ public static final String ID_GENERATION_LOCATION = "idGenerationLocation"; //$NON-NLS-1$
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStore.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStore.java
index 5b747cb5ef..ac17de97b8 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStore.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStore.java
@@ -10,8 +10,10 @@
*/
package org.eclipse.emf.cdo.server;
+import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOID.ObjectType;
import org.eclipse.net4j.util.om.monitor.ProgressDistributor;
@@ -191,4 +193,15 @@ public interface IStore
{
NONE, BRANCHING
}
+
+ /**
+ * A marker interface for {@link IStore stores} that can handle {@link CDOID IDs} assigned by a
+ * {@link IDGenerationLocation#CLIENT client}, typically {@link ObjectType#UUID UUIDs}.
+ *
+ * @author Eike Stepper
+ * @since 4.1
+ */
+ public interface CanHandleClientAssignedIDs
+ {
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreAccessor.java
index d007df92cd..d93c7cad2b 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreAccessor.java
@@ -665,7 +665,9 @@ public interface IStoreAccessor extends IQueryHandlerProvider, BranchLoader, Com
* where the accumulated backend changes can be committed atomically.
*
* @see #rawCommit(double, OMMonitor)
+ * @deprecated Not used anymore
*/
+ @Deprecated
public void rawDelete(CDOID id, int version, CDOBranch branch, EClass eClass, OMMonitor monitor);
/**
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/StoreAccessor.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/StoreAccessor.java
index 9f3805b007..5b988af6e9 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/StoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/StoreAccessor.java
@@ -12,6 +12,7 @@
*/
package org.eclipse.emf.cdo.spi.server;
+import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.server.ISession;
@@ -76,7 +77,11 @@ public abstract class StoreAccessor extends StoreAccessorBase
writePackageUnits(newPackageUnits, monitor.fork(newPackageUnits.length));
}
- addIDMappings(context, monitor.fork());
+ if (getStore().getRepository().getIDGenerationLocation() == IDGenerationLocation.STORE)
+ {
+ addIDMappings(context, monitor.fork());
+ }
+
applyIDMappings(context, monitor);
if (detachedObjects.length != 0)
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Offline.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Offline.java
index a751d4aaab..062479ddc6 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Offline.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Offline.java
@@ -118,7 +118,6 @@ public class AllTestsDBH2Offline extends DBConfigs
props.put(IRepository.Props.SUPPORTING_BRANCHES, "true");
}
- @Override
public IStore createStore(String repoName)
{
IMappingStrategy mappingStrategy = createMappingStrategy();
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBStoreRepositoryConfig.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBStoreRepositoryConfig.java
index b229875ec0..609ba57bec 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBStoreRepositoryConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBStoreRepositoryConfig.java
@@ -52,7 +52,6 @@ public abstract class DBStoreRepositoryConfig extends RepositoryConfig
return true;
}
- @Override
public IStore createStore(String repoName)
{
IMappingStrategy mappingStrategy = createMappingStrategy();
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/SQLQueryTest.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/SQLQueryTest.java
index 30646c87fe..ee82eb0df1 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/SQLQueryTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/SQLQueryTest.java
@@ -95,7 +95,6 @@ public class SQLQueryTest extends AbstractCDOTest
}
transaction.commit();
- enableConsole();
}
@CleanRepositoriesBefore
@@ -135,7 +134,6 @@ public class SQLQueryTest extends AbstractCDOTest
}
transaction.commit();
- enableConsole();
}
@CleanRepositoriesBefore
@@ -162,7 +160,6 @@ public class SQLQueryTest extends AbstractCDOTest
}
transaction.commit();
- enableConsole();
}
public void testPaging() throws Exception
@@ -200,7 +197,6 @@ public class SQLQueryTest extends AbstractCDOTest
}
transaction.commit();
- enableConsole();
}
public void testIterator() throws Exception
@@ -232,7 +228,6 @@ public class SQLQueryTest extends AbstractCDOTest
}
transaction.commit();
- enableConsole();
}
public void _testNonCdoObjectQueries() throws Exception
@@ -281,6 +276,7 @@ public class SQLQueryTest extends AbstractCDOTest
}
}
+ @CleanRepositoriesBefore
public void testNonCDOObjectQueries_Complex() throws Exception
{
msg("Opening session");
@@ -293,19 +289,29 @@ public class SQLQueryTest extends AbstractCDOTest
{
msg("Query for customer fields");
- CDOQuery query = transaction.createQuery("sql", "SELECT STREET, CITY, NAME FROM MODEL1_CUSTOMER");
+ CDOQuery query = transaction.createQuery("sql", "SELECT street, city, name FROM model1_customer ORDER BY street");
query.setParameter("cdoObjectQuery", false);
List<Object[]> results = query.getResult(Object[].class);
for (int i = 0; i < NUM_OF_CUSTOMERS; i++)
{
- assertEquals(true, results.get(i)[0].equals("Street " + i));
- assertEquals(true, i == 0 ? results.get(i)[1] == null : results.get(i)[1].equals("City " + i));
- assertEquals(true, results.get(i)[2].equals(i + ""));
+ assertEquals("Street " + i, results.get(i)[0]);
+ Object actual = results.get(i)[1];
+ if (i == 0)
+ {
+ assertEquals(null, actual);
+ }
+ else
+ {
+ assertEquals("City " + i, actual);
+ }
+
+ assertEquals("" + i, results.get(i)[2]);
}
}
}
+ @CleanRepositoriesBefore
public void testNonCDOObjectQueries_Complex_MAP() throws Exception
{
msg("Opening session");
@@ -316,25 +322,31 @@ public class SQLQueryTest extends AbstractCDOTest
msg("Opening transaction for querying");
CDOTransaction transaction = session.openTransaction();
- {
- msg("Query for customer fields");
- CDOQuery query = transaction.createQuery("sql", "SELECT STREET, CITY, NAME FROM MODEL1_CUSTOMER");
- query.setParameter("cdoObjectQuery", false);
- query.setParameter("mapQuery", true);
+ msg("Query for customer fields");
+ CDOQuery query = transaction.createQuery("sql", "SELECT street, city, name FROM model1_customer ORDER BY street");
+ query.setParameter("cdoObjectQuery", false);
+ query.setParameter("mapQuery", true);
- List<Map<String, Object>> results = query.getResult();
- for (int i = 0; i < NUM_OF_CUSTOMERS; i++)
+ List<Map<String, Object>> results = query.getResult();
+ for (int i = 0; i < NUM_OF_CUSTOMERS; i++)
+ {
+ assertEquals("Street " + i, results.get(i).get("STREET"));
+ Object actual = results.get(i).get("CITY");
+ if (i == 0)
{
- assertEquals(true, results.get(i).get("STREET").equals("Street " + i));
- assertEquals(true, i == 0 ? results.get(i).get("CITY") == null : results.get(i).get("CITY").equals("City " + i));
- assertEquals(true, results.get(i).get("NAME").equals(i + ""));
+ assertEquals(null, actual);
}
+ else
+ {
+ assertEquals("City " + i, actual);
+ }
+
+ assertEquals("" + i, results.get(i).get("NAME"));
}
}
private void createTestSet(CDOSession session)
{
- // disableConsole();
msg("Opening transaction");
CDOTransaction transaction = session.openTransaction();
@@ -352,8 +364,6 @@ public class SQLQueryTest extends AbstractCDOTest
{
throw WrappedException.wrap(ex);
}
-
- enableConsole();
}
private void fillResource(CDOResource resource)
diff --git a/plugins/org.eclipse.emf.cdo.tests.db4o/src/org/eclipse/emf/cdo/tests/db4o/AllTestsDB4O.java b/plugins/org.eclipse.emf.cdo.tests.db4o/src/org/eclipse/emf/cdo/tests/db4o/AllTestsDB4O.java
index 80c441e18c..ec0cdd3314 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db4o/src/org/eclipse/emf/cdo/tests/db4o/AllTestsDB4O.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db4o/src/org/eclipse/emf/cdo/tests/db4o/AllTestsDB4O.java
@@ -92,8 +92,7 @@ public class AllTestsDB4O extends AllConfigs
props.put(IRepository.Props.SUPPORTING_BRANCHES, "false");
}
- @Override
- protected IStore createStore(String repoName)
+ public IStore createStore(String repoName)
{
File tempFolder = TMPUtil.getTempFolder();
File file = new File(tempFolder, "cdodb_" + repoName + ".db4o");
diff --git a/plugins/org.eclipse.emf.cdo.tests.db4o/src/org/eclipse/emf/cdo/tests/db4o/AllTestsMEMDB4O.java b/plugins/org.eclipse.emf.cdo.tests.db4o/src/org/eclipse/emf/cdo/tests/db4o/AllTestsMEMDB4O.java
index 732954ba91..8fccfa3de0 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db4o/src/org/eclipse/emf/cdo/tests/db4o/AllTestsMEMDB4O.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db4o/src/org/eclipse/emf/cdo/tests/db4o/AllTestsMEMDB4O.java
@@ -44,13 +44,13 @@ public class AllTestsMEMDB4O extends AllTestsDB4O
props.put(IRepository.Props.SUPPORTING_BRANCHES, "false");
}
- @Override
- protected IStore createStore(String repoName)
+ public IStore createStore(String repoName)
{
if (!isRestarting())
{
MEMDB4OStore.clearContainer();
}
+
return new MEMDB4OStore();
}
diff --git a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateConfig.java b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateConfig.java
index ed8ee9b1dc..3b9612caf8 100644
--- a/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests.hibernate/src/org/eclipse/emf/cdo/tests/hibernate/HibernateConfig.java
@@ -65,8 +65,7 @@ public class HibernateConfig extends RepositoryConfig
}
}
- @Override
- protected IStore createStore(String repoName)
+ public IStore createStore(String repoName)
{
// note the provider properties are read from the store/repository level
IHibernateMappingProvider mappingProvider = TeneoUtil.createMappingProvider();
diff --git a/plugins/org.eclipse.emf.cdo.tests.mongodb/src/org/eclipse/emf/cdo/tests/mongodb/MongoDBStoreRepositoryConfig.java b/plugins/org.eclipse.emf.cdo.tests.mongodb/src/org/eclipse/emf/cdo/tests/mongodb/MongoDBStoreRepositoryConfig.java
index 2e06f8d31d..073300d861 100644
--- a/plugins/org.eclipse.emf.cdo.tests.mongodb/src/org/eclipse/emf/cdo/tests/mongodb/MongoDBStoreRepositoryConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests.mongodb/src/org/eclipse/emf/cdo/tests/mongodb/MongoDBStoreRepositoryConfig.java
@@ -71,7 +71,6 @@ public class MongoDBStoreRepositoryConfig extends RepositoryConfig
super.tearDown();
}
- @Override
public IStore createStore(String repoName)
{
MongoURI mongoURI = new MongoURI("mongodb://localhost");
diff --git a/plugins/org.eclipse.emf.cdo.tests.objectivity/src/org/eclipse/emf/cdo/tests/objectivity/ObjyStoreRepositoryConfig.java b/plugins/org.eclipse.emf.cdo.tests.objectivity/src/org/eclipse/emf/cdo/tests/objectivity/ObjyStoreRepositoryConfig.java
index b19f5d28e6..e81eee762f 100644
--- a/plugins/org.eclipse.emf.cdo.tests.objectivity/src/org/eclipse/emf/cdo/tests/objectivity/ObjyStoreRepositoryConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests.objectivity/src/org/eclipse/emf/cdo/tests/objectivity/ObjyStoreRepositoryConfig.java
@@ -47,8 +47,7 @@ public abstract class ObjyStoreRepositoryConfig extends RepositoryConfig
storeConfig.resetFD();
}
- @Override
- protected IStore createStore(String repoName)
+ public IStore createStore(String repoName)
{
// We might need to use the repoName to our advantage!!!
System.out.println("************* ObjyStore creation ****************\n");
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InitialTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InitialTest.java
index f1685da3e4..a45912d2ca 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InitialTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InitialTest.java
@@ -11,6 +11,7 @@
package org.eclipse.emf.cdo.tests;
import org.eclipse.emf.cdo.CDOState;
+import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.session.CDOSession;
@@ -822,6 +823,13 @@ public class InitialTest extends AbstractCDOTest
assertEquals(supplier, CDOUtil.getEObject(supplierFromURI));
EObject supplierAfterCommit2 = transaction.getResourceSet().getEObject(supplierTempURI, true);
- assertEquals(null, supplierAfterCommit2);
+ if (session.getRepositoryInfo().getIDGenerationLocation() == IDGenerationLocation.STORE)
+ {
+ assertEquals(null, supplierAfterCommit2);
+ }
+ else
+ {
+ assertEquals(supplier, supplierAfterCommit2);
+ }
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/WorkspaceTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/WorkspaceTest.java
index 3865555a48..d4c2ae19c5 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/WorkspaceTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/WorkspaceTest.java
@@ -10,6 +10,7 @@
*/
package org.eclipse.emf.cdo.tests;
+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.commit.CDOChangeSetData;
@@ -19,10 +20,8 @@ import org.eclipse.emf.cdo.common.revision.CDOAllRevisionsProvider;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.internal.server.mem.MEMStore;
import org.eclipse.emf.cdo.server.IRepository;
import org.eclipse.emf.cdo.server.IStore;
-import org.eclipse.emf.cdo.server.mem.MEMStoreUtil;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.session.CDOSessionConfiguration;
import org.eclipse.emf.cdo.session.CDOSessionConfigurationFactory;
@@ -41,6 +40,7 @@ import org.eclipse.emf.cdo.util.CommitException;
import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.emf.cdo.workspace.CDOWorkspace;
import org.eclipse.emf.cdo.workspace.CDOWorkspaceBase;
+import org.eclipse.emf.cdo.workspace.CDOWorkspaceConfiguration;
import org.eclipse.emf.cdo.workspace.CDOWorkspaceUtil;
import org.eclipse.net4j.jvm.JVMUtil;
@@ -94,11 +94,10 @@ public class WorkspaceTest extends AbstractCDOTest
@Override
protected void doSetUp() throws Exception
{
- disableConsole();
super.doSetUp();
+
skipUnlessAuditing();
skipHandleRevisions();
- skipTest(!getRepository().getStore().getObjectIDTypes().equals(MEMStore.OBJECT_ID_TYPES));
CDOSession session = openSession();
transaction = session.openTransaction();
@@ -116,7 +115,6 @@ public class WorkspaceTest extends AbstractCDOTest
JVMUtil.prepareContainer(getClientContainer());
localStore = createLocalStore();
-
CDOUtil.setLegacyModeDefault(true);
}
@@ -197,6 +195,8 @@ public class WorkspaceTest extends AbstractCDOTest
public void testAddObjects() throws Exception
{
+ skipTest(getRepository().getIDGenerationLocation() == IDGenerationLocation.STORE);
+
InternalCDOWorkspace workspace = checkout("MAIN", CDOBranchPoint.UNSPECIFIED_DATE);
CDOTransaction transaction = workspace.openTransaction();
@@ -322,6 +322,8 @@ public class WorkspaceTest extends AbstractCDOTest
public void testAddObjects2() throws Exception
{
+ skipTest(getRepository().getIDGenerationLocation() == IDGenerationLocation.STORE);
+
InternalCDOWorkspace workspace = checkout("MAIN", CDOBranchPoint.UNSPECIFIED_DATE);
CDOTransaction transaction = workspace.openTransaction();
@@ -462,6 +464,8 @@ public class WorkspaceTest extends AbstractCDOTest
public void testLocalChangesAfterAdd() throws Exception
{
+ skipTest(getRepository().getIDGenerationLocation() == IDGenerationLocation.STORE);
+
InternalCDOWorkspace workspace = checkout("MAIN", CDOBranchPoint.UNSPECIFIED_DATE);
CDOTransaction transaction = workspace.openTransaction();
@@ -542,6 +546,8 @@ public class WorkspaceTest extends AbstractCDOTest
public void testLocalChangesAfterAdd2() throws Exception
{
+ skipTest(getRepository().getIDGenerationLocation() == IDGenerationLocation.STORE);
+
InternalCDOWorkspace workspace = checkout("MAIN", CDOBranchPoint.UNSPECIFIED_DATE);
CDOTransaction transaction = workspace.openTransaction();
@@ -639,6 +645,8 @@ public class WorkspaceTest extends AbstractCDOTest
public void testCheckinAfterAdd() throws Exception
{
+ skipTest(getRepository().getIDGenerationLocation() == IDGenerationLocation.STORE);
+
InternalCDOWorkspace workspace = checkout("MAIN", CDOBranchPoint.UNSPECIFIED_DATE);
IOUtil.ERR().println("Checkout done");
@@ -735,6 +743,8 @@ public class WorkspaceTest extends AbstractCDOTest
public void testCheckinAfterAdd2() throws Exception
{
+ skipTest(getRepository().getIDGenerationLocation() == IDGenerationLocation.STORE);
+
InternalCDOWorkspace workspace = checkout("MAIN", CDOBranchPoint.UNSPECIFIED_DATE);
CDOTransaction transaction = workspace.openTransaction();
@@ -865,6 +875,8 @@ public class WorkspaceTest extends AbstractCDOTest
public void testCheckin2AfterAdd() throws Exception
{
+ skipTest(getRepository().getIDGenerationLocation() == IDGenerationLocation.STORE);
+
InternalCDOWorkspace workspace = checkout("MAIN", CDOBranchPoint.UNSPECIFIED_DATE);
CDOTransaction transaction = workspace.openTransaction();
@@ -1003,6 +1015,8 @@ public class WorkspaceTest extends AbstractCDOTest
public void testUpdateAfterMasterAdd() throws Exception
{
+ skipTest(getRepository().getIDGenerationLocation() == IDGenerationLocation.STORE);
+
InternalCDOWorkspace workspace = checkout("MAIN", CDOBranchPoint.UNSPECIFIED_DATE);
assertNotSame(CDOBranchPoint.UNSPECIFIED_DATE, workspace.getTimeStamp());
@@ -1098,6 +1112,8 @@ public class WorkspaceTest extends AbstractCDOTest
public void testUpdateAfterMasterAndLocalAdd() throws Exception
{
+ skipTest(getRepository().getIDGenerationLocation() == IDGenerationLocation.STORE);
+
InternalCDOWorkspace workspace = checkout("MAIN", CDOBranchPoint.UNSPECIFIED_DATE);
assertNotSame(CDOBranchPoint.UNSPECIFIED_DATE, workspace.getTimeStamp());
@@ -1196,7 +1212,7 @@ public class WorkspaceTest extends AbstractCDOTest
protected IStore createLocalStore()
{
- return MEMStoreUtil.createMEMStore();
+ return getRepositoryConfig().createStore(CDOWorkspaceConfiguration.DEFAULT_LOCAL_REPOSITORY_NAME);
}
protected InternalCDOWorkspace checkout(String branchPath, long timeStamp)
@@ -1208,13 +1224,21 @@ public class WorkspaceTest extends AbstractCDOTest
CDOWorkspaceBase base = CDOWorkspaceUtil.createFolderWorkspaceBase(folder);
IOUtil.ERR().println("CDOWorkspaceBaseline: " + folder.getAbsolutePath());
- InternalCDOWorkspace workspace = (InternalCDOWorkspace)CDOWorkspaceUtil.checkout(localStore, base, remote,
- branchPath, timeStamp);
+ CDOWorkspaceConfiguration config = CDOWorkspaceUtil.createWorkspaceConfiguration();
+ config.setStore(localStore);
+ config.setBase(base);
+ config.setRemote(remote);
+ config.setBranchPath(branchPath);
+ config.setTimeStamp(timeStamp);
+ config.setIDGenerationLocation(getRepository().getIDGenerationLocation());
+ InternalCDOWorkspace workspace = (InternalCDOWorkspace)config.checkout();
workspaces.add(workspace);
+
InternalRepository localRepository = workspace.getLocalRepository();
registerRepository(localRepository);
LifecycleUtil.activate(localRepository);
+
return workspace;
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_327604_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_327604_Test.java
index cdfb93808f..a7d6bb373b 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_327604_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_327604_Test.java
@@ -34,6 +34,7 @@ import org.eclipse.emf.cdo.util.CommitException;
import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.emf.cdo.workspace.CDOWorkspace;
import org.eclipse.emf.cdo.workspace.CDOWorkspaceBase;
+import org.eclipse.emf.cdo.workspace.CDOWorkspaceConfiguration;
import org.eclipse.emf.cdo.workspace.CDOWorkspaceUtil;
import org.eclipse.net4j.jvm.JVMUtil;
@@ -159,10 +160,16 @@ public class Bugzilla_327604_Test extends AbstractCDOTest
CDOWorkspaceBase base = CDOWorkspaceUtil.createFolderWorkspaceBase(folder);
IOUtil.ERR().println("CDOWorkspaceBaseline: " + folder.getAbsolutePath());
- InternalCDOWorkspace workspace = (InternalCDOWorkspace)CDOWorkspaceUtil.checkout(localStore, base, remote,
- branchPath, timeStamp);
+ CDOWorkspaceConfiguration config = CDOWorkspaceUtil.createWorkspaceConfiguration();
+ config.setStore(localStore);
+ config.setBase(base);
+ config.setRemote(remote);
+ config.setBranchPath(branchPath);
+ config.setTimeStamp(timeStamp);
+ InternalCDOWorkspace workspace = (InternalCDOWorkspace)config.checkout();
workspaces.add(workspace);
+
InternalRepository localRepository = workspace.getLocalRepository();
registerRepository(localRepository);
LifecycleUtil.activate(localRepository);
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IRepositoryConfig.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IRepositoryConfig.java
index 0c7f07af12..988530e652 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IRepositoryConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IRepositoryConfig.java
@@ -10,6 +10,7 @@
*/
package org.eclipse.emf.cdo.tests.config;
+import org.eclipse.emf.cdo.server.IStore;
import org.eclipse.emf.cdo.spi.server.InternalRepository;
import java.util.Map;
@@ -30,4 +31,6 @@ public interface IRepositoryConfig extends IConfig
public void registerRepository(InternalRepository repository);
public void setRestarting(boolean b);
+
+ public IStore createStore(String repoName);
}
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 46ec669957..b98243161c 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
@@ -139,6 +139,8 @@ public abstract class RepositoryConfig extends Config implements IRepositoryConf
}
}
+ // int xxx;
+ // repositoryProperties.put(IRepository.Props.ID_GENERATION_LOCATION, IDGenerationLocation.CLIENT.toString());
return repositoryProperties;
}
@@ -419,8 +421,6 @@ public abstract class RepositoryConfig extends Config implements IRepositoryConf
return repository;
}
- protected abstract IStore createStore(String repoName);
-
protected InternalRepository getTestRepository()
{
return (InternalRepository)getTestProperty(PROP_TEST_REPOSITORY);
@@ -766,8 +766,7 @@ public abstract class RepositoryConfig extends Config implements IRepositoryConf
super("MEM");
}
- @Override
- protected IStore createStore(String repoName)
+ public IStore createStore(String repoName)
{
return MEMStoreUtil.createMEMStore();
}
@@ -795,8 +794,7 @@ public abstract class RepositoryConfig extends Config implements IRepositoryConf
super("MEMAudits");
}
- @Override
- protected IStore createStore(String repoName)
+ public IStore createStore(String repoName)
{
return MEMStoreUtil.createMEMStore();
}
@@ -824,8 +822,7 @@ public abstract class RepositoryConfig extends Config implements IRepositoryConf
super("MEMBranches");
}
- @Override
- protected IStore createStore(String repoName)
+ public IStore createStore(String repoName)
{
return MEMStoreUtil.createMEMStore();
}
@@ -850,11 +847,10 @@ public abstract class RepositoryConfig extends Config implements IRepositoryConf
public MEMOffline()
{
- super("MEM_OFFLINE");
+ super("MEMOffline");
}
- @Override
- protected IStore createStore(String repoName)
+ public IStore createStore(String repoName)
{
return MEMStoreUtil.createMEMStore();
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestSessionConfiguration.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestSessionConfiguration.java
index 099945508a..81c2408d9e 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestSessionConfiguration.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestSessionConfiguration.java
@@ -11,6 +11,7 @@
package org.eclipse.emf.cdo.tests.util;
import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
+import org.eclipse.emf.cdo.common.id.CDOIDGenerator;
import org.eclipse.emf.cdo.common.protocol.CDOAuthenticator;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.session.CDOSessionConfiguration;
@@ -37,6 +38,11 @@ public abstract class TestSessionConfiguration extends Notifier implements CDOSe
throw new UnsupportedOperationException();
}
+ public void setIDGenerator(CDOIDGenerator idGenerator)
+ {
+ throw new UnsupportedOperationException();
+ }
+
public void setActivateOnOpen(boolean activateOnOpen)
{
throw new UnsupportedOperationException();
@@ -67,6 +73,11 @@ public abstract class TestSessionConfiguration extends Notifier implements CDOSe
throw new UnsupportedOperationException();
}
+ public CDOIDGenerator getIDGenerator()
+ {
+ throw new UnsupportedOperationException();
+ }
+
public CDOAuthenticator getAuthenticator()
{
throw new UnsupportedOperationException();
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/messages/messages.properties b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/messages/messages.properties
index 8c3ad7b830..3a466e8a32 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/messages/messages.properties
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/messages/messages.properties
@@ -85,6 +85,8 @@ CDOSessionPropertySource_28=Supporting Ecore
CDOSessionPropertySource_29=Whether the repository of this session is supporting Ecore instances.
CDOSessionPropertySource_30=Ensure Referential Integrity
CDOSessionPropertySource_31=Whether the repository of this session is ensuring referential integrity.
+CDOSessionPropertySource_32=ID Generation Location
+CDOSessionPropertySource_33=One of STORE, CLIENT.
CDOSessionPropertySource_3=The ID of this session.
CDOSessionPropertySource_4=User
CDOSessionPropertySource_5=The ID of the authenticated user of this session.
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/properties/CDOSessionPropertySource.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/properties/CDOSessionPropertySource.java
index 362f7a5f9c..b483f05bee 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/properties/CDOSessionPropertySource.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/properties/CDOSessionPropertySource.java
@@ -52,6 +52,8 @@ public class CDOSessionPropertySource extends CDOPropertySource<CDOSession>
private static final String ENSURE_REFERENTIAL_INTEGRITY = "ensureReferentialIntegrity"; //$NON-NLS-1$
+ private static final String ID_GENERATION_LOCATION = "idGenerationLocation"; //$NON-NLS-1$
+
private static final String STORE_TYPE = "storeType"; //$NON-NLS-1$
private static final String OBJECT_ID_TYPES = "objectIDTypes"; //$NON-NLS-1$
@@ -111,6 +113,10 @@ public class CDOSessionPropertySource extends CDOPropertySource<CDOSession>
Messages.getString("CDOSessionPropertySource_30"), //$NON-NLS-1$
Messages.getString("CDOSessionPropertySource_31")); //$NON-NLS-1$
+ addPropertyDescriptor(CATEGORY_REPOSITORY, ID_GENERATION_LOCATION, //
+ Messages.getString("CDOSessionPropertySource_32"), //$NON-NLS-1$
+ Messages.getString("CDOSessionPropertySource_33")); //$NON-NLS-1$
+
addPropertyDescriptor(CATEGORY_REPOSITORY, STORE_TYPE, //
Messages.getString("CDOSessionPropertySource_24"), //$NON-NLS-1$
Messages.getString("CDOSessionPropertySource_25")); //$NON-NLS-1$
@@ -178,6 +184,16 @@ public class CDOSessionPropertySource extends CDOPropertySource<CDOSession>
return session.getRepositoryInfo().isSupportingBranches();
}
+ if (ENSURE_REFERENTIAL_INTEGRITY.equals(id))
+ {
+ return session.getRepositoryInfo().isEnsuringReferentialIntegrity();
+ }
+
+ if (ID_GENERATION_LOCATION.equals(id))
+ {
+ return session.getRepositoryInfo().getIDGenerationLocation();
+ }
+
if (STORE_TYPE.equals(id))
{
return session.getRepositoryInfo().getStoreType();
diff --git a/plugins/org.eclipse.emf.cdo.workspace.efs/src/org/eclipse/emf/cdo/workspace/efs/CDOFS.java b/plugins/org.eclipse.emf.cdo.workspace.efs/src/org/eclipse/emf/cdo/workspace/efs/CDOFS.java
index a9db7705e7..82735cb43f 100644
--- a/plugins/org.eclipse.emf.cdo.workspace.efs/src/org/eclipse/emf/cdo/workspace/efs/CDOFS.java
+++ b/plugins/org.eclipse.emf.cdo.workspace.efs/src/org/eclipse/emf/cdo/workspace/efs/CDOFS.java
@@ -18,6 +18,7 @@ import org.eclipse.emf.cdo.server.db.IDBStore;
import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
import org.eclipse.emf.cdo.workspace.CDOWorkspace;
import org.eclipse.emf.cdo.workspace.CDOWorkspaceBase;
+import org.eclipse.emf.cdo.workspace.CDOWorkspaceConfiguration;
import org.eclipse.emf.cdo.workspace.CDOWorkspaceUtil;
import org.eclipse.emf.cdo.workspace.internal.efs.CDOWorkspaceFileSystem;
import org.eclipse.emf.cdo.workspace.internal.efs.CDOWorkspaceStore;
@@ -61,10 +62,14 @@ public final class CDOFS
{
IDBStore local = creatLocalStore(projectFolder);
CDOWorkspaceBase base = createWorkspaceBase(new File(projectFolder, "base"));
-
IRepositoryLocation remote = readRepositoryLocation(projectFolder);
- CDOWorkspace workspace = CDOWorkspaceUtil.open(local, base, remote);
+ CDOWorkspaceConfiguration config = CDOWorkspaceUtil.createWorkspaceConfiguration();
+ config.setStore(local);
+ config.setBase(base);
+ config.setRemote(remote);
+
+ CDOWorkspace workspace = config.open();
return workspace;
}
@@ -103,7 +108,14 @@ public final class CDOFS
String branchPath = checkoutSource.getBranchPath();
long timeStamp = checkoutSource.getTimeStamp();
- CDOWorkspace workspace = CDOWorkspaceUtil.checkout(local, base, remote, branchPath, timeStamp);
+ CDOWorkspaceConfiguration config = CDOWorkspaceUtil.createWorkspaceConfiguration();
+ config.setStore(local);
+ config.setBase(base);
+ config.setRemote(remote);
+ config.setBranchPath(branchPath);
+ config.setTimeStamp(timeStamp);
+
+ CDOWorkspace workspace = config.checkout();
CDOWorkspaceStore store = getFileSystem().addWorkspaceStore(projectName, workspace);
return store.toURI();
}
diff --git a/plugins/org.eclipse.emf.cdo.workspace/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.workspace/META-INF/MANIFEST.MF
index c0fcf176db..a5ce9349ed 100644
--- a/plugins/org.eclipse.emf.cdo.workspace/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.workspace/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.emf.cdo.workspace;singleton:=true
-Bundle-Version: 4.0.0.qualifier
+Bundle-Version: 4.1.0.qualifier
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -12,7 +12,7 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)";resoluti
org.eclipse.emf.cdo.server.net4j;bundle-version="[4.0.0,5.0.0)",
org.eclipse.emf.cdo.net4j;bundle-version="[4.0.0,5.0.0)",
org.eclipse.net4j.jvm;bundle-version="[4.0.0,5.0.0)"
-Export-Package: org.eclipse.emf.cdo.internal.workspace;version="4.0.0";x-friends:="org.eclipse.emf.cdo.tests,org.eclipse.emf.cdo.tests.db",
- org.eclipse.emf.cdo.internal.workspace.bundle;version="4.0.0";x-internal:=true,
- org.eclipse.emf.cdo.spi.workspace;version="4.0.0",
- org.eclipse.emf.cdo.workspace;version="4.0.0"
+Export-Package: org.eclipse.emf.cdo.internal.workspace;version="4.1.0";x-friends:="org.eclipse.emf.cdo.tests,org.eclipse.emf.cdo.tests.db",
+ org.eclipse.emf.cdo.internal.workspace.bundle;version="4.1.0";x-internal:=true,
+ org.eclipse.emf.cdo.spi.workspace;version="4.1.0",
+ org.eclipse.emf.cdo.workspace;version="4.1.0"
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();
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java
index da97778d5c..0afbcaa681 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java
@@ -627,14 +627,15 @@ public class CDOResourceImpl extends CDOResourceNodeImpl implements CDOResource,
try
{
CDOID id = CDOIDUtil.read(uriFragment);
- if (CDOIDUtil.isNull(id) || id.isTemporary() && !cdoView().isObjectRegistered(id))
+ InternalCDOView view = cdoView();
+ if (CDOIDUtil.isNull(id) || view.isObjectNew(id) && !view.isObjectRegistered(id))
{
return null;
}
if (id.isObject())
{
- CDOObject object = cdoView().getObject(id, true);
+ CDOObject object = view.getObject(id, true);
return CDOUtil.getEObject(object);
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDOSession.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDOSession.java
index b3b52d46dd..b4a0ccd125 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDOSession.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDOSession.java
@@ -19,6 +19,7 @@ import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
import org.eclipse.emf.cdo.common.commit.CDOCommitInfoManager;
+import org.eclipse.emf.cdo.common.id.CDOIDGenerator;
import org.eclipse.emf.cdo.common.lob.CDOLobStore;
import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
@@ -116,6 +117,11 @@ public interface CDOSession extends CDOCommonSession, CDOUpdatable, CDOTransacti
public CDOSession.ExceptionHandler getExceptionHandler();
/**
+ * @since 4.1
+ */
+ public CDOIDGenerator getIDGenerator();
+
+ /**
* Refreshes the object caches of all (non-historical) {@link CDOView views}.
*
* @since 3.0
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDOSessionConfiguration.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDOSessionConfiguration.java
index 42c3e2851e..02912bb8ff 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDOSessionConfiguration.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDOSessionConfiguration.java
@@ -11,6 +11,7 @@
package org.eclipse.emf.cdo.session;
import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
+import org.eclipse.emf.cdo.common.id.CDOIDGenerator;
import org.eclipse.emf.cdo.common.protocol.CDOAuthenticator;
import org.eclipse.net4j.util.event.IEvent;
@@ -63,6 +64,21 @@ public interface CDOSessionConfiguration extends INotifier
public void setExceptionHandler(CDOSession.ExceptionHandler exceptionHandler);
/**
+ * @see CDOSession#getIDGenerator()
+ * @since 4.1
+ */
+ public CDOIDGenerator getIDGenerator();
+
+ /**
+ * A special ID generator can be set <b>before</b> the session is opened and can not be changed thereafter. If not
+ * <code>null</code>, the passed generator <b>must be</b> thread-safe.
+ *
+ * @see CDOSession#getIDGenerator()
+ * @since 4.1
+ */
+ public void setIDGenerator(CDOIDGenerator idGenerator);
+
+ /**
* Returns the authenticator of this configuration, never <code>null</code>.
*/
public CDOAuthenticator getAuthenticator();
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java
index 3fcac5abf7..c1fff7f383 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java
@@ -1091,9 +1091,10 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
}
EStructuralFeature.Internal internalFeature = (EStructuralFeature.Internal)eFeature;
- EReference oppositeReference = instance.cdoID().isTemporary() ? null : internalFeature.getEOpposite();
+ InternalCDOView view = instance.cdoView();
+ EReference oppositeReference = view.isObjectNew(instance.cdoID()) ? null : internalFeature.getEOpposite();
- CDOStore cdoStore = instance.cdoView().getStore();
+ CDOStore cdoStore = view.getStore();
EStore eStore = instance.eStore();
if (eFeature.isMany())
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOQueryImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOQueryImpl.java
index 50d2b86a12..5fd40fa773 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOQueryImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOQueryImpl.java
@@ -165,7 +165,7 @@ public class CDOQueryImpl extends CDOQueryInfoImpl implements CDOQuery
throw new UnsupportedOperationException(OBJECT_NOT_PERSISTED_MESSAGE);
}
- if (id.isTemporary())
+ if (view.isObjectNew(id))
{
throw new UnsupportedOperationException(OBJECT_NOT_PERSISTED_MESSAGE);
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionConfigurationImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionConfigurationImpl.java
index 314aa4430e..607d3855fe 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionConfigurationImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionConfigurationImpl.java
@@ -13,6 +13,7 @@ package org.eclipse.emf.internal.cdo.session;
import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
import org.eclipse.emf.cdo.common.commit.CDOCommitInfoManager;
+import org.eclipse.emf.cdo.common.id.CDOIDGenerator;
import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
import org.eclipse.emf.cdo.common.protocol.CDOAuthenticator;
import org.eclipse.emf.cdo.common.revision.CDORevisionManager;
@@ -46,6 +47,8 @@ public abstract class CDOSessionConfigurationImpl extends Notifier implements In
private CDOSession.ExceptionHandler exceptionHandler;
+ private CDOIDGenerator idGenerator;
+
private InternalCDOBranchManager branchManager;
private InternalCDOPackageRegistry packageRegistry;
@@ -139,6 +142,17 @@ public abstract class CDOSessionConfigurationImpl extends Notifier implements In
this.exceptionHandler = exceptionHandler;
}
+ public CDOIDGenerator getIDGenerator()
+ {
+ return idGenerator;
+ }
+
+ public void setIDGenerator(CDOIDGenerator idGenerator)
+ {
+ checkNotOpen();
+ this.idGenerator = idGenerator;
+ }
+
public InternalCDOBranchManager getBranchManager()
{
return branchManager;
@@ -258,8 +272,10 @@ public abstract class CDOSessionConfigurationImpl extends Notifier implements In
{
session.options().setPassiveUpdateEnabled(passiveUpdateEnabled);
session.options().setPassiveUpdateMode(passiveUpdateMode);
+
session.setMainBranchLocal(mainBranchLocal);
session.setExceptionHandler(exceptionHandler);
+ session.setIDGenerator(idGenerator);
session.setAuthenticator(authenticator);
session.setRevisionManager(revisionManager);
session.setBranchManager(branchManager);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java
index cbafb992e7..50e9c385dc 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java
@@ -24,6 +24,7 @@ import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
import org.eclipse.emf.cdo.common.commit.CDOCommitInfoManager;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDGenerator;
import org.eclipse.emf.cdo.common.lob.CDOLobInfo;
import org.eclipse.emf.cdo.common.lob.CDOLobStore;
import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
@@ -137,6 +138,8 @@ public abstract class CDOSessionImpl extends CDOTransactionContainerImpl impleme
{
private ExceptionHandler exceptionHandler;
+ private CDOIDGenerator idGenerator;
+
private InternalCDOPackageRegistry packageRegistry;
private InternalCDOBranchManager branchManager;
@@ -242,6 +245,17 @@ public abstract class CDOSessionImpl extends CDOTransactionContainerImpl impleme
this.exceptionHandler = exceptionHandler;
}
+ public CDOIDGenerator getIDGenerator()
+ {
+ return idGenerator;
+ }
+
+ public void setIDGenerator(CDOIDGenerator idGenerator)
+ {
+ checkInactive();
+ this.idGenerator = idGenerator;
+ }
+
public InternalCDOPackageRegistry getPackageRegistry()
{
return packageRegistry;
@@ -259,6 +273,7 @@ public abstract class CDOSessionImpl extends CDOTransactionContainerImpl impleme
public void setBranchManager(InternalCDOBranchManager branchManager)
{
+ checkInactive();
this.branchManager = branchManager;
}
@@ -269,6 +284,7 @@ public abstract class CDOSessionImpl extends CDOTransactionContainerImpl impleme
public void setRevisionManager(InternalCDORevisionManager revisionManager)
{
+ checkInactive();
this.revisionManager = revisionManager;
}
@@ -279,6 +295,7 @@ public abstract class CDOSessionImpl extends CDOTransactionContainerImpl impleme
public void setCommitInfoManager(InternalCDOCommitInfoManager commitInfoManager)
{
+ checkInactive();
this.commitInfoManager = commitInfoManager;
}
@@ -289,6 +306,7 @@ public abstract class CDOSessionImpl extends CDOTransactionContainerImpl impleme
public void setSessionProtocol(CDOSessionProtocol sessionProtocol)
{
+ checkInactive();
if (exceptionHandler == null)
{
this.sessionProtocol = sessionProtocol;
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOSavepointImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOSavepointImpl.java
index debdba0bb0..db69033adc 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOSavepointImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOSavepointImpl.java
@@ -282,9 +282,10 @@ public class CDOSavepointImpl extends CDOUserSavepointImpl implements InternalCD
{
for (Entry<CDOID, CDOObject> entry : savepoint.getNewObjects().entrySet())
{
- if (!getSharedDetachedObjects().contains(entry.getKey()))
+ CDOID id = entry.getKey();
+ if (!getSharedDetachedObjects().contains(id))
{
- newObjects.put(entry.getKey(), entry.getValue());
+ newObjects.put(id, entry.getValue());
}
}
}
@@ -334,16 +335,17 @@ public class CDOSavepointImpl extends CDOUserSavepointImpl implements InternalCD
{
for (Entry<CDOID, CDORevisionDelta> entry : savepoint.getRevisionDeltas().entrySet())
{
- // Skipping temporary
- if (entry.getKey().isTemporary() || getSharedDetachedObjects().contains(entry.getKey()))
+ // Skipping new or detached objects
+ CDOID id = entry.getKey();
+ if (isNewObject(id) || getSharedDetachedObjects().contains(id))
{
continue;
}
- CDORevisionDeltaImpl revisionDelta = (CDORevisionDeltaImpl)revisionDeltas.get(entry.getKey());
+ CDORevisionDeltaImpl revisionDelta = (CDORevisionDeltaImpl)revisionDeltas.get(id);
if (revisionDelta == null)
{
- revisionDeltas.put(entry.getKey(), entry.getValue().copy());
+ revisionDeltas.put(id, entry.getValue().copy());
}
else
{
@@ -376,13 +378,14 @@ public class CDOSavepointImpl extends CDOUserSavepointImpl implements InternalCD
for (Entry<CDOID, CDOObject> entry : savepoint.getDetachedObjects().entrySet())
{
- if (!entry.getKey().isTemporary())
+ CDOID id = entry.getKey();
+ if (!isNewObject(id))
{
// Bug 283985 (Re-attachment):
// Object is only included if it was not reattached in a later savepoint
- if (!reattachedObjectIDs.contains(entry.getKey()))
+ if (!reattachedObjectIDs.contains(id))
{
- detachedObjects.put(entry.getKey(), entry.getValue());
+ detachedObjects.put(id, entry.getValue());
}
}
}
@@ -407,6 +410,27 @@ public class CDOSavepointImpl extends CDOUserSavepointImpl implements InternalCD
}
}
+ public boolean isNewObject(CDOID id)
+ {
+ if (id.isTemporary())
+ {
+ return true;
+ }
+
+ synchronized (transaction)
+ {
+ for (InternalCDOSavepoint savepoint = this; savepoint != null; savepoint = savepoint.getPreviousSavepoint())
+ {
+ if (savepoint.getNewObjects().containsKey(id))
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
public void rollback()
{
synchronized (transaction)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java
index b83b675440..f08c15dbbc 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java
@@ -17,6 +17,7 @@ package org.eclipse.emf.internal.cdo.transaction;
import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.CDOState;
+import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
@@ -27,6 +28,7 @@ import org.eclipse.emf.cdo.common.commit.CDOCommitData;
import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
import org.eclipse.emf.cdo.common.commit.CDOCommitInfoManager;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDGenerator;
import org.eclipse.emf.cdo.common.id.CDOIDProvider;
import org.eclipse.emf.cdo.common.id.CDOIDTemp;
import org.eclipse.emf.cdo.common.id.CDOIDUtil;
@@ -55,7 +57,6 @@ import org.eclipse.emf.cdo.eresource.CDOResourceNode;
import org.eclipse.emf.cdo.eresource.EresourceFactory;
import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl;
import org.eclipse.emf.cdo.eresource.impl.CDOResourceNodeImpl;
-import org.eclipse.emf.cdo.internal.common.commit.CDOChangeSetDataImpl;
import org.eclipse.emf.cdo.internal.common.commit.CDOCommitDataImpl;
import org.eclipse.emf.cdo.internal.common.commit.FailureCommitInfo;
import org.eclipse.emf.cdo.internal.common.protocol.CDODataInputImpl;
@@ -154,7 +155,6 @@ import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.atomic.AtomicInteger;
/**
* @author Eike Stepper
@@ -193,7 +193,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
private CDOTransactionStrategy transactionStrategy;
- private AtomicInteger lastTemporaryID = new AtomicInteger();
+ private CDOIDGenerator idGenerator;
private volatile long lastCommitTime = UNSPECIFIED_DATE;
@@ -475,7 +475,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
return null;
}
- return applyChangeSetData(result, ancestorInfo, targetInfo, source).getElement1();
+ return applyChangeSet(result, ancestorInfo, targetInfo, source).getChangeSetData();
}
private CDOChangeSet createChangeSet(Set<CDOID> ids, CDORevisionAvailabilityInfo startInfo,
@@ -485,28 +485,35 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
return CDORevisionUtil.createChangeSet(startInfo.getBranchPoint(), endInfo.getBranchPoint(), data);
}
- public synchronized Pair<CDOChangeSetData, Pair<Map<CDOID, CDOID>, List<CDOID>>> applyChangeSetData(
+ @Deprecated
+ public Pair<CDOChangeSetData, Pair<Map<CDOID, CDOID>, List<CDOID>>> applyChangeSetData(
CDOChangeSetData changeSetData, CDORevisionProvider ancestorProvider, CDORevisionProvider targetProvider,
CDOBranchPoint source)
{
- CDOChangeSetData result = new CDOChangeSetDataImpl();
+ throw new UnsupportedOperationException();
+ }
+
+ public synchronized ApplyChangeSetResult applyChangeSet(CDOChangeSetData changeSetData,
+ CDORevisionProvider ancestorProvider, CDORevisionProvider targetProvider, CDOBranchPoint source)
+ {
+ ApplyChangeSetResult result = new ApplyChangeSetResult();
// Merges from local offline branches may require additional ID mappings: localID -> tempID
- Pair<Map<CDOID, CDOID>, List<CDOID>> mappedLocalIDs = null;
if (source != null && source.getBranch().isLocal())
{
- mappedLocalIDs = applyLocalIDMapping(changeSetData);
+ applyLocalIDMapping(changeSetData, result);
}
// New objects
- applyNewObjects(changeSetData.getNewObjects(), result.getNewObjects());
+ applyNewObjects(changeSetData.getNewObjects(), result.getChangeSetData().getNewObjects());
// Detached objects
- Set<CDOObject> detachedSet = applyDetachedObjects(changeSetData.getDetachedObjects(), result.getDetachedObjects());
+ Set<CDOObject> detachedSet = applyDetachedObjects(changeSetData.getDetachedObjects(), result.getChangeSetData()
+ .getDetachedObjects());
// Changed objects
Map<CDOID, InternalCDORevision> oldRevisions = applyChangedObjects(changeSetData.getChangedObjects(),
- ancestorProvider, targetProvider, result.getChangedObjects());
+ ancestorProvider, targetProvider, result.getChangeSetData().getChangedObjects());
// Delta notifications
Collection<CDORevisionDelta> notificationDeltas = lastSavepoint.getRevisionDeltas().values();
@@ -515,20 +522,21 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
sendDeltaNotifications(notificationDeltas, detachedSet, oldRevisions);
}
- return new Pair<CDOChangeSetData, Pair<Map<CDOID, CDOID>, List<CDOID>>>(result, mappedLocalIDs);
+ return result;
}
- private Pair<Map<CDOID, CDOID>, List<CDOID>> applyLocalIDMapping(CDOChangeSetData changeSetData)
+ private void applyLocalIDMapping(CDOChangeSetData changeSetData, ApplyChangeSetResult result)
{
+ Map<CDOID, CDOID> idMappings = result.getIDMappings();
+
// Collect needed ID mappings
- Map<CDOID, CDOID> idMappings = new HashMap<CDOID, CDOID>();
for (CDOIDAndVersion key : changeSetData.getNewObjects())
{
InternalCDORevision revision = (InternalCDORevision)key;
if (revision.getBranch().isLocal())
{
CDOID oldID = revision.getID();
- CDOIDTemp newID = getNextTemporaryID();
+ CDOID newID = createIDForNewObject();
idMappings.put(oldID, newID);
revision.setID(newID);
@@ -548,21 +556,15 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
revision.adjustReferences(idMapper);
}
- List<CDOID> adjustedObjects = new ArrayList<CDOID>();
for (CDORevisionKey key : changeSetData.getChangedObjects())
{
InternalCDORevisionDelta revisionDelta = (InternalCDORevisionDelta)key;
- boolean adjusted = revisionDelta.adjustReferences(idMapper);
- if (adjusted)
+ if (revisionDelta.adjustReferences(idMapper))
{
- adjustedObjects.add(revisionDelta.getID());
+ result.getAdjustedObjects().add(revisionDelta.getID());
}
}
-
- return new Pair<Map<CDOID, CDOID>, List<CDOID>>(idMappings, adjustedObjects);
}
-
- return null;
}
private void applyNewObjects(List<CDOIDAndVersion> newObjects, List<CDOIDAndVersion> result)
@@ -751,9 +753,18 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
conflict -= resolved;
}
+ /**
+ * @deprecated {@link #createIDForNewObject()} is called since 4.1.
+ */
+ @Deprecated
public synchronized CDOIDTemp getNextTemporaryID()
{
- return CDOIDUtil.createTempObject(lastTemporaryID.incrementAndGet());
+ throw new UnsupportedOperationException();
+ }
+
+ public CDOID createIDForNewObject()
+ {
+ return idGenerator.generateCDOID();
}
public synchronized CDOResourceFolder createResourceFolder(String path)
@@ -1025,7 +1036,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
return null;
}
- if (id.isTemporary() && isDetached(id))
+ if (isObjectNew(id) && isObjectDetached(id))
{
throw new ObjectNotFoundException(id, this);
}
@@ -1033,7 +1044,13 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
return super.getObject(id, loadOnDemand);
}
- private boolean isDetached(CDOID id)
+ @Override
+ public boolean isObjectNew(CDOID id)
+ {
+ return lastSavepoint.isNewObject(id);
+ }
+
+ private boolean isObjectDetached(CDOID id)
{
return lastSavepoint.getSharedDetachedObjects().contains(id);
}
@@ -1122,22 +1139,24 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
private Set<CDOID> rollbackCompletely(CDOUserSavepoint savepoint)
{
- Set<CDOID> idsOfNewObjectWithDeltas = new HashSet<CDOID>();
+ Set<CDOID> idsOfNewObjectsWithDeltas = new HashSet<CDOID>();
// Start from the last savepoint and come back up to the active
for (InternalCDOSavepoint itrSavepoint = lastSavepoint; itrSavepoint != null; itrSavepoint = itrSavepoint
.getPreviousSavepoint())
{
- // Rollback new objects created after the save point
- Map<CDOID, CDOObject> newObjects = itrSavepoint.getNewObjects();
- for (CDOID id : newObjects.keySet())
+ // Rollback new objects attached after the save point
+ Map<CDOID, CDOObject> newObjectsMap = itrSavepoint.getNewObjects();
+ for (CDOID id : newObjectsMap.keySet())
{
- CDOObject object = newObjects.get(id);
+ CDOObject object = newObjectsMap.get(id);
removeObject(id, object);
}
+ // Rollback new objects re-attached after the save point
+ Map<CDOID, CDOObject> reattachedObjectsMap = itrSavepoint.getReattachedObjects();
Set<CDOID> detachedIDs = itrSavepoint.getDetachedObjects().keySet();
- for (CDOObject reattachedObject : itrSavepoint.getReattachedObjects().values())
+ for (CDOObject reattachedObject : reattachedObjectsMap.values())
{
CDOID id = reattachedObject.cdoID();
if (!detachedIDs.contains(id))
@@ -1151,42 +1170,43 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
{
for (CDORevisionDelta dirtyObject : revisionDeltas.values())
{
- if (dirtyObject.getID().isTemporary())
+ CDOID id = dirtyObject.getID();
+ if (isObjectNew(id))
{
- idsOfNewObjectWithDeltas.add(dirtyObject.getID());
+ idsOfNewObjectsWithDeltas.add(id);
}
}
}
- // Rollback all persisted objects
Map<CDOID, CDOObject> detachedObjectsMap = itrSavepoint.getDetachedObjects();
if (!detachedObjectsMap.isEmpty())
{
- for (Entry<CDOID, CDOObject> entryDirty : detachedObjectsMap.entrySet())
+ for (Entry<CDOID, CDOObject> detachedObjectEntry : detachedObjectsMap.entrySet())
{
- if (entryDirty.getKey().isTemporary())
+ CDOID id = detachedObjectEntry.getKey();
+ if (isObjectNew(id))
{
- idsOfNewObjectWithDeltas.add(entryDirty.getKey());
+ idsOfNewObjectsWithDeltas.add(id);
}
else
{
- InternalCDOObject internalDirtyObject = (InternalCDOObject)entryDirty.getValue();
- InternalCDORevision cleanRev = cleanRevisions.get(internalDirtyObject);
- cleanObject(internalDirtyObject, cleanRev);
+ InternalCDOObject detachedObject = (InternalCDOObject)detachedObjectEntry.getValue();
+ InternalCDORevision cleanRev = cleanRevisions.get(detachedObject);
+ cleanObject(detachedObject, cleanRev);
}
}
}
for (Entry<CDOID, CDOObject> entryDirtyObject : itrSavepoint.getDirtyObjects().entrySet())
{
- // Rollback all persisted objects
- if (!entryDirtyObject.getKey().isTemporary())
+ CDOID id = entryDirtyObject.getKey();
+ if (!isObjectNew(id))
{
InternalCDOObject internalDirtyObject = (InternalCDOObject)entryDirtyObject.getValue();
// Bug 283985 (Re-attachment): Skip objects that were reattached, because
// they were already reset to TRANSIENT earlier in this method
- if (!itrSavepoint.getReattachedObjects().values().contains(internalDirtyObject))
+ if (!reattachedObjectsMap.values().contains(internalDirtyObject))
{
CDOStateMachine.INSTANCE.rollback(internalDirtyObject);
}
@@ -1199,7 +1219,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
}
}
- return idsOfNewObjectWithDeltas;
+ return idsOfNewObjectsWithDeltas;
}
private void loadSavepoint(CDOSavepoint savepoint, Set<CDOID> idsOfNewObjectWithDeltas)
@@ -1265,14 +1285,15 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
{
for (CDORevisionDelta delta : itrSavepoint.getRevisionDeltas().values())
{
- if (delta.getID().isTemporary() && !idsOfNewObjectWithDeltas.contains(delta.getID())
- || detachedObjects.containsKey(delta.getID()))
+ CDOID id = delta.getID();
+ boolean isNew = isObjectNew(id);
+ if (isNew && !idsOfNewObjectWithDeltas.contains(id) || detachedObjects.containsKey(id))
{
continue;
}
- Map<CDOID, CDOObject> map = delta.getID().isTemporary() ? newObjMaps : dirtyObjects;
- InternalCDOObject object = (InternalCDOObject)map.get(delta.getID());
+ Map<CDOID, CDOObject> map = isNew ? newObjMaps : dirtyObjects;
+ InternalCDOObject object = (InternalCDOObject)map.get(id);
// Change state of the objects
merger.merge(object, delta);
@@ -1715,7 +1736,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
cleanRevisions.clear();
dirty = false;
conflict = 0;
- lastTemporaryID.set(0);
+ idGenerator.reset();
}
else
{
@@ -1921,9 +1942,12 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
InternalCDORevision revision = (InternalCDORevision)in.readCDORevision();
CDOID oldID = revision.getID();
- CDOIDTemp newID = getNextTemporaryID();
- idMappings.put(oldID, newID);
- revision.setID(newID);
+ if (oldID.isTemporary())
+ {
+ CDOID newID = createIDForNewObject();
+ idMappings.put(oldID, newID);
+ revision.setID(newID);
+ }
revisions.add(revision);
}
@@ -2072,6 +2096,26 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
return query;
}
+ @Override
+ protected void doActivate() throws Exception
+ {
+ super.doActivate();
+
+ InternalCDOSession session = getSession();
+ if (session.getRepositoryInfo().getIDGenerationLocation() == IDGenerationLocation.STORE)
+ {
+ idGenerator = new CDOIDGenerator.TempID();
+ }
+ else
+ {
+ idGenerator = session.getIDGenerator();
+ if (idGenerator == null)
+ {
+ idGenerator = CDOIDGenerator.UUID;
+ }
+ }
+ }
+
/**
* @since 2.0
*/
@@ -2082,6 +2126,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
lastSavepoint = null;
firstSavepoint = null;
transactionStrategy = null;
+ idGenerator = null;
super.doDeactivate();
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CommitIntegrityCheck.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CommitIntegrityCheck.java
index e841719a38..e8cd2b53eb 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CommitIntegrityCheck.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CommitIntegrityCheck.java
@@ -312,11 +312,13 @@ public class CommitIntegrityCheck
{
return true;
}
+
if (idOrObject instanceof EObject)
{
CDOObject obj = CDOUtil.getCDOObject((EObject)idOrObject);
return obj.cdoState() == CDOState.NEW;
}
+
return false;
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java
index 0dc8f09eb0..4e816e914c 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java
@@ -584,7 +584,7 @@ public abstract class AbstractCDOView extends Lifecycle implements InternalCDOVi
for (CDOObject target : targetObjects)
{
CDOID id = getXRefTargetID(target);
- if (id.isTemporary())
+ if (isObjectNew(id))
{
throw new IllegalArgumentException("Cross referencing for uncommitted new objects not supported " + target);
}
@@ -689,7 +689,7 @@ public abstract class AbstractCDOView extends Lifecycle implements InternalCDOVi
return null;
}
- excludeTempIDs(id);
+ excludeNewObject(id);
localLookupObject = createObject(id);
// CDOResource have a special way to register to the view.
@@ -708,14 +708,19 @@ public abstract class AbstractCDOView extends Lifecycle implements InternalCDOVi
return lastLookupObject;
}
- protected synchronized void excludeTempIDs(CDOID id)
+ protected synchronized void excludeNewObject(CDOID id)
{
- if (id.isTemporary())
+ if (isObjectNew(id))
{
throw new ObjectNotFoundException(id, this);
}
}
+ public boolean isObjectNew(CDOID id)
+ {
+ return id.isTemporary();
+ }
+
/**
* @since 2.0
*/
@@ -882,7 +887,13 @@ public abstract class AbstractCDOView extends Lifecycle implements InternalCDOVi
if (object.cdoView() != null && FSMUtil.isNew(object))
{
String uri = EcoreUtil.getURI(eObject).toString();
- return CDOIDUtil.createTempObjectExternal(uri);
+ if (object.cdoID().isTemporary())
+ {
+ return CDOIDUtil.createTempObjectExternal(uri);
+ }
+
+ // New objects with non-temporary IDs are possible. Likely UUIDs
+ return CDOIDUtil.createExternal(uri);
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStateMachine.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStateMachine.java
index dc33de14c1..5b9f344f03 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStateMachine.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOStateMachine.java
@@ -526,7 +526,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
if (!reattaching)
{
// Prepare object
- CDOID id = transaction.getNextTemporaryID();
+ CDOID id = transaction.createIDForNewObject();
object.cdoInternalSetID(id);
object.cdoInternalSetView(transaction);
changeState(object, CDOState.PREPARED);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/AbstractObjectConflictResolver.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/AbstractObjectConflictResolver.java
index 42ffba2878..dfa0b2a037 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/AbstractObjectConflictResolver.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/AbstractObjectConflictResolver.java
@@ -176,8 +176,8 @@ public abstract class AbstractObjectConflictResolver extends AbstractConflictRes
CDOChangeSetData localChangeSet = transaction.getChangeSetData();
transaction.rollback();
- transaction.applyChangeSetData(remoteChangeSet, transaction, transaction, transaction);
- transaction.applyChangeSetData(localChangeSet, transaction, transaction, transaction);
+ transaction.applyChangeSet(remoteChangeSet, transaction, transaction, transaction);
+ transaction.applyChangeSet(localChangeSet, transaction, transaction, transaction);
}
private CDOChangeSetData createChangeSet(List<CDORevisionDelta> revisionDeltas)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOSessionProtocol.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOSessionProtocol.java
index 5f5cedceda..1032720deb 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOSessionProtocol.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOSessionProtocol.java
@@ -13,6 +13,7 @@ package org.eclipse.emf.spi.cdo;
import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.CDOObjectReference;
import org.eclipse.emf.cdo.common.CDOCommonRepository;
+import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
@@ -270,14 +271,16 @@ public interface CDOSessionProtocol extends CDOProtocol, PackageLoader, BranchLo
private List<InternalCDOPackageUnit> packageUnits = new ArrayList<InternalCDOPackageUnit>();
+ private IDGenerationLocation repositoryIDGenerationLocation;
+
/**
- * @since 4.0
+ * @since 4.1
*/
public OpenSessionResult(int sessionID, String userID, String repositoryUUID,
CDOCommonRepository.Type repositoryType, CDOCommonRepository.State repositoryState, String storeType,
Set<CDOID.ObjectType> objectIDTypes, long repositoryCreationTime, long lastUpdateTime, CDOID rootResourceID,
boolean repositorySupportingAudits, boolean repositorySupportingBranches, boolean repositorySupportingEcore,
- boolean repositoryEnsuringReferentialIntegrity)
+ boolean repositoryEnsuringReferentialIntegrity, IDGenerationLocation repositoryIDGenerationLocation)
{
this.sessionID = sessionID;
this.userID = userID;
@@ -293,6 +296,7 @@ public interface CDOSessionProtocol extends CDOProtocol, PackageLoader, BranchLo
this.repositorySupportingBranches = repositorySupportingBranches;
this.repositorySupportingEcore = repositorySupportingEcore;
this.repositoryEnsuringReferentialIntegrity = repositoryEnsuringReferentialIntegrity;
+ this.repositoryIDGenerationLocation = repositoryIDGenerationLocation;
}
public int getSessionID()
@@ -387,6 +391,14 @@ public interface CDOSessionProtocol extends CDOProtocol, PackageLoader, BranchLo
return repositoryEnsuringReferentialIntegrity;
}
+ /**
+ * @since 4.1
+ */
+ public IDGenerationLocation getRepositoryIDGenerationLocation()
+ {
+ return repositoryIDGenerationLocation;
+ }
+
public RepositoryTimeResult getRepositoryTimeResult()
{
return repositoryTimeResult;
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOSavepoint.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOSavepoint.java
index 04fe7b61f5..7f42eb937d 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOSavepoint.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOSavepoint.java
@@ -36,4 +36,9 @@ public interface InternalCDOSavepoint extends CDOSavepoint, InternalCDOUserSavep
public Set<CDOID> getSharedDetachedObjects();
public void recalculateSharedDetachedObjects();
+
+ /**
+ * @since 4.1
+ */
+ public boolean isNewObject(CDOID id);
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOSession.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOSession.java
index bc075db5d7..c82f67d8ad 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOSession.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOSession.java
@@ -15,6 +15,7 @@ import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
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.lob.CDOLobStore;
import org.eclipse.emf.cdo.common.protocol.CDOAuthenticator;
import org.eclipse.emf.cdo.common.revision.CDORevision;
@@ -120,6 +121,11 @@ public interface InternalCDOSession extends CDOSession, PackageProcessor, Packag
public void setExceptionHandler(CDOSession.ExceptionHandler exceptionHandler);
/**
+ * @since 4.1
+ */
+ public void setIDGenerator(CDOIDGenerator idGenerator);
+
+ /**
* @since 3.0
*/
public void setFetchRuleManager(CDOFetchRuleManager fetchRuleManager);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOTransaction.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOTransaction.java
index 60db5d4a3f..773970b7e1 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOTransaction.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOTransaction.java
@@ -21,6 +21,7 @@ import org.eclipse.emf.cdo.common.revision.CDORevisionProvider;
import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
import org.eclipse.emf.cdo.eresource.CDOResourceFolder;
+import org.eclipse.emf.cdo.internal.common.commit.CDOChangeSetDataImpl;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.emf.cdo.transaction.CDOCommitContext;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
@@ -29,6 +30,8 @@ import org.eclipse.net4j.util.collection.Pair;
import org.eclipse.emf.spi.cdo.CDOSessionProtocol.CommitTransactionResult;
+import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -73,9 +76,18 @@ public interface InternalCDOTransaction extends CDOTransaction, InternalCDOUserT
public void detachObject(InternalCDOObject object);
+ /**
+ * @deprecated {@link #createIDForNewObject()} is called since 4.1.
+ */
+ @Deprecated
public CDOIDTemp getNextTemporaryID();
/**
+ * @since 4.1
+ */
+ public CDOID createIDForNewObject();
+
+ /**
* @since 4.0
*/
public void registerAttached(InternalCDOObject object, boolean isNew);
@@ -94,12 +106,24 @@ public interface InternalCDOTransaction extends CDOTransaction, InternalCDOUserT
* {@link #merge(CDOBranchPoint, org.eclipse.emf.cdo.transaction.CDOMerger) merge} or if the merge was not in
* a {@link CDOBranch#isLocal() local} branch.
* @since 4.0
+ * @deprecated Use {@link #applyChangeSet(CDOChangeSetData, CDORevisionProvider, CDORevisionProvider, CDOBranchPoint)}
*/
+ @Deprecated
public Pair<CDOChangeSetData, Pair<Map<CDOID, CDOID>, List<CDOID>>> applyChangeSetData(
CDOChangeSetData changeSetData, CDORevisionProvider ancestorProvider, CDORevisionProvider targetProvider,
CDOBranchPoint source);
/**
+ * @param source
+ * May be <code>null</code> if changeSetData does not result from a
+ * {@link #merge(CDOBranchPoint, org.eclipse.emf.cdo.transaction.CDOMerger) merge} or if the merge was not in
+ * a {@link CDOBranch#isLocal() local} branch.
+ * @since 4.1
+ */
+ public ApplyChangeSetResult applyChangeSet(CDOChangeSetData changeSetData, CDORevisionProvider ancestorProvider,
+ CDORevisionProvider targetProvider, CDOBranchPoint source);
+
+ /**
* @since 4.0
*/
public Map<InternalCDOObject, InternalCDORevision> getCleanRevisions();
@@ -122,4 +146,36 @@ public interface InternalCDOTransaction extends CDOTransaction, InternalCDOUserT
public void postCommit(CommitTransactionResult result);
}
+
+ /**
+ * @author Eike Stepper
+ * @since 4.1
+ */
+ public final class ApplyChangeSetResult
+ {
+ private CDOChangeSetData changeSetData = new CDOChangeSetDataImpl();
+
+ private Map<CDOID, CDOID> idMappings = new HashMap<CDOID, CDOID>();
+
+ private List<CDOID> adjustedObjects = new ArrayList<CDOID>();
+
+ public ApplyChangeSetResult()
+ {
+ }
+
+ public CDOChangeSetData getChangeSetData()
+ {
+ return changeSetData;
+ }
+
+ public Map<CDOID, CDOID> getIDMappings()
+ {
+ return idMappings;
+ }
+
+ public List<CDOID> getAdjustedObjects()
+ {
+ return adjustedObjects;
+ }
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOView.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOView.java
index b445bc9f8f..345a1ae2ce 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOView.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOView.java
@@ -118,6 +118,11 @@ public interface InternalCDOView extends CDOView, CDOIDProvider, ILifecycle
*/
public boolean isObjectLocked(CDOObject object, LockType lockType, boolean byOthers);
+ /**
+ * @since 4.1
+ */
+ public boolean isObjectNew(CDOID id);
+
public void handleAddAdapter(InternalCDOObject eObject, Adapter adapter);
public void handleRemoveAdapter(InternalCDOObject eObject, Adapter adapter);
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AllTests.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AllTests.java
index 8cf91ee8de..562992e7af 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AllTests.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AllTests.java
@@ -21,6 +21,7 @@ import org.eclipse.net4j.util.tests.SecurityTest;
import org.eclipse.net4j.util.tests.SortedFileMapTest;
import org.eclipse.net4j.util.tests.StringCompressorTest;
import org.eclipse.net4j.util.tests.SynchronizingCorrelatorTest;
+import org.eclipse.net4j.util.tests.UUIDGeneratorTest;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -33,6 +34,7 @@ public class AllTests
public static Test suite()
{
TestSuite suite = new TestSuite("Tests for Net4j"); //$NON-NLS-1$
+ suite.addTestSuite(UUIDGeneratorTest.class);
suite.addTestSuite(MultiMapTest.class);
suite.addTestSuite(SortedFileMapTest.class);
suite.addTestSuite(SynchronizingCorrelatorTest.class);
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/UUIDGeneratorTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/UUIDGeneratorTest.java
new file mode 100644
index 0000000000..cfd89a788a
--- /dev/null
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/UUIDGeneratorTest.java
@@ -0,0 +1,59 @@
+/**
+ * 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.net4j.util.tests;
+
+import org.eclipse.net4j.util.UUIDGenerator;
+
+/**
+ * @author Eike Stepper
+ * @since 3.2
+ */
+public class UUIDGeneratorTest extends AbstractOMTest
+{
+ public void testCodec()
+ {
+ byte[] uuid = new byte[16];
+ long start = System.currentTimeMillis();
+
+ for (int b3 = Byte.MIN_VALUE; b3 <= Byte.MAX_VALUE; b3++)
+ {
+ for (int b2 = Byte.MIN_VALUE; b2 <= Byte.MAX_VALUE; b2++)
+ {
+ // System.out.println(b3 + ", " + b2);
+ for (int b1 = Byte.MIN_VALUE; b1 <= Byte.MAX_VALUE; b1++)
+ {
+ for (int off = 0; off < 13; off++)
+ {
+ check(uuid, b1, b2, b3, off);
+ }
+ }
+ }
+ }
+
+ long millis = System.currentTimeMillis() - start;
+ System.out.println("Millis: " + millis);
+ }
+
+ private static void check(byte[] uuid, int b1, int b2, int b3, int off)
+ {
+ uuid[0 + off] = (byte)b1;
+ uuid[2 + off] = (byte)b2;
+ uuid[3 + off] = (byte)b3;
+
+ String encoded = UUIDGenerator.DEFAULT.encode(uuid);
+ byte[] decoded = UUIDGenerator.DEFAULT.decode(encoded);
+
+ for (int i = 0; i < 3; i++)
+ {
+ assertEquals(uuid[i + off], decoded[i + off]);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/HexUtil.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/HexUtil.java
index 29a853dd6e..75bff1fc59 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/HexUtil.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/HexUtil.java
@@ -134,7 +134,7 @@ public final class HexUtil
b2 = (byte)Character.digit(s.charAt(i + 1), 16);
if (b1 < 0 || b2 < 0)
{
- throw new NumberFormatException();
+ throw new NumberFormatException(s);
}
out[off + i / 2] = (byte)(b1 << 4 | b2);
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/UUIDGenerator.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/UUIDGenerator.java
new file mode 100644
index 0000000000..f58a71ae7d
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/UUIDGenerator.java
@@ -0,0 +1,372 @@
+/**
+ * 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.net4j.util;
+
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.security.SecureRandom;
+import java.util.Enumeration;
+import java.util.GregorianCalendar;
+import java.util.Random;
+
+/**
+ * Generates 16 byte UUID values and can encode them to Strings, decode from Strings respectively.
+ *
+ * @author Eike Stepper
+ * @since 3.2
+ */
+public final class UUIDGenerator
+{
+ public static final int NODE_ADDRESS_BYTES = 6;
+
+ public static final UUIDGenerator DEFAULT = new UUIDGenerator();
+
+ public UUIDGenerator(byte[] nodeAddress)
+ {
+ Random random = new SecureRandom();
+
+ clockSequence = (short)random.nextInt(16384);
+ updateClockSequence();
+
+ if (nodeAddress == null)
+ {
+ try
+ {
+ nodeAddress = getHardwareAddressAddress();
+ }
+ catch (Throwable ex)
+ {
+ // Generate a 48 bit node identifier;
+ // This is an alternative to the IEEE 802 host address, which is not available in Java.
+ //
+ nodeAddress = new byte[6];
+ random.nextBytes(nodeAddress);
+ }
+ }
+
+ setNodeAddress(nodeAddress);
+ }
+
+ public UUIDGenerator()
+ {
+ this(null);
+ }
+
+ public synchronized String generate()
+ {
+ updateCurrentTime();
+ encode(uuid, buffer);
+ return new String(buffer);
+ }
+
+ public synchronized void generate(byte[] uuid)
+ {
+ updateCurrentTime();
+
+ for (int i = 0; i < 16; i++)
+ {
+ uuid[i] = this.uuid[i];
+ }
+ }
+
+ public String encode(byte[] uuid)
+ {
+ char[] buffer = createBuffer();
+ encode(uuid, buffer);
+ return new String(buffer);
+ }
+
+ public byte[] decode(String string)
+ {
+ byte[] uuid = createUUID();
+
+ char c1;
+ char c2;
+ char c3;
+ char c4;
+
+ int i1;
+ int i2;
+ int i3;
+ int i4;
+
+ for (int i = 0; i < 5; ++i)
+ {
+ c1 = string.charAt(4 * i + 1);
+ c2 = string.charAt(4 * i + 2);
+ c3 = string.charAt(4 * i + 3);
+ c4 = string.charAt(4 * i + 4);
+
+ i1 = BASE64_INDEX[c1 - BASE64_INDEX_OFFSET];
+ i2 = BASE64_INDEX[c2 - BASE64_INDEX_OFFSET];
+ i3 = BASE64_INDEX[c3 - BASE64_INDEX_OFFSET];
+ i4 = BASE64_INDEX[c4 - BASE64_INDEX_OFFSET];
+
+ uuid[3 * i] = (byte)(i1 << 2 | i2 >>> 4);
+ uuid[3 * i + 1] = (byte)((i2 & 0xF) << 4 | i3 >>> 2);
+ uuid[3 * i + 2] = (byte)((i3 & 0x3) << 6 | i4);
+ }
+
+ // Handle the last chars at the end.
+ //
+ c1 = string.charAt(21);
+ c2 = string.charAt(22);
+
+ i1 = BASE64_INDEX[c1 - BASE64_INDEX_OFFSET];
+ i2 = BASE64_INDEX[c2 - BASE64_INDEX_OFFSET];
+
+ uuid[15] = (byte)(i1 << 2 | i2 >>> 4);
+
+ return uuid;
+ }
+
+ private static final char[] BASE64_DIGITS = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
+ 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
+ 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5',
+ '6', '7', '8', '9', '-', '_' };
+
+ private static final byte[] BASE64_INDEX;
+
+ private static final int BASE64_INDEX_OFFSET;
+
+ /**
+ * An adjustment to convert the Java epoch of Jan 1, 1970 00:00:00 to the epoch required by the IETF specification,
+ * Oct 15, 1582 00:00:00.
+ */
+ private static final long EPOCH_ADJUSTMENT = new GregorianCalendar(1970, 0, 1, 0, 0, 0).getTime().getTime()
+ - new GregorianCalendar(1582, 9, 15, 0, 0, 0).getTime().getTime();
+
+ private long lastTime = System.currentTimeMillis() + EPOCH_ADJUSTMENT;
+
+ private short clockSequence;
+
+ private short timeAdjustment;
+
+ private int sleepTime = 1;
+
+ private final char[] buffer = createBuffer();
+
+ /**
+ * A cached array of bytes representing the UUID. The second 8 bytes will be kept the same unless the clock sequence
+ * has changed.
+ */
+ private final byte[] uuid = createUUID();
+
+ static
+ {
+ byte[] index = new byte[256];
+ int min = Integer.MAX_VALUE;
+ int max = Integer.MIN_VALUE;
+
+ for (byte i = 0; i < BASE64_DIGITS.length; i++)
+ {
+ char digit = BASE64_DIGITS[i];
+ if (digit < min)
+ {
+ min = digit;
+ }
+
+ if (digit > max)
+ {
+ max = digit;
+ }
+
+ index[digit] = i;
+ }
+
+ int length = max - min + 1;
+ BASE64_INDEX = new byte[length];
+ BASE64_INDEX_OFFSET = min;
+ System.arraycopy(index, BASE64_INDEX_OFFSET, BASE64_INDEX, 0, length);
+ }
+
+ private byte[] getHardwareAddressAddress() throws Throwable
+ {
+ Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
+ while (networkInterfaces.hasMoreElements())
+ {
+ NetworkInterface networkInterface = networkInterfaces.nextElement();
+
+ try
+ {
+ // This is a call to a JRE 1.6 method!
+ byte[] nodeAddress = networkInterface.getHardwareAddress();
+ if (nodeAddress != null && nodeAddress.length == NODE_ADDRESS_BYTES)
+ {
+ return nodeAddress;
+ }
+ }
+ catch (Throwable ex)
+ {
+ //$FALL-THROUGH$
+ }
+ }
+
+ throw new SocketException("Hardware address could not be determined");
+ }
+
+ private void setNodeAddress(byte[] nodeAddress)
+ {
+ // Set the most significant bit of the first octet to 1 so as to distinguish it from IEEE node addresses
+ //
+ nodeAddress[0] |= (byte)0x80;
+
+ // The node identifier is already in network byte order,
+ // so there is no need to do any byte order reversing.
+ //
+ for (int i = 0; i < NODE_ADDRESS_BYTES; ++i)
+ {
+ uuid[i + 10] = nodeAddress[i];
+ }
+ }
+
+ /**
+ * Updates the clock sequence portion of the UUID. The clock sequence portion may seem odd, but in the specification,
+ * the high order byte comes before the low order byte. The variant is multiplexed into the high order octet of
+ * clockseq_hi.
+ */
+ private void updateClockSequence()
+ {
+ // clockseq_hi
+ uuid[8] = (byte)(clockSequence >> 8 & 0x3F | 0x80);
+ // clockseq_low
+ uuid[9] = (byte)(clockSequence & 0xFF);
+ }
+
+ /**
+ * Updates the UUID with the current time, compensating for the fact that the clock resolution may be less than 100
+ * ns. The byte array will have its first eight bytes populated with the time in the correct sequence of bytes, as per
+ * the specification.
+ */
+ private void updateCurrentTime()
+ {
+ // Get the current time in milliseconds since the epoch
+ // and adjust it to match the epoch required by the specification.
+ //
+ long currentTime = System.currentTimeMillis() + EPOCH_ADJUSTMENT;
+
+ if (lastTime > currentTime)
+ {
+ // The system clock has been rewound so the clock sequence must be incremented
+ // to ensure that a duplicate UUID is not generated.
+ //
+ ++clockSequence;
+
+ if (16384 == clockSequence)
+ {
+ clockSequence = 0;
+ }
+
+ updateClockSequence();
+ }
+ else if (lastTime == currentTime)
+ {
+ // The system time hasn't changed so add some increment of 100s of nanoseconds to guarantee uniqueness.
+ //
+ ++timeAdjustment;
+
+ if (timeAdjustment > 9999)
+ {
+ // Wait so that the clock can catch up and the time adjustment won't overflow.
+ try
+ {
+ Thread.sleep(sleepTime);
+ }
+ catch (InterruptedException exception)
+ {
+ // We just woke up.
+ }
+
+ timeAdjustment = 0;
+ currentTime = System.currentTimeMillis() + EPOCH_ADJUSTMENT;
+
+ while (lastTime == currentTime)
+ {
+ try
+ {
+ ++sleepTime;
+ Thread.sleep(1);
+ }
+ catch (InterruptedException exception)
+ {
+ // We just woke up.
+ }
+ currentTime = System.currentTimeMillis() + EPOCH_ADJUSTMENT;
+ }
+ }
+ }
+ else
+ {
+ timeAdjustment = 0;
+ }
+
+ lastTime = currentTime;
+
+ // Since the granularity of time in Java is only milliseconds,
+ // add an adjustment so that the time is represented in 100s of nanoseconds.
+ // The version number (1) is multiplexed into the most significant hex digit.
+ //
+ currentTime *= 10000;
+ currentTime += timeAdjustment;
+ currentTime |= 0x1000000000000000L;
+
+ // Place the time into the byte array in network byte order.
+ //
+ for (int i = 0; i < 4; ++i)
+ {
+ // time_low
+ //
+ uuid[i] = (byte)(currentTime >> 8 * (3 - i) & 0xFFL);
+ }
+
+ for (int i = 0; i < 2; ++i)
+ {
+ // time_mid
+ //
+ uuid[i + 4] = (byte)(currentTime >> 8 * (1 - i) + 32 & 0xFFL);
+ }
+
+ for (int i = 0; i < 2; ++i)
+ {
+ // time_hi
+ //
+ uuid[i + 6] = (byte)(currentTime >> 8 * (1 - i) + 48 & 0xFFL);
+ }
+ }
+
+ private void encode(byte[] uuid, char[] buffer)
+ {
+ for (int i = 0; i < 5; ++i)
+ {
+ buffer[4 * i + 1] = BASE64_DIGITS[uuid[i * 3] >> 2 & 0x3F];
+ buffer[4 * i + 2] = BASE64_DIGITS[uuid[i * 3] << 4 & 0x30 | uuid[i * 3 + 1] >> 4 & 0xF];
+ buffer[4 * i + 3] = BASE64_DIGITS[uuid[i * 3 + 1] << 2 & 0x3C | uuid[i * 3 + 2] >> 6 & 0x3];
+ buffer[4 * i + 4] = BASE64_DIGITS[uuid[i * 3 + 2] & 0x3F];
+ }
+
+ // Handle the last byte at the end.
+ //
+ buffer[21] = BASE64_DIGITS[uuid[15] >> 2 & 0x3F];
+ buffer[22] = BASE64_DIGITS[uuid[15] << 4 & 0x30];
+ }
+
+ private byte[] createUUID()
+ {
+ return new byte[16];
+ }
+
+ private char[] createBuffer()
+ {
+ char[] buffer = new char[23];
+ buffer[0] = '_';
+ return buffer;
+ }
+}

Back to the top