Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2010-10-11 06:36:24 +0000
committerEike Stepper2010-10-11 06:36:24 +0000
commit51287706ff9bd5f983392816c84a69338cda5db6 (patch)
tree86deb54117f2aadf363549d2328b96e5aa7c67f9
parentc16c4bdd5b39061398ebb0bb6308b213c7047103 (diff)
downloadcdo-51287706ff9bd5f983392816c84a69338cda5db6.tar.gz
cdo-51287706ff9bd5f983392816c84a69338cda5db6.tar.xz
cdo-51287706ff9bd5f983392816c84a69338cda5db6.zip
[327417] Split CDOTransactionHandler in two parts
https://bugs.eclipse.org/bugs/show_bug.cgi?id=327417
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOWatchListView.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/CDOWorkspaceImpl.java4
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOAutoAttacher.java3
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDODefaultTransactionHandler.java32
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDODefaultTransactionHandler1.java49
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDODefaultTransactionHandler2.java46
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOPushTransaction.java26
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOTransaction.java18
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOTransactionHandler.java112
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOTransactionHandler1.java112
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOTransactionHandler2.java41
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOTransactionHandlerBase.java22
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java105
13 files changed, 400 insertions, 175 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOWatchListView.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOWatchListView.java
index afcf591dbb..609418ef7a 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOWatchListView.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOWatchListView.java
@@ -17,13 +17,12 @@ import org.eclipse.emf.cdo.internal.ui.actions.RemoveContainerItemAction;
import org.eclipse.emf.cdo.internal.ui.dnd.CDOObjectDropAdapter;
import org.eclipse.emf.cdo.internal.ui.messages.Messages;
import org.eclipse.emf.cdo.transaction.CDOCommitContext;
-import org.eclipse.emf.cdo.transaction.CDODefaultTransactionHandler;
+import org.eclipse.emf.cdo.transaction.CDODefaultTransactionHandler2;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
import org.eclipse.emf.cdo.view.CDOView;
-
import org.eclipse.net4j.util.container.Container;
import org.eclipse.net4j.util.container.ContainerEvent;
import org.eclipse.net4j.util.container.IContainer;
@@ -338,7 +337,7 @@ public class CDOWatchListView extends ViewPart implements ISelectionProvider
/**
* @author Victor Roldan Betancort
*/
- private final class TransactionHandler extends CDODefaultTransactionHandler
+ private final class TransactionHandler extends CDODefaultTransactionHandler2
{
public TransactionHandler()
{
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 ac51f43385..1f85d57c29 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
@@ -35,7 +35,7 @@ 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.transaction.CDOCommitContext;
-import org.eclipse.emf.cdo.transaction.CDODefaultTransactionHandler;
+import org.eclipse.emf.cdo.transaction.CDODefaultTransactionHandler2;
import org.eclipse.emf.cdo.transaction.CDOMerger;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.util.ReadOnlyException;
@@ -356,7 +356,7 @@ public class CDOWorkspaceImpl implements CDOWorkspace
}
CDOTransaction transaction = (CDOTransaction)view;
- transaction.addTransactionHandler(new CDODefaultTransactionHandler()
+ transaction.addTransactionHandler(new CDODefaultTransactionHandler2()
{
@Override
public void committedTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOAutoAttacher.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOAutoAttacher.java
index 2a81088dc6..9af24abaed 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOAutoAttacher.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOAutoAttacher.java
@@ -25,7 +25,6 @@ import org.eclipse.emf.cdo.common.revision.delta.CDOUnsetFeatureDelta;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.util.CDOUtil;
-
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.spi.cdo.FSMUtil;
@@ -37,7 +36,7 @@ import java.util.List;
* @author Simon McDuff
* @since 2.0
*/
-public class CDOAutoAttacher extends CDODefaultTransactionHandler
+public class CDOAutoAttacher extends CDODefaultTransactionHandler1
{
private CDOTransaction transaction;
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 8db4f8c8a6..02853cc449 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
@@ -4,20 +4,18 @@
* 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.CDOObject;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
-
/**
* @author Eike Stepper
* @since 2.0
*/
-public abstract class CDODefaultTransactionHandler implements CDOTransactionHandler
+public abstract class CDODefaultTransactionHandler extends CDODefaultTransactionHandler1 implements
+ CDOTransactionHandler
{
protected CDODefaultTransactionHandler()
{
@@ -26,30 +24,6 @@ public abstract class CDODefaultTransactionHandler implements CDOTransactionHand
/*
* This implementation does nothing. Clients may override to provide specialized behaviour.
*/
- public void attachingObject(CDOTransaction transaction, CDOObject object)
- {
- // Do nothing
- }
-
- /*
- * This implementation does nothing. Clients may override to provide specialized behaviour.
- */
- public void detachingObject(CDOTransaction transaction, CDOObject object)
- {
- // Do nothing
- }
-
- /*
- * This implementation does nothing. Clients may override to provide specialized behaviour.
- */
- public void modifyingObject(CDOTransaction transaction, CDOObject object, CDOFeatureDelta featureChange)
- {
- // Do nothing
- }
-
- /*
- * This implementation does nothing. Clients may override to provide specialized behaviour.
- */
public void committingTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
{
// 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
new file mode 100644
index 0000000000..13e0402adc
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDODefaultTransactionHandler1.java
@@ -0,0 +1,49 @@
+/**
+ * Copyright (c) 2004 - 2010 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.CDOObject;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
+
+/**
+ * @author Eike Stepper
+ * @since 4.0
+ */
+public abstract class CDODefaultTransactionHandler1 implements CDOTransactionHandler1
+{
+ protected CDODefaultTransactionHandler1()
+ {
+ }
+
+ /*
+ * This implementation does nothing. Clients may override to provide specialized behaviour.
+ */
+ public void attachingObject(CDOTransaction transaction, CDOObject object)
+ {
+ // Do nothing
+ }
+
+ /*
+ * This implementation does nothing. Clients may override to provide specialized behaviour.
+ */
+ public void detachingObject(CDOTransaction transaction, CDOObject object)
+ {
+ // Do nothing
+ }
+
+ /*
+ * This implementation does nothing. Clients may override to provide specialized behaviour.
+ */
+ public void modifyingObject(CDOTransaction transaction, CDOObject object, CDOFeatureDelta featureChange)
+ {
+ // Do nothing
+ }
+}
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
new file mode 100644
index 0000000000..4362272074
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDODefaultTransactionHandler2.java
@@ -0,0 +1,46 @@
+/**
+ * Copyright (c) 2004 - 2010 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;
+
+/**
+ * @author Eike Stepper
+ * @since 4.0
+ */
+public abstract class CDODefaultTransactionHandler2 implements CDOTransactionHandler2
+{
+ protected CDODefaultTransactionHandler2()
+ {
+ }
+
+ /*
+ * This implementation does nothing. Clients may override to provide specialized behaviour.
+ */
+ public void committingTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
+ {
+ // Do nothing
+ }
+
+ /*
+ * This implementation does nothing. Clients may override to provide specialized behaviour.
+ */
+ public void rolledBackTransaction(CDOTransaction transaction)
+ {
+ // Do nothing
+ }
+
+ /*
+ * This implementation does nothing. Clients may override to provide specialized behaviour.
+ */
+ public void committedTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
+ {
+ // Do nothing
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOPushTransaction.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOPushTransaction.java
index f23619e189..fef024a60c 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOPushTransaction.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOPushTransaction.java
@@ -288,7 +288,10 @@ public class CDOPushTransaction extends Notifier implements CDOTransaction
delegate.addObjectHandler(handler);
}
- public void addTransactionHandler(CDOTransactionHandler handler)
+ /**
+ * @since 4.0
+ */
+ public void addTransactionHandler(CDOTransactionHandlerBase handler)
{
delegate.addTransactionHandler(handler);
}
@@ -482,6 +485,22 @@ public class CDOPushTransaction extends Notifier implements CDOTransaction
return delegate.getTransactionHandlers();
}
+ /**
+ * @since 4.0
+ */
+ public CDOTransactionHandler1[] getTransactionHandlers1()
+ {
+ return delegate.getTransactionHandlers1();
+ }
+
+ /**
+ * @since 4.0
+ */
+ public CDOTransactionHandler2[] getTransactionHandlers2()
+ {
+ return delegate.getTransactionHandlers2();
+ }
+
public int getViewID()
{
return delegate.getViewID();
@@ -555,7 +574,10 @@ public class CDOPushTransaction extends Notifier implements CDOTransaction
delegate.removeObjectHandler(handler);
}
- public void removeTransactionHandler(CDOTransactionHandler handler)
+ /**
+ * @since 4.0
+ */
+ public void removeTransactionHandler(CDOTransactionHandlerBase handler)
{
delegate.removeTransactionHandler(handler);
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOTransaction.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOTransaction.java
index b1ba398553..b2609b613c 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOTransaction.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOTransaction.java
@@ -81,14 +81,14 @@ public interface CDOTransaction extends CDOView, CDOUserTransaction, CDOChangeSe
public CDOResource getOrCreateResource(String path);
/**
- * @since 3.0
+ * @since 4.0
*/
- public void addTransactionHandler(CDOTransactionHandler handler);
+ public void addTransactionHandler(CDOTransactionHandlerBase handler);
/**
- * @since 3.0
+ * @since 4.0
*/
- public void removeTransactionHandler(CDOTransactionHandler handler);
+ public void removeTransactionHandler(CDOTransactionHandlerBase handler);
/**
* @since 3.0
@@ -96,6 +96,16 @@ public interface CDOTransaction extends CDOView, CDOUserTransaction, CDOChangeSe
public CDOTransactionHandler[] getTransactionHandlers();
/**
+ * @since 4.0
+ */
+ public CDOTransactionHandler1[] getTransactionHandlers1();
+
+ /**
+ * @since 4.0
+ */
+ public CDOTransactionHandler2[] getTransactionHandlers2();
+
+ /**
* @since 3.0
*/
public CDOSavepoint setSavepoint();
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOTransactionHandler.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOTransactionHandler.java
index 83acb63a7f..e2d8915e6b 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOTransactionHandler.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOTransactionHandler.java
@@ -13,120 +13,10 @@
*/
package org.eclipse.emf.cdo.transaction;
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
-import org.eclipse.emf.cdo.view.CDOView;
-
/**
* @author Eike Stepper
* @since 2.0
*/
-public interface CDOTransactionHandler
+public interface CDOTransactionHandler extends CDOTransactionHandler1, CDOTransactionHandler2
{
- /**
- * Called by a <code>CDOTransaction</code> <b>before</b> an object is added. The implementor of this method is allowed
- * to throw an unchecked exception that will propagate up to the operation that is about to add the object (thereby
- * preventing the operation from successful completion).
- * <p>
- * <b>Note:</b> Implementors <b>must not</b> start threads which access the {@link CDOView view} and wait for their
- * completion since deadlocks can result. The following example causes a deadlock:<br>
- *
- * <pre>
- * getDisplay().syncExec(new Runnable()
- * {
- * public void run()
- * {
- * try
- * {
- * cdoObject.getName();
- * }
- * catch (Exception ignore)
- * {
- * }
- * }
- * });
- * </pre>
- *
- * If you need to synchronously execute threads which access the {@link CDOView view} you should use
- * {@link CDOAsyncTransactionHandler}.
- */
- public void attachingObject(CDOTransaction transaction, CDOObject object);
-
- /**
- * Called by a <code>CDOTransaction</code> <b>before</b> an object is detached. The implementor of this method is
- * allowed to throw an unchecked exception that will propagate up to the operation that is about to remove the object
- * (thereby preventing the operation from completing successfully).
- * <p>
- * <b>Note:</b> Implementors <b>must not</b> start threads which access the {@link CDOView view} and wait for their
- * completion since deadlocks can result. The following example causes a deadlock:<br>
- *
- * <pre>
- * getDisplay().syncExec(new Runnable()
- * {
- * public void run()
- * {
- * try
- * {
- * cdoObject.getName();
- * }
- * catch (Exception ignore)
- * {
- * }
- * }
- * });
- * </pre>
- *
- * If you need to synchronously execute threads which access the {@link CDOView view} you should use
- * {@link CDOAsyncTransactionHandler}.
- */
- public void detachingObject(CDOTransaction transaction, CDOObject object);
-
- /**
- * Called by a <code>CDOTransaction</code> <b>before</b> an object is modified. The implementor of this method is
- * allowed to throw an unchecked exception that will propagate up to the operation that is about to modify the object
- * (thereby preventing the operation from completing successfully).
- * <p>
- * <b>Note:</b> Implementors <b>must not</b> start threads which access the {@link CDOView view} and wait for their
- * completion since deadlocks can result. The following example causes a deadlock:<br>
- *
- * <pre>
- * getDisplay().syncExec(new Runnable()
- * {
- * public void run()
- * {
- * try
- * {
- * cdoObject.getName();
- * }
- * catch (Exception ignore)
- * {
- * }
- * }
- * });
- * </pre>
- *
- * If you need to synchronously execute threads which access the {@link CDOView view} you should use
- * {@link CDOAsyncTransactionHandler}.
- */
- public void modifyingObject(CDOTransaction transaction, CDOObject object, CDOFeatureDelta featureDelta);
-
- /**
- * Called by a <code>CDOTransaction</code> <b>before</b> it is being committed. The implementor of this method is
- * allowed to throw an unchecked exception that will propagate up to the operation that is about to commit the
- * transaction (thereby preventing the operation from completing successfully). The implementor of this method is
- * allowed to apply changes to the object graph managed by the transaction.
- */
- public void committingTransaction(CDOTransaction transaction, CDOCommitContext commitContext);
-
- /**
- * 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.
- */
- public void committedTransaction(CDOTransaction transaction, CDOCommitContext commitContext);
-
- /**
- * Called by a <code>CDOTransaction</code> <b>after</b> it is rolled back. If the implementor of this method throws an
- * exception it will be logged as an error and subsequent handlers will be further called.
- */
- public void rolledBackTransaction(CDOTransaction transaction);
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOTransactionHandler1.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOTransactionHandler1.java
new file mode 100644
index 0000000000..ad60a0cb68
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOTransactionHandler1.java
@@ -0,0 +1,112 @@
+/**
+ * Copyright (c) 2004 - 2010 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
+ * Simon McDuff - bug 201266
+ * Simon McDuff - bug 233314
+ * Simon McDuff - bug 247143
+ */
+package org.eclipse.emf.cdo.transaction;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
+import org.eclipse.emf.cdo.view.CDOView;
+
+/**
+ * @author Eike Stepper
+ * @since 4.0
+ */
+public interface CDOTransactionHandler1 extends CDOTransactionHandlerBase
+{
+ /**
+ * Called by a <code>CDOTransaction</code> <b>before</b> an object is added. The implementor of this method is allowed
+ * to throw an unchecked exception that will propagate up to the operation that is about to add the object (thereby
+ * preventing the operation from successful completion).
+ * <p>
+ * <b>Note:</b> Implementors <b>must not</b> start threads which access the {@link CDOView view} and wait for their
+ * completion since deadlocks can result. The following example causes a deadlock:<br>
+ *
+ * <pre>
+ * getDisplay().syncExec(new Runnable()
+ * {
+ * public void run()
+ * {
+ * try
+ * {
+ * cdoObject.getName();
+ * }
+ * catch (Exception ignore)
+ * {
+ * }
+ * }
+ * });
+ * </pre>
+ *
+ * If you need to synchronously execute threads which access the {@link CDOView view} you should use
+ * {@link CDOAsyncTransactionHandler}.
+ */
+ public void attachingObject(CDOTransaction transaction, CDOObject object);
+
+ /**
+ * Called by a <code>CDOTransaction</code> <b>before</b> an object is detached. The implementor of this method is
+ * allowed to throw an unchecked exception that will propagate up to the operation that is about to remove the object
+ * (thereby preventing the operation from completing successfully).
+ * <p>
+ * <b>Note:</b> Implementors <b>must not</b> start threads which access the {@link CDOView view} and wait for their
+ * completion since deadlocks can result. The following example causes a deadlock:<br>
+ *
+ * <pre>
+ * getDisplay().syncExec(new Runnable()
+ * {
+ * public void run()
+ * {
+ * try
+ * {
+ * cdoObject.getName();
+ * }
+ * catch (Exception ignore)
+ * {
+ * }
+ * }
+ * });
+ * </pre>
+ *
+ * If you need to synchronously execute threads which access the {@link CDOView view} you should use
+ * {@link CDOAsyncTransactionHandler}.
+ */
+ public void detachingObject(CDOTransaction transaction, CDOObject object);
+
+ /**
+ * Called by a <code>CDOTransaction</code> <b>before</b> an object is modified. The implementor of this method is
+ * allowed to throw an unchecked exception that will propagate up to the operation that is about to modify the object
+ * (thereby preventing the operation from completing successfully).
+ * <p>
+ * <b>Note:</b> Implementors <b>must not</b> start threads which access the {@link CDOView view} and wait for their
+ * completion since deadlocks can result. The following example causes a deadlock:<br>
+ *
+ * <pre>
+ * getDisplay().syncExec(new Runnable()
+ * {
+ * public void run()
+ * {
+ * try
+ * {
+ * cdoObject.getName();
+ * }
+ * catch (Exception ignore)
+ * {
+ * }
+ * }
+ * });
+ * </pre>
+ *
+ * If you need to synchronously execute threads which access the {@link CDOView view} you should use
+ * {@link CDOAsyncTransactionHandler}.
+ */
+ public void modifyingObject(CDOTransaction transaction, CDOObject object, CDOFeatureDelta featureDelta);
+}
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
new file mode 100644
index 0000000000..f1dd78ee29
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOTransactionHandler2.java
@@ -0,0 +1,41 @@
+/**
+ * Copyright (c) 2004 - 2010 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
+ * Simon McDuff - bug 201266
+ * Simon McDuff - bug 233314
+ * Simon McDuff - bug 247143
+ */
+package org.eclipse.emf.cdo.transaction;
+
+/**
+ * @author Eike Stepper
+ * @since 4.0
+ */
+public interface CDOTransactionHandler2 extends CDOTransactionHandlerBase
+{
+ /**
+ * Called by a <code>CDOTransaction</code> <b>before</b> it is being committed. The implementor of this method is
+ * allowed to throw an unchecked exception that will propagate up to the operation that is about to commit the
+ * transaction (thereby preventing the operation from completing successfully). The implementor of this method is
+ * allowed to apply changes to the object graph managed by the transaction.
+ */
+ public void committingTransaction(CDOTransaction transaction, CDOCommitContext commitContext);
+
+ /**
+ * 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.
+ */
+ public void committedTransaction(CDOTransaction transaction, CDOCommitContext commitContext);
+
+ /**
+ * Called by a <code>CDOTransaction</code> <b>after</b> it is rolled back. If the implementor of this method throws an
+ * exception it will be logged as an error and subsequent handlers will be further called.
+ */
+ public void rolledBackTransaction(CDOTransaction transaction);
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOTransactionHandlerBase.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOTransactionHandlerBase.java
new file mode 100644
index 0000000000..676266432b
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOTransactionHandlerBase.java
@@ -0,0 +1,22 @@
+/**
+ * Copyright (c) 2004 - 2010 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
+ * Simon McDuff - bug 201266
+ * Simon McDuff - bug 233314
+ * Simon McDuff - bug 247143
+ */
+package org.eclipse.emf.cdo.transaction;
+
+/**
+ * @author Eike Stepper
+ * @since 4.0
+ */
+public interface CDOTransactionHandlerBase
+{
+}
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 82e18d9ec1..a329671f1c 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
@@ -75,13 +75,16 @@ import org.eclipse.emf.cdo.spi.common.revision.PointerCDORevision;
import org.eclipse.emf.cdo.transaction.CDOCommitContext;
import org.eclipse.emf.cdo.transaction.CDOConflictResolver;
import org.eclipse.emf.cdo.transaction.CDOConflictResolver2;
-import org.eclipse.emf.cdo.transaction.CDODefaultTransactionHandler;
+import org.eclipse.emf.cdo.transaction.CDODefaultTransactionHandler1;
import org.eclipse.emf.cdo.transaction.CDOMerger;
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.CDOTransactionHandler1;
+import org.eclipse.emf.cdo.transaction.CDOTransactionHandler2;
+import org.eclipse.emf.cdo.transaction.CDOTransactionHandlerBase;
import org.eclipse.emf.cdo.transaction.CDOTransactionStartedEvent;
import org.eclipse.emf.cdo.transaction.CDOUserSavepoint;
import org.eclipse.emf.cdo.util.CDOURIUtil;
@@ -160,12 +163,21 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_TRANSACTION, CDOTransactionImpl.class);
- private FastList<CDOTransactionHandler> transactionHandlers = new FastList<CDOTransactionHandler>()
+ private FastList<CDOTransactionHandler1> transactionHandlers1 = new FastList<CDOTransactionHandler1>()
{
@Override
- protected CDOTransactionHandler[] newArray(int length)
+ protected CDOTransactionHandler1[] newArray(int length)
{
- return new CDOTransactionHandler[length];
+ return new CDOTransactionHandler1[length];
+ }
+ };
+
+ private FastList<CDOTransactionHandler2> transactionHandlers2 = new FastList<CDOTransactionHandler2>()
+ {
+ @Override
+ protected CDOTransactionHandler2[] newArray(int length)
+ {
+ return new CDOTransactionHandler2[length];
}
};
@@ -259,19 +271,68 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
return super.setBranchPoint(branchPoint);
}
- public void addTransactionHandler(CDOTransactionHandler handler)
+ public void addTransactionHandler(CDOTransactionHandlerBase handler)
{
- transactionHandlers.add(handler);
+ if (handler instanceof CDOTransactionHandler1)
+ {
+ transactionHandlers1.add((CDOTransactionHandler1)handler);
+ }
+
+ if (handler instanceof CDOTransactionHandler2)
+ {
+ transactionHandlers2.add((CDOTransactionHandler2)handler);
+ }
}
- public void removeTransactionHandler(CDOTransactionHandler handler)
+ public void removeTransactionHandler(CDOTransactionHandlerBase handler)
{
- transactionHandlers.remove(handler);
+ if (handler instanceof CDOTransactionHandler1)
+ {
+ transactionHandlers1.remove((CDOTransactionHandler1)handler);
+ }
+
+ if (handler instanceof CDOTransactionHandler2)
+ {
+ transactionHandlers2.remove((CDOTransactionHandler2)handler);
+ }
}
public CDOTransactionHandler[] getTransactionHandlers()
{
- return transactionHandlers.get();
+ Set<CDOTransactionHandler> result = new HashSet<CDOTransactionHandler>();
+ synchronized (transactionHandlers1)
+ {
+ synchronized (transactionHandlers2)
+ {
+ for (CDOTransactionHandler1 handler : transactionHandlers1.get())
+ {
+ if (handler instanceof CDOTransactionHandler)
+ {
+ result.add((CDOTransactionHandler)handler);
+ }
+ }
+
+ for (CDOTransactionHandler2 handler : transactionHandlers2.get())
+ {
+ if (handler instanceof CDOTransactionHandler)
+ {
+ result.add((CDOTransactionHandler)handler);
+ }
+ }
+ }
+ }
+
+ return result.toArray(new CDOTransactionHandler[result.size()]);
+ }
+
+ public CDOTransactionHandler1[] getTransactionHandlers1()
+ {
+ return transactionHandlers1.get();
+ }
+
+ public CDOTransactionHandler2[] getTransactionHandlers2()
+ {
+ return transactionHandlers2.get();
}
@Override
@@ -1194,12 +1255,12 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
*/
public void detachObject(InternalCDOObject object)
{
- CDOTransactionHandler[] handlers = getTransactionHandlers();
+ CDOTransactionHandler1[] handlers = getTransactionHandlers1();
if (handlers != null)
{
for (int i = 0; i < handlers.length; i++)
{
- CDOTransactionHandler handler = handlers[i];
+ CDOTransactionHandler1 handler = handlers[i];
handler.detachingObject(this, object);
}
}
@@ -1328,12 +1389,12 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
fireEvent(new FinishedEvent(CDOTransactionFinishedEvent.Type.ROLLED_BACK, idMappings), listeners);
}
- CDOTransactionHandler[] handlers = getTransactionHandlers();
+ CDOTransactionHandler2[] handlers = getTransactionHandlers2();
if (handlers != null)
{
for (int i = 0; i < handlers.length; i++)
{
- CDOTransactionHandler handler = handlers[i];
+ CDOTransactionHandler2 handler = handlers[i];
try
{
@@ -1405,12 +1466,12 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
registerNewPackage(object.eClass().getEPackage());
- CDOTransactionHandler[] handlers = getTransactionHandlers();
+ CDOTransactionHandler1[] handlers = getTransactionHandlers1();
if (handlers != null)
{
for (int i = 0; i < handlers.length; i++)
{
- CDOTransactionHandler handler = handlers[i];
+ CDOTransactionHandler1 handler = handlers[i];
handler.attachingObject(this, object);
}
}
@@ -1462,12 +1523,12 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
((InternalCDORevisionDelta)revisionDelta).addFeatureDelta(featureDelta);
}
- CDOTransactionHandler[] handlers = getTransactionHandlers();
+ CDOTransactionHandler1[] handlers = getTransactionHandlers1();
if (handlers != null)
{
for (int i = 0; i < handlers.length; i++)
{
- CDOTransactionHandler handler = handlers[i];
+ CDOTransactionHandler1 handler = handlers[i];
handler.modifyingObject(this, object, featureDelta);
}
}
@@ -2204,11 +2265,11 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
TRACER.trace("commit()"); //$NON-NLS-1$
}
- CDOTransactionHandler[] handlers = getTransactionHandlers();
+ CDOTransactionHandler2[] handlers = getTransactionHandlers2();
if (handlers != null)
{
final boolean[] modifiedAgain = { false };
- CDOTransactionHandler modifiedAgainHandler = new CDODefaultTransactionHandler()
+ CDOTransactionHandler1 modifiedAgainHandler = new CDODefaultTransactionHandler1()
{
@Override
public void modifyingObject(CDOTransaction transaction, CDOObject object, CDOFeatureDelta featureChange)
@@ -2224,7 +2285,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
for (int i = 0; i < handlers.length; i++)
{
modifiedAgain[0] = false;
- CDOTransactionHandler handler = handlers[i];
+ CDOTransactionHandler2 handler = handlers[i];
handler.committingTransaction(getTransaction(), this);
if (modifiedAgain[0])
{
@@ -2330,12 +2391,12 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
}
}
- CDOTransactionHandler[] handlers = getTransactionHandlers();
+ CDOTransactionHandler2[] handlers = getTransactionHandlers2();
if (handlers != null)
{
for (int i = 0; i < handlers.length; i++)
{
- CDOTransactionHandler handler = handlers[i];
+ CDOTransactionHandler2 handler = handlers[i];
handler.committedTransaction(transaction, this);
}
}

Back to the top