Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2009-11-07 07:32:33 -0500
committerEike Stepper2009-11-07 07:32:33 -0500
commitcd1bd9d265af105c885c14ade38bb4ee72dfcdf4 (patch)
treefea34adbd2ae08f62c08b1f1e300a12f2416840b /plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction
parent8f8228673b8b6c1007ef3644c8416272cedbf5ab (diff)
downloadcdo-cd1bd9d265af105c885c14ade38bb4ee72dfcdf4.tar.gz
cdo-cd1bd9d265af105c885c14ade38bb4ee72dfcdf4.tar.xz
cdo-cd1bd9d265af105c885c14ade38bb4ee72dfcdf4.zip
[292917] Remove dependencies on CDOSavepointImpl
https://bugs.eclipse.org/bugs/show_bug.cgi?id=292917
Diffstat (limited to 'plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction')
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOSavepointImpl.java122
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOSingleTransactionStrategyImpl.java12
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java34
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOUserSavepointImpl.java (renamed from plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/AbstractSavepoint.java)52
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOXASavepointImpl.java37
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOXATransactionImpl.java40
6 files changed, 163 insertions, 134 deletions
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 e6535985e6..997eb803be 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
@@ -23,8 +23,11 @@ import org.eclipse.emf.cdo.internal.common.revision.delta.CDORevisionDeltaImpl;
import org.eclipse.emf.cdo.internal.common.revision.delta.InternalCDOFeatureDelta;
import org.eclipse.net4j.util.collection.MultiMap;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import org.eclipse.emf.spi.cdo.InternalCDOSavepoint;
import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
+import org.eclipse.emf.spi.cdo.InternalCDOUserSavepoint;
import java.util.Collections;
import java.util.HashMap;
@@ -39,7 +42,7 @@ import java.util.concurrent.ConcurrentMap;
* @author Simon McDuff
* @since 2.0
*/
-public class CDOSavepointImpl extends AbstractSavepoint
+public class CDOSavepointImpl extends CDOUserSavepointImpl implements InternalCDOSavepoint
{
private Map<CDOID, CDOResource> newResources = new HashMap<CDOID, CDOResource>();
@@ -76,12 +79,12 @@ public class CDOSavepointImpl extends AbstractSavepoint
*/
private Set<CDOID> sharedDetachedObjects;
- private boolean isDirty;
+ private boolean dirty;
- public CDOSavepointImpl(InternalCDOTransaction transaction, CDOSavepointImpl lastSavepoint)
+ public CDOSavepointImpl(InternalCDOTransaction transaction, InternalCDOSavepoint lastSavepoint)
{
super(transaction, lastSavepoint);
- isDirty = transaction.isDirty();
+ dirty = transaction.isDirty();
if (lastSavepoint == null)
{
sharedDetachedObjects = new HashSet<CDOID>();
@@ -92,6 +95,42 @@ public class CDOSavepointImpl extends AbstractSavepoint
}
}
+ @Override
+ public InternalCDOTransaction getTransaction()
+ {
+ return (InternalCDOTransaction)super.getTransaction();
+ }
+
+ @Override
+ public InternalCDOSavepoint getFirstSavePoint()
+ {
+ return (InternalCDOSavepoint)super.getFirstSavePoint();
+ }
+
+ @Override
+ public InternalCDOSavepoint getPreviousSavepoint()
+ {
+ return (InternalCDOSavepoint)super.getPreviousSavepoint();
+ }
+
+ @Override
+ public InternalCDOSavepoint getNextSavepoint()
+ {
+ return (InternalCDOSavepoint)super.getNextSavepoint();
+ }
+
+ @Override
+ public void setPreviousSavepoint(InternalCDOUserSavepoint previousSavepoint)
+ {
+ super.setPreviousSavepoint(previousSavepoint);
+ }
+
+ @Override
+ public void setNextSavepoint(InternalCDOUserSavepoint nextSavepoint)
+ {
+ super.setNextSavepoint(nextSavepoint);
+ }
+
public void clear()
{
newResources.clear();
@@ -100,11 +139,12 @@ public class CDOSavepointImpl extends AbstractSavepoint
revisionDeltas.clear();
baseNewObjects.clear();
detachedObjects.clear();
+ // TODO reattachedObjects.clear(); ???
}
public boolean isDirty()
{
- return isDirty;
+ return dirty;
}
public Map<CDOID, CDOResource> getNewResources()
@@ -122,6 +162,12 @@ public class CDOSavepointImpl extends AbstractSavepoint
return detachedObjects;
}
+ // Bug 283985 (Re-attachment)
+ public Map<CDOID, CDOObject> getReattachedObjects()
+ {
+ return reattachedObjects;
+ }
+
public Map<CDOID, CDOObject> getDirtyObjects()
{
return dirtyObjects;
@@ -149,11 +195,11 @@ public class CDOSavepointImpl extends AbstractSavepoint
{
if (getPreviousSavepoint() == null)
{
- return getDirtyObjects();
+ return Collections.unmodifiableMap(getDirtyObjects());
}
MultiMap.ListBased<CDOID, CDOObject> dirtyObjects = new MultiMap.ListBased<CDOID, CDOObject>();
- for (CDOSavepointImpl savepoint = this; savepoint != null; savepoint = savepoint.getPreviousSavepoint())
+ for (InternalCDOSavepoint savepoint = this; savepoint != null; savepoint = savepoint.getPreviousSavepoint())
{
dirtyObjects.getDelegates().add(savepoint.getDirtyObjects());
}
@@ -174,7 +220,7 @@ public class CDOSavepointImpl extends AbstractSavepoint
if (getSharedDetachedObjects().size() == 0)
{
MultiMap.ListBased<CDOID, CDOObject> newObjects = new MultiMap.ListBased<CDOID, CDOObject>();
- for (CDOSavepointImpl savepoint = this; savepoint != null; savepoint = savepoint.getPreviousSavepoint())
+ for (InternalCDOSavepoint savepoint = this; savepoint != null; savepoint = savepoint.getPreviousSavepoint())
{
newObjects.getDelegates().add(savepoint.getNewObjects());
}
@@ -183,7 +229,7 @@ public class CDOSavepointImpl extends AbstractSavepoint
}
Map<CDOID, CDOObject> newObjects = new HashMap<CDOID, CDOObject>();
- for (CDOSavepointImpl savepoint = this; savepoint != null; savepoint = savepoint.getPreviousSavepoint())
+ for (InternalCDOSavepoint savepoint = this; savepoint != null; savepoint = savepoint.getPreviousSavepoint())
{
for (Entry<CDOID, CDOObject> entry : savepoint.getNewObjects().entrySet())
{
@@ -210,7 +256,7 @@ public class CDOSavepointImpl extends AbstractSavepoint
if (getSharedDetachedObjects().size() == 0)
{
MultiMap.ListBased<CDOID, CDOResource> newResources = new MultiMap.ListBased<CDOID, CDOResource>();
- for (CDOSavepointImpl savepoint = this; savepoint != null; savepoint = savepoint.getPreviousSavepoint())
+ for (InternalCDOSavepoint savepoint = this; savepoint != null; savepoint = savepoint.getPreviousSavepoint())
{
newResources.getDelegates().add(savepoint.getNewResources());
}
@@ -219,7 +265,7 @@ public class CDOSavepointImpl extends AbstractSavepoint
}
Map<CDOID, CDOResource> newResources = new HashMap<CDOID, CDOResource>();
- for (CDOSavepointImpl savepoint = this; savepoint != null; savepoint = savepoint.getPreviousSavepoint())
+ for (InternalCDOSavepoint savepoint = this; savepoint != null; savepoint = savepoint.getPreviousSavepoint())
{
for (Entry<CDOID, CDOResource> entry : savepoint.getNewResources().entrySet())
{
@@ -244,7 +290,7 @@ public class CDOSavepointImpl extends AbstractSavepoint
}
MultiMap.ListBased<CDOID, CDORevision> newObjects = new MultiMap.ListBased<CDOID, CDORevision>();
- for (CDOSavepointImpl savepoint = this; savepoint != null; savepoint = savepoint.getPreviousSavepoint())
+ for (InternalCDOSavepoint savepoint = this; savepoint != null; savepoint = savepoint.getPreviousSavepoint())
{
newObjects.getDelegates().add(savepoint.getBaseNewObjects());
}
@@ -264,7 +310,7 @@ public class CDOSavepointImpl extends AbstractSavepoint
// We need to combined the result for all delta in different Savepoint
Map<CDOID, CDORevisionDelta> revisionDeltas = new HashMap<CDOID, CDORevisionDelta>();
- for (CDOSavepointImpl savepoint = (CDOSavepointImpl)getFirstSavePoint(); savepoint != null; savepoint = savepoint
+ for (InternalCDOSavepoint savepoint = getFirstSavePoint(); savepoint != null; savepoint = savepoint
.getNextSavepoint())
{
for (Entry<CDOID, CDORevisionDelta> entry : savepoint.getRevisionDeltas().entrySet())
@@ -295,23 +341,14 @@ public class CDOSavepointImpl extends AbstractSavepoint
public Map<CDOID, CDOObject> getAllDetachedObjects()
{
- if (getPreviousSavepoint() == null)
+ if (getPreviousSavepoint() == null && reattachedObjects.isEmpty())
{
- Map<CDOID, CDOObject> detachedObjects = getDetachedObjects();
-
- // Bug 283985 (Re-attachment):
- // Object is only included if it was not reattached in a later savepoint
- for (CDOID id : getReattachedObjects().keySet())
- {
- detachedObjects.remove(id);
- }
-
- return Collections.unmodifiableMap(detachedObjects);
+ return Collections.unmodifiableMap(getDetachedObjects());
}
Map<CDOID, CDOObject> detachedObjects = new HashMap<CDOID, CDOObject>();
Set<CDOID> reattachedObjectIDs = new HashSet<CDOID>(); // Bug 283985 (Re-attachment)
- for (CDOSavepointImpl savepoint = this; savepoint != null; savepoint = savepoint.getPreviousSavepoint())
+ for (InternalCDOSavepoint savepoint = this; savepoint != null; savepoint = savepoint.getPreviousSavepoint())
{
reattachedObjectIDs.addAll(savepoint.getReattachedObjects().keySet());
@@ -332,16 +369,10 @@ public class CDOSavepointImpl extends AbstractSavepoint
return detachedObjects;
}
- // Bug 283985 (Re-attachment)
- public Map<CDOID, CDOObject> getReattachedObjects()
- {
- return reattachedObjects;
- }
-
public void recalculateSharedDetachedObjects()
{
sharedDetachedObjects.clear();
- for (CDOSavepointImpl savepoint = this; savepoint != null; savepoint = savepoint.getPreviousSavepoint())
+ for (InternalCDOSavepoint savepoint = this; savepoint != null; savepoint = savepoint.getPreviousSavepoint())
{
for (CDOID id : savepoint.getDetachedObjects().keySet())
{
@@ -350,31 +381,10 @@ public class CDOSavepointImpl extends AbstractSavepoint
}
}
- @Override
- public CDOSavepointImpl getPreviousSavepoint()
- {
- return (CDOSavepointImpl)super.getPreviousSavepoint();
- }
-
- @Override
- public CDOSavepointImpl getNextSavepoint()
- {
- return (CDOSavepointImpl)super.getNextSavepoint();
- }
-
- public void setPreviousSavepoint(CDOSavepointImpl previousSavepoint)
- {
- super.setPreviousSavepoint(previousSavepoint);
- }
-
- public void setNextSavepoint(CDOSavepointImpl nextSavepoint)
- {
- super.setNextSavepoint(nextSavepoint);
- }
-
- @Override
public void rollback()
{
- getUserTransaction().rollback(this);
+ InternalCDOTransaction transaction = getTransaction();
+ LifecycleUtil.checkActive(transaction);
+ transaction.getTransactionStrategy().rollback(transaction, this);
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOSingleTransactionStrategyImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOSingleTransactionStrategyImpl.java
index 924b49aa19..773f2fb62b 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOSingleTransactionStrategyImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOSingleTransactionStrategyImpl.java
@@ -4,14 +4,12 @@
* 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:
* Simon McDuff - initial API and implementation
**************************************************************************/
package org.eclipse.emf.internal.cdo.transaction;
-import org.eclipse.emf.cdo.transaction.CDOSavepoint;
-
import org.eclipse.emf.internal.cdo.bundle.OM;
import org.eclipse.net4j.util.om.monitor.EclipseMonitor;
@@ -20,7 +18,9 @@ import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.net4j.util.transaction.TransactionException;
import org.eclipse.emf.spi.cdo.CDOTransactionStrategy;
+import org.eclipse.emf.spi.cdo.InternalCDOSavepoint;
import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
+import org.eclipse.emf.spi.cdo.InternalCDOUserSavepoint;
import org.eclipse.emf.spi.cdo.CDOSessionProtocol.CommitTransactionResult;
import org.eclipse.emf.spi.cdo.InternalCDOTransaction.InternalCDOCommitContext;
@@ -72,12 +72,12 @@ public class CDOSingleTransactionStrategyImpl implements CDOTransactionStrategy
commitContext.postCommit(result);
}
- public void rollback(InternalCDOTransaction transaction, CDOSavepoint savepoint)
+ public void rollback(InternalCDOTransaction transaction, InternalCDOUserSavepoint savepoint)
{
- transaction.handleRollback(savepoint);
+ transaction.handleRollback((InternalCDOSavepoint)savepoint);
}
- public CDOSavepoint setSavepoint(InternalCDOTransaction transaction)
+ public InternalCDOUserSavepoint setSavepoint(InternalCDOTransaction transaction)
{
return transaction.handleSetSavepoint();
}
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 81d5ca2a3b..64b57b163b 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
@@ -37,12 +37,12 @@ import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionDelta;
import org.eclipse.emf.cdo.transaction.CDOConflictResolver;
-import org.eclipse.emf.cdo.transaction.CDOSavepoint;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.transaction.CDOTransactionConflictEvent;
import org.eclipse.emf.cdo.transaction.CDOTransactionFinishedEvent;
import org.eclipse.emf.cdo.transaction.CDOTransactionHandler;
import org.eclipse.emf.cdo.transaction.CDOTransactionStartedEvent;
+import org.eclipse.emf.cdo.transaction.CDOUserSavepoint;
import org.eclipse.emf.cdo.util.CDOURIUtil;
import org.eclipse.emf.cdo.view.CDOViewResourcesEvent;
@@ -68,8 +68,10 @@ import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.spi.cdo.CDOTransactionStrategy;
import org.eclipse.emf.spi.cdo.InternalCDOObject;
+import org.eclipse.emf.spi.cdo.InternalCDOSavepoint;
import org.eclipse.emf.spi.cdo.InternalCDOSession;
import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
+import org.eclipse.emf.spi.cdo.InternalCDOUserSavepoint;
import org.eclipse.emf.spi.cdo.CDOSessionProtocol.CommitTransactionResult;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -105,9 +107,9 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
}
};
- private CDOSavepointImpl lastSavepoint = new CDOSavepointImpl(this, null);
+ private InternalCDOSavepoint lastSavepoint = new CDOSavepointImpl(this, null);
- private CDOSavepointImpl firstSavepoint = lastSavepoint;
+ private InternalCDOSavepoint firstSavepoint = lastSavepoint;
private boolean dirty;
@@ -480,7 +482,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
/**
* @since 2.0
*/
- public CDOSavepointImpl getLastSavepoint()
+ public InternalCDOSavepoint getLastSavepoint()
{
checkActive();
return lastSavepoint;
@@ -726,12 +728,12 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
}
}
- private Set<CDOID> rollbackCompletely(CDOSavepoint savepoint)
+ private Set<CDOID> rollbackCompletely(CDOUserSavepoint savepoint)
{
Set<CDOID> idsOfNewObjectWithDeltas = new HashSet<CDOID>();
// Start from the last savepoint and come back up to the active
- for (CDOSavepointImpl itrSavepoint = lastSavepoint; itrSavepoint != null; itrSavepoint = itrSavepoint
+ for (InternalCDOSavepoint itrSavepoint = lastSavepoint; itrSavepoint != null; itrSavepoint = itrSavepoint
.getPreviousSavepoint())
{
// Rollback new objects created after the save point
@@ -797,7 +799,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
return idsOfNewObjectWithDeltas;
}
- private void loadSavepoint(CDOSavepoint savepoint, Set<CDOID> idsOfNewObjectWithDeltas)
+ private void loadSavepoint(CDOUserSavepoint savepoint, Set<CDOID> idsOfNewObjectWithDeltas)
{
lastSavepoint.recalculateSharedDetachedObjects();
@@ -856,7 +858,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
cleanObject(internalDirtyObject, getRevision(entryDirtyObject.getKey(), true));
}
- for (CDOSavepointImpl itrSavepoint = firstSavepoint; itrSavepoint != savepoint; itrSavepoint = itrSavepoint
+ for (InternalCDOSavepoint itrSavepoint = firstSavepoint; itrSavepoint != savepoint; itrSavepoint = itrSavepoint
.getNextSavepoint())
{
CDOObjectMerger merger = new CDOObjectMerger();
@@ -947,23 +949,23 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
/**
* @since 2.0
*/
- public void rollback(CDOSavepoint savepoint)
+ public void rollback(CDOUserSavepoint savepoint)
{
checkActive();
- getTransactionStrategy().rollback(this, savepoint);
+ getTransactionStrategy().rollback(this, (InternalCDOUserSavepoint)savepoint);
}
/**
* @since 2.0
*/
- public void handleRollback(CDOSavepoint savepoint)
+ public void handleRollback(InternalCDOSavepoint savepoint)
{
if (savepoint == null)
{
throw new IllegalArgumentException(Messages.getString("CDOTransactionImpl.3")); //$NON-NLS-1$
}
- if (savepoint.getUserTransaction() != this)
+ if (savepoint.getTransaction() != this)
{
throw new IllegalArgumentException(MessageFormat.format(Messages.getString("CDOTransactionImpl.4"), savepoint)); //$NON-NLS-1$
}
@@ -990,7 +992,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
// Rollback objects
Set<CDOID> idsOfNewObjectWithDeltas = rollbackCompletely(savepoint);
- lastSavepoint = (CDOSavepointImpl)savepoint;
+ lastSavepoint = savepoint;
// Make savepoint active. Erase savepoint that could have be after
lastSavepoint.setNextSavepoint(null);
lastSavepoint.clear();
@@ -1047,7 +1049,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
/**
* @since 2.0
*/
- public CDOSavepoint handleSetSavepoint()
+ public InternalCDOSavepoint handleSetSavepoint()
{
// Take a copy of all new objects for the current save point
addToBase(lastSavepoint.getNewObjects());
@@ -1060,10 +1062,10 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
/**
* @since 2.0
*/
- public CDOSavepoint setSavepoint()
+ public InternalCDOSavepoint setSavepoint()
{
checkActive();
- return getTransactionStrategy().setSavepoint(this);
+ return (InternalCDOSavepoint)getTransactionStrategy().setSavepoint(this);
}
private void addToBase(Map<CDOID, ? extends CDOObject> objects)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/AbstractSavepoint.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOUserSavepointImpl.java
index db8d6812e6..9ad0236a70 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/AbstractSavepoint.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOUserSavepointImpl.java
@@ -4,31 +4,31 @@
* 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:
* Simon McDuff - initial API and implementation
* Eike Stepper - maintenance
**************************************************************************/
package org.eclipse.emf.internal.cdo.transaction;
-import org.eclipse.emf.cdo.transaction.CDOSavepoint;
-import org.eclipse.emf.cdo.transaction.CDOUserTransaction;
+import org.eclipse.emf.spi.cdo.InternalCDOUserSavepoint;
+import org.eclipse.emf.spi.cdo.InternalCDOUserTransaction;
/**
* @author Simon McDuff
* @since 2.0
*/
-public abstract class AbstractSavepoint implements CDOSavepoint
+public abstract class CDOUserSavepointImpl implements InternalCDOUserSavepoint
{
- private CDOUserTransaction userTransaction;
+ private InternalCDOUserTransaction transaction;
- private AbstractSavepoint previousSavepoint;
+ private InternalCDOUserSavepoint previousSavepoint;
- private AbstractSavepoint nextSavepoint;
+ private InternalCDOUserSavepoint nextSavepoint;
- public AbstractSavepoint(CDOUserTransaction transaction, AbstractSavepoint lastSavepoint)
+ public CDOUserSavepointImpl(InternalCDOUserTransaction transaction, InternalCDOUserSavepoint lastSavepoint)
{
- userTransaction = transaction;
+ this.transaction = transaction;
previousSavepoint = lastSavepoint;
if (previousSavepoint != null)
{
@@ -36,40 +36,41 @@ public abstract class AbstractSavepoint implements CDOSavepoint
}
}
- public void setPreviousSavepoint(AbstractSavepoint previousSavepoint)
+ public InternalCDOUserTransaction getTransaction()
{
- this.previousSavepoint = previousSavepoint;
+ return transaction;
}
- public void setNextSavepoint(AbstractSavepoint nextSavepoint)
+ public InternalCDOUserSavepoint getPreviousSavepoint()
{
- this.nextSavepoint = nextSavepoint;
+ return previousSavepoint;
}
- public CDOSavepoint getNextSavepoint()
+ public void setPreviousSavepoint(InternalCDOUserSavepoint previousSavepoint)
{
- return nextSavepoint;
+ this.previousSavepoint = previousSavepoint;
}
- public CDOSavepoint getPreviousSavepoint()
+ public InternalCDOUserSavepoint getNextSavepoint()
{
- return previousSavepoint;
+ return nextSavepoint;
}
- public AbstractSavepoint getFirstSavePoint()
+ public void setNextSavepoint(InternalCDOUserSavepoint nextSavepoint)
{
- return previousSavepoint != null ? previousSavepoint.getFirstSavePoint() : this;
+ this.nextSavepoint = nextSavepoint;
}
- public CDOUserTransaction getUserTransaction()
+ public InternalCDOUserSavepoint getFirstSavePoint()
{
- return userTransaction;
+ return previousSavepoint != null ? previousSavepoint.getFirstSavePoint() : this;
}
public boolean isValid()
{
- CDOSavepoint lastSavepoint = getUserTransaction().getLastSavepoint();
- for (CDOSavepoint savepoint = lastSavepoint; savepoint != null; savepoint = savepoint.getPreviousSavepoint())
+ InternalCDOUserSavepoint lastSavepoint = getTransaction().getLastSavepoint();
+ for (InternalCDOUserSavepoint savepoint = lastSavepoint; savepoint != null; savepoint = savepoint
+ .getPreviousSavepoint())
{
if (savepoint == this)
{
@@ -79,9 +80,4 @@ public abstract class AbstractSavepoint implements CDOSavepoint
return false;
}
-
- public void rollback()
- {
- getUserTransaction().rollback(this);
- }
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOXASavepointImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOXASavepointImpl.java
index 3a36c54dd2..6aa14f8531 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOXASavepointImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOXASavepointImpl.java
@@ -11,7 +11,9 @@
package org.eclipse.emf.internal.cdo.transaction;
import org.eclipse.emf.cdo.transaction.CDOSavepoint;
-import org.eclipse.emf.cdo.transaction.CDOUserTransaction;
+
+import org.eclipse.emf.spi.cdo.InternalCDOXASavepoint;
+import org.eclipse.emf.spi.cdo.InternalCDOXATransaction;
import java.util.List;
@@ -19,15 +21,39 @@ import java.util.List;
* @author Simon McDuff
* @since 2.0
*/
-public class CDOXASavepointImpl extends AbstractSavepoint
+public class CDOXASavepointImpl extends CDOUserSavepointImpl implements InternalCDOXASavepoint
{
private List<CDOSavepoint> savepoints;
- public CDOXASavepointImpl(CDOUserTransaction transaction, AbstractSavepoint lastSavepoint)
+ public CDOXASavepointImpl(InternalCDOXATransaction transaction, InternalCDOXASavepoint lastSavepoint)
{
super(transaction, lastSavepoint);
}
+ @Override
+ public InternalCDOXATransaction getTransaction()
+ {
+ return (InternalCDOXATransaction)super.getTransaction();
+ }
+
+ @Override
+ public InternalCDOXASavepoint getFirstSavePoint()
+ {
+ return (InternalCDOXASavepoint)super.getFirstSavePoint();
+ }
+
+ @Override
+ public InternalCDOXASavepoint getNextSavepoint()
+ {
+ return (InternalCDOXASavepoint)super.getNextSavepoint();
+ }
+
+ @Override
+ public InternalCDOXASavepoint getPreviousSavepoint()
+ {
+ return (InternalCDOXASavepoint)super.getPreviousSavepoint();
+ }
+
public List<CDOSavepoint> getSavepoints()
{
return savepoints;
@@ -37,4 +63,9 @@ public class CDOXASavepointImpl extends AbstractSavepoint
{
this.savepoints = savepoints;
}
+
+ public void rollback()
+ {
+ getTransaction().rollback(this);
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOXATransactionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOXATransactionImpl.java
index 52363fdabb..5334a9e03b 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOXATransactionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOXATransactionImpl.java
@@ -33,6 +33,8 @@ import org.eclipse.emf.common.notify.Notifier;
import org.eclipse.emf.spi.cdo.CDOSessionProtocol;
import org.eclipse.emf.spi.cdo.CDOTransactionStrategy;
import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
+import org.eclipse.emf.spi.cdo.InternalCDOUserSavepoint;
+import org.eclipse.emf.spi.cdo.InternalCDOXASavepoint;
import org.eclipse.emf.spi.cdo.InternalCDOXATransaction;
import org.eclipse.emf.spi.cdo.CDOSessionProtocol.CommitTransactionResult;
import org.eclipse.emf.spi.cdo.InternalCDOTransaction.InternalCDOCommitContext;
@@ -41,7 +43,6 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.SubProgressMonitor;
-import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -97,9 +98,9 @@ public class CDOXATransactionImpl implements InternalCDOXATransaction
private Map<InternalCDOTransaction, Set<CDOID>> requestedCDOID = new HashMap<InternalCDOTransaction, Set<CDOID>>();
- private CDOXASavepointImpl lastSavepoint = new CDOXASavepointImpl(this, null);
+ private InternalCDOXASavepoint lastSavepoint = new CDOXASavepointImpl(this, null);
- private CDOXASavepointImpl firstSavepoint = lastSavepoint;
+ private InternalCDOXASavepoint firstSavepoint = lastSavepoint;
private CDOTransactionStrategy transactionStrategy = new CDOXATransactionStrategyImpl();
@@ -307,7 +308,7 @@ public class CDOXATransactionImpl implements InternalCDOXATransaction
}
}
- public CDOXASavepointImpl getLastSavepoint()
+ public InternalCDOXASavepoint getLastSavepoint()
{
return lastSavepoint;
}
@@ -317,25 +318,14 @@ public class CDOXATransactionImpl implements InternalCDOXATransaction
rollback(firstSavepoint);
}
- public void rollback(CDOSavepoint savepoint)
+ public void rollback(InternalCDOXASavepoint savepoint)
{
- if (savepoint == null)
- {
- throw new IllegalArgumentException(Messages.getString("CDOXATransactionImpl.5")); //$NON-NLS-1$
- }
-
- if (savepoint.getUserTransaction() != this)
- {
- throw new IllegalArgumentException(MessageFormat.format(Messages.getString("CDOXATransactionImpl.6"), savepoint)); //$NON-NLS-1$
- }
-
if (!savepoint.isValid())
{
throw new IllegalArgumentException(Messages.getString("CDOXATransactionImpl.7") + savepoint); //$NON-NLS-1$
}
- CDOXASavepointImpl savepointSet = (CDOXASavepointImpl)savepoint;
- List<CDOSavepoint> savepoints = savepointSet.getSavepoints();
+ List<CDOSavepoint> savepoints = savepoint.getSavepoints();
if (savepoints == null)
{
savepoints = getListSavepoints();
@@ -343,21 +333,21 @@ public class CDOXATransactionImpl implements InternalCDOXATransaction
for (CDOSavepoint indexSavePoint : savepoints)
{
- InternalCDOTransaction transaction = (InternalCDOTransaction)indexSavePoint.getUserTransaction();
- CDOSingleTransactionStrategyImpl.INSTANCE.rollback(transaction, indexSavePoint);
+ InternalCDOTransaction transaction = (InternalCDOTransaction)indexSavePoint.getTransaction();
+ CDOSingleTransactionStrategyImpl.INSTANCE.rollback(transaction, (InternalCDOUserSavepoint)indexSavePoint);
}
- lastSavepoint = savepointSet;
+ lastSavepoint = savepoint;
lastSavepoint.setNextSavepoint(null);
lastSavepoint.setSavepoints(null);
}
- public CDOSavepoint setSavepoint()
+ public InternalCDOXASavepoint setSavepoint()
{
List<CDOSavepoint> savepoints = getListSavepoints();
for (CDOSavepoint savepoint : savepoints)
{
- InternalCDOTransaction transaction = (InternalCDOTransaction)savepoint.getUserTransaction();
+ InternalCDOTransaction transaction = (InternalCDOTransaction)savepoint.getTransaction();
CDOSingleTransactionStrategyImpl.INSTANCE.setSavepoint(transaction);
}
@@ -424,13 +414,13 @@ public class CDOXATransactionImpl implements InternalCDOXATransaction
CDOXATransactionImpl.this.commit(progressMonitor);
}
- public void rollback(InternalCDOTransaction transaction, CDOSavepoint savepoint)
+ public void rollback(InternalCDOTransaction transaction, InternalCDOUserSavepoint savepoint)
{
checkAccess();
- CDOXATransactionImpl.this.rollback(savepoint);
+ CDOXATransactionImpl.this.rollback((InternalCDOXASavepoint)savepoint);
}
- public CDOSavepoint setSavepoint(InternalCDOTransaction transaction)
+ public InternalCDOUserSavepoint setSavepoint(InternalCDOTransaction transaction)
{
checkAccess();
return CDOXATransactionImpl.this.setSavepoint();

Back to the top