从注释处理器应用 CGLib 代理 [英] Applying CGLib Proxy from a Annotation Processor
问题描述
我有一个可以在编译时处理自定义注释的工作注释处理器,我想应用 CGLIB 代理以将逻辑应用于使用 MethodInterceptor
的某些方法,我有两件事独立工作.我不知道如何应用注释处理器中的 CGLIB 代码.
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.
我想要做的是能够使用我的自定义注释对类进行注释,并让它自动添加我已经应用到它的 Enhancer
代码,这样我就不必手动应用Enhancer
代码我自己.
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.
推荐答案
那个项目做同样的事情.然而,不幸的是,实现似乎依赖于编译器,因为它们依赖于 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屋!