Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-04-05 06:59:43 -0400
committerEike Stepper2013-04-05 06:59:43 -0400
commitea01b6f2e7d00f946dec8eca9356ee4036c79daa (patch)
tree76e89be43c7eb38b44edc23ac1d7ef4a6e5d38c2
parent2a8dc8184486bf58f9fc8951f40be1fcf673bb2b (diff)
downloadcdo-ea01b6f2e7d00f946dec8eca9356ee4036c79daa.tar.gz
cdo-ea01b6f2e7d00f946dec8eca9356ee4036c79daa.tar.xz
cdo-ea01b6f2e7d00f946dec8eca9356ee4036c79daa.zip
Refactor CDOXATransactionImpl to supprt JTA
-rw-r--r--plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitXATransactionPhase1Indication.java4
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOXATransactionImpl.java94
2 files changed, 60 insertions, 38 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitXATransactionPhase1Indication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitXATransactionPhase1Indication.java
index 165c60cedc..b1ecd692cc 100644
--- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitXATransactionPhase1Indication.java
+++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitXATransactionPhase1Indication.java
@@ -15,6 +15,7 @@ import org.eclipse.emf.cdo.common.protocol.CDODataInput;
import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
import org.eclipse.emf.cdo.internal.server.XATransactionCommitContext;
+import org.eclipse.emf.cdo.spi.server.InternalTransaction;
import org.eclipse.net4j.util.om.monitor.OMMonitor;
@@ -39,7 +40,8 @@ public class CommitXATransactionPhase1Indication extends CommitTransactionIndica
protected void initializeCommitContext(CDODataInput in) throws Exception
{
int viewID = in.readInt();
- commitContext = new XATransactionCommitContext(getTransaction(viewID));
+ InternalTransaction transaction = getTransaction(viewID);
+ commitContext = new XATransactionCommitContext(transaction);
}
@Override
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 42c1803f6c..f8202a3012 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
@@ -91,7 +91,7 @@ import java.util.concurrent.TimeoutException;
* All {@link CDOTransaction} includes in the commit process need to have finish their phase before moving to the next
* phase. For one phase, every {@link CDOTransaction} could have their own thread. It depends of the ExecutorService.
* <p>
- *
+ *
* @author Simon McDuff
* @since 2.0
*/
@@ -294,9 +294,34 @@ public class CDOXATransactionImpl implements InternalCDOXATransaction
public CDOCommitInfo commit(IProgressMonitor progressMonitor) throws CommitException
{
+ commitPrepare(progressMonitor);
+ int phase = 0;
+
+ try
+ {
+ // We need to complete 3 phases
+ while (phase <= 2)
+ {
+ commitPhase(progressMonitor);
+ ++phase;
+ }
+ }
+ catch (Exception ex)
+ {
+ commitException(progressMonitor, phase, ex);
+ }
+ finally
+ {
+ commitFinally(progressMonitor);
+ }
+
+ return null;
+ }
+
+ public void commitPrepare(IProgressMonitor progressMonitor)
+ {
CheckUtil.checkArg(progressMonitor, "progressMonitor"); //$NON-NLS-1$
progressMonitor.beginTask(Messages.getString("CDOXATransactionImpl.4"), 3); //$NON-NLS-1$
- int phase = 0;
for (InternalCDOTransaction transaction : transactions)
{
@@ -305,49 +330,44 @@ public class CDOXATransactionImpl implements InternalCDOXATransaction
xaContext.setState(CDOXAPhase1State.INSTANCE);
activeContexts.put(transaction, xaContext);
}
+ }
- try
+ public void commitPhase(IProgressMonitor progressMonitor) throws InterruptedException, ExecutionException
+ {
+ send(activeContexts.values(), new SubProgressMonitor(progressMonitor, 1));
+ }
+
+ public void commitException(IProgressMonitor progressMonitor, int phase, Exception ex) throws CommitException
+ {
+ if (phase < 2)
{
- // We need to complete 3 phases
- while (phase < 3)
+ // Phase 0 and 1 are the only two phases we can cancel.
+ for (InternalCDOXACommitContext xaContext : activeContexts.values())
{
- send(activeContexts.values(), new SubProgressMonitor(progressMonitor, 1));
- ++phase;
+ xaContext.setState(CDOXACancel.INSTANCE);
}
- return null;
- }
- catch (Exception ex)
- {
- if (phase < 2)
+ try
{
- // Phase 0 and 1 are the only two phases we can cancel.
- for (InternalCDOXACommitContext xaContext : activeContexts.values())
- {
- xaContext.setState(CDOXACancel.INSTANCE);
- }
-
- try
- {
- send(activeContexts.values(), new SubProgressMonitor(progressMonitor, 2 - phase));
- }
- catch (InterruptedException ex1)
- {
- throw WrappedException.wrap(ex1);
- }
- catch (ExecutionException ex1)
- {
- OM.LOG.warn(ex1);
- }
+ send(activeContexts.values(), new SubProgressMonitor(progressMonitor, 2 - phase));
+ }
+ catch (InterruptedException ex1)
+ {
+ throw WrappedException.wrap(ex1);
+ }
+ catch (ExecutionException ex1)
+ {
+ OM.LOG.warn(ex1);
}
-
- throw new CommitException(ex);
- }
- finally
- {
- cleanUp();
- progressMonitor.done();
}
+
+ throw new CommitException(ex);
+ }
+
+ public void commitFinally(IProgressMonitor progressMonitor)
+ {
+ cleanUp();
+ progressMonitor.done();
}
public InternalCDOXASavepoint getLastSavepoint()

Back to the top