Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2011-08-29 07:46:11 +0000
committerEike Stepper2011-08-29 07:46:11 +0000
commit2a7f4fb49c863c5c52d092b8b7c1faa23bef33bf (patch)
treec3e71fc474c59b536117b388143c76381194b099
parentcac3c0ef7e7cb257acedccc19c8f3352c8411201 (diff)
downloadcdo-2a7f4fb49c863c5c52d092b8b7c1faa23bef33bf.tar.gz
cdo-2a7f4fb49c863c5c52d092b8b7c1faa23bef33bf.tar.xz
cdo-2a7f4fb49c863c5c52d092b8b7c1faa23bef33bf.zip
[356049] CDOWorkspace.merge() is broken
https://bugs.eclipse.org/bugs/show_bug.cgi?id=356049
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOChangeSetData.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOChangeSetDataImpl.java9
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitInfoImpl.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/DelegatingCommitInfo.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/FailureCommitInfo.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/OfflineClone.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/WorkspaceTest.java53
-rw-r--r--plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/AbstractCDOWorkspaceBase.java87
-rw-r--r--plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/CDOWorkspaceImpl.java310
-rw-r--r--plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/FolderCDOWorkspaceBase.java71
-rw-r--r--plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/spi/workspace/InternalCDOWorkspaceBase.java24
-rw-r--r--plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceBase2.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceUtil.java5
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDODefaultTransactionHandler.java7
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDODefaultTransactionHandler1.java8
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDODefaultTransactionHandler2.java8
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDODefaultTransactionHandler3.java54
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOTransactionHandler2.java6
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOTransactionHandler3.java32
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java5
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java17
21 files changed, 535 insertions, 202 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOChangeSetData.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOChangeSetData.java
index c49728e6a9..98f2cfe947 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOChangeSetData.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOChangeSetData.java
@@ -11,12 +11,14 @@
package org.eclipse.emf.cdo.common.commit;
import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
+import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
import java.util.List;
+import java.util.Map;
/**
* A {@link CDOChangeKindProvider change kind provider} with detailed information about {@link #getNewObjects() new},
@@ -68,4 +70,9 @@ public interface CDOChangeSetData extends CDOChangeKindProvider
* {@link CDOBranchVersion#UNSPECIFIED_VERSION unspecified}.
*/
public List<CDOIDAndVersion> getDetachedObjects();
+
+ /**
+ * @since 4.1
+ */
+ public Map<CDOID, CDOChangeKind> getChangeKinds();
}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOChangeSetDataImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOChangeSetDataImpl.java
index 37cbdb45b2..a06a6e231a 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOChangeSetDataImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOChangeSetDataImpl.java
@@ -192,14 +192,19 @@ public class CDOChangeSetDataImpl implements CDOChangeSetData
return detachedObjects;
}
- public synchronized CDOChangeKind getChangeKind(CDOID id)
+ public synchronized Map<CDOID, CDOChangeKind> getChangeKinds()
{
if (changeKindCache == null)
{
changeKindCache = new CDOChangeKindCache(this);
}
- return changeKindCache.getChangeKind(id);
+ return changeKindCache;
+ }
+
+ public CDOChangeKind getChangeKind(CDOID id)
+ {
+ return getChangeKinds().get(id);
}
@Override
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitInfoImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitInfoImpl.java
index 5d39e62ce9..790b368b24 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitInfoImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitInfoImpl.java
@@ -27,6 +27,7 @@ import org.eclipse.net4j.util.CheckUtil;
import java.text.MessageFormat;
import java.util.List;
+import java.util.Map;
/**
* @author Eike Stepper
@@ -115,6 +116,12 @@ public class CDOCommitInfoImpl extends CDOBranchPointImpl implements CDOCommitIn
return commitData.getDetachedObjects();
}
+ public Map<CDOID, CDOChangeKind> getChangeKinds()
+ {
+ loadCommitDataIfNeeded();
+ return commitData.getChangeKinds();
+ }
+
public CDOChangeKind getChangeKind(CDOID id)
{
loadCommitDataIfNeeded();
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/DelegatingCommitInfo.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/DelegatingCommitInfo.java
index f8df974a88..0fe5f7ff03 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/DelegatingCommitInfo.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/DelegatingCommitInfo.java
@@ -21,6 +21,7 @@ import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
import java.util.List;
+import java.util.Map;
/**
* @author Eike Stepper
@@ -88,6 +89,11 @@ public abstract class DelegatingCommitInfo implements CDOCommitInfo
return getDelegate().getDetachedObjects();
}
+ public Map<CDOID, CDOChangeKind> getChangeKinds()
+ {
+ return getDelegate().getChangeKinds();
+ }
+
public CDOChangeKind getChangeKind(CDOID id)
{
return getDelegate().getChangeKind(id);
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/FailureCommitInfo.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/FailureCommitInfo.java
index a97a77fb40..32809d76c3 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/FailureCommitInfo.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/FailureCommitInfo.java
@@ -22,6 +22,7 @@ import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
/**
* @author Eike Stepper
@@ -93,6 +94,11 @@ public class FailureCommitInfo implements CDOCommitInfo
return Collections.emptyList();
}
+ public Map<CDOID, CDOChangeKind> getChangeKinds()
+ {
+ return Collections.emptyMap();
+ }
+
public CDOChangeKind getChangeKind(CDOID id)
{
return null;
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/OfflineClone.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/OfflineClone.java
index 7adcad11fb..d551fc52e9 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/OfflineClone.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/OfflineClone.java
@@ -36,6 +36,7 @@ import org.eclipse.net4j.util.om.monitor.Monitor;
import org.eclipse.net4j.util.om.monitor.OMMonitor;
import java.util.List;
+import java.util.Map;
/**
* @author Eike Stepper
@@ -204,14 +205,19 @@ public class OfflineClone extends SynchronizableRepository
};
}
- public synchronized CDOChangeKind getChangeKind(CDOID id)
+ public synchronized Map<CDOID, CDOChangeKind> getChangeKinds()
{
if (changeKindCache == null)
{
changeKindCache = new CDOChangeKindCache(this);
}
- return changeKindCache.getChangeKind(id);
+ return changeKindCache;
+ }
+
+ public CDOChangeKind getChangeKind(CDOID id)
+ {
+ return getChangeKinds().get(id);
}
}
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 7891409dcc..611988d47c 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
@@ -1034,6 +1034,49 @@ public class WorkspaceTest extends AbstractCDOTest
assertEquals(totalObjects + 1, dumpObjects(null, resource));
}
+ @Requires(IRepositoryConfig.CAPABILITY_UUIDS)
+ public void testUpdateTwiceAfterMasterAdd() throws Exception
+ {
+ InternalCDOWorkspace workspace = checkout("MAIN", CDOBranchPoint.UNSPECIFIED_DATE);
+ assertNotSame(CDOBranchPoint.UNSPECIFIED_DATE, workspace.getTimeStamp());
+
+ CDOResource resource = transaction.getResource(getResourcePath(RESOURCE));
+ resource.getContents().add(createProduct(9999));
+ transaction.commit();
+
+ CDOTransaction local = workspace.update(null);
+ assertEquals(true, local.isDirty());
+ assertEquals(1, local.getNewObjects().size());
+ assertEquals(1, local.getDirtyObjects().size());
+ assertEquals(0, local.getDetachedObjects().size());
+
+ local.commit();
+ assertEquals(false, local.isDirty());
+ assertEquals(0, local.getNewObjects().size());
+ assertEquals(0, local.getDirtyObjects().size());
+ assertEquals(0, local.getDetachedObjects().size());
+ assertEquals(0, workspace.getBase().getIDs().size());
+ local.close();
+
+ local = workspace.update(null);
+ assertEquals(false, local.isDirty());
+ assertEquals(0, local.getNewObjects().size());
+ assertEquals(0, local.getDirtyObjects().size());
+ assertEquals(0, local.getDetachedObjects().size());
+ assertEquals(0, workspace.getBase().getIDs().size());
+
+ local.commit();
+ assertEquals(false, local.isDirty());
+ assertEquals(0, local.getNewObjects().size());
+ assertEquals(0, local.getDirtyObjects().size());
+ assertEquals(0, local.getDetachedObjects().size());
+ assertEquals(0, workspace.getBase().getIDs().size());
+
+ CDOView view = workspace.openView();
+ resource = view.getResource(getResourcePath(RESOURCE));
+ assertEquals(totalObjects + 1, dumpObjects(null, resource));
+ }
+
public void testUpdateAfterMasterDetach() throws Exception
{
InternalCDOWorkspace workspace = checkout("MAIN", CDOBranchPoint.UNSPECIFIED_DATE);
@@ -1074,30 +1117,36 @@ public class WorkspaceTest extends AbstractCDOTest
public void testUpdateAfterMasterAndLocalModify() throws Exception
{
+ // Checkout local
InternalCDOWorkspace workspace = checkout("MAIN", CDOBranchPoint.UNSPECIFIED_DATE);
assertNotSame(CDOBranchPoint.UNSPECIFIED_DATE, workspace.getTimeStamp());
+ // Modify master
assertEquals(1, modifyProduct(transaction, 1, "MODIFIED_"));
transaction.commit();
+ // Modify local
CDOTransaction local = workspace.openTransaction();
assertEquals(1, modifyProduct(local, 2, "MODIFIED_"));
local.commit();
local.close();
+ // Update local
local = workspace.update(new DefaultCDOMerger.PerFeature.ManyValued());
assertEquals(true, local.isDirty());
assertEquals(0, local.getNewObjects().size());
assertEquals(1, local.getDirtyObjects().size());
assertEquals(0, local.getDetachedObjects().size());
+ // Commit local
local.commit();
assertEquals(false, local.isDirty());
assertEquals(0, local.getNewObjects().size());
assertEquals(0, local.getDirtyObjects().size());
assertEquals(0, local.getDetachedObjects().size());
- assertEquals(0, workspace.getBase().getIDs().size());
+ assertEquals(1, workspace.getBase().getIDs().size());
+ // Verify local
CDOView view = workspace.openView();
assertEquals(2, countModifiedProduct(view));
}
@@ -1133,7 +1182,7 @@ public class WorkspaceTest extends AbstractCDOTest
assertEquals(0, local.getNewObjects().size());
assertEquals(0, local.getDirtyObjects().size());
assertEquals(0, local.getDetachedObjects().size());
- assertEquals(0, workspace.getBase().getIDs().size());
+ assertEquals(6, workspace.getBase().getIDs().size());
CDOView view = workspace.openView();
resource = view.getResource(getResourcePath(RESOURCE));
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 c0a15391dc..e2ababcc02 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
@@ -10,7 +10,6 @@
*/
package org.eclipse.emf.cdo.internal.workspace;
-import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDProvider;
import org.eclipse.emf.cdo.common.protocol.CDODataInput;
@@ -21,18 +20,13 @@ import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager;
import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-import org.eclipse.emf.cdo.spi.server.InternalRepository;
-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.CDOTransaction;
-import org.eclipse.emf.cdo.workspace.CDOWorkspaceBase2;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
-
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
@@ -40,16 +34,10 @@ import java.util.Set;
/**
* @author Eike Stepper
*/
-public abstract class AbstractCDOWorkspaceBase implements InternalCDOWorkspaceBase, CDOWorkspaceBase2
+public abstract class AbstractCDOWorkspaceBase implements InternalCDOWorkspaceBase
{
private InternalCDOWorkspace workspace;
- private InternalStore store;
-
- private InternalCDOPackageRegistry packageRegistry;
-
- private InternalCDOBranchManager branchManager;
-
private Set<CDOID> ids;
protected AbstractCDOWorkspaceBase()
@@ -59,10 +47,6 @@ public abstract class AbstractCDOWorkspaceBase implements InternalCDOWorkspaceBa
public void init(InternalCDOWorkspace workspace)
{
this.workspace = workspace;
- InternalRepository localRepository = workspace.getLocalRepository();
- store = localRepository.getStore();
- packageRegistry = localRepository.getPackageRegistry(false);
- branchManager = localRepository.getBranchManager();
}
public final InternalCDOWorkspace getWorkspace()
@@ -80,40 +64,32 @@ public abstract class AbstractCDOWorkspaceBase implements InternalCDOWorkspaceBa
return ids;
}
- public final synchronized void updateAfterCommit(CDOTransaction transaction)
+ @Deprecated
+ public final void updateAfterCommit(CDOTransaction transaction)
{
- InternalCDOTransaction tx = (InternalCDOTransaction)transaction;
- Set<CDOID> dirtyObjects = tx.getDirtyObjects().keySet();
- Set<CDOID> detachedObjects = tx.getDetachedObjects().keySet();
- for (InternalCDORevision revision : tx.getCleanRevisions().values())
- {
- CDOID id = revision.getID();
- if (dirtyObjects.contains(id) || detachedObjects.contains(id))
- {
- if (isAddedObject(id))
- {
- if (ids != null)
- {
- ids.remove(id);
- }
-
- deregisterObject(id);
- }
- else
- {
- getIDs().add(id);
- registerChangedOrDetachedObject(revision);
- }
- }
- }
+ throw new UnsupportedOperationException();
+ }
+
+ public final synchronized void registerChangedOrDetachedObject(InternalCDORevision revision)
+ {
+ getIDs().add(revision.getID());
+ doRegisterChangedOrDetachedObject(revision);
+ }
- // Don't use keySet() because only the values() are ID-mapped!
- for (CDOObject object : tx.getNewObjects().values())
+ public final synchronized void registerAddedObject(CDOID id)
+ {
+ getIDs().add(id);
+ doRegisterAddedObject(id);
+ }
+
+ public final synchronized void deregisterObject(CDOID id)
+ {
+ if (ids != null)
{
- CDOID id = object.cdoID();
- getIDs().add(id);
- registerAddedObject(id);
+ ids.remove(id);
}
+
+ doDeregisterObject(id);
}
public final synchronized void clear()
@@ -132,23 +108,22 @@ public abstract class AbstractCDOWorkspaceBase implements InternalCDOWorkspaceBa
return getIDs().contains(id);
}
- protected boolean isAddedObject(CDOID id)
- {
- // throw new RuntimeException("Check whether CDOID.isLocal() is still valid with UUIDs");
- return store.isLocal(id);
- }
-
protected CDODataInput createCDODataInput(ExtendedDataInputStream edis) throws IOException
{
+ InternalCDOPackageRegistry packageRegistry = workspace.getLocalRepository().getPackageRegistry(false);
+ InternalCDOBranchManager branchManager = workspace.getLocalRepository().getBranchManager();
CDORevisionFactory revisionFactory = CDORevisionFactory.DEFAULT;
CDOListFactory listFactory = CDOListFactory.DEFAULT;
+
return CDOCommonUtil.createCDODataInput(edis, packageRegistry, branchManager, null, revisionFactory, listFactory,
null);
}
protected CDODataOutput createCDODataOutput(ExtendedDataOutputStream edos)
{
+ InternalCDOPackageRegistry packageRegistry = workspace.getLocalRepository().getPackageRegistry(false);
CDOIDProvider idProvider = CDOIDProvider.NOOP;
+
return CDOCommonUtil.createCDODataOutput(edos, packageRegistry, idProvider);
}
@@ -156,9 +131,9 @@ public abstract class AbstractCDOWorkspaceBase implements InternalCDOWorkspaceBa
protected abstract Set<CDOID> doGetIDs();
- protected abstract void registerChangedOrDetachedObject(InternalCDORevision revision);
+ protected abstract void doRegisterChangedOrDetachedObject(InternalCDORevision revision);
- protected abstract void registerAddedObject(CDOID id);
+ protected abstract void doRegisterAddedObject(CDOID id);
- protected abstract void deregisterObject(CDOID id);
+ protected abstract void doDeregisterObject(CDOID id);
}
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 190487f9c7..0a7bfa8d29 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
@@ -27,6 +27,7 @@ import org.eclipse.emf.cdo.common.revision.CDORevisionHandler;
import org.eclipse.emf.cdo.common.revision.CDORevisionManager;
import org.eclipse.emf.cdo.common.revision.CDORevisionProvider;
import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
+import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
import org.eclipse.emf.cdo.internal.server.Repository;
import org.eclipse.emf.cdo.net4j.CDONet4jSessionConfiguration;
import org.eclipse.emf.cdo.net4j.CDONet4jUtil;
@@ -46,7 +47,9 @@ import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranch;
import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager;
import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
import org.eclipse.emf.cdo.spi.common.revision.CDOIDMapper;
+import org.eclipse.emf.cdo.spi.common.revision.DetachedCDORevision;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+import org.eclipse.emf.cdo.spi.common.revision.ManagedRevisionProvider;
import org.eclipse.emf.cdo.spi.server.InternalRepository;
import org.eclipse.emf.cdo.spi.server.InternalStore;
import org.eclipse.emf.cdo.spi.workspace.InternalCDOWorkspace;
@@ -54,6 +57,7 @@ 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.CDODefaultTransactionHandler3;
import org.eclipse.emf.cdo.transaction.CDOMerger;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.transaction.CDOTransactionFinishedEvent;
@@ -61,7 +65,6 @@ import org.eclipse.emf.cdo.util.CommitException;
import org.eclipse.emf.cdo.util.ReadOnlyException;
import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.emf.cdo.workspace.CDOWorkspace;
-import org.eclipse.emf.cdo.workspace.CDOWorkspaceUtil;
import org.eclipse.net4j.Net4jUtil;
import org.eclipse.net4j.jvm.IJVMAcceptor;
@@ -174,7 +177,7 @@ public class CDOWorkspaceImpl extends Notifier implements InternalCDOWorkspace
private void setDirtyFromBase()
{
- setDirty(!CDOWorkspaceUtil.getWorkspaceBase2(base).isEmpty());
+ setDirty(!base.isEmpty());
}
protected void checkout()
@@ -297,6 +300,7 @@ public class CDOWorkspaceImpl extends Notifier implements InternalCDOWorkspace
{
CDOTransaction transaction = getLocalSession().openTransaction();
initView(transaction);
+ initTransaction(transaction);
return (InternalCDOTransaction)transaction;
}
@@ -304,9 +308,79 @@ public class CDOWorkspaceImpl extends Notifier implements InternalCDOWorkspace
{
CDOTransaction transaction = getLocalSession().openTransaction(resourceSet);
initView(transaction);
+ initTransaction(transaction);
return (InternalCDOTransaction)transaction;
}
+ protected void initView(CDOView view)
+ {
+ synchronized (views)
+ {
+ views.add((InternalCDOView)view);
+ }
+
+ view.addListener(new ViewAdapter());
+
+ if (view instanceof CDOTransaction)
+ {
+ if (fixed)
+ {
+ throw new ReadOnlyException("Workspace is fixed");
+ }
+
+ if (idGenerationLocation != IDGenerationLocation.CLIENT)
+ {
+ CDOTransaction transaction = (CDOTransaction)view;
+ transaction.addTransactionHandler(new CDODefaultTransactionHandler1()
+ {
+ @Override
+ public void attachingObject(CDOTransaction transaction, CDOObject object)
+ {
+ throw new IllegalStateException("Attaching new objects is only supported for IDGenerationLocation.CLIENT");
+ }
+ });
+ }
+ }
+ }
+
+ protected void initTransaction(CDOTransaction transaction)
+ {
+ transaction.addTransactionHandler(new CDODefaultTransactionHandler2()
+ {
+ @Override
+ public void committedTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
+ {
+ InternalCDOTransaction tx = (InternalCDOTransaction)transaction;
+ Set<CDOID> dirtyObjects = tx.getDirtyObjects().keySet();
+ Set<CDOID> detachedObjects = tx.getDetachedObjects().keySet();
+ for (InternalCDORevision revision : tx.getCleanRevisions().values())
+ {
+ CDOID id = revision.getID();
+ boolean isDetached = detachedObjects.contains(id);
+
+ if (isDetached && base.isAddedObject(id))
+ {
+ base.deregisterObject(id);
+ }
+
+ if (dirtyObjects.contains(id) || isDetached)
+ {
+ base.registerChangedOrDetachedObject(revision);
+ }
+ }
+
+ // Don't use keySet() because only the values() are ID-mapped!
+ for (CDOObject object : tx.getNewObjects().values())
+ {
+ CDOID id = object.cdoID();
+ base.registerAddedObject(id);
+ }
+
+ setDirtyFromBase();
+ }
+ });
+ }
+
public InternalCDOTransaction update(CDOMerger merger)
{
return merge(merger, branchPath);
@@ -319,55 +393,137 @@ public class CDOWorkspaceImpl extends Notifier implements InternalCDOWorkspace
public InternalCDOTransaction merge(CDOMerger merger, String branchPath, long timeStamp)
{
- InternalCDOSession remoteSession = openRemoteSession();
-
- try
+ final InternalCDOSession remoteSession = openRemoteSession();
+ if (timeStamp == CDOBranchPoint.UNSPECIFIED_DATE)
{
- InternalCDOBranchManager branchManager = remoteSession.getBranchManager();
- CDOBranchPoint basePoint = branchManager.getBranch(branchPath).getPoint(this.timeStamp);
- CDOBranchPoint remotePoint = branchManager.getBranch(branchPath).getPoint(timeStamp);
+ timeStamp = remoteSession.getLastUpdateTime();
+ }
- CDOBranchPointRange range = CDOBranchUtil.createRange(basePoint, remotePoint);
- CDOChangeSetData remoteData = remoteSession.getSessionProtocol().loadChangeSets(range)[0];
+ final long newTimeStamp = timeStamp;
- CDOChangeSetData localData = getLocalChanges();
- if (!localData.isEmpty())
- {
- CDOChangeSet localChanges = CDORevisionUtil.createChangeSet(basePoint, null, localData);
- CDOChangeSet remoteChanges = CDORevisionUtil.createChangeSet(basePoint, remotePoint, remoteData);
- remoteData = merger.merge(localChanges, remoteChanges);
- }
+ final InternalCDOBranchManager branchManager = remoteSession.getBranchManager();
+ final CDOBranchPoint basePoint = branchManager.getBranch(branchPath).getPoint(this.timeStamp);
+ final CDOBranchPoint remotePoint = branchManager.getBranch(branchPath).getPoint(newTimeStamp);
+
+ final CDOBranchPointRange range = CDOBranchUtil.createRange(basePoint, remotePoint);
+
+ final CDOChangeSetData remoteData = remoteSession.getSessionProtocol().loadChangeSets(range)[0];
+ final CDOChangeSetData localData = getLocalChanges();
+ final CDOChangeSetData result = getMergeResult(merger, basePoint, remotePoint, localData, remoteData);
+
+ final InternalCDOTransaction transaction = (InternalCDOTransaction)getLocalSession().openTransaction();
+ initView(transaction);
- InternalCDOTransaction transaction = openTransaction();
- transaction.addTransactionHandler(new CDODefaultTransactionHandler2()
+ transaction.applyChangeSet(result, new BaseRevisionProvider(), this, null, false);
+ transaction.addTransactionHandler(new CDODefaultTransactionHandler3()
+ {
+ @Override
+ public void committedTransaction(CDOTransaction transaction, CDOCommitContext commitContext, CDOCommitInfo result)
{
- @Override
- public void committedTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
+ try
+ {
+ Set<CDOID> affectedIDs = getAffectedIDs(commitContext, remoteData);
+
+ CDORevisionProvider local = CDOWorkspaceImpl.this;
+ CDORevisionProvider remote = new ManagedRevisionProvider(remoteSession.getRevisionManager(), remotePoint);
+
+ updateBase(affectedIDs, local, remote);
+ setTimeStamp(newTimeStamp);
+ }
+ finally
{
- clearBase();
+ LifecycleUtil.deactivate(remoteSession);
}
- });
+ }
- transaction.applyChangeSet(remoteData, new CDORevisionProvider()
+ private void updateBase(Set<CDOID> affectedIDs, CDORevisionProvider local, CDORevisionProvider remote)
{
- public CDORevision getRevision(CDOID id)
+ for (CDOID id : affectedIDs)
{
- CDORevision revision = base.getRevision(id);
- if (revision == null)
+ CDORevision localRevision = getRevision(id, local);
+ CDORevision remoteRevision = getRevision(id, remote);
+ if (localRevision == null)
+ {
+ if (remoteRevision == null)
+ {
+ // Unchanged
+ base.deregisterObject(id);
+ }
+ else
+ {
+ // Detached
+ base.registerChangedOrDetachedObject((InternalCDORevision)remoteRevision);
+ }
+ }
+ else
{
- revision = CDOWorkspaceImpl.this.getRevision(id);
+ if (remoteRevision == null)
+ {
+ // Added
+ base.registerAddedObject(id);
+ }
+ else
+ {
+ CDORevisionDelta delta = localRevision.compare(remoteRevision);
+ if (delta.isEmpty())
+ {
+ // Unchanged
+ base.deregisterObject(id);
+ }
+ else
+ {
+ // Changed
+ base.registerChangedOrDetachedObject((InternalCDORevision)remoteRevision);
+ }
+ }
}
+ }
+ }
- return revision;
+ private Set<CDOID> getAffectedIDs(CDOCommitContext commitContext, final CDOChangeSetData remoteData)
+ {
+ Set<CDOID> affectedIDs = new HashSet<CDOID>();
+
+ // Base IDs
+ affectedIDs.addAll(base.getIDs());
+
+ // Remote IDs
+ affectedIDs.addAll(remoteData.getChangeKinds().keySet());
+
+ // Local IDs
+ affectedIDs.addAll(commitContext.getNewObjects().keySet());
+ affectedIDs.addAll(commitContext.getDirtyObjects().keySet());
+ affectedIDs.addAll(commitContext.getDetachedObjects().keySet());
+
+ return affectedIDs;
+ }
+
+ private CDORevision getRevision(CDOID id, CDORevisionProvider revisionProvider)
+ {
+ CDORevision revision = revisionProvider.getRevision(id);
+ if (revision instanceof DetachedCDORevision)
+ {
+ revision = null;
}
- }, this, null, false);
- return transaction;
- }
- finally
+ return revision;
+ }
+ });
+
+ return transaction;
+ }
+
+ private CDOChangeSetData getMergeResult(CDOMerger merger, CDOBranchPoint basePoint, CDOBranchPoint remotePoint,
+ CDOChangeSetData localData, CDOChangeSetData remoteData)
+ {
+ if (localData.isEmpty())
{
- LifecycleUtil.deactivate(remoteSession);
+ return remoteData;
}
+
+ CDOChangeSet localChanges = CDORevisionUtil.createChangeSet(basePoint, null, localData);
+ CDOChangeSet remoteChanges = CDORevisionUtil.createChangeSet(basePoint, remotePoint, remoteData);
+ return merger.merge(localChanges, remoteChanges);
}
public void revert()
@@ -411,23 +567,11 @@ public class CDOWorkspaceImpl extends Notifier implements InternalCDOWorkspace
throw new CommitException(ex);
}
- // Attaching new objects is only supported for IDGenerationLocation.CLIENT
- // CDOIDMapper idMapper = getIDMapper(transaction, result.getIDMappings());
-
transaction.setCommitComment(comment);
CDOCommitInfo info = transaction.commit();
- // Attaching new objects is only supported for IDGenerationLocation.CLIENT
- // if (idMapper != null)
- // {
- // adjustLocalIDs(idMapper, result.getAdjustedObjects());
- // }
-
clearBase();
-
- timeStamp = info.getTimeStamp();
- saveProperties();
-
+ setTimeStamp(info.getTimeStamp());
return info;
}
finally
@@ -704,52 +848,6 @@ public class CDOWorkspaceImpl extends Notifier implements InternalCDOWorkspace
}
}
- protected void initView(CDOView view)
- {
- synchronized (views)
- {
- views.add((InternalCDOView)view);
- }
-
- view.addListener(new ViewAdapter());
-
- if (view instanceof CDOTransaction)
- {
- if (fixed)
- {
- throw new ReadOnlyException("Workspace is fixed");
- }
-
- CDOTransaction transaction = (CDOTransaction)view;
- transaction.addTransactionHandler(new CDODefaultTransactionHandler2()
- {
- @Override
- public void committedTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
- {
- 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");
- }
- });
- }
- }
- }
-
- protected void committedTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
- {
- base.updateAfterCommit(transaction);
- setDirtyFromBase();
- }
-
protected InternalCDOSession openRemoteSession()
{
CDOSessionConfiguration configuration = remoteSessionConfigurationFactory.createSessionConfiguration();
@@ -772,6 +870,15 @@ public class CDOWorkspaceImpl extends Notifier implements InternalCDOWorkspace
return session;
}
+ protected void setTimeStamp(long timeStamp)
+ {
+ Map<String, String> props = new HashMap<String, String>();
+ props.put(PROP_TIME_STAMP, String.valueOf(timeStamp));
+ localRepository.getStore().setPersistentProperties(props);
+
+ this.timeStamp = timeStamp;
+ }
+
protected void saveProperties()
{
Map<String, String> props = new HashMap<String, String>();
@@ -793,6 +900,23 @@ public class CDOWorkspaceImpl extends Notifier implements InternalCDOWorkspace
/**
* @author Eike Stepper
*/
+ private class BaseRevisionProvider implements CDORevisionProvider
+ {
+ public CDORevision getRevision(CDOID id)
+ {
+ CDORevision revision = base.getRevision(id);
+ if (revision == null)
+ {
+ revision = CDOWorkspaceImpl.this.getRevision(id);
+ }
+
+ return revision;
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
public final class ViewAdapter extends LifecycleEventAdapter
{
public ViewAdapter()
diff --git a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/FolderCDOWorkspaceBase.java b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/FolderCDOWorkspaceBase.java
index d8d0395222..0220fb6af9 100644
--- a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/FolderCDOWorkspaceBase.java
+++ b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/FolderCDOWorkspaceBase.java
@@ -48,33 +48,6 @@ public class FolderCDOWorkspaceBase extends AbstractCDOWorkspaceBase
return folder;
}
- @Override
- public String toString()
- {
- return "FolderBase[" + folder.getAbsolutePath() + "]";
- }
-
- @Override
- protected void doClear()
- {
- IOUtil.delete(folder);
- checkExists(folder, false);
- createFolder();
- }
-
- @Override
- protected Set<CDOID> doGetIDs()
- {
- Set<CDOID> ids = new HashSet<CDOID>();
- for (String key : folder.list())
- {
- CDOID id = getCDOID(key);
- ids.add(id);
- }
-
- return ids;
- }
-
public final synchronized CDORevision getRevision(CDOID id)
{
File file = getFile(id);
@@ -102,8 +75,46 @@ public class FolderCDOWorkspaceBase extends AbstractCDOWorkspaceBase
}
}
+ public boolean isAddedObject(CDOID id)
+ {
+ File file = getFile(id);
+ if (!file.exists())
+ {
+ return false;
+ }
+
+ return file.length() == 0;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "FolderBase[" + folder.getAbsolutePath() + "]";
+ }
+
+ @Override
+ protected void doClear()
+ {
+ IOUtil.delete(folder);
+ checkExists(folder, false);
+ createFolder();
+ }
+
+ @Override
+ protected Set<CDOID> doGetIDs()
+ {
+ Set<CDOID> ids = new HashSet<CDOID>();
+ for (String key : folder.list())
+ {
+ CDOID id = getCDOID(key);
+ ids.add(id);
+ }
+
+ return ids;
+ }
+
@Override
- protected void registerChangedOrDetachedObject(InternalCDORevision revision)
+ protected void doRegisterChangedOrDetachedObject(InternalCDORevision revision)
{
File file = getFile(revision.getID());
if (file.exists())
@@ -132,7 +143,7 @@ public class FolderCDOWorkspaceBase extends AbstractCDOWorkspaceBase
}
@Override
- protected void registerAddedObject(CDOID id)
+ protected void doRegisterAddedObject(CDOID id)
{
File file = getFile(id);
if (file.exists())
@@ -157,7 +168,7 @@ public class FolderCDOWorkspaceBase extends AbstractCDOWorkspaceBase
}
@Override
- protected void deregisterObject(CDOID id)
+ protected void doDeregisterObject(CDOID id)
{
File file = getFile(id);
file.delete();
diff --git a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/spi/workspace/InternalCDOWorkspaceBase.java b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/spi/workspace/InternalCDOWorkspaceBase.java
index 8d5e250ff8..1e4d95ff36 100644
--- a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/spi/workspace/InternalCDOWorkspaceBase.java
+++ b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/spi/workspace/InternalCDOWorkspaceBase.java
@@ -10,13 +10,17 @@
*/
package org.eclipse.emf.cdo.spi.workspace;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.workspace.CDOWorkspaceBase;
+import org.eclipse.emf.cdo.workspace.CDOWorkspaceBase2;
/**
* @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 InternalCDOWorkspaceBase extends CDOWorkspaceBase
+public interface InternalCDOWorkspaceBase extends CDOWorkspaceBase2
{
public static final String PRODUCT_GROUP = "org.eclipse.emf.cdo.workspace.bases";
@@ -24,6 +28,22 @@ public interface InternalCDOWorkspaceBase extends CDOWorkspaceBase
public void init(InternalCDOWorkspace workspace);
+ /**
+ * @since 4.1
+ */
+ public void registerChangedOrDetachedObject(InternalCDORevision revision);
+
+ /**
+ * @since 4.1
+ */
+ public void registerAddedObject(CDOID id);
+
+ /**
+ * @since 4.1
+ */
+ public void deregisterObject(CDOID id);
+
+ @Deprecated
public void updateAfterCommit(CDOTransaction transaction);
public void clear();
diff --git a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceBase2.java b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceBase2.java
index a5165bbebc..75f7b28844 100644
--- a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceBase2.java
+++ b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceBase2.java
@@ -23,4 +23,9 @@ public interface CDOWorkspaceBase2 extends CDOWorkspaceBase
public boolean isEmpty();
public boolean containsID(CDOID id);
+
+ /**
+ * @since 4.1
+ */
+ public boolean isAddedObject(CDOID id);
}
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 e6874e0e41..9993e32bef 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
@@ -212,5 +212,10 @@ public final class CDOWorkspaceUtil
{
return getIDs().contains(id);
}
+
+ public boolean isAddedObject(CDOID id)
+ {
+ return containsID(id) && getRevision(id) == null;
+ }
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDODefaultTransactionHandler.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDODefaultTransactionHandler.java
index 8eaffcc7bb..e19ca0c8a2 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDODefaultTransactionHandler.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDODefaultTransactionHandler.java
@@ -16,8 +16,7 @@ package org.eclipse.emf.cdo.transaction;
* @author Eike Stepper
* @since 2.0
*/
-public abstract class CDODefaultTransactionHandler extends CDODefaultTransactionHandler1 implements
- CDOTransactionHandler
+public class CDODefaultTransactionHandler extends CDODefaultTransactionHandler1 implements CDOTransactionHandler
{
protected CDODefaultTransactionHandler()
{
@@ -34,7 +33,7 @@ public abstract class CDODefaultTransactionHandler extends CDODefaultTransaction
/**
* This implementation does nothing. Clients may override to provide specialized behaviour.
*/
- public void rolledBackTransaction(CDOTransaction transaction)
+ public void committedTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
{
// Do nothing
}
@@ -42,7 +41,7 @@ public abstract class CDODefaultTransactionHandler extends CDODefaultTransaction
/**
* This implementation does nothing. Clients may override to provide specialized behaviour.
*/
- public void committedTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
+ public void rolledBackTransaction(CDOTransaction transaction)
{
// Do nothing
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDODefaultTransactionHandler1.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDODefaultTransactionHandler1.java
index e767c950e9..3808117665 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDODefaultTransactionHandler1.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDODefaultTransactionHandler1.java
@@ -19,13 +19,13 @@ import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
* @author Eike Stepper
* @since 4.0
*/
-public abstract class CDODefaultTransactionHandler1 implements CDOTransactionHandler1
+public class CDODefaultTransactionHandler1 implements CDOTransactionHandler1
{
protected CDODefaultTransactionHandler1()
{
}
- /*
+ /**
* This implementation does nothing. Clients may override to provide specialized behaviour.
*/
public void attachingObject(CDOTransaction transaction, CDOObject object)
@@ -33,7 +33,7 @@ public abstract class CDODefaultTransactionHandler1 implements CDOTransactionHan
// Do nothing
}
- /*
+ /**
* This implementation does nothing. Clients may override to provide specialized behaviour.
*/
public void detachingObject(CDOTransaction transaction, CDOObject object)
@@ -41,7 +41,7 @@ public abstract class CDODefaultTransactionHandler1 implements CDOTransactionHan
// Do nothing
}
- /*
+ /**
* This implementation does nothing. Clients may override to provide specialized behaviour.
*/
public void modifyingObject(CDOTransaction transaction, CDOObject object, CDOFeatureDelta featureChange)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDODefaultTransactionHandler2.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDODefaultTransactionHandler2.java
index 406b9e49ae..73921e3d0a 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDODefaultTransactionHandler2.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDODefaultTransactionHandler2.java
@@ -16,13 +16,13 @@ package org.eclipse.emf.cdo.transaction;
* @author Eike Stepper
* @since 4.0
*/
-public abstract class CDODefaultTransactionHandler2 implements CDOTransactionHandler2
+public class CDODefaultTransactionHandler2 implements CDOTransactionHandler2
{
protected CDODefaultTransactionHandler2()
{
}
- /*
+ /**
* This implementation does nothing. Clients may override to provide specialized behaviour.
*/
public void committingTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
@@ -30,7 +30,7 @@ public abstract class CDODefaultTransactionHandler2 implements CDOTransactionHan
// Do nothing
}
- /*
+ /**
* This implementation does nothing. Clients may override to provide specialized behaviour.
*/
public void rolledBackTransaction(CDOTransaction transaction)
@@ -38,7 +38,7 @@ public abstract class CDODefaultTransactionHandler2 implements CDOTransactionHan
// Do nothing
}
- /*
+ /**
* This implementation does nothing. Clients may override to provide specialized behaviour.
*/
public void committedTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDODefaultTransactionHandler3.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDODefaultTransactionHandler3.java
new file mode 100644
index 0000000000..d48051c731
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDODefaultTransactionHandler3.java
@@ -0,0 +1,54 @@
+/**
+ * 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.transaction;
+
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+
+/**
+ * @author Eike Stepper
+ * @since 4.1
+ */
+public class CDODefaultTransactionHandler3 implements CDOTransactionHandler3
+{
+ protected CDODefaultTransactionHandler3()
+ {
+ }
+
+ /**
+ * This implementation does nothing. Clients may override to provide specialized behaviour.
+ */
+ public void committingTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
+ {
+ // Do nothing
+ }
+
+ @Deprecated
+ public void committedTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
+ {
+ // Do nothing
+ }
+
+ /**
+ * This implementation does nothing. Clients may override to provide specialized behaviour.
+ */
+ public void committedTransaction(CDOTransaction transaction, CDOCommitContext commitContext, CDOCommitInfo result)
+ {
+ // Do nothing
+ }
+
+ /**
+ * This implementation does nothing. Clients may override to provide specialized behaviour.
+ */
+ public void rolledBackTransaction(CDOTransaction transaction)
+ {
+ // Do nothing
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOTransactionHandler2.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOTransactionHandler2.java
index 7e6c1a18d5..4181232285 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOTransactionHandler2.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOTransactionHandler2.java
@@ -13,6 +13,8 @@
*/
package org.eclipse.emf.cdo.transaction;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+
/**
* A call-back interface that is called by a {@link CDOTransaction transcation} when it is about to be committed, has
* been committed or rolled back.
@@ -33,6 +35,10 @@ public interface CDOTransactionHandler2 extends CDOTransactionHandlerBase
/**
* Called by a <code>CDOTransaction</code> <b>after</b> it is being committed. The implementor of this method is
* <b>not</b> allowed to throw an unchecked exception.
+ * <p>
+ * If you're interested in the results of the commit operation consider to implement
+ * {@link CDOTransactionHandler3#committedTransaction(CDOTransaction, CDOCommitContext, CDOCommitInfo)
+ * CDOTransactionHandler3.committedTransaction()}.
*/
public void committedTransaction(CDOTransaction transaction, CDOCommitContext commitContext);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOTransactionHandler3.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOTransactionHandler3.java
new file mode 100644
index 0000000000..7b9e0f3628
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOTransactionHandler3.java
@@ -0,0 +1,32 @@
+/**
+ * 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.transaction;
+
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+
+/**
+ * A call-back interface that is called by a {@link CDOTransaction transcation} when it is about to be committed, has
+ * been committed or rolled back.
+ *
+ * @author Eike Stepper
+ * @since 4.1
+ */
+public interface CDOTransactionHandler3 extends CDOTransactionHandler2
+{
+ /**
+ * Called by a <code>CDOTransaction</code> <b>after</b> it is being committed. The implementor of this method is
+ * <b>not</b> allowed to throw an unchecked exception.
+ * <p>
+ * Note that {@link CDOTransactionHandler2#committedTransaction(CDOTransaction, CDOCommitContext)
+ * CDOTransactionHandler2.committedTransaction()} is not called.
+ */
+ public void committedTransaction(CDOTransaction transaction, CDOCommitContext commitContext, CDOCommitInfo result);
+}
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 293f899465..0c3f04c28c 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
@@ -1701,6 +1701,11 @@ public abstract class CDOSessionImpl extends CDOTransactionContainerImpl impleme
return commitInfo.getDetachedObjects();
}
+ public Map<CDOID, CDOChangeKind> getChangeKinds()
+ {
+ return commitInfo.getChangeKinds();
+ }
+
public CDOChangeKind getChangeKind(CDOID id)
{
return commitInfo.getChangeKind(id);
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 92f160cf1a..0d1a9d2329 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
@@ -82,6 +82,7 @@ import org.eclipse.emf.cdo.transaction.CDOTransactionFinishedEvent;
import org.eclipse.emf.cdo.transaction.CDOTransactionHandler;
import org.eclipse.emf.cdo.transaction.CDOTransactionHandler1;
import org.eclipse.emf.cdo.transaction.CDOTransactionHandler2;
+import org.eclipse.emf.cdo.transaction.CDOTransactionHandler3;
import org.eclipse.emf.cdo.transaction.CDOTransactionHandlerBase;
import org.eclipse.emf.cdo.transaction.CDOTransactionStartedEvent;
import org.eclipse.emf.cdo.transaction.CDOUserSavepoint;
@@ -2556,9 +2557,11 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
try
{
InternalCDOSession session = getSession();
+ long timeStamp = result.getTimeStamp();
+
if (result.getRollbackMessage() != null)
{
- CDOCommitInfo commitInfo = new FailureCommitInfo(result.getTimeStamp(), result.getPreviousTimeStamp());
+ CDOCommitInfo commitInfo = new FailureCommitInfo(timeStamp, result.getPreviousTimeStamp());
session.invalidate(commitInfo, transaction);
return;
}
@@ -2588,7 +2591,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
removeObject(id);
}
- CDOCommitInfo commitInfo = makeCommitInfo(result.getTimeStamp(), result.getPreviousTimeStamp());
+ CDOCommitInfo commitInfo = makeCommitInfo(timeStamp, result.getPreviousTimeStamp());
session.invalidate(commitInfo, transaction);
// Bug 290032 - Sticky views
@@ -2618,7 +2621,15 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
for (int i = 0; i < handlers.length; i++)
{
CDOTransactionHandler2 handler = handlers[i];
- handler.committedTransaction(transaction, this);
+ if (handler instanceof CDOTransactionHandler3)
+ {
+ CDOTransactionHandler3 handler3 = (CDOTransactionHandler3)handler;
+ handler3.committedTransaction(transaction, this, commitInfo);
+ }
+ else
+ {
+ handler.committedTransaction(transaction, this);
+ }
}
}

Back to the top