我为我的应用程序激活了aspectj加载时织入,并添加了一个定义方面的aop.xml文件。我发现我的classpath上的spring-aspects jar也包含一个aop.xml文件,当我配置我的应用程序以aspectjweaver.jar作为java代理启动时,它会被加载。看起来,这个文件是未使用的,当没有织入被激活时,但激活时会增加应用程序的启动时间。这个文件是用来做什么的?
fcwjkofz1#
你说的是this file。引用它的内容,稍微重新格式化:
<?xml version="1.0"?><!-- AspectJ load-time weaving config file to install common Spring aspects. --><aspectj> <!--<weaver options="-showWeaveInfo"/>--> <aspects> <aspect name="org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect"/> <aspect name="org.springframework.scheduling.aspectj.AnnotationAsyncExecutionAspect"/> <aspect name="org.springframework.transaction.aspectj.AnnotationTransactionAspect"/> <aspect name="org.springframework.transaction.aspectj.JtaAnnotationTransactionAspect"/> <aspect name="org.springframework.cache.aspectj.AnnotationCacheAspect"/> <aspect name="org.springframework.cache.aspectj.JCacheCacheAspect"/> </aspects></aspectj>
<?xml version="1.0"?>
<!-- AspectJ load-time weaving config file to install common Spring aspects. -->
<aspectj>
<!--<weaver options="-showWeaveInfo"/>-->
<aspects>
<aspect name="org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect"/>
<aspect name="org.springframework.scheduling.aspectj.AnnotationAsyncExecutionAspect"/>
<aspect name="org.springframework.transaction.aspectj.AnnotationTransactionAspect"/>
<aspect name="org.springframework.transaction.aspectj.JtaAnnotationTransactionAspect"/>
<aspect name="org.springframework.cache.aspectj.AnnotationCacheAspect"/>
<aspect name="org.springframework.cache.aspectj.JCacheCacheAspect"/>
</aspects>
</aspectj>
字符串首先,谈到spring-aspects,你需要了解它使用的是原生的AOP J,而不是基于代理的Spring AOP。用于编织方面的技术称为加载时编织(LTW),即目标类字节码在类加载期间被一个编织代理转换,通常像这样添加到JVM命令行:
spring-aspects
java ... -javaagent:/my/aspectjweaver.jar -javaagent:/my/spring-aspects.jar
型你看,你可以同时使用一个甚至多个代理。这是一个通用的、标准化的JVM机制。ANOJ只是碰巧使用它,就像许多其他Java代理一样。Spring手册中有一章描述了how to use native AspectJ in Spring。一个简短的段落涉及aop.xml,进一步指向相应的AspectJ manual chapter。简而言之:
aop.xml
1条答案
按热度按时间fcwjkofz1#
你说的是this file。引用它的内容,稍微重新格式化:
字符串
首先,谈到
spring-aspects
,你需要了解它使用的是原生的AOP J,而不是基于代理的Spring AOP。用于编织方面的技术称为加载时编织(LTW),即目标类字节码在类加载期间被一个编织代理转换,通常像这样添加到JVM命令行:型
你看,你可以同时使用一个甚至多个代理。这是一个通用的、标准化的JVM机制。ANOJ只是碰巧使用它,就像许多其他Java代理一样。
Spring手册中有一章描述了how to use native AspectJ in Spring。一个简短的段落涉及
aop.xml
,进一步指向相应的AspectJ manual chapter。简而言之:
aop.xml
文件。spring-aspects
自带了自己的aop.xml
文件,它列出了库中当前包含的六个方面。