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
Spring-Business.xml
<aop:config> <aop:aspect ref="businessAspect"> <aop:pointcut id="businessExp" expression="execution(* com.kruders.spring.aop.BusinessImpl*.*(..))" /> <aop:around method="around" 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;
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");
joinPoint.proceed();
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.