PDA

View Full Version : Advised classes loose their @annotations?



memelet
May 22nd, 2005, 11:27 AM
I am advising a class with an introduction. That class contains @annotated methods. The subclass created by cglib adds the introduction correctly, but all the annotations on the methods from the advised class are lost. All the annotations have @Inhertited declared.

Is this a known issue with cglib subclasses?

memelet
May 22nd, 2005, 11:58 AM
Since I have beans that are being advised and also exported as mbeans -- and that works -- I decided to look at AbstractMBeanInfoAssembler. Appearently, it makes an explicit check to see if the class has cglib-proxied:



protected Class getClassToExpose(Object managedBean) {
if (AopUtils.isCglibProxy(managedBean)) {
return managedBean.getClass().getSuperclass();
}
return managedBean.getClass();
}


But I'm still not sure if the reason was because the method annotations are stripped from the cglib-proxied subclass. If so, I'm in trouble, because the method I'm trying to introduce defines an annotation that needs to processed at runtime. Therefore I cannot simply upcast like the snippet above (ie, I need to see the methods on the subclass as well).