Re: [aspectwerkz-user] Query About Tansaction Aspect

Mattias J <[email protected]>
Newsgroups gmane.comp.java.aspectwerkz.user
Message-ID <6.2.1.2.0.20050404165016.055191b8@bar>
I have created an aspect for JTA transactions, and I chose to use an around 
advice with catch and finally.
Basically
       try {
         tx.begin();
         return joinPoint.proceed();
       }
       catch(Throwable t) { // (We rollback on all errors, not only 
SQLExceptions)
         tx.setRollbackOnly();
         throw t;
       }
       finally {
         if(userTransaction.getStatus() == Status.STATUS_MARKED_ROLLBACK) {
           tx.rollback();
         }
         else {
           tx.commit();
         }
       }
     }

There is an explanation of the difference between call() and execution() in 
the archives (should be in the FAQ!).
Basically call() modifies the bytecode calling the adviced method while 
execution() modifies the bytecode of the method itself.
AFAIK execution() is the normal procedure if the adviced method is your own 
code and call() is for putting advice on third party APIs.

At 2005-04-04 11:28, you wrote:
>hi all,
>
>i have a developed transaction aspect with the following methodology
>
>
>i constructed a Aspect Class with three methods  described below :
>
>1. beforeTransaction
>                    ---- which will do con.setAutoCommit(false)
>      Pointcut expression is call(some method which will executes batch
>of SQL queries)
>      Advice is type is before
>
>2. After Transaction
>                   ---- which will do con.commit();
>     Pointcut expression is call(some method which will executes batch
>of SQL queries)
>     Advice is type is After
>
>3. AfterThrowingTransaction
>                   ---- which will do con.rollback()
>     Pointcut expression is call(some method which will executes batch
>of SQL queries)
>     Advice is type is After throwing(java.sql.SQLException+)
>
>is this the right way to do transaction and which expression in have
>use( call or execution ) in pointcut.
>
>with regards
>ravi
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.