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 InterceptorsI 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.