rjivan
Jul 5th, 2007, 04:45 PM
I am looking to migrate my code base from Spring 1.2.8 to Spring 2.0..6. I have a couple of hibernate beans that are being injected using DependencyInjectionInterceptorFactoryBean from the spring-sandbox. With 2.0.6 I've read that the recommend approach for domain object injection is via AspectJ. I have followed the following steps get Spring to inject in my domain object.
1. Created aop.xml in the META-INF directory
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE aspectj PUBLIC
"-//AspectJ//DTD//EN" "http://www.eclipse.org/aspectj/dtd/aspectj.dtd">
<aspectj>
<weaver options="-showWeaveInfo -XmessageHandlerClass:org.springframework.aop.aspec tj.AspectJWeaverMessageHandler">
<include within="com.mycompany.domain..*" />
</weaver>
<aspects>
<include within="org.springframework.beans.factory.aspectj.Annotati onBeanConfigurerAspect"/>
</aspects>
</aspectj>
2. Added @Configurable annotation to my domain object
@Configurable
public class Test {
private Long id;
private String name;
private TestDAO testDAO;
//setter and getters
.....
}
3. Added the following entries in applicationContext.xml
<aop:spring-configured/>
<aop:aspectj-autoproxy/>
<bean id="testDAO class="TestDAO">
</bean>
<bean class="Test" scope="prototype">
<property name="testDAO" ref="testDAO"/>
</bean>
4, Added the jvm option -javaagent:c:\tomcat\common\lib\aspectjweaver.jar
What I startup up the application I see that the property testDAO in the class Test is null. What am I missing?
1. Created aop.xml in the META-INF directory
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE aspectj PUBLIC
"-//AspectJ//DTD//EN" "http://www.eclipse.org/aspectj/dtd/aspectj.dtd">
<aspectj>
<weaver options="-showWeaveInfo -XmessageHandlerClass:org.springframework.aop.aspec tj.AspectJWeaverMessageHandler">
<include within="com.mycompany.domain..*" />
</weaver>
<aspects>
<include within="org.springframework.beans.factory.aspectj.Annotati onBeanConfigurerAspect"/>
</aspects>
</aspectj>
2. Added @Configurable annotation to my domain object
@Configurable
public class Test {
private Long id;
private String name;
private TestDAO testDAO;
//setter and getters
.....
}
3. Added the following entries in applicationContext.xml
<aop:spring-configured/>
<aop:aspectj-autoproxy/>
<bean id="testDAO class="TestDAO">
</bean>
<bean class="Test" scope="prototype">
<property name="testDAO" ref="testDAO"/>
</bean>
4, Added the jvm option -javaagent:c:\tomcat\common\lib\aspectjweaver.jar
What I startup up the application I see that the property testDAO in the class Test is null. What am I missing?