verystrongjoe
verystrongjoe

Reputation: 3921

I want to use pure aspectJ in Spring framework

I want to change Spring AOP to pure aspectJ in spring framework.

Spring AOP is used like below.

<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>

and I'll change it to pure aspectJ accroding to below url's page

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

  1. spring-aspect.jar is set in classpath.

  2. So I made aop.xml.

<aspectj>
    <weaver>
        <include within="cosmos.*" />
    </weaver>
    <aspects>
        <aspect name="com.sds.testopia.logger.aop.TestopiaAspect" />
    </aspects>
</aspectj>
  1. Next, I can't know very well.. I guess that I will use Load Time Weaver and Log Aspect File have to change .aj foramt using aspect, point-cut keyword and making jar..

I want to get specific and detail explanation. thx.

Upvotes: 2

Views: 797

Answers (1)

Sean Patrick Floyd
Sean Patrick Floyd

Reputation: 299198

AspectJ doesn't work with Spring's XML-style AOP. You need to use either traditional AspectJ (.aj) or the annotation based @AspectJ (.java) format. But you can't create AspectJ aspects using XML (only Spring AOP aspects).

Upvotes: 2

Related Questions