我想在Spring框架中使用纯aspectJ

时间:2012-01-20 04:40:57

标签: aop aspectj

我想在Spring框架中将Spring AOP更改为纯aspectJ。

使用Spring AOP,如下所示。

<aop:config >
  <aop:pointcut id="testopiaLogging" expression="execution(public * cosmos..*SVC.*(..))"  />
  <aop:aspect ref="testopiaLoggingAspect">
    <aop:after-throwing method="throwError" throwing="exception" pointcut-ref="testopiaLogging"/>
    <aop:after-returning method="log" returning="retVal" pointcut-ref="testopiaLogging"/>
  </aop:aspect>
</aop:config>

我将把它改为纯粹的aspectJ,然后将其改为url的页面

http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/aop.html#aop-using-aspectj

  1. spring-aspect.jar在classpath中设置。

  2. 所以我制作了aop.xml。

  3. <aspectj>
        <weaver>
            <include within="cosmos.*" />
        </weaver>
        <aspects>
            <aspect name="com.sds.testopia.logger.aop.TestopiaAspect" />
        </aspects>
    </aspectj>
    
    1. 接下来,我不太清楚..我想我会使用Load Time Weaver和 Log Aspect File必须使用aspect,point-cut关键字和制作jar来改变.aj foramt。
    2. 我想获得具体和详细的​​解释。 THX。

1 个答案:

答案 0 :(得分:2)

AspectJ不适用于Spring的XML风格的AOP。您需要使用传统的AspectJ(.aj)或基于注释的@AspectJ(。java)格式。但是你不能使用XML创建AspectJ方面(只有Spring AOP方面)。