"의존관계 주입(DI)은 다양한 형태로 적용할 수 있다. DI의 가장 중요한 개념은 제3자의 도움을 통해서 두 오브젝트 사이의 유연한 관계가 설정되도록 만든다는 것이다. 이 개념을 따르는 DI를 구현하고 적용하는 방법은 매우 다양하다.

일반적으로는 DI는 의존관계에 있는 두 개의 오브젝트와 이 관계를 다이나믹하게 설정해주는 오브젝트 팩토리 (DI컨테이너), 그리고 이를 사용하는 클라이언트라는 4개의 오브젝트 사이에서 일어난다. 하지만 경우에 따라서 원시적인 전략패턴 구조를 따라서 클라이언트가 오브젝트 팩토리의 책임을 함께 가지고 있을 수도 있다. 또는 클라이언트와 전략(의존 오브젝트)이 결합될 수도 있다. 심지어는 클라이언트와 DI관계에 있는 두 개의 오브젝트가 모두 하나의 클래스 안에 담길 수도 있다.

이런 경우에는 DI가 매우 작은 단위의 코드와 메소드 사이에서 일어나기도 한다. 얼핏 보면 DI 같아보이지 않지만 세밀하게 관찰해보면 엄연히 DI가 이루어지고 있다는 것을 알 수 있다. 이렇게 DI의 장점을 단순화 해서 IoC컨테이너의 도움 없이 코드 내에서 적용한 경우를 마이크로 DI라고 부르기도 한다. 또는 코드에 의한 DI라는 의미로 일종의 수동 DI라고 볼 수 있다."

- 3장에서

 

실제로 스프링에는 클라이언트 메소드 내에서 전략을 정의(선택이나 오브젝트 생성이 아니라)하는 DI도 적지 않고, 클라이언트를 컨텍스트와 같은 클래스에 두기도 한다. 아예 전략이 private static class로 정의되어있어서 특정 클라이언트 내부 구현에만 사용되는 경우도 매우 흔하다. DI라고 하면 XML과 컨테이너, 애노테이션과 잘 분리된 클래스를 상상할지 모르겠지만, DI는 사실 평범한 구현 코드 안에서도 매우 영리하게 사용될 수 있는 기법이다.

Related posts:

  1. Dependency Injection 표준화?
  2. JSR-330 Dependency Injection for Java 최종 승인
  3. EJB3의 Dependency Injection
  4. DI의 본질 – 다이나믹 (타입) 언어는 Dependency Injection이 필요없는가?
  5. Dependency Injection의 Dependency란 무엇인가?
  6. Code Organization & Cyclic Dependency Problem
  7. Spring 3.0 (42) Spring Dependency Matrix 업데이트
  8. Spring 3.0 (53) Spring Dependency Matrix 업데이트
  9. Spring 3.0 (7) Spring 3.0 Dependency Matrix
  10. 유쾌한 이슈처리 재촉 메일
  11. DI와 인터페이스
  12. [토스3] 테스트를 위한 필드 주입 유틸
  13. 토비의 스프링 3이 나오기까지 (9)
  14. 스프링에서 테스트란

Facebook comments:

to “마이크로 DI(dependency injection)”

  1. porno begenisi cialis viagra porn porno begenisi cialis viagra porn

  2. Thanks in support of sharing such a pleasant thinking, article is pleasant, thats why i
    have read it completely

  3. Thank you for some other great article. The place else may just anyone
    get that kind of info in such a perfect approach of writing?
    I have a presentation subsequent week, and I am on the look for such information.

  4. porno begenisi cialis viagra porn porno begenisi cialis viagra porn

  5. I will right away grab your rss feed as I can not find your email subscription link or e-newsletter service. Do you have any? Kindly let me know so that I could subscribe. Thanks.

  6. porno begenisi cialis viagra porn porno begenisi cialis viagra porn

  7. Thank you for sharing superb informations. Your web-site is so cool. I am impressed by the details that you’ve on this web site. It reveals how nicely you understand this subject. Bookmarked this website page, will come back for more articles. You, my friend, ROCK! I found simply the information I already searched everywhere and just could not come across. What a great site.

  8. porno begenisi cialis viagra porn porno begenisi cialis viagra porn

  9. Heya i am for the first time here. I came across this board and I to find It truly helpful & it helped me out much. I hope to present one thing again and aid others such as you helped me.

  10. I absolutely love your blog.. Very nice colors & theme.
    Did you create this amazing site yourself? Please reply back as I’m attempting to create my own blog
    and want to learn where you got this from or what the theme is called.

    Cheers!

  11. whoah this weblog is great i really like reading your articles. Keep up the great work! You realize, a lot of individuals are searching round for this info, you can aid them greatly.

  12. F*ckin’ remarkable things here. I am very glad to see your post. Thanks a lot and i am looking forward to contact you. Will you kindly drop me a e-mail?

  13. Thanks for finally writing about > 마이크로 DI(dependency injection)
    » Toby's Epril < Liked it!

  14. Appreciate it for helping out, wonderful info. “If at first you don’t succeed, find out if the loser gets anything.” by Bill Lyon.

  15. What i do not understood is actually how you’re now not really much more well-preferred than you may be now. You’re very intelligent. You recognize thus significantly when it comes to this topic, made me in my view consider it from a lot of numerous angles. Its like women and men don’t seem to be involved unless it’s something to do with Girl gaga! Your own stuffs outstanding. At all times maintain it up!

  16. I think the admin of this web page is truly working hard in support of his
    web page, for the reason that here every data is quality based information.

  17. Wonderful blog! Do you have any helpful hints for aspiring writers? I’m planning to start my own blog soon but I’m a little lost on everything. Would you propose starting with a free platform like WordPress or go for a paid option? There are so many options out there that I’m totally overwhelmed .. Any suggestions? Thanks a lot!

  18. One other important aspect is that if you are a senior, travel insurance with regard to pensioners is something you ought to really look at. The mature you are, a lot more at risk you might be for permitting something awful happen to you while in another country. If you are never covered by several comprehensive insurance policy, you could have several serious difficulties. Thanks for discussing your suggestions on this website.

  19. Very nice post. I just stumbled upon your blog and wanted to say that I have truly enjoyed browsing your blog posts. After all I’ll be subscribing to your feed and I hope you write again very soon!

  20. I cherished as much as you will obtain performed proper here. The cartoon is attractive, your authored material stylish. nonetheless, you command get bought an shakiness over that you would like be turning in the following. ill without a doubt come further previously once more as precisely the similar just about a lot frequently within case you protect this hike.

  21. After research a few of the blog posts in your web site now, and I actually like your method of blogging. I bookmarked it to my bookmark website checklist and will be checking again soon. Pls take a look at my web site as well and let me know what you think.

  22. Simply wish to say your article is as surprising. The clearness in your put up
    is just spectacular and i can suppose you are an expert in this subject.
    Well along with your permission allow me to seize your RSS feed to
    stay up to date with coming near near post. Thanks a million and please carry on the gratifying work.

  23. whoah this weblog is magnificent i like studying your posts. Keep up the great work! You understand, many individuals are looking round for this info, you can aid them greatly.

  24. Hello my family member! I want to say that this post is amazing, great written and include approximately all vital infos. I would like to see more posts like this.

  25. Hello! Quick question that’s entirely off topic. Do you know how to make your site mobile friendly? My website looks weird when viewing from my apple iphone. I’m trying to find a template or plugin that might be able to fix this problem. If you have any recommendations, please share. Cheers!

  26. I dugg some of you post as I cogitated they were invaluable very beneficial

  27. Heya i’m for the first time here. I came across this board and I find It really useful & it helped me out much. I hope to give something back and help others like you aided me.

  28. I’m really inspired together with your writing skills as well as with the format to your blog. Is this a paid topic or did you customize it yourself? Either way keep up the excellent quality writing, it is rare to see a great weblog like this one today..

  29. Keep working ,fantastic job!

  30. Attractive section of content. I just stumbled upon your web site and in accession capital to assert that I get actually enjoyed account your blog posts. Any way I’ll be subscribing to your augment and even I achievement you access consistently quickly.

  31. Remarkable issues here. I am very happy to peer your article.
    Thanks a lot and I’m taking a look ahead to contact you.
    Will you please drop me a e-mail?

  32. Good post. I learn something new and challenging on websites I stumbleupon every day.
    It will always be interesting to read content from other authors and practice something from other web sites.

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