AspectJ <aop:after>

After (finally) advice runs however a matched method execution exits. It is declared using <aop:after/> 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

Spring-Business.xml

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

2. Aspect Class

Now write a Aspect which will profile our business method.

BusinessAspect.java

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

3. Output

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

Do Something Here
After method is called


No comments yet.

Leave a Reply