얼마전에 전사 프레임워크 라이브러리에 spring2.0을 사용을 해도 된다는 메일을 받았다. 

그날로 바로 관심있던 deendency한 라이브러리(spring-aspects.jar)도 추가로 maven pom.xml에 추가를 하고 몇 가지를 테스트를 해봤다.

The spring-aspects.jar contains an annotation-driven aspect that exploits this capability to allow dependency-injection of any object

spring-aspects는 annotation기반으로 depdency injection이 가능하다.

spring2.0에서 aspect를 이용해서 domain model에 dependency  injection을 하는 방법
http://www.springframework.org/docs/reference/aop.html

Using AspectJ Load-time weaving (LTW) with Spring applications
http://www.springframework.org/docs/reference/aop.html#aop-aj-ltw

<!DOCTYPE aspectj PUBLIC
"-//AspectJ//DTD//EN"
"http://www.eclipse.org/aspectj/dtd/aspectj.dtd">

<aspectj>
<weaver
options="-showWeaveInfo
-XmessageHandlerClass:org.springframework.aop.aspectj.AspectJWeaverMessageHandler">
<include within="com.xyz.myapp..*"/>
</weaver>
</aspectj>

weaving되는 package를 결정을 할수가 있다. /META-INF/aop.xml에 정의를 해서 사용을 하면 된다

A Practical Guide to Using an Aspect Library (part I)
http://www.aspectprogrammer.org/blogs/adrian/2006/02/a_practical_gui_2.html
prototype or singleton?

AOP@Work: Dependency injection with AspectJ and Spring
http://www-128.ibm.com/developerworks/java/library/j-aopwork13.html

Spring, DDD and AspectJ - An Example
http://ryanbreidenbach.blogspot.com/2006/09/spring-ddd-and-aspectj-example.html

덧글이 흥미롭네요. 좋은 예제는 아닌듯...OTL

Configurable API
http://www.springframework.org/docs/api/org/springframework/beans/factory/annotation/Configurable.html

Spring 2.0 AOP - Spruce Up Your Domain Model
http://www.ologist.co.kr/308
예전에 spring2.0 new feature가 나올때 정리한 것

열심히 코드짜고 테스트를 해보다가, weaving에 일단 무릎 꿇다...^^;
runtime시 이 파라미터를 모두 추가하는 것은 지금 일단 시기가 적절치 않다. 그 밖에 품질을 위해서 신경을 써야 할게 더 많다. 일단, 명시적인 코드상의 DI를 하도록 해야겠다.

weaving rumtime VM parameter
-javaagent:lib/aspectjweaver.jar



Posted by ologist
 TAG , ,

블로그 이미지
ologist

공지사항

Yesterday170
Today57
Total33,498

달력

 « |  » 2012.02
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29      

최근에 받은 트랙백

글 보관함