This is slightly dangerous though, since if the second action throws an
exception or for some reason doesn't execute, you've got a TX left open
(unless of course you're using Cameron's ContainerInterceptor).

-Pat

----- Original Message -----
From: "Jason Carreira" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, July 15, 2003 1:22 PM
Subject: RE: [OS-webwork] WebWork2 Action Chains and Interceptors


Ok, let me try again. Here's the order of execution:

Action1 Interceptors - before

    Action1 - execute

      Result -> ActionChainingResult

         Action2 Interceptors - before

           Action2 - execute

             Result -> JSP

        Action2 Interceptors - after

Action1 Interceptors - after

Now if you have the TransactionInterceptor applied to BOTH Actions, and
the before does basically this:

if (getThreadLocalTransaction() == null) {

   Transaction tx = ....
   setThreadLocalTransaction(tx);

} else {

   commitTransaction();
   Transaction tx = ....
   setThreadLocalTransaction(tx);

}

and the after does this:

if (getThreadLocalTransaction() != null) {

   commitTransaction();

}

protected void commitTransaction() {

   getThreadLocalTransaction().commit();
   setThreadLocalTransaction(null);

}

then you should get the behavior you want.

Action1 Interceptors - before will create a transaction

Action2 Interceptors - before will commit the outside transaction and
create a new one

Action2 Interceptors - after will commit the second transaction

Action1 Interceptors - after will do nothing

You could break this into 2 Interceptors if you want, or parameterize
the TransactionInterceptor for different behavior (commit outer
transaction? ignore outer transaction? etc)

Jason

-----Original Message-----
From: Cameron Braid [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 15, 2003 4:02 PM
To: [EMAIL PROTECTED]
Subject: RE: [OS-webwork] WebWork2 Action Chains and
Interceptors


I am using a threadlocal for both the session and transaction
objects.

The issue - which you seem to have missed - is that the chained
FROM action's interceptors are executed around the chained TO action.

This happens because the chain is implemented as a result which
is a part of the chained FROM action's invocation.

I will just adopt object orientation once again .. how about
that eh !  and use a superclass to implement the transaction container.




-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork

Reply via email to