어제 12시쯤에 잠들었는데 3시에 그만 깨고 말았다. 다시 잠들려는 찰라에 부스럭 거리면서 일어나 돌아다니는 기선이 때문에 다시 잠들기회를 놓쳤다. 이런! 잠은 안오고 멀뚱히 있기 뭐해서 이런 저런 일을 하다가 결국 심심해서 4시에 광남이 형과 영회를 깨워서 불러서 함께 놀기 시작했다. 셋째날은 이렇게 일찍 시작 되었다.

모이면 맨날 하는 얘기.. 광남이 형의 OKJSP를 OKSpring으로 바꾸거나, OK Java SPring으로 바꾸자는 것. 이번 기회에 완벽한 스프링빠로 만들어야 할텐데… 만나는 외국 스프링 개발자들마다 OKJSP 사이트를 홍보하며 "JSP 걱정없다 OK!"를 외치는 형의 모습을 보니 OKJSP가 어떻게 한국최고의 자바 커뮤니티로 성장했는지를 알 수 있을 것 같다.

 

일어난지 5시간 만에 아침을 듬뿍 먹고 이제 셋째날 첫째 세션 실시간 포스팅 시작.

JavaConfig은 꽤 오랜동안 milestone 상태로 머물러있는 프로젝트였다. 3.0에는 core에 병합이 된다고 하니 기대할만하다.

  • JavaConfig은 <bean/> 을 @Bean으로 대체하자는 것.
  • Type-safety를 원하고, pure Java(refactorable)로 작업하는 것을 선호한다면 JavaConfig
  • DI container의 full power를 제공한다.

IDE와 XML namespace 등의 도움으로 spring xml config.은 상당히 편해졌다.  하지만 몇가지 문제를 남겼는데..

  • String 기반이라는 문제가 그 대표적인 것이다. String은 리팩토링에 적합하지 않다.
  • XML에서 가져오는 getBean()은 casting의 부담도 있다.

JavaConfig은 Java5+의 장점을 최대한 활용할 수 있고, string에서 벗어나게 해준다. (Generics, @nnotations)

  • <bean ..class="ClassName"> ===> @Bean ClassName method() {…}
  • <bean/>은 @bean에 그대로 매핑될 수 있다.
  • <beans />는 @Configuration으로 대체가능하다. 오호!
    • beans는 class레벨로, bean은 method레벨로 정의할 수 있다.
    • method의 이름이 bean id가 된다.

Bootstrap : JavaConfigApplicationContext

@Configuration

public class AppConfig {

  public @Bean FooService fooService() {

    return new FooService();

}

각종 annotation, component scan, aspect 설정들을 모두 JavaConfig을 통해서 처리하는 것이 가능하다.

XML을 JavaConfig으로 import 할 수도 있다. 점진적으로 JavaConfig으로 변환도 가능하다.

JavaConfig과 XML은 거의 완벽하게 상호변환이 가능하다. JavaConfig이 더 type-safe 하다는 것만 빼고.

앞으로 자체 namespace 지원기능도 추가될 예정이다.

 

여러개의 @Configuration 클래스에 @Bean이 나뉘어 있고, 상호참조를 한다면? 이때는 JavaConfig 자체에 @DI를 적용할 수 있다. 즉 @Autowired로 다른 @Bean설정을 DI해서 사용하는 것이 가능하다. DI의 DI로구만.

이렇게 설정한 JavaConfig은 거의 완벽하게 refactorable하다. 또 IDE를 통해서 navigation하는 것이 매우 편리하다.

@Import를 사용하면 import되는 클래스에는 @Configuration등의 설정이 필요없고, import시키는 쪽 클래스의 설정에 따르게 된다. XML의 import와 개념이 비슷하다.

 

WebApp은 어떻게?

일반적인 접근방법은 web.xml에 listener로 ContextLoaderListener를 정의해서 xml을 로딩한다.

ContextConfig에 옵션을 하나주어서 xml 대신 JavaConfig class를 사용하도록 재정의할 수 있다.

 

JavaConfig의 장점은 xml 작성보다는 IDE의 편리한 지원을 받아 자바코드를 작성하는 것이 더 편리하고 직관적이라는 것이다. 당연히 type-safe하며, 리팩토링이 완벽하게 지원된다는 것이 가장 큰 장점. 또한 DI나 각종 빈의 생성도 자바코드로 원하는 대로 유연하게 작성할 수 있다는 장점도 있다. 또 설정을 모듈화 하기도 편리하고.

단점으로는 아무래도 설정이 많아지면 자바코드가 많아지고 xml보다는 가독성이 좀 떨어질 것이다. 하지만 @autowired, @component 스타일의 스캔을 사용한다면 또 설정자체가 많지 않으니 별 문제가 되지 않을 수도.

이제 본격적으로 xml, annotation, java 세가지 방식의 스프링 설정이 경쟁적으로 사용되어질 때가 된듯 하다. 스프링소스에서 공개한 것은 아니지만, ruby로 설정하는 것도 있다고 하니.. 스프링설정의 유연함은 점점 더 늘어간다. 하지만 best practice와 선택의 고민이라는 문제를 던져주기도 한다. 행복한 고민일 듯.

 

PetClinic을 JavaConfig으로 변환하는 데모를 끝내고 이제 roadmap.

M5가 거의 Spring3.0과 비슷하게 등장. Spring3.0에 JavaConfig의 core가 삽입. Spring 3.0 릴리즈 직후에 1.0GA 릴리즈 목표다. 언제나 목표는 목표, 계획은 계획이니깐. 어쨌든 Spring3.0에 삽입된다는 것이 가장 중요한 결정인듯. 근데 core만 들어간다고 하는데 core가 아닌 것들은 어떻게 구분되는 것일까?

Related posts:

  1. Spring 3.0 (30) R-723 JavaConfig 통합
  2. S1A 2008 넷째날 정리
  3. S1A 2008 둘째날 SpringSecurity 2.5
  4. S1A 2008 둘째날 – Grails
  5. S1A 2008 셋째날 정리
  6. Spring 3.0 (33) JavaConfig의 통합과 변신. 메타-빈(meta-bean) 개념의 등장.
  7. SpringOneAmerica 2008 첫날
  8. S1A 2008 사진모음
  9. SpringOneAmerica 2008 그리고 SpringSource Webinar
  10. S1A 2008 둘째날 정리
  11. Spring 3.0 (1) 프로젝트 구조와 빌드 시스템의 변화
  12. SpringOne 2008 (1) – OSGi
  13. Spring 3.0 (56) @Bean 사용의 주의사항
  14. Spring 3.0 (24) 3.0 M2 공개 이틀전
  15. Spring 3.0 (44) Spring 3.0과 JEE6

Facebook comments:

to “S1A 2008 셋째날 – Spring JavaConfig”

  1. One other issue is when you are in a situation where you do not have a cosigner then you may genuinely wish to try to exhaust all of your educational funding options. You could find many grants or loans and other grants that will supply you with funding to support with education expenses. Many thanks for the post.

  2. Hi, i feel that i noticed you visited my site thus i came to “go back the desire”.I’m attempting to to find issues to enhance my website!I guess its adequate to use some of your ideas!!

  3. Hello! I’ve been reading your website for a long time now and finally got the courage to go ahead and give you a shout out from Dallas Texas! Just wanted to tell you keep up the excellent work!

  4. Hello There. I found your weblog the usage of msn. That is a very smartly written article. I’ll be sure to bookmark it and come back to learn more of your useful info. Thanks for the post. I’ll definitely return.

  5. Dead pent content material , thanks for information .

  6. viagra comprar
    If your business is not really that well known you really should take care about signing oneself up for a long0term lease contract. As time goes on your business may increase along with the home you possess might not be enough for what exactly you need. Developing a long0term rent holds you again for quite a while.
    cialis kopen
    Congrats! You’re possessing a child! Take a number of the puzzle away from effort and shipping and delivery by joining giving birth classes. You can learn about indications of effort and just how the baby really travels through your physique and to your forearms. It’s an excellent chance to request questions you might have and street address any concerns that have been bothering you!
    kamagra svizzera
    If you are paying out for your very own medical insurance, then get anything you are eligible to – such as taxation compose-offs. The United states federal government allows you to subtract any health care costs that tally approximately 7.5% or more of your gross earnings, together with your typical insurance premiums and in many cases some elective remedies like LASIK.
    viagra kaufen rezeptfrei

  7. kamagra 100mg oral jelly
    A great tip for enhancing your storage is that you need to secret the mind. This will be significant if you encourage your self that you just are unable to bear in mind anything then you never ever can. Furthermore should you persuade on your own that you are efficient at recalling, then you remain a far greater possibility of keeping anything to the long lasting memory space.
    Super Kamagra Auf Rechnung
    Are you currently fed up with always being forced to secure up your canine when friends arrive more than? Are you experiencing issues leaving your puppy alone, for a brief go to the food store? Effectively, there are actually points that can be done to help get the obedient canine that you have always wanted to have. The following tips will help you during this process of training your pet dog.
    priligy kaufen
    Give your customers an opportunity to opt-out from receiving your text messages. The structure of the communications ought to quickly include an “prefer-out” set of directions or phrase. You should employ phrases which get the message across that they can escape your messages. Including terms like “UNSUBSCRIBE” and “STOP.”
    kamagra gel australia

  8. Hello just wanted to give you a brief heads up and let you know a few of the pictures aren’t loading correctly. I’m not sure why but I think its a linking issue. I’ve tried it in two different web browsers and both show the same results.

  9. Some genuinely quality content on this internet site , saved to fav.

  10. One other important issue is that if you are a senior citizen, travel insurance regarding pensioners is something you must really contemplate. The elderly you are, the more at risk you will be for allowing something terrible happen to you while abroad. If you are definitely not covered by a number of comprehensive insurance policies, you could have a number of serious issues. Thanks for discussing your suggestions on this blog site.

  11. Hello.This post was really interesting, especially because I was investigating for thoughts on this topic last Sunday.

  12. You are my breathing in, I possess few blogs and sometimes run out from post :) . “He who controls the past commands the future. He who commands the future conquers the past.” by George Orwell.

  13. viagra online uk
    While you are considering property insurance there are actually issues you can do to help with all the charges of your respective premium. Something that you can opt to do is always to create your deductible increased. It will lower your superior however you should remember that more compact things like a broken window may have to be compensated out from bank account on your part.
    cialis generika
    Showcase your writing capabilities and inventive capabilities with a comprehensive, exciting stock portfolio. Even when you are not seeking a profession on paper or marketing and advertising, connection abilities are essential in almost any occupation. Your profile ought to include various written papers, like press announcements, enterprise records, research discoveries and professional summaries. These show that one could get in touch with others in a professional environment and formal circumstance.
    kamagra shop
    If you are purchasing a whole new automobile, you ought to know that this car’s warrantee almost certainly offers providers including towing or covers a leasing car although the one you have requires fixes. When you guarantee covers these features, you should decline them on the insurance plan. If you warrantee expires, make sure you change your insurance policy again.
    cialis hinta

  14. cialis ricetta
    Even though you can attempt home cures for example sleeping with a tennis ball or getting to sleep with a special pillow, it’s best to utilize a CPAP unit. CPAP equipment require you to use a inhaling and exhaling mask while you are in bed to help you receive added fresh air. This makes sure that you simply will not stop inhaling when you are sleeping.
    kamagra danmark
    When composing your picture, take note of the climate. When it is overcast outside, keep the atmosphere from the picture whenever you can. Black and white photographs can also be the ideal choice in order to snap exterior upon an overcast day. When the weather conditions are nice and warm, you will get a great deal of fantastic pictures, make absolutely certain your subject matter isn’t squinting with the sun.
    vardenafil kaufen
    Preferably, this informative article really helped you to definitely understand a few of the ways that specialists produce wonderful glasses and pots of coffee. Utilize them so that you can begin to understand how to make your own espresso far better. Your friends and relations will many thanks. They can also be surprised about your new ability.The Right Cup Of Joe Is Inside Your Reach – Follow These Tips!
    viagra svizzera

  15. Right here is the right web site for anyone who would like to understand this topic. You understand so much its almost hard to argue with you (not that I really would want to…HaHa). You definitely put a fresh spin on a topic that’s been written about for decades. Great stuff, just excellent.

  16. Hello, you used to write excellent, but the last few posts have been kinda boring¡K I miss your great writings. Past few posts are just a little out of track! come on!

  17. Hello.This post was extremely interesting, particularly since I was investigating for thoughts on this subject last week.

  18. I truly appreciate this post. I’ve been looking everywhere for this! Thank goodness I found it on Bing. You have made my day! Thx again!

  19. I’d must examine with you here. Which is not something I often do! I get pleasure from studying a submit that may make folks think. Additionally, thanks for allowing me to comment!

  20. Undeniably imagine that that you stated. Your favorite reason appeared to be on the web the easiest factor to consider of. I say to you, I definitely get irked at the same time as folks consider concerns that they plainly don’t realize about. You managed to hit the nail upon the highest as neatly as defined out the whole thing without having side effect , other people can take a signal. Will likely be again to get more. Thank you

  21. obviously like your web-site however you need to take a look at the spelling on several of your posts. Several of them are rife with spelling issues and I in finding it very troublesome to inform the truth nevertheless I’ll surely come back again.

  22. Thanks a lot for sharing this with all people you really realize what you are speaking approximately! Bookmarked. Kindly also visit my site =). We will have a hyperlink alternate agreement among us!

  23. I blog quite often and I seriously thank you for your content. Your article has truly peaked my interest. I’m going to bookmark your website and keep checking for new information about once a week. I subscribed to your RSS feed too.

Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

© 2017 Toby's Epril Suffusion theme by Sayontan Sinha