Wednesday, March 4, 2009

Aspect J load Time Weaving

I am able to inject spring container managed beans into Struts action classes using aspect-j load time weaving (without using struts2-springplugin jar ).
Steps

Add the following lines into the spring xml

<context:spring-configured />

<context:annotation-config />

This is for the identification of the annotations inside classes

<context:load-time-weaver aspectj-weaving="on"/>

This is to enable the weaving
2.include @Configurable annotation above the class name

3.Autowire any spring component bean using autowired annotation @Autowired

4.The following jars need be included (both are bundles with spring Dm server)

com.springsource.org.aspectj.weaver &
com.springsource.org.aspectj.runtime
For this to work the container should be having a class loader which is capable of weaving and Spring DM server is capable of it


By adding the above @Configurable tag any class instantiated (either by reflection or by non spring container) can be associated with the beans created by spring container .The byte code injecting into the class happensthrough aspectj load time weaving.


But I am not sure how costly is this process.

No comments:

 
Free Domain Names @ .co.nr!