You don't need to implement Ordered interface.
In Spring AOP you can do things much easier.
@Aspect
@Order(1)
public class AspectA
{
@Before("............")
public void doit() {}
}
@Aspect
@Order(2)
public class AspectB
{
@Before(".............")
public void doit() {}
}
Update:
@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;
}
}
Now the application Context Configuration XML:
<context:annotation-config />
<aop:aspectj-autoproxy />
<bean id="springAspect" class="com.vanilla.aspect.SpringAspect" />
<bean id="springAspect2" class="com.vanilla.aspect.SpringAspect2" />
You need to enable AOP proxy by:
<aop:aspectj-autoproxy />
otherwise no advice will be activated.
Update 2:
I just make a research on this issue. @order
annotation works only on Spring's based proxy AOP (Which I'm using in my example). Accoridng to documentation if you are using weaving you should use declare precedence option.
Update 3
- I don't see any advices in your code, just aspects and pointcuts.
- If your Advice classes are: x.y.z.SystemArchitecture
then you need to configure it at as
<bean id="systemArchitecture" class="x.y.z.SystemArchitecture" />
and I don't see it in your code.
- "execution (* com.jajah.StorageManager.HomeController.*(..))" what are you targeting on? Can you write it using words?
Anyway. Please drop me a message on facebook and I'll send you working example which does exactly what are you trying to do.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…