从注解处理器应用CGLIB代理 [英] Applying CGLib Proxy from a Annotation Processor

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

问题描述

我有一个工作注解处理器在编译时处理我的​​自定义批注,我想申请一个CGLIB代理申请逻辑的一些使用方法的MethodInterceptor ,我有两件事情独立工作。我无法弄清楚如何从注解处理器应用CGLIB code。

I have a working Annotation Processor that processes my custom annotation at compile time, I want to apply a CGLIB proxy to apply logic to some of the methods using MethodInterceptor, I have the two things working independently. I can't figure out how to apply the CGLIB code from the Annotation Processor.

我想要做的是能注释一类我自定义的注释,并让它自动地添加增强 code我有工作应用了所以我不必手动应用增强 code我的自我。

What I want to do is to be able to Annotate a class with my custom annotation and have it automagically add the Enhancer code I have working applied to it so I don't have to manually apply the Enhancer code my self.

这看起来像是一个完美的使用案例注释处理在编译时。

This seems like the perfect use case for Annotation Processing at compile time.

推荐答案

看一看 http://projectlombok.org

这项目做同样的事情。然而,不幸的是,实施似乎是编译器相关的,因为他们依靠的com.sun。*类。这使得它很难对其他厂商的JVM实现运行。

That project does the same thing. However, unfortunately the implementation seems to be compiler dependent since they rely on com.sun.* classes. This makes it hard to run on JVM implementations of other vendors.

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

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