AspectJ <aop:after-returning>

After returning advice runs when a matched method execution returns normally. It is declared using <aop:after-returning/> tag.

For sample code in details, refer the following link. Click Here

1. Configure Spring AOP

Create Spring-Business.xml and write the following code


    <aop:aspect ref="businessAspect">
        <aop:pointcut id="businessExp"
            expression="execution(* com.kruders.spring.aop.BusinessImpl*.*(..))" />

2. Aspect Class

Now write a Aspect which will profile our business method.

package com.kruders.spring.aspect;
public class BusinessAspect {
    public void afterReturning() {
        System.out.println("After returning method is called");

3. Output

When you run the above example you’ll get an output like:

Do Something Here
After returning method is called

No comments yet.

Leave a Reply