保留在CGLIB代理注解? [英] Retain annotations on CGLIB proxies?

查看:583
本文介绍了保留在CGLIB代理注解?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想创建使用AOP框架,它使用CGLIB创建的代理对象的对象。
奇怪的是,强化的代理对象是没有任何注解previous类的了!

Am trying to create an object using an AOP framework which uses CGLIB to create proxy objects. Strangely enough, the "enhanced" proxy object is devoid of ANY annotations the previous class had!

谁能告诉我,我怎样才能使CGLIB保留在它创建?

Can anyone tell me how can I make CGLIB retain the annotations on the proxies it creates?

干杯!
Nirav

Cheers! Nirav

推荐答案

CGLIB创建给定类的子类来生成代理。注释都没有在子类pserved除非注释定义明确指定$ P $。 <一href=\"http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/annotation/Inherited.html\">@Inherited注释用于此目的。

CGLIB creates subclasses of given classes to generate proxies. Annotations are not preserved in subclasses unless explicitly specified in annotation definition. @Inherited annotation is used for this purpose.

您可以在您定义的注释使用此批注,并让他们在子类中访问,如下:

You can use this annotation in the annotations you define, and make them reachable in subclasses, as following:

@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface MyAnnotation {
}

这篇关于保留在CGLIB代理注解?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆