<dependency>
<groupId>com.nepxion</groupId>
<artifactId>matrix-aop-starter</artifactId>
<version>X.X.X</version>
</dependency>
<bean id="myAspect" class="com.example.MyAspect"/>
<bean id="myService" class="com.example.MyService">
<property name="aspect" ref="myAspect"/>
</bean>
<aop:config>
<aop:aspect ref="myAspect">
<aop:pointcut id="myPointcut" expression="execution(* com.example.MyService.*(..))"/>
<aop:around method="around" pointcut-ref="myPointcut"/>
</aop:aspect>
</aop:config>
public class MyAspect {
public void before(JoinPoint joinPoint) {
}
public void afterReturning(JoinPoint joinPoint, Object result) {
}
public void afterThrowing(JoinPoint joinPoint, Throwable throwable) {
}
public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
Object result = joinPoint.proceed();
return result;
}
}
public class Main {
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("spring-context.xml");
MyService myService = (MyService) context.getBean("myService");
myService.doSomething();
}
}