diff options
author | Eike Stepper | 2011-08-20 03:22:16 +0000 |
---|---|---|
committer | Eike Stepper | 2011-08-20 03:22:16 +0000 |
commit | da422adb3e30a9b7843f707bb0024e8ca83efb38 (patch) | |
tree | edc9f949b92d04e0b333d13e2a2fc22fe0eaf69a | |
parent | 86a14631845e281fb1737779872b7d3d4abe2142 (diff) | |
download | cdo-da422adb3e30a9b7843f707bb0024e8ca83efb38.tar.gz cdo-da422adb3e30a9b7843f707bb0024e8ca83efb38.tar.xz cdo-da422adb3e30a9b7843f707bb0024e8ca83efb38.zip |
[355285] Make CDOIDGenerator aware of EObject
https://bugs.eclipse.org/bugs/show_bug.cgi?id=355285
5 files changed, 26 insertions, 14 deletions
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 index 93da0bc8c0..d35fd7570f 100644 --- 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 @@ -12,6 +12,7 @@ package org.eclipse.emf.cdo.common.id; import org.eclipse.net4j.util.UUIDGenerator; +import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.util.EcoreUtil; /** @@ -27,7 +28,7 @@ public interface CDOIDGenerator */ public static final CDOIDGenerator NULL = new CDOIDGenerator() { - public CDOID generateCDOID() + public CDOID generateCDOID(EObject object) { return CDOID.NULL; } @@ -43,7 +44,7 @@ public interface CDOIDGenerator */ public static final CDOIDGenerator UUID = new CDOIDGenerator() { - public CDOID generateCDOID() + public CDOID generateCDOID(EObject object) { byte[] bytes = new byte[16]; UUIDGenerator.DEFAULT.generate(bytes); @@ -56,7 +57,16 @@ public interface CDOIDGenerator } }; - public CDOID generateCDOID(); + /** + * Generates a {@link CDOID}. + * + * @param object + * the object to generate a new CDOID for if available, <code>null</code> otherwise. + */ + public CDOID generateCDOID(EObject object); + /** + * Called at the end of a commit operation to give this ID generator a chance to reset its sequence of IDs. + */ public void reset(); } 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 60fac60b3a..d8c51bf38d 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 @@ -1595,7 +1595,6 @@ public class Repository extends Container<Object> implements InternalRepository protected void initRootResource() { CDOBranchPoint head = branchManager.getMainBranch().getHead(); - CDOID id = createRootResourceID(); CDORevisionFactory factory = getRevisionManager().getFactory(); InternalCDORevision rootResource = (InternalCDORevision)factory @@ -1604,6 +1603,8 @@ public class Repository extends Container<Object> implements InternalRepository rootResource.setBranchPoint(head); rootResource.setContainerID(CDOID.NULL); rootResource.setContainingFeatureID(0); + + CDOID id = createRootResourceID(); rootResource.setID(id); rootResource.setResourceID(id); @@ -1656,7 +1657,7 @@ public class Repository extends Container<Object> implements InternalRepository return CDOIDUtil.createTempObject(1); } - return CDOIDGenerator.UUID.generateCDOID(); + return CDOIDGenerator.UUID.generateCDOID(null); } protected void readRootResource() 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 2f81f19424..9755eea515 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 @@ -538,7 +538,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa if (revision.getBranch().isLocal()) { CDOID oldID = revision.getID(); - CDOID newID = createIDForNewObject(); + CDOID newID = createIDForNewObject(null); idMappings.put(oldID, newID); revision.setID(newID); @@ -756,7 +756,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa } /** - * @deprecated {@link #createIDForNewObject()} is called since 4.1. + * @deprecated {@link #createIDForNewObject(EObject object)} is called since 4.1. */ @Deprecated public synchronized CDOIDTemp getNextTemporaryID() @@ -764,9 +764,9 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa throw new UnsupportedOperationException(); } - public CDOID createIDForNewObject() + public CDOID createIDForNewObject(EObject object) { - return idGenerator.generateCDOID(); + return idGenerator.generateCDOID(object); } public synchronized CDOResourceFolder createResourceFolder(String path) @@ -1943,7 +1943,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa CDOID oldID = revision.getID(); if (oldID.isTemporary()) { - CDOID newID = createIDForNewObject(); + CDOID newID = createIDForNewObject(null); idMappings.put(oldID, newID); revision.setID(newID); } @@ -2321,7 +2321,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa { } - public CDOID generateCDOID() + public CDOID generateCDOID(EObject object) { return CDOIDUtil.createTempObject(lastTemporaryID.incrementAndGet()); } 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 5b9f344f03..1622714663 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.createIDForNewObject(); + CDOID id = transaction.createIDForNewObject(object.cdoInternalInstance()); object.cdoInternalSetID(id); object.cdoInternalSetView(transaction); changeState(object, CDOState.PREPARED); 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 773970b7e1..71550d6df7 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 @@ -28,6 +28,7 @@ import org.eclipse.emf.cdo.transaction.CDOTransaction; import org.eclipse.net4j.util.collection.Pair; +import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.spi.cdo.CDOSessionProtocol.CommitTransactionResult; import java.util.ArrayList; @@ -77,7 +78,7 @@ public interface InternalCDOTransaction extends CDOTransaction, InternalCDOUserT public void detachObject(InternalCDOObject object); /** - * @deprecated {@link #createIDForNewObject()} is called since 4.1. + * @deprecated {@link #createIDForNewObject(EObject)} is called since 4.1. */ @Deprecated public CDOIDTemp getNextTemporaryID(); @@ -85,7 +86,7 @@ public interface InternalCDOTransaction extends CDOTransaction, InternalCDOUserT /** * @since 4.1 */ - public CDOID createIDForNewObject(); + public CDOID createIDForNewObject(EObject object); /** * @since 4.0 |