AspectJ <aop:around>

The final kind of advice is around advice. Around advice runs “around” a matched method execution. It is declared using <aop:around/> 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;
import org.aspectj.lang.ProceedingJoinPoint;
public class BusinessAspect {
    public void around(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("Around method is called");
        System.out.println("Around before is running");
        System.out.println("Around after is running");    

3. Output

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

Around method is called
Around before is running
Do Something Here
Around after is running

No comments yet.

Leave a Reply