Announcement Announcement Module
Collapse
No announcement yet.
Pointcut not working for this Spring class Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Pointcut not working for this Spring class

    I would like to trigger method "doSomething" before DELETE operations in DAO, but the method is not invoked with the following pointcut:
    Code:
    <aop:pointcut id="daoDelete" expression="execution(* org.springframework.orm.ibatis.SqlMapClientTemplate.delete(..))"/>
    <aop:before pointcut-ref="daoDelete" method="doSomething"/>
    
    public class XYZDAOImpl extends SqlMapClientDaoSupport implements XYZDAO {
        public int deleteByPrimaryKey(String id) {
    	...
            int rows = getSqlMapClientTemplate().delete("XYZ.deleteByPrimaryKey", key);
            return rows;
        }
    }
    However, if I change the pointcut to that below, it works! But I cannot implement in this way because I have no control on the DELETE method name in DAOs.
    Can someone help me solve this strange problem? Thanks.
    Code:
    <aop:pointcut id="daoDelete" expression="execution(* abc.apps.*.dao.*DAO.*delete*(..))"/>
    Last edited by blueboy; Mar 20th, 2009, 03:21 AM.

  • #2
    Your XYZDAOImpl isn't spring exposed? Why not? Your extending spring support classes. I don't think you should look for the spring pointcut but rather define the pointcut based on "your" spring exposed classes.

    Comment


    • #3
      Originally posted by blueboy View Post
      However, if I change the pointcut to that below, it works! But I cannot implement in this way because I have no control on the DELETE method name in DAOs.
      Can someone help me solve this strange problem? Thanks.
      Spring aop is built on proxies and if the proxied object performs the self-call, aop logic in not applied. Feel free to read more about that at the reference - 6.6.1. Understanding AOP proxies.

      The reference chapter I mentioned suggests two solutions to the problem - refactor the code or tie the code to the spring api. ANother way is to use aspectj weaving.

      Comment

      Working...
      X