Announcement Announcement Module
Collapse
No announcement yet.
Transactional on AspectJ Interceptors Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Transactional on AspectJ Interceptors

    Hi, I wish to define an interceptor which logs requests to a certain table in the database. Currently, my interceptor looks something like:

    Code:
    @Around("execution(public * com.xyz.abc.SomeClass.someMethod*(..))")
    @Transactional(propagation=Propagation.REQUIRED)
    public Object handleRequest(ProceedingJoinPoint pjp) throws Throwable {
    ...
      try {
        basicErrorChecking();
        pjp.proceed();
      } catch (SomeException ex) {
        logExceptionInDatabase(ex);
      }
    ...
    }

    And on the target:

    Code:
    @Transactional(propagation=Propagation.NESTED, rollbackFor=CustomException.class)
    public String someMethod(String a, String b) throws CustomException {
      ...
    }
    I am not sure how to configure this. Simply using the following code:

    Code:
    <aop:aspectj-autoproxy />
    <tx:annotation-driven transaction-manager="transactionManager" order="20"/>
    disregards Transactional attributes in the interceptor.

  • #2
    Take a look at this thread for an example of logging database access:
    http://forum.springframework.org/showthread.php?t=9945

    Comment

    Working...
    X