I just started playing with Spring AOP yesterday, so please bare with me. I have a couple questions that I'm sure one the guru's could answer pretty easily.
We have some domain objects that do not implement any interfaces. They are persisted in LDAP and I'd like to implement lazy loading for some of the related data, also in LDAP.
I have developed/configured a test aspect that is triggered by a pointcut on an interface method call, but I have not been able to figure out how to get a regular domain object method call wrapped.
I added the attribute proxy-target-class="true" to the aop:config tag, but it didn't make any difference. I know a method is being called, because I have a log entry made within the call. I do not see the aspect log entry in this case, so I must have something wrong in the config, which looks very much like the following:
Code:
<bean id="domObj" class="com.xyz.domain.TestDomainObject" scope="prototype" />
<aop:config proxy-target-class="true">
<aop:pointcut id="testPointcut"
expression="execution(* com.xyz.domain.TestDomainObject.*(..))" />
<aop:aspect id="testAspect" ref="ldapLazyLoader">
<aop:before pointcut-ref="testPointcut" method="doLogMethodCall" />
</aop:aspect>
</aop:config>
The ldapLazyLoader ref is a normal POJO, without @Aspect annotations. The methods in it only make log entries at this time. I just want to get to the point were the aspect is being executed properly before adding the real code.
I also tried expression="bean(domObj)" for the pointcut, but I'm pretty sure that's not correct and it didn't work.
FYI, the technology in use is:
- tomcat 6.0.14
- spring 2.5.x
- cglib-2.1.3
- aspectjrt and aspectjweaver that comes with spring 2.5.x
So, I have the following questions:
1) what's wrong with my config?
2) do I have to define a bean for each and every object (Interface or regular class - e.g. a domain object) that I want to provide aspect advice to?
3) I tried to see debug info in the log (log4j is in use) for org.aspectj, but I can't seem to get ANY output from those classes during startup or runtime. Should I be able to see startup and/or runtime debug messages from aspectj?
TIA,
Rich