Announcement Announcement Module
Collapse
No announcement yet.
How to intercept the inherited methods when using spring AOP? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to intercept the inherited methods when using spring AOP?

    I have a class, like
    public Class BaseDao
    {
    public void test()
    {
    system.out.println('Test')
    }
    }

    now I declare an interface and a new class which implements it ,and also this class extends BaseDao,like
    public Interface TestDao
    {
    public void test();
    }

    public class TestDaoImpl implements TestDao extends BaseDao
    {

    }

    My AOP config is below:
    <aop:config>
    <aopointcut id="daoOperation" expression="execution(* com.test..*(..))"/>
    <aop:aspect id="doExceptionCatch" ref="exceptionCatch">
    <aop:before
    pointcut-ref="daoOperation"
    method="doBeforeCatchHibernateException"/>
    </aop:aspect>
    </aop:config>

    I got a problem,I couldn't intercept the mathod test from class TestDaoImpl.
    I think the problem is because method test is inherited from class TestDao,how can i deal with it.

    Thanks!

  • #2
    On execution poincut the signature qualifing type is the type that declared the method so the pointcut

    Code:
    execution(* foo.bar..*.*(..))
    will pick any method execution if the method is declared or overriden in a class contained in the foo.bar package. Inheritance is not enough.


    Cheers
    Last edited by chelu; May 30th, 2013, 08:14 AM.

    Comment

    Working...
    X