기다리던 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. В этом плане Русский Вулкан надежный
    вариант.

  2. В первом случае регистрация
    не обязательна.

  3. Below we discuss the popular real casino games.

  4. Кроме гривны, возможна игра на рубли и доллары.

  5. Ни один раз выигрывал крупную сумму именно на них.

  6. You will make decisions onn yor own hand.

  7. Online Holding Tank For. The truth is we have more.

  8. Я наслаждаюсь вашим сайтом …
    Несмотря на то, что я также имею портал, я все-таки новичок в этой
    теме ;) У вас имеются полезные подсказки для неопытных владельцев веб-ресурсов?

  9. The Age of Industry had to be rescusitated once again. pointed out that health is the flexibility
    of an organism to respond to. To me, obfuscation abounded, and probably intentionally so.

  10. Pretty! This was an incredibly wonderful article. Many thanks for supplying this info.

  11. I used to be suggested this web site via my cousin. I am now not certain whether or not this post is written by him as nobody else realize such
    exact about my problem. You are wonderful! Thanks!

  12. Nevertheless, opponents for this approach claim that care for people with autism is the duty of parents and the duty
    of school systems.

  13. Рады приветствовать Вас в онлайн казино Вулкан!

    Look at my blog; http://petewentz.Ru/ (petewentz.ru)

  14. Have you ever thought about writing an e-book or guest authoring on other websites?
    I have a blog based on the same subjects you discuss and would really like to have you share some stories/information. I know my viewers would
    value your work. If you’re even remotely interested, feel free to shoot
    me an e-mail.

  15. Закинул 50 долларов, пока в плюсе на
    25 долларов.

  16. В этом можно убедиться, зайдя на любой такой слот.

  17. Thank you for some other informative blog. Where else could I get that type of info written in such an ideal way?
    I’ve a undertaking that I am simply now operating on, and I have been on the glance out for such info.

  18. В первом случае регистрация не обязательна.

  19. Человечек-палочка сегодня известен почти всем.

  20. Можем сказать одно – его действия не противозаконны.

  21. The search for online hidden object games endss at !

  22. Curso é primeiro da série Redator de Sucesso”.

  23. Oi.queria descobrir se queima de q48 é só pra homens.

  24. Wonderful website you have here but I was
    wondering if you knew of any message boards that cover the same topics discussed in this article?
    I’d really like to be a part of online community where I can get
    suggestions from other knowledgeable individuals that share the same
    interest. If you have any suggestions, please let
    me know. Appreciate it!

  25. Sim, fórmula negócio acessível funciona.

  26. pokersoda situs kontol

  27. If you’re searching for help with autism in Vegas or for a
    Las Vegas autism Therapist these professionals provide autism treatment, autism therapy, autism counseling, autism help and therapy for autism.
    They comprise autism counselors, autism shrinks, autism
    psychotherapists and autism Therapists. A Therapist might help with
    analysis in the autism spectrum or aspergers in Las Vegas.
    The professionals work with autism in kids or children with autism,
    autism in teenagers or teens with autism and autism in adults or adults with
    autism.

  28. Quality articles or reviews is the crucial to be a focus for the viewers to visit the web page, that’s what this web site is providing.

  29. Asking questions are actually pleasant thing if you
    are not understanding anything totally, however this article offers nice
    understanding yet.

  30. I’m impressed, I have to admit. Rarely do I encounter
    a blog that’s equally educative and interesting, and let me tell
    you, you have hit the nail on the head. The problem is something
    that too few folks are speaking intelligently about.

    I’m very happy I found this in my search for something concerning this.

  31. What’s up all, here every person is sharing
    these know-how, so it’s pleasant to read this weblog, and I used to pay a visit this blog every day.

  32. Fantastic web site. Lots of useful info here.

    I am sending it to a few pals ans additionally sharing in delicious.

    And obviously, thanks for your sweat!

  33. Try substituting the cream with silken tofu.

  34. Beware of using illegal means to download your music.

  35. Yes! Finally something about national forest.

  36. hello!,I like your writing so much! proportion we communicate more about your article on AOL?
    I need a specialist on this space to resolve my problem.
    Maybe that is you! Taking a look forward to look you.

  37. It’s a shame you don’t have a donate button! I’d definitely donate
    to this superb blog! I suppose for now i’ll settle for bookmarking and
    adding your RSS feed to my Google account. I look forward to new updates and will talk about this website
    with my Facebook group. Talk soon!

  38. Hi, this weekend is good in support of me, as this moment i am reading this great educational piece of writing
    here at my residence.

  39. I don’t know whether it’s just me or if perhaps everybody else
    experiencing problems with your site. It looks like some of the text on your content are running off the
    screen. Can somebody else please comment and let me know if this is happening to them
    too? This might be a problem with my browser because I’ve had this happen before.
    Many thanks

  40. What i do not realize is if truth be told how you’re now not really much more
    neatly-preferred than you might be now. You’re so intelligent.

    You recognize thus significantly relating to this topic, made me in my view imagine it from a lot of varied angles.
    Its like men and women aren’t fascinated until it is something
    to accomplish with Girl gaga! Your own stuffs great. At all
    times deal with it up!

  41. Excellent post. I was checking continuously this weblog and I’m inspired!

    Very helpful info specifically the final phase :) I handle such info a lot.
    I used to be seeking this particular info for a long time.
    Thank you and good luck.

  42. Conheça Curso de Maquiagem Profissional.

  43. Hi it’s me, I am also visiting this web site on a regular basis, this web site
    is truly fastidious and the people are in fact
    sharing good thoughts.

  44. Do you mind if I quote a few of your posts as long as I
    provide credit and sources back to your website? My blog is in the very same niche
    as yours and my visitors would genuinely benefit from some of the information you provide here.
    Please let me know if this okay with you. Thanks!

  45. If you would like to take much from this piece of writing then you have to apply these techniques to your won blog.

  46. Hi, I do think this is a great web site. I stumbledupon it ;
    ) I will return once again since i have bookmarked it.
    Money and freedom is the greatest way to change,may you be rich and contine to help other people. http://Herzenlib.ru/bitrix/rk.php?goto=https://Mixmag.com.tr/read/carl-cox-istanbul-news

  47. Greate pieces. Keep posting such kind of info on your blog.

    Im really impressed by your site.
    Hello there, You’ve performed a fantastic job.
    I’ll definitely dkgg it and forr my part recommend to my friends.
    I am sure they’ll be benefited ftom this website. http://0rz.tw/JYGti

  48. Thank you for the auspicious writeup. It in truth used
    to be a leisure account it. Look complicated to more delivered agreeable from
    you! However, how could we be in contact?

  49. Question Number. It’s quick, simple and super fun.

    Also visit my site – как играть в рулетку

  50. The theme of this game is based around guns.

    My page как играть в рулетку (http://www.clubduat.Ru/)

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