Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2009-11-07 08:20:13 -0500
committerEike Stepper2009-11-07 08:20:13 -0500
commite6e1bd8067d086ca722f0a4aff3ac8fbf8ae3ce0 (patch)
tree92b0d6ac183e350c6131fdc564ea975860a7e176 /plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction
parentcd1bd9d265af105c885c14ade38bb4ee72dfcdf4 (diff)
downloadcdo-e6e1bd8067d086ca722f0a4aff3ac8fbf8ae3ce0.tar.gz
cdo-e6e1bd8067d086ca722f0a4aff3ac8fbf8ae3ce0.tar.xz
cdo-e6e1bd8067d086ca722f0a4aff3ac8fbf8ae3ce0.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/CDOTransactionImpl.java17
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOXACommitContextImpl.java9
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOXATransactionImpl.java204
3 files changed, 118 insertions, 112 deletions
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 64b57b163b..d664d9ce5a 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,6 +37,7 @@ 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;
@@ -107,7 +108,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
}
};
- private InternalCDOSavepoint lastSavepoint = new CDOSavepointImpl(this, null);
+ private InternalCDOSavepoint lastSavepoint = createSavepoint(null);
private InternalCDOSavepoint firstSavepoint = lastSavepoint;
@@ -799,7 +800,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
return idsOfNewObjectWithDeltas;
}
- private void loadSavepoint(CDOUserSavepoint savepoint, Set<CDOID> idsOfNewObjectWithDeltas)
+ private void loadSavepoint(CDOSavepoint savepoint, Set<CDOID> idsOfNewObjectWithDeltas)
{
lastSavepoint.recalculateSharedDetachedObjects();
@@ -885,7 +886,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
}
}
- dirty = ((CDOSavepointImpl)savepoint).isDirty();
+ dirty = savepoint.isDirty();
}
/**
@@ -1051,14 +1052,18 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
*/
public InternalCDOSavepoint handleSetSavepoint()
{
- // Take a copy of all new objects for the current save point
addToBase(lastSavepoint.getNewObjects());
addToBase(lastSavepoint.getNewResources());
- lastSavepoint = new CDOSavepointImpl(this, lastSavepoint);
+ lastSavepoint = createSavepoint(lastSavepoint);
return lastSavepoint;
}
+ protected CDOSavepointImpl createSavepoint(InternalCDOSavepoint lastSavepoint)
+ {
+ return new CDOSavepointImpl(this, lastSavepoint);
+ }
+
/**
* @since 2.0
*/
@@ -1375,7 +1380,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
/**
* @author Simon McDuff
*/
- private class CDOCommitContextImpl implements InternalCDOCommitContext
+ private final class CDOCommitContextImpl implements InternalCDOCommitContext
{
private Map<CDOID, CDOResource> newResources;
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOXACommitContextImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOXACommitContextImpl.java
index 29221b5e63..1cd69dcd8a 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOXACommitContextImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOXACommitContextImpl.java
@@ -20,13 +20,13 @@ import org.eclipse.emf.cdo.internal.common.id.CDOIDTempObjectExternalImpl;
import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.internal.cdo.messages.Messages;
-import org.eclipse.emf.internal.cdo.transaction.CDOXATransactionImpl.CDOXAState;
import org.eclipse.net4j.util.ImplementationError;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.spi.cdo.InternalCDOObject;
import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
+import org.eclipse.emf.spi.cdo.InternalCDOXATransaction;
import org.eclipse.emf.spi.cdo.CDOSessionProtocol.CommitTransactionResult;
import org.eclipse.emf.spi.cdo.InternalCDOTransaction.InternalCDOCommitContext;
import org.eclipse.emf.spi.cdo.InternalCDOXATransaction.InternalCDOXACommitContext;
@@ -44,7 +44,7 @@ import java.util.Map;
*/
public class CDOXACommitContextImpl implements InternalCDOXACommitContext
{
- private CDOXATransactionImpl transactionManager;
+ private InternalCDOXATransaction transactionManager;
private IProgressMonitor progressMonitor;
@@ -58,13 +58,13 @@ public class CDOXACommitContextImpl implements InternalCDOXACommitContext
private Map<InternalCDOObject, CDOIDTempObjectExternalImpl> objectToID = new HashMap<InternalCDOObject, CDOIDTempObjectExternalImpl>();
- public CDOXACommitContextImpl(CDOXATransactionImpl manager, InternalCDOCommitContext commitContext)
+ public CDOXACommitContextImpl(InternalCDOXATransaction manager, InternalCDOCommitContext commitContext)
{
transactionManager = manager;
delegateCommitContext = commitContext;
}
- public CDOXATransactionImpl getTransactionManager()
+ public InternalCDOXATransaction getTransactionManager()
{
return transactionManager;
}
@@ -143,7 +143,6 @@ public class CDOXACommitContextImpl implements InternalCDOXACommitContext
public CDOID provideCDOID(Object idOrObject)
{
CDOID id = getTransaction().provideCDOID(idOrObject);
-
if (id instanceof CDOIDTempObjectExternalImpl)
{
if (idOrObject instanceof InternalEObject)
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 5334a9e03b..d17293601d 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
@@ -38,6 +38,7 @@ 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;
+import org.eclipse.emf.spi.cdo.InternalCDOXATransaction.InternalCDOXACommitContext.CDOXAState;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -94,17 +95,17 @@ public class CDOXATransactionImpl implements InternalCDOXATransaction
private ExecutorService executorService = createExecutorService();
- private Map<InternalCDOTransaction, CDOXACommitContextImpl> activeContext = new HashMap<InternalCDOTransaction, CDOXACommitContextImpl>();
+ private Map<InternalCDOTransaction, InternalCDOXACommitContext> activeContext = new HashMap<InternalCDOTransaction, InternalCDOXACommitContext>();
private Map<InternalCDOTransaction, Set<CDOID>> requestedCDOID = new HashMap<InternalCDOTransaction, Set<CDOID>>();
- private InternalCDOXASavepoint lastSavepoint = new CDOXASavepointImpl(this, null);
+ private InternalCDOXASavepoint lastSavepoint = createSavepoint(null);
private InternalCDOXASavepoint firstSavepoint = lastSavepoint;
- private CDOTransactionStrategy transactionStrategy = new CDOXATransactionStrategyImpl();
+ private CDOTransactionStrategy transactionStrategy = createTransactionStrategy();
- private CDOXAInternalAdapter internalAdapter = new CDOXAInternalAdapter();
+ private CDOXAInternalAdapter internalAdapter = createInternalAdapter();
public CDOXATransactionImpl()
{
@@ -162,15 +163,15 @@ public class CDOXATransactionImpl implements InternalCDOXATransaction
viewSet.eAdapters().remove(internalAdapter);
};
- public void add(InternalCDOTransaction view, CDOID object)
+ public void add(InternalCDOTransaction transaction, CDOID object)
{
synchronized (requestedCDOID)
{
- Set<CDOID> ids = requestedCDOID.get(view);
+ Set<CDOID> ids = requestedCDOID.get(transaction);
if (ids == null)
{
ids = new HashSet<CDOID>();
- requestedCDOID.put(view, ids);
+ requestedCDOID.put(transaction, ids);
}
ids.add(object);
@@ -183,12 +184,12 @@ public class CDOXATransactionImpl implements InternalCDOXATransaction
return ids.toArray(new CDOID[ids.size()]);
}
- public CDOXACommitContextImpl getCommitContext(CDOTransaction transaction)
+ public InternalCDOXACommitContext getCommitContext(CDOTransaction transaction)
{
return activeContext.get(transaction);
}
- private void send(Collection<CDOXACommitContextImpl> xaContexts, final IProgressMonitor progressMonitor)
+ private void send(Collection<InternalCDOXACommitContext> xaContexts, final IProgressMonitor progressMonitor)
throws InterruptedException, ExecutionException
{
progressMonitor.beginTask("", xaContexts.size()); //$NON-NLS-1$
@@ -196,7 +197,7 @@ public class CDOXATransactionImpl implements InternalCDOXATransaction
try
{
List<Future<Object>> futures = new ArrayList<Future<Object>>();
- for (CDOXACommitContextImpl xaContext : xaContexts)
+ for (InternalCDOXACommitContext xaContext : xaContexts)
{
xaContext.setProgressMonitor(new SynchonizedSubProgressMonitor(progressMonitor, 1));
futures.add(executorService.submit(xaContext));
@@ -222,7 +223,7 @@ public class CDOXATransactionImpl implements InternalCDOXATransaction
finally
{
progressMonitor.done();
- for (CDOXACommitContextImpl xaContext : xaContexts)
+ for (InternalCDOXACommitContext xaContext : xaContexts)
{
xaContext.setProgressMonitor(null);
}
@@ -263,7 +264,7 @@ public class CDOXATransactionImpl implements InternalCDOXATransaction
for (InternalCDOTransaction transaction : transactions)
{
InternalCDOCommitContext context = transaction.createCommitContext();
- CDOXACommitContextImpl xaContext = new CDOXACommitContextImpl(this, context);
+ InternalCDOXACommitContext xaContext = createXACommitContext(context);
xaContext.setState(CDOXAPhase1State.INSTANCE);
activeContext.put(transaction, xaContext);
}
@@ -282,9 +283,9 @@ public class CDOXATransactionImpl implements InternalCDOXATransaction
if (phase < 2)
{
// Phase 0 and 1 are the only two phases we can cancel.
- for (CDOXACommitContextImpl transaction : activeContext.values())
+ for (InternalCDOXACommitContext xaContext : activeContext.values())
{
- transaction.setState(CDOXACancel.INSTANCE);
+ xaContext.setState(CDOXACancel.INSTANCE);
}
try
@@ -352,10 +353,35 @@ public class CDOXATransactionImpl implements InternalCDOXATransaction
}
getLastSavepoint().setSavepoints(savepoints);
- lastSavepoint = new CDOXASavepointImpl(this, getLastSavepoint());
+ lastSavepoint = createSavepoint(getLastSavepoint());
return lastSavepoint;
}
+ protected CDOXACommitContextImpl createXACommitContext(InternalCDOCommitContext context)
+ {
+ return new CDOXACommitContextImpl(this, context);
+ }
+
+ protected CDOXATransactionStrategyImpl createTransactionStrategy()
+ {
+ return new CDOXATransactionStrategyImpl(this);
+ }
+
+ protected CDOXAInternalAdapter createInternalAdapter()
+ {
+ return new CDOXAInternalAdapter(this);
+ }
+
+ protected CDOXASavepointImpl createSavepoint(InternalCDOXASavepoint lastSavepoint)
+ {
+ return new CDOXASavepointImpl(this, lastSavepoint);
+ }
+
+ protected ExecutorService createExecutorService()
+ {
+ return Executors.newFixedThreadPool(10);
+ }
+
private List<CDOSavepoint> getListSavepoints()
{
synchronized (transactions)
@@ -370,9 +396,58 @@ public class CDOXATransactionImpl implements InternalCDOXATransaction
}
}
- protected ExecutorService createExecutorService()
+ /**
+ * @author Simon McDuff
+ */
+ public static class CDOXAInternalAdapter implements Adapter
{
- return Executors.newFixedThreadPool(10);
+ private InternalCDOXATransaction xaTransaction;
+
+ public CDOXAInternalAdapter(InternalCDOXATransaction xaTransaction)
+ {
+ this.xaTransaction = xaTransaction;
+ }
+
+ public InternalCDOXATransaction getXATransaction()
+ {
+ return xaTransaction;
+ }
+
+ public Notifier getTarget()
+ {
+ return null;
+ }
+
+ public boolean isAdapterForType(Object type)
+ {
+ return false;
+ }
+
+ public void notifyChanged(Notification notification)
+ {
+ switch (notification.getEventType())
+ {
+ case Notification.ADD:
+ if (notification.getNewValue() instanceof InternalCDOTransaction)
+ {
+ getXATransaction().add((InternalCDOTransaction)notification.getNewValue());
+ }
+
+ break;
+
+ case Notification.REMOVE:
+ if (notification.getOldValue() instanceof InternalCDOTransaction)
+ {
+ getXATransaction().remove((InternalCDOTransaction)notification.getNewValue());
+ }
+
+ break;
+ }
+ }
+
+ public void setTarget(Notifier newTarget)
+ {
+ }
}
/**
@@ -380,8 +455,11 @@ public class CDOXATransactionImpl implements InternalCDOXATransaction
*/
private final class CDOXATransactionStrategyImpl implements CDOTransactionStrategy
{
- public CDOXATransactionStrategyImpl()
+ private InternalCDOXATransaction xaTransaction;
+
+ public CDOXATransactionStrategyImpl(InternalCDOXATransaction xaTransaction)
{
+ this.xaTransaction = xaTransaction;
}
public void setTarget(InternalCDOTransaction transaction)
@@ -411,56 +489,31 @@ public class CDOXATransactionImpl implements InternalCDOXATransaction
public void commit(InternalCDOTransaction transactionCommit, IProgressMonitor progressMonitor) throws Exception
{
checkAccess();
- CDOXATransactionImpl.this.commit(progressMonitor);
+ xaTransaction.commit(progressMonitor);
}
public void rollback(InternalCDOTransaction transaction, InternalCDOUserSavepoint savepoint)
{
checkAccess();
- CDOXATransactionImpl.this.rollback((InternalCDOXASavepoint)savepoint);
+ xaTransaction.rollback((InternalCDOXASavepoint)savepoint);
}
public InternalCDOUserSavepoint setSavepoint(InternalCDOTransaction transaction)
{
checkAccess();
- return CDOXATransactionImpl.this.setSavepoint();
+ return xaTransaction.setSavepoint();
}
}
/**
* @author Simon McDuff
*/
- public static abstract class CDOXAState
- {
- public static final CDOXAState DONE = new CDOXAState()
- {
- @Override
- protected void handle(CDOXACommitContextImpl xaContext, IProgressMonitor progressMonitor) throws Exception
- {
- progressMonitor.done();
- }
- };
-
- protected void check_result(CommitTransactionResult result)
- {
- if (result != null && result.getRollbackMessage() != null)
- {
- throw new TransactionException(result.getRollbackMessage());
- }
- }
-
- protected abstract void handle(CDOXACommitContextImpl xaContext, IProgressMonitor progressMonitor) throws Exception;
- };
-
- /**
- * @author Simon McDuff
- */
public static class CDOXAPhase1State extends CDOXAState
{
public static final CDOXAPhase1State INSTANCE = new CDOXAPhase1State();
@Override
- protected void handle(CDOXACommitContextImpl xaContext, IProgressMonitor progressMonitor) throws Exception
+ public void handle(InternalCDOXACommitContext xaContext, IProgressMonitor progressMonitor) throws Exception
{
xaContext.preCommit();
CommitTransactionResult result = null;
@@ -489,7 +542,7 @@ public class CDOXATransactionImpl implements InternalCDOXATransaction
}
@Override
- protected void handle(CDOXACommitContextImpl xaContext, IProgressMonitor progressMonitor) throws Exception
+ public void handle(InternalCDOXACommitContext xaContext, IProgressMonitor progressMonitor) throws Exception
{
if (xaContext.getTransaction().isDirty())
{
@@ -515,7 +568,7 @@ public class CDOXATransactionImpl implements InternalCDOXATransaction
}
@Override
- protected void handle(CDOXACommitContextImpl xaContext, IProgressMonitor progressMonitor) throws Exception
+ public void handle(InternalCDOXACommitContext xaContext, IProgressMonitor progressMonitor) throws Exception
{
if (xaContext.getTransaction().isDirty())
{
@@ -542,63 +595,12 @@ public class CDOXATransactionImpl implements InternalCDOXATransaction
}
@Override
- protected void handle(CDOXACommitContextImpl xaContext, IProgressMonitor progressMonitor) throws Exception
+ public void handle(InternalCDOXACommitContext xaContext, IProgressMonitor progressMonitor) throws Exception
{
CDOSessionProtocol sessionProtocol = xaContext.getTransaction().getSession().getSessionProtocol();
OMMonitor monitor = new EclipseMonitor(progressMonitor);
CommitTransactionResult result = sessionProtocol.commitTransactionCancel(xaContext, monitor);
check_result(result);
}
- };
-
- /**
- * @author Simon McDuff
- */
- public class CDOXAInternalAdapter implements Adapter
- {
- public CDOXAInternalAdapter()
- {
- }
-
- public CDOXATransactionImpl getCDOXA()
- {
- return CDOXATransactionImpl.this;
- }
-
- public Notifier getTarget()
- {
- return null;
- }
-
- public boolean isAdapterForType(Object type)
- {
- return false;
- }
-
- public void notifyChanged(Notification notification)
- {
- switch (notification.getEventType())
- {
- case Notification.ADD:
- if (notification.getNewValue() instanceof InternalCDOTransaction)
- {
- CDOXATransactionImpl.this.add((InternalCDOTransaction)notification.getNewValue());
- }
-
- break;
-
- case Notification.REMOVE:
- if (notification.getOldValue() instanceof InternalCDOTransaction)
- {
- CDOXATransactionImpl.this.remove((InternalCDOTransaction)notification.getNewValue());
- }
-
- break;
- }
- }
-
- public void setTarget(Notifier newTarget)
- {
- }
}
}

Back to the top