Spring Java Configuration Project

The Spring Java Configuration project is an experiment in producing a Java-based alternative to configuring Spring Application Contexts. While most people currently use XML to configure bean definitions in their Application Contexts, Spring's versatility and metadata based internal handling of bean definitions means alternatives to XML config are easy to implement. Aside from the Java Config, Properties files and Groovy builder support already exists.

http://www.springframework.org/javaconfig


다음과 같은 코드로 spring wire dependencies를 설정을 할 수가 있다.
@Bean(scope = DefaultScopes.SINGLETON)
public Person rod() {
return new Person("Rod Johnson");
}

@Bean(scope = DefaultScopes.PROTOTYPE)
public Book book() {
Book book = new Book("Expert One-on-One J2EE Design and Development");
book.setAuthor(rod()); // rod() method is actually a bean reference !
return book;
}

나같은 경우는 자바코드로 만드는 dependencyn wiring이 더 가독성이 좋아보인다.
또한 이클립스라는 걸출한 툴에 리팩토링기능을 불안해하지 않고, 얼마든지 사용을 할 수가 있다.

물론 Spring IDE를 사용하면 refactoring은 몰라도 rename을 통해서 클래스 이름이 변경이 되면,
에러표시가 나와서 수동으로 수정은 가능하다.
언제나 java로 된 configuration이 좋은 것은 아니지만, 분명한 장점을 인지하고 사용을 한다면 훌륭한 표현방법이 될 것이다.

개인적으로는 자바로 된 표현이 매력적으로 보인다.

http://static.springframework.org/spring-javaconfig/docs/1.0-m2a/reference/html/


Posted by ologist

블로그 이미지
ologist

공지사항

Yesterday191
Today136
Total34,708

달력

 « |  » 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      

최근에 받은 트랙백

글 보관함