이번주는 스프링과 Groovy/Grails의 공동 컨퍼런스인 SpringOne2GX가 열리는 기간이다. 컨퍼런스 발표와 개발자간의 교류, 각종 파티 등으로 분주하게 보내고 있어야 할 시간이지만 우리의 착실한 유겐은 오늘도 열심히 스프링 3.0 마무리 작업에 애를 쓰고 있는 것 같다. 그러나 RC2 이슈가 줄지는 않고 오히려 새로운 이런 저런 기능을 만들고, 기존에 추가한 기능과 코드를 다듬는 작업을 열심히 하고 있다. 유겐은 자신이 만든 코드를 꾸준히 다듬는다. 테스트 코드도 리팩토링 하고 정리하는 등에도 적지 않은 시간을 투자하는 것 같다. 클린업 밥 삼촌이 보면 좋아할 일이다. 새로운 기능이 꾸준히 깔끔하게 추가되려면 먼저 기존 코드들과 설계와 심지어 테스트 조차 잘 정리가 되 있어야 한다. 그래서 남은 이슈를 빨리 줄이는데보다 이런 저런 코드를 다듬어나가는 데 시간을 들이는 것 같다.

아무튼 어제 올라온 업데이트를 보다가 한가지 눈에 띄는 것 발견. 스프링에서 가장 오래된, 무려 8년이 넘은 인터페이스이자 스프링 IoC/DI의 핵심이라고 할 수 있는 BeanFactory에 새로운 메소드가 추가됐다. 

추가된 메소드는 getBean()이다.

<T> T getBean(Class<T> requiredType) throws BeansException;

이미 여러 개의 getBean()이 있는데 뭘 또 추가한 것일까? 그것도 이 시점에서?

사실 나는 이 메소드가 왜 등장하지 않는지에 대해서 2.5 시절부터 의아해했다. 2.5의 대표적인 추가기능은 바로 @Autowired이다. Fine-grained Type Autowiring이라고도 불리는  @Autowired는 타입을 이용한 자동와이어링 기법을 프로퍼티나 메소드 단위로 세밀하게 지정할 수 있도록 만들어준 것이다. 특별한 경우가 아니고는 한 컨테이너에 올라가는 빈들은 대부분 고유한 타입을 가지고 있다. 즉, 대부분 타입당 하나의 빈이 존재한다. 따라서 관리대상인 오브젝트를 후보로 해서 대입가능한 타입을 추적하면 쉽게 DI할 대상을 찾을 수 있다. 나는 이 방식이 사실상 스프링의 표준 DI방식으로 자리잡고 있다고 생각된다.

그런데 스프링 DI의 가장 기본이 되는 BeanFactory 인터페이스의 메소드에는 이렇게 타입을 가지고 고유한 빈을 찾는 메소드가 존재하지 않았다. 물론 일반적으로는 getBean()을 직접 사용하는 경우가 거의 없겠지만, 그래도 종종 테스트나 학습을 위한 목적으로 AC나 BF를 직접 사용하다보면 항상 아쉬운게 이 것이었다. 왜 getBean()은 다 이름으로만 찾도록 만들었을까.

재밌는 것은 빈의 이름은 타입으로 찾는 기능이 있었다는 사실. BeanFactory에 있는 것은 아니지만 대표적인 BF구현인 DefaultListableBeanFactory(AC가 사용하는게 이 놈이다)에는 getBeanNamesForType(Class)라는 것이 있다. 타입을 주면 그에 해당하는 빈 이름들을 배열로 돌려준다.

아무튼 무슨 생각에서였는지 유겐은 이제야 타입을 가지고 빈 오브젝트를 바로 찾아주는 getBean(Class) 메소드를 추가했다. 개념은 @Autowired랑 같다. 주어진 타입과 일치하는 빈이 하나만 존재하면 그것을 돌려주고, 하나 이상이면 예외를 발생시킨다.

getBean(이름) 시대는 이제 서서히 사라지는 것일지도 모르겠다.

Related posts:

  1. Spring 3.0 (58) Static Class를 XML없이 빈으로 등록하기
  2. Inside Spring (5) PropertyPlaceholderConfigurer를 @Bean으로 정의해서는 안되는 이유
  3. Spring 3.0 (53) Spring Dependency Matrix 업데이트
  4. Spring 3.0 (42) Spring Dependency Matrix 업데이트
  5. Spring 3.0 (35) Spring 3.0 Reference Document 공개
  6. Spring 3.0 (26) Spring Expression Language와 @Value
  7. Spring 3.0 (7) Spring 3.0 Dependency Matrix
  8. 유쾌한 이슈처리 재촉 메일
  9. Spring 3.0 (56) @Bean 사용의 주의사항
  10. Spring 3.0 (38) Spring Reference 업데이트
  11. Spring 3.0 (44) Spring 3.0과 JEE6
  12. Spring 3.0 (4) – Maven에서 Spring 3.0 최신버전 사용하기
  13. InsideSpring (1) Annotated Factory Method (@Configuration)을 쓰는 4가지 방법 (2)
  14. 스프링 빈의 이름은 한글로 지어도 된다
  15. S1A 2008 셋째날 – Spring JavaConfig

Facebook comments:

to “Spring 3.0 (55) getBean(Class) 등장”

  1. It’s an remarkable article for all the internet viewers; they
    will obtain advantage from it I am sure.

  2. This is a great tip especially to those new to the blogosphere.
    Brief but very accurate information… Appreciate
    your sharing this one. A must read article!

  3. Heya i’m for the primary time here. I found this board and I to find It really helpful & it helped me out a lot.

    I’m hoping to present something back and help others like you aided me.

  4. An interesting dialogue is price comment. I feel that it is best to write more on this matter, it might not be a taboo subject but usually people are not enough to talk on such topics. To the next. Cheers

  5. kamagra 100 mg
    No person loves to think about it, but maintaining a present will is a crucial element of guarding your personal funds, in the worst case situation. Unless you currently have a will, then no less than take time to produce and help save documents which cover your main assets. When you put an resource or a relative, you should also enhance your will.
    Cialis lilly
    Stay away from making choices about online payday loans from the placement of fear. You could be in the center of a financial situation. Feel very long, and difficult before you apply for a pay day loan. Bear in mind, you need to pay out it back, in addition interest. Be sure it will be possible to do that, so you do not make a new problems for your self.
    levitra generico
    One of the better points to enhance a properly well balanced diet regime if you are attempting to lose consider is exercising. To start out, try working out thrice a week for approximately 45 minutes at a time. Cardio routines such as running, Zumba, the move mill, leaping rope as well as getting a good stroll will improve your fat burning capacity each day along with advise you regarding weight reduction goals.
    kamagra gel

  6. cialis senza ricetta
    Know the title of the individual you are giving your curriculum vitae to. Don’t to put it simply “to that it might worry”. That demonstrates very lazy pondering. It is way better to contact the organization and ask them who will likely be obtaining your cv. This little touch may be what gets you that interview.
    viagra gĂĽnstig
    Probably the most essential food items that you can place within your body for the your hair are many fruits. Fruits have various valuable nutrients and enhance any dish throughout the day or nighttime. Consume fresh fruits to get a substantial amount of vitamin C, which helps with collagen development for your personal head of hair.
    levitra kokemuksia
    As we discussed, it is easy to earn a considerable amount of dollars by purchasing real-estate. Following all these recommendations, it is possible to purchase professional real estate effectively. You can earn a living, continue investing, or preserve for retirement living. Whichever your decision, it could happen whenever you put money into industrial property.Recommendations Of Other Available Choices Apart from Private Bankruptcy
    viagra gĂĽnstig kaufen

  7. It抯 laborious to search out educated people on this subject, however you sound like you know what you抮e talking about! Thanks

  8. Thank you a bunch for sharing this with all
    of us you actually realize what you’re talking about!
    Bookmarked. Please also seek advice from my site =). We can have a hyperlink
    alternate agreement between us

  9. kamagra prezzo
    Avoid plagiarism without exception. Even though web is substantial, this may not ensure it is okay to rob articles that is certainly authored by other people. Actual fees and penalties are out there for individuals who decide to copy the information of other folks. However you might not be caught, search engines like yahoo will not directory identical content material, offering what you send ineffective anyway. It simply it not operate the risk.
    kamagra gel
    When evaluating games for small children, have a look at the way the characters from the activity work. Is harm to others a significant part of your game? Is there a prize for measures that damage other folks? How frequently does hurting another persona happen? These questions will help you measure the stage and type of violence within a video game.
    kamagra oral jerry
    Seek added help in the event you get behind with your courses. It is definitely very easy to get behind, especially if you had been a great university student in high school graduation who never ever was required to operate that tough. Receive the enable you to require before you begin possessing critical difficulties, and you will do wonderful.
    levitra generika

  10. dapoxetine 60mg kaufen
    Make time to check out the inspector for your possible home. Factors to consider that they are certified, work with a reputable business and when feasible are with an inspector organization that may be non-profit. If not, their accreditations may be supplied by a non-reliable organization that products them for nothing more than a cost.
    Viagra pfizer
    As presently identified, nervousness is often only a standard response to not familiar situation and then there is risk engaged. But extreme or continuous stress and anxiety will not be a typical reaction and it may significantly impair your capability to reside and appreciate your daily life. The advice and methods from the write-up previously mentioned can help you take care of overwhelming anxiousness and return to a happier daily life.The Best Way To Market Your Own Home For A Earnings
    vardenafil kaufen
    Masticating juicers are a great kind of juice machine in case you are searching for which kind of juicer is the ideal decision. Masticating juicers are delicate and then make liquid without having doing damage to or removing important nutrition of the vegetables and fruit. This enables you to the liquid remain clean longer.
    cialis bijsluiter

  11. Spot on with this write-up, I truly think this web site needs much more consideration. I抣l most likely be once more to learn far more, thanks for that info.

  12. levitra schweiz
    To have a fascinating image, play around using the lighting. In the event the normal lighting is not best, do not feel the need to resort to your camera’s flash. Have fun with the dark areas on the scene, or move your subject matter in to the lighting and permit the darkness take away the history powering them. There are numerous approaches to play with light that may at first seem lower than positive but work out effectively eventually.
    Vardenafil Ă–sterreich
    Lookup within your community paper, the courthouse and even other realtor workplaces for home foreclosure entries, or residences that happen to be being sold by HUD for your very best income when buying property. These qualities are sold at a serious lower price to obtain them from the books.
    kamagra suisse
    When it is time and energy to make monthly payments on your a credit card, make sure that you pay out over the lowest sum that you have to pay out. In the event you only pay the little sum needed, it should take you lengthier to spend the money you owe off as well as the fascination will probably be progressively raising.
    priligy goedkoop

  13. Hey there! I understand this is kind of off-topic however I
    had to ask. Does running a well-established blog like yours require a large amount of work?
    I am completely new to writing a blog but I
    do write in my journal on a daily basis. I’d like to start a blog so I can share my experience and thoughts online.
    Please let me know if you have any recommendations or tips for new aspiring blog owners.

    Appreciate it!

  14. First of all I want to say excellent blog!
    I had a quick question which I’d like to ask if you do
    not mind. I was interested to know how you center yourself
    and clear your thoughts before writing. I have had difficulty
    clearing my thoughts in getting my thoughts out. I truly do take pleasure in writing however it just seems like the first 10 to 15 minutes are usually wasted simply just trying to figure out how to begin. Any suggestions or tips?
    Cheers!

  15. Needed to put you a little bit of note so as to give thanks the moment again for the incredible tactics you have shared here. It’s quite incredibly generous of people like you to grant unreservedly what a number of us would’ve offered for sale as an e-book in order to make some bucks for themselves, particularly considering that you could have done it if you decided. These tactics in addition worked like the fantastic way to fully grasp that other people have the identical fervor really like my very own to figure out way more with respect to this matter. I’m certain there are many more enjoyable situations in the future for folks who take a look at your blog post.

  16. WOW just what I was searching for. Came here by searching for coconut oil

  17. I definitely wanted to make a quick word to be able to appreciate you for all the remarkable tactics you are sharing here. My rather long internet research has finally been recognized with reputable insight to write about with my neighbours. I would say that many of us readers are definitely blessed to be in a good website with many outstanding people with good principles. I feel quite happy to have discovered your entire web page and look forward to tons of more pleasurable minutes reading here. Thanks again for a lot of things.

  18. My husband and i have been peaceful that Chris managed to complete his preliminary research via the ideas he gained through the web site. It’s not at all simplistic to just find yourself releasing methods which many people may have been making money from. And we keep in mind we have the blog owner to be grateful to for that. Those explanations you’ve made, the easy website menu, the relationships you help foster – it’s mostly fabulous, and it is making our son and our family understand the theme is fun, and that’s seriously important. Thank you for the whole lot!

  19. What’s up mates, pleasant article and nice arguments commented at this
    place, I am really enjoying by these.

  20. I’m not that much of a internet reader to be honest but your blogs really nice, keep it up!
    I’ll go ahead and bookmark your site to come back in the future.
    All the best

  21. Hey there! I’m at work surfing around your blog from my new iphone!
    Just wanted to say I love reading through
    your blog and look forward to all your posts! Carry on the fantastic work!

  22. The very heart of your writing while appearing agreeable originally, did not work well with me after some time. Somewhere within the paragraphs you were able to make me a believer unfortunately only for a very short while. I however have got a problem with your jumps in logic and one would do well to fill in those gaps. If you can accomplish that, I could certainly be fascinated.

  23. My spouse and i got so excited that Emmanuel managed to conclude his web research from the ideas he gained from your blog. It is now and again perplexing to just happen to be giving for free tips and hints that many some people have been trying to sell. And we also figure out we now have the writer to be grateful to for this. The main explanations you’ve made, the easy blog menu, the friendships you make it possible to create – it’s got most fantastic, and it is leading our son and us do think that subject matter is cool, which is certainly highly vital. Many thanks for the whole thing!

  24. I visit every day some web pages and blogs to read content, however this blog provides quality based posts.

  25. Wonderful blog! I found it while surfing around on Yahoo News. Do you have any suggestions on how to get listed in Yahoo News? I’ve been trying for a while but I never seem to get there! Appreciate it

  26. My spouse and i felt so thankful that Albert could finish off his homework out of the precious recommendations he obtained while using the web page. It’s not at all simplistic to just be making a gift of facts that some other people might have been selling. And we consider we now have the website owner to be grateful to because of that. These explanations you made, the simple site navigation, the relationships you will make it possible to engender – it’s most extraordinary, and it’s really letting our son and our family believe that this subject matter is exciting, and that is very serious. Thank you for the whole thing!

  27. This piece of writing provides clear idea in favor of the new users of blogging,
    that truly how to do blogging and site-building.

  28. Can you tell us more about this? I’d want to find out some additional information.

  29. Thanks for the good writeup. It if truth be told was once a
    leisure account it. Glance advanced to far brought agreeable from you!
    However, how can we communicate?

  30. I’m writing to let you be aware of what a helpful discovery my wife’s princess obtained reading through your site. She realized numerous details, which include how it is like to have a wonderful helping heart to let men and women easily understand some hard to do subject areas. You truly exceeded visitors’ expectations. Thank you for rendering such interesting, trustworthy, informative not to mention cool thoughts on that topic to Mary.

  31. I think other web-site proprietors should take this site as an model, very clean and magnificent user friendly style and design, as well as the content. You are an expert in this topic!

  32. I have to express thanks to the writer for rescuing me from this type of challenge. After looking throughout the world wide web and coming across techniques that were not helpful, I was thinking my entire life was done. Living without the presence of strategies to the issues you’ve solved as a result of your article content is a serious case, as well as the ones that might have in a wrong way affected my entire career if I had not come across the website. The competence and kindness in taking care of the whole lot was very useful. I’m not sure what I would have done if I had not come upon such a subject like this. I’m able to at this moment look forward to my future. Thanks very much for this expert and sensible help. I will not be reluctant to recommend your site to anybody who desires tips about this area.

  33. Hi i am kavin, its my first occasion to commenting anyplace, when i read this piece of writing i thought i could also create comment
    due to this sensible post.

  34. I enjoy you because of your entire hard work on this blog. Gloria really loves participating in internet research and it’s obvious why. Many of us notice all concerning the powerful means you create simple tips and hints via your web blog and therefore encourage contribution from some others on this matter then our own princess is now becoming educated a whole lot. Take advantage of the remaining portion of the new year. Your performing a fabulous job.

  35. 3000mg Amoxicillin A Day Cheap Viagra Without Prescription Cialis Viagra Scaduto Conseguenze Mediche

  36. I used to be suggested this blog via my cousin. I am
    now not certain whether this submit is written through him as no one else recognize such detailed approximately my difficulty.

    You are wonderful! Thank you!

  37. I am commenting to let you be aware of what a amazing encounter my cousin’s child encountered browsing the blog. She figured out so many issues, including how it is like to have a very effective giving style to make many more easily completely grasp chosen complex subject matter. You truly did more than her desires. I appreciate you for churning out the informative, trusted, informative as well as fun thoughts on that topic to Lizeth.

  38. Propecia Liver Side Effects Amoxicillin Standard Dose Viagra Prices Usa cialis Finasteride Cash Delivery Overseas

  39. I as well as my pals happened to be reading the best secrets on your website and so instantly came up with an awful feeling I had not expressed respect to the web blog owner for those strategies. My young men were certainly very interested to see all of them and have now honestly been making the most of those things. Appreciation for simply being considerably considerate and for selecting this form of helpful subject areas most people are really wanting to be informed on. My personal sincere apologies for not expressing gratitude to you sooner.

  40. Thanks so much for providing individuals with an extremely special possiblity to read articles and blog posts from this web site. It is always so pleasing and packed with a lot of fun for me and my office colleagues to search your web site at the least 3 times in one week to study the newest items you have. Of course, I am at all times fulfilled with the special tricks you serve. Certain 3 facts on this page are truly the most effective we’ve had.

  41. Alway reading this blog :) If anyone here is interested in increasing their viewers, can I recommend a really great gig. Find it here- moz da, or just visit https://www.fiverr.com/fastandy/create-300-web-2-contextual-links-df-high-da-low-obl, it’s amazing!

  42. I wanted to put you that bit of note in order to give many thanks once again just for the stunning principles you’ve featured on this site. It’s simply shockingly open-handed with you to convey extensively exactly what most people could have made available for an e book in making some money for their own end, specifically seeing that you might have done it if you desired. Those inspiring ideas in addition served to provide a easy way to be sure that other individuals have a similar dreams like my personal own to understand great deal more when considering this issue. Certainly there are several more pleasant sessions up front for those who read your blog post.

  43. Hi there fantastic website! Does running a blog such as this take a lot
    of work? I have no expertise in coding but I was hoping to
    start my own blog in the near future. Anyways, if
    you have any recommendations or tips for new blog owners please share.
    I know this is off topic but I just had to ask.
    Appreciate it!

  44. I must convey my gratitude for your kindness giving support to persons who really need guidance on this one matter. Your special commitment to getting the message all-around has been definitely informative and has in every case made somebody much like me to reach their desired goals. Your new valuable instruction entails so much to me and even further to my peers. Thank you; from each one of us.

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