I am trying to advice spring http message converter but, I can’t get it to work.
@Pointcut("within(org.springframework.http.converter.xml.MarshallingHttpMessageConverter)")
public void converterPointcut() {
}
@Pointcut("execution(* *(..))")
public void converterMethodPointcut() {
}
@Around("converterPointcut() && converterMethodPointcut()")
public Object aroundConverter(ProceedingJoinPoint iJoinPoint) {
Object aProceed = null;
try {
aProceed = iJoinPoint.proceed();
} catch (Throwable anException) {
anException.printStackTrace();
}
return aProceed;
}
Anything wrong here?
a) using
within, you are only advising the Methods of theMarshallingHttpMessageConverterclass, are you sure that’s what you want?b) to weave a library class you need to either set up load time weaving
or run the spring jars through the aspectj compiler (ouch, don’t do that). Do you have load time weaving set up?c) define can’t get it to work: what happens, what doesn’t happen?
Update: I think you are trying to solve the wrong problem. Don’t use AspectJ, just extend the class (none of the methods are final) and register the extended class as
HttpMessageConverter