Reputation: 10151
The standard example of using Spring AOP for transaction management using the following configuration:
<aop:config>
<aop:pointcut id="myaop" expression="execution(* my.package.*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="myaop" />
</aop:config>
However this requires that AspectJWeaver.jar is on the classpath. Is it possible to write this pointcut without the need for this dependency? I understand that Spring AOP depends on some of the classes from AspectJWeaver, without actually using the load time weaving, but can we use Spring AOP without requiring this jar at all? The documentation doesn't state anywhere that the jar is a required dependency unless you are using specific AspectJ annotations. And the POM file for Spring AOP lists it as an optional dependency.
Upvotes: 1
Views: 324
Reputation: 124581
In essence it is quite simple, don't write an AspectJ pointcut. Which basically boils down to not using the pointcut
tag anymore but by registering non-aspectj pointcuts in your application context.
You could for instance create an instance of the JdkRegexpMethodPointcut
and link that to your registered advisor.
<bean id="myaop" class="org.springframework.aop.support.JdkRegexpMethodPointcut">
<property name="pattern" value=".*get.*" />
</bean>
However I would strongly suggest staying with the AspectJ support it is much more powerful and easier to use then the older implementations. The aspectj classes it uses are for parsing the pointcuts and understanding the AspectJ language.
Upvotes: 2