且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Spring 和 Java EE 的结合

更新时间:2023-12-04 11:35:40

直接使用 AspectJ 而不是 Spring 对它的特定支持它应该可以正常工作,这允许开发在 Spring 和 Java EE 中都可以工作的方面.

Using AspectJ directly and not the spring specific support for it it should work OK, this allows to develop aspects that work both in Spring and Java EE.

可以通过三种方式将 AspectJ 方面编织到代码中:

There are three ways to weave the AspectJ aspects into the code:

  • 编译时编织,意味着我们需要有代码

  • compile time weaving, meaning we need to have the code

字节码编织可以用于没有可用代码的第三方 jar

byte code weaving can be used for third party jars for which no code is available

加载时间编织(不是spring 特定支持)可用于在类加载时编织方面,这可能更具侵入性,因为它需要 JVM 范围的代理,并访问服务器启动脚本.

load time weaving (not the spring specific support) can be used to weave the aspects at class loading time, this can be more invasive as it requires a JVM wide agent, and access to the server startup script.

spring支持 LTW 允许以更方便的方式使用 LTW,但它仅适用于 Spring 应用程序,与上面的 LTW 通用机制不同.

The spring support for LTW allows to use LTW in a more convenient way but it only works for spring applications, unlike the LTW general mechanism above.

所以如果直接使用 LTW 太麻烦,字节码编织和编译时编织仍然是有效的选择,尽管会影响构建过程.

So if using LTW directly is too cumbersome, byte code weaving and compile time weaving are still valid options, although with impact on the build process.