기다리던 M2의 최종 릴리즈는 기한을 넘긴채 아직 별 소식이 없다. 마지막 남은 이슈 하나만 해결되면 될 것 같은데 지연되고 있는 것은 혹시 내부에서 M2 발표에 대해서 좀 더 신중을 기하자는 논의가 있는 것이 아닌가 모르겠다. M2까지 진행됐으면서도 아직 레퍼런스 매뉴얼이나 제대로된 샘플조차 제공되지 않고 있는 부분에서 아무래도 마일스톤 버전의 공개가 가지는 효과를 반감시킬 수 있다는 지적이 있을 법도 싶다.

 

Spring Expression Language

레퍼런스 매뉴얼과 충분한 샘플이 없는 상태에서 가장 좋은 학습방법은 바로 테스트코드를 보는 것이다.

3.0에서 추가된 대표적인 기능 중의 하나는 스프링 전용의 expression language(근데 이걸 뭐라 번역하나..)를 지원한다는 것이다. 

처음 EL 소식을 듣고는 view에서 사용할 것도 아니고 구지 EL이 뭐가 필요할까라고 의문을 가졌는데 지난 S1A에서 본 SpringSecurity의 데모를 보고 그 필요성을 알게됐다. 설정의 일부이면서 런타임시 값의 평가(evaluate)가 필요한 영역에 적합한 용도라는 생각이다. 좀 더 사용예를 찾아봐야겠지만, 그런 케이스는 적지 않으리라고 본다.

 

@Value

EL의 특별한 케이스로 @Value 태그가 있다. 2.5에서 등장한 @Autowired와 같은 애노테이션 방식의 DI에서 불편했던 점은 다른 빈의 레퍼런스가 아닌 값(value)을 넣는 것이 불가능하다는 점이었다. 스프링의 설정에서 value라는 것은 단지 int, string 정도의 타입만을 말하지 않는다. PropertyEditor라는 개념을 이용해서 매우 다양한 타입의 오브젝트로 변환이 가능한 것이 스프링의 value 프로퍼티이다.  그래서 2.5에서 설정에서 value를 넣어야 하는 빈이 있을 때는 어쩔 수 없이 XML로 빼내야 하는 번거로움이 있었다.

하지만 3.0에서는 @Value라는 것을 이용해서 값을 직접 넣을 수 있다. 필드(또는 세팃용 메소드)앞에 @Autowired @Value("myvalue…")  형식으로 사용하면 된다.

여기서 단순한 고정값 뿐 아니라 다이나믹한 평가값을 넣을 수 있게 하기 위해서 EL이 등장한다. 예를 들어 다른 빈의 프로퍼티 값을 읽어서 value로 사용하고 싶다면,

@Value("#{otherBean.name}")

과 같은 식으로 사용할 수 있다. 또 시스템의 프로퍼티 값을 읽거나 Scope의 컨텍스트 값을 가져올 수도 있다.

당연히 일반적인 EL의 평가값을 가져오는 것도 가능하다.

@Value("#{1 > 2}")

@Value("#{ ‘[' + myDataSource.driverName + ']‘})

이런 스타일도 가능하다.

 

요즘 3.0으로 실무에 사용될 간단한 애플리케이션을 개발하고 있다. (고객 사이트를 마루타로 -_-) 당장에 value 설정을 위해서 XML에 빈을 직접 넣어야 하는 작업이 없어진 것만으로도 매우 편한 느낌이다.

EL이나 @Value에 대해서 알고 싶으면 스프링소스의 해당 Test코드를 잘 분석해보면 된다. @Value의 사용법을 보고 싶다면 context 모듈의 ApplicationContextExpressionTests클래스를 살펴보기 바란다.

Related posts:

  1. Spring 3.0 (12) Expression 모듈의 선택 라이브러리 분석
  2. Spring Expressions(SpEL)를 이용한 Mockito Argument Matcher 만들기
  3. Spring 3.0 EL (Spel)을 이용한 AssertThrows 확장 (3)
  4. Spring 3.0 EL (Spel)을 이용한 AssertThrows 확장 (2)
  5. Spring 3.0 (10) AOP 모듈의 선택 라이브러리 분석
  6. Spring 3.0 (53) Spring Dependency Matrix 업데이트
  7. Spring 3.0 (42) Spring Dependency Matrix 업데이트
  8. Spring 3.0 (35) Spring 3.0 Reference Document 공개
  9. Spring 3.0 (7) Spring 3.0 Dependency Matrix
  10. 유쾌한 이슈처리 재촉 메일
  11. Spring 3.0 (38) Spring Reference 업데이트
  12. Spring 3.0 (44) Spring 3.0과 JEE6
  13. Spring 3.0 (4) – Maven에서 Spring 3.0 최신버전 사용하기
  14. Spring 3.0 (28) R-669 Update
  15. Spring 3.0 (45) Spring 3.0 M4 버전 추가

Facebook comments:

to “Spring 3.0 (26) Spring Expression Language와 @Value”

  1. I just like the valuable info you provide to your articles.
    I will bookmark your blog and test once more here regularly.
    I’m rather sure I’ll be told many new stuff proper right here!
    Good luck for the next!

  2. Thank you for every other informative web site. The place
    else may just I get that type of information written in such a perfect way?
    I have a undertaking that I’m just now operating on, and I have been on the look out for such information.

  3. Thanks for finally writing about > Spring 3.0 (26) Spring
    Expression Language와 @Value » Toby's Epril < Liked it!

  4. Only wanna remark on few general things, The website layout is perfect, the
    subject matter is really great :D .

  5. This article will assist the internet visitors for creating new blog or even a blog from start to end.

  6. With havin so much content do you ever run into any problems of plagorism or copyright violation? My site has a lot of exclusive content I’ve either created myself or outsourced but it
    seems a lot of it is popping it up all over the web without
    my permission. Do you know any techniques to help reduce content
    from being stolen? I’d truly appreciate it.

  7. Nonton film streaming subtitle Indonesia gratis download online.

  8. Der Artikel ist wirklich gut. Das Thema hat mich schon interessiert und ich konnte hier
    noch einiges ergänzendes finden. Ich bin schon sehr gespannt,
    weitere Neuigkeiten zu lesen. Danke und Grüße aus Heidelberg Marco Feindler

  9. Simply want to say your article is as surprising. The clarity on your submit
    is simply nice and i can think you’re knowledgeable in this subject.

    Well along with your permission let me to clutch your
    RSS feed to stay up to date with forthcoming post.
    Thank you a million and please continue the enjoyable work.

  10. Asking questions are actually nice thing if you are not understanding anything
    completely, except this article gives good understanding
    even.

  11. I do trust all of the ideas you have offered for your post.
    They’re very convincing and will certainly work.
    Nonetheless, the posts are too short for novices.
    Could you please extend them a little from next time?

    Thank you for the post.

  12. whoah this weblog is excellent i love reading your articles.

    Keep up the great work! You already know, a lot of people are looking around
    for this info, you could aid them greatly.

  13. Thank you for any other magnificent post. The place else may
    anybody get that type of info in such a perfect means of writing?

    I have a presentation next week, and I am on the
    search for such info.

  14. Hey I am so grateful I found your site, I really found you by mistake, while I was browsing on Aol for something else,
    Nonetheless I am here now and would just like to say kudos for a tremendous post
    and a all round thrilling blog (I also love the theme/design), I don’t have time to browse
    it all at the moment but I have saved it and also added your RSS feeds, so when I have time I will be back to read a lot more, Please do keep up the awesome b.

  15. Hi there, its fastidious paragraph regarding media print,
    we all be familiar with media is a fantastic source of data.

  16. I was more than happy to discover this website.
    I need to to thank you for ones time for this particularly wonderful read!!
    I definitely liked every bit of it and I have you saved as a favorite to check out new things in your
    blog.

  17. Because the admin of this website is working, no doubt very rapidly it will be well-known,
    due to its feature contents.

  18. It’s in point of fact a great and helpful piece of info. I am happy
    that you simply shared this helpful info with us.
    Please stay us up to date like this. Thank you for sharing.

  19. Why viewers still make use of to read news papers when in this technological world everything is existing on net?

  20. Awesome! Its truly amazing post, I have got much clear idea on the topic of from this piece of writing.

  21. excellent points altogether, you simply received a emblem new reader.
    What may you recommend in regards to your post that you simply made a
    few days ago? Any certain?

  22. It’s not my first time to visit this site, i am visiting this site dailly and obtain good
    information from here all the time.

  23. Nowadays, individuals like to enjoy 3D films having the most up
    to date animation and effects. This is occurring because of hectic lifestyles people have and require some
    type of home entertainment for their leisure. Viewing movies is a good way
    to relax yourself after having a stressful day.
    As number of individuals enjoying flicks
    is expanding frequently much more number of films are being produced.
    Typically, 2 to 3 motion pictures get released at the same time.

    These days the computer animated 3D films remain in excellent
    need and also people like enjoying them.
    Although, 3D movies are called motion pictures for the kids, this is not the
    situation now as lots of grownups as well take
    pleasure in watching these flicks. The majority of the households like enjoying 3D flicks as they are lively and also enjoyable at the same time.
    The animation shown in 3D movies is awesome always as well as individuals just outstanding.
    Actually they make you really feel that the items are
    coming in the direction of you in the flick.

  24. The majority of the households like seeing 3D movies as they are vibrant as well as
    enjoyable at the same time. The animation received 3D films is exhilarating always and people just amazing.
    Actually they make you really feel that the things
    are coming towards you in the flick.

    With the technologies developing regularly, really enjoyable 3D motion pictures are being launched.
    These films bring even more life onto the
    display which makes them feel more alive and also genuine.
    3D films are ending up being much more popular amongst audience as they see something different which is
    absolutely unseen. Aside from this, such films check out numerous opportunities which are both interesting and also thrilling.

    There are no such possibilities that these motion pictures come
    to be flop as they have fascinating characters and also a remarkable story.

    These films just call for good voice as well as photo high
    quality to develop an unique result on the mind of audience.
    3D computer animations present no such problems and also they always are perfect and also individuals enjoy them a lot.
    The manufacturing of 3D motion pictures is very
    pricey as it needs extremely sophisticated software programs,
    advanced workstations as well as obviously the unique effects laboratory.

    As a result, 3D motion pictures form a great for of entertainment for people of every
    ages as well as specifically kids.

  25. It’s a shame you don’t have a donate button! I’d definitely donate to this excellent blog!
    I guess for now i’ll settle for book-marking and adding
    your RSS feed to my Google account. I look forward to brand new updates and will share this website with my Facebook group.
    Talk soon!

  26. Excellent items from you, man. I have take note your
    stuff prior to and you’re just extremely wonderful. I really like what you’ve received right here, really like what you’re saying and the way by which you say it.
    You’re making it enjoyable and you continue to take care of to stay it smart.
    I cant wait to learn much more from you. That is really a tremendous
    site.

  27. If you are going for finest contents like myself, only
    pay a quick visit this web site every day as it
    presents quality contents, thanks

  28. I am regular reader, how are you everybody? This piece of writing posted
    at this web page is truly pleasant.

  29. I go to see daily a few websites and blogs to read articles or reviews,
    except this website offers quality based posts.

  30. Having read this I thought it was extremely enlightening.
    I appreciate you spending some time and effort
    to put this article together. I once again find myself spending a lot of time both reading and leaving comments.
    But so what, it was still worth it!

  31. You ought to take part in a contest for one of the best websites on the web.
    I will recommend this website!

  32. Nice respond in return of this matter with solid arguments and describing all about that.

  33. Wow, wonderful weblog layout! How long have you been running a blog for?
    you made blogging look easy. The overall look of your
    site is excellent, as well as the content!

  34. Yes, we buy houses in AZ for a good worth.

  35. Appreciating the persistence you put into your blog and detailed information you offer.
    It’s nice to come across a blog every once in a while that isn’t the same old rehashed material.
    Fantastic read! I’ve bookmarked your site and I’m adding your RSS feeds to my Google account.

  36. Thanks for finally writing about > Spring 3.0 (26) Spring Expression Language와 @Value » Toby's Epril < Liked it!

  37. Appreciating the time and effort you put into your website
    and detailed information you present. It’s nice to come across a blog every once in a while that isn’t the
    same unwanted rehashed material. Excellent read! I’ve bookmarked your site and I’m including your RSS feeds to my Google account.

  38. Claire (Gina Carano), an ex-military specialist, comes home to the current news of her father’s passing
    only to find little at odds with her defiant 13-year-old son, Charlie (Anton Gillis-Adelman).
    With the news this Claire has inherited a big sum of
    money from her father’s business Charlie is snatched for a ransom.
    Instead of searching for help Claire takes one of several
    kidnappers, Larsen (Brendan Fehr), as a hostage and forces him to lead her on the perilous
    journey to save her son from the secret figure only known as
    the daddy (Richard Dreyfuss). The trek takes Claire deep inside mountains of the Yukon, at the US – Canadian edge as
    a winter storm treatments. As the odds of survival learn to
    mount against Clair this lady has no choice but to form an impossible
    alliance with Larsen to avoid wasting her son and pull
    through the wild of the very good North.

  39. Good day I am so glad I found your blog page,
    I really found you by accident, while I was researching on Digg for something
    else, Anyways I am here now and would just like to say thanks for a fantastic post and a all round interesting
    blog (I also love the theme/design), I don’t have time to read through it all
    at the moment but I have bookmarked it and also included your
    RSS feeds, so when I have time I will be back to read more,
    Please do keep up the excellent b.

  40. I visit day-to-day some web sites and sites to
    read content, except this web site gives quality based posts.

  41. Thanks to my father who informed me regarding this webpage,
    this website is actually remarkable.

  42. Hi there everyone, it’s my first visit at this website, and piece
    of writing is genuinely fruitful for me, keep up posting these articles or reviews.

  43. I do trust all the concepts you have introduced on your post.

    They are very convincing and can certainly work. Nonetheless, the
    posts are very short for beginners. May just you please
    lengthen them a little from next time? Thanks for the post.

  44. Nice weblog right here! Additionally your site a lot up very fast!
    What web host are you the use of? Can I am getting your affiliate link to your host?
    I desire my web site loaded up as fast as yours lol

  45. Thanks for the marvelous posting! I truly enjoyed reading it, you could be a great author.
    I will be sure to bookmark your blog and definitely will come back in the future.
    I want to encourage continue your great work, have a nice day!

  46. I used to be recommended this blog by my cousin. I’m not certain whether this put
    up is written via him as nobody else understand
    such distinct about my difficulty. You are amazing! Thank you!

  47. Unquestionably believe that which you stated. Your favorite justification appeared to be
    on the internet the easiest thing to be aware of.
    I say to you, I certainly get annoyed while people think about worries that they plainly do not know about.
    You managed to hit the nail upon the top as well as defined out the whole thing without having side-effects , people could take
    a signal. Will likely be back to get more. Thanks

  48. I’ve learn a few excellent stuff here. Definitely price bookmarking for revisiting.
    I wonder how much attempt you place to make one of
    these wonderful informative website.

  49. Wow, that’s what I was seeking for, what a data! present here at this
    webpage, thanks admin of this site.

  50. Truly when someone doesn’t know then its
    up to other users that they will assist, so here it
    takes place.

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