你不需要实现Ordered接口。
在Spring AOP中,你可以轻松做事。
@Aspect
@Order(1)
public class AspectA
{
@Before("............")
public void doit() {}
}
@Aspect
@Order(2)
public class AspectB
{
@Before(".............")
public void doit() {}
}
更新:
@Aspect
@Order(1)
public class SpringAspect {
@pointcut("within(com.vanilla.service.MyService+)")
public void businessLogicMethods(){}
@Around("businessLogicMethods()")
public Object profile(ProceedingJoinPoint pjp) throws Throwable {
System.out.println("running Advice #1");
Object output = pjp.proceed();
return output;
}
}
@Aspect
@Order(2)
public class SpringAspect2 {
@pointcut("within(com.vanilla.service.MyService+)")
public void businessLogicMethods(){}
@Around("businessLogicMethods()")
public Object profile(ProceedingJoinPoint pjp) throws Throwable {
System.out.println("running Advice #2");
Object output = pjp.proceed();
return output;
}
}
现在,应用程序上下文配置XML:
<context:annotation-config />
<aop:aspectj-autoproxy />
<bean id="springAspect" class="com.vanilla.aspect.SpringAspect" />
<bean id="springAspect2" class="com.vanilla.aspect.SpringAspect2" />
你需要通过以下方式启用AOP代理:
<aop:aspectj-autoproxy />
否则,将不会激活任何建议。
更新2:
我只是对此问题进行研究。@order
注解仅适用于基于Spring的代理AOP(在我的示例中使用的是)。如果你使用的是编织文件,则应使用声明优先级选项。
更新3
那么你需要将其配置为
<bean id="systemArchitecture" class="x.y.z.SystemArchitecture" />
我在你的代码中看不到它。