Hi, I have the following code:
appContext.xml
ExceptionPointcuts.javaCode:<bean id="validation" class="Validation" />
<bean id="genericExceptionAdvice" class="GenericExceptionAdvice">
<property name="order" value="1"/>
</bean>
<bean id="specificExceptionAdvice" class="SpecificExceptionAdvice">
<property name="order" value="0"/>
</bean>
<aop:aspectj-autoproxy/>
GenericExceptionAdvice.javaCode:@Aspect
public class ExceptionPointcuts {
@Pointcut("!execution(* SpecificExceptionAdvice.*(..)) && execution(* *(..))")
public void allMethods() {}
@Pointcut("execution(* Validation.validateSoapMessage(..))")
public void validateSoapMessage() {}
}
SpecificExceptionAdvice .javaCode:@Aspect
public class GenericExceptionAdvice implements Ordered {
private int order;
public int getOrder() {
return this.order;
}
public void setOrder(int order) {
this.order = order;
}
@AfterThrowing(pointcut = "ExceptionPointcuts.allMethods()", throwing = "ex")
public void handleException(Exception ex) throws ServiceException {
throw new ServiceException("Generic Exception Advice", ex,
);
}
}
Now when an exception is thrown in Validation.validateSoapmessage() there are a number of issues which I find perplexingCode:@Aspect
public class SpecificExceptionAdvice implements Ordered {
private int order;
public int getOrder() {
return this.order;
}
public void setOrder(int order) {
this.order = order;
}
@AfterThrowing(pointcut = "ExceptionPointcuts.validateSoapMessage()", throwing = "ex")
public void handleSpecificException(Exception ex) throws ServiceException {
throw new ServiceException("Some specific exception info here", ex
);
}
}
1. GenericExceptionAdvice executes before SpecificExceptionAdvice. When I set the order of SpecificExceptionAdvice to 1 then the method in SpecificExceptionAdvice executes first???
2. When an exception is thrown in SpecificExceptionAdvice it is then caught by GenericExceptionAdvice even though I have specified the pointcut to ignore this Class?

