Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 203511

Summary: Provide vetoable transaction hooks
Product: [Modeling] EMF Reporter: Eike Stepper <stepper>
Component: cdo.coreAssignee: Eike Stepper <stepper>
Status: CLOSED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: smcduff
Version: 1.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Eike Stepper CLA 2007-09-15 02:37:01 EDT
Provide vetoable transaction hooks to handle:
- adding objects
- modifying objects
- committing transactions
Comment 1 Eike Stepper CLA 2007-09-15 02:39:31 EDT
Added support for the following handler interface:


public interface CDOTransactionHandler
{
  /**
   * 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.
   */
  public void addingObject(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.
   * <p>
   * Note: This method will be called at most once per object until the associated transaction is committed.
   */
  public void modifyingObject(CDOTransaction transaction, CDOObject object);

  /**
   * 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.
   */
  public void committingTransaction(CDOTransaction transaction);
}

Committed to CVS.
Comment 2 Simon Mc Duff CLA 2007-09-15 09:46:18 EDT
This will be very useful!!

Thank you Eike!

Basically I could add my adapter at this point... and I will be notify immediatly after. Right ?

With that mechanism I will be able to react depending of the annotation in the EMF model!

Thank you again!


(In reply to comment #1)
> Added support for the following handler interface:
> public interface CDOTransactionHandler
> {
>   /**
>    * 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.
>    */
>   public void addingObject(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.
>    * <p>
>    * Note: This method will be called at most once per object until the
> associated transaction is committed.
>    */
>   public void modifyingObject(CDOTransaction transaction, CDOObject object);
>   /**
>    * 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.
>    */
>   public void committingTransaction(CDOTransaction transaction);
> }
> Committed to CVS.

Comment 3 Eike Stepper CLA 2007-09-15 12:26:16 EDT
(In reply to comment #2)
> Basically I could add my adapter at this point... and I will be notify
> immediatly after. Right ?

I prefer to call it a handler. It doesn't need to implement emf.comon.notify.Adapter. I tend to call things like it a handler because my IListeners all listen to IEvents. Handlers break this pattern but are a bit more optimized.

And yes, from the point when you've added your handler to a CDOTransaction, it receives the three notifications. I forgot to mention that I broadened the CDOTransaction API itself so that you can ask about current dirty objects and the like...

> With that mechanism I will be able to react depending of the annotation in the
> EMF model!

That should be possible as well:
  InternalEObject eObject = cdoObject.cdoInternalInstance();
  eObject.eClass().getEAnnotations()...
Comment 4 Eike Stepper CLA 2007-10-16 05:22:44 EDT
Fixed in I200710101632.
Comment 5 Nick Boldt CLA 2008-01-28 16:44:35 EST
Move to verified as per bug 206558.
Comment 6 Eike Stepper CLA 2008-06-10 02:29:42 EDT
Reversioned due to graduation
Comment 7 Eike Stepper CLA 2008-09-11 13:48:40 EDT
CLOSING