<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd">
<bean id="myBean" class="com.example.MyBean" />
<bean id="myAspect" class="com.example.MyAspect" />
<aop:aspectj-autoproxy />
</beans>
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;
@Aspect
@Component
public class MyAspect {
@Before("execution(public void com.example.MyBean.myMethod())")
public void beforeAdvice() {
}
@After("execution(public void com.example.MyBean.myMethod())")
public void afterAdvice() {
}
@Around("execution(public void com.example.MyBean.myMethod())")
public void aroundAdvice(ProceedingJoinPoint joinPoint) throws Throwable {
joinPoint.proceed();
}
}
public class MyBean {
public void myMethod() {
}
}