3.0에 추가된 SpEL의 활용방법은 매우 다양하다. SpEL을 사용하면 기존에 애용되던 ${}와 <context:property-placeholder>를 대체할 수도 있다.

${}로 property place holder를 만들어 두고 프로퍼티 파일을 읽어서 value를 바꿔치기 하는 방법은 환경에 따라서 자주 변하는 DB연결정보와 같은 설정정보를 XML이나 소스코드에서 분리시킬 수 있다는 장점이 있다. SRP에 따르면 responsibility, 즉 변하는 이유가 다르면 분리해야 한다. 설정 정보도 마찬가지다.

${} 방식의 단점은 프로퍼티 파일의 키 값에 ${ prefix와 } suffix를 붙여서 find-and-replace 방식으로 동작한다는 점이다. 매칭되는 키 값이 존재하지 않으면 ${} 부분이 그대로 남을 수 있다. 설정을 빼먹은 것이라면 모르겠지만 오타로 인해서 이름을 잘못 적거나 ${}을 제대로 넣지 않아도 경고 없이 그냥 넘어간다. 내부적으로는 BFPP에 의해서 동작하는 것이므로 ${}을 가진 빈 입장에서는 수동적이다. 남이 변경해주면 고맙고 아니어도 불평을 할 수 없다.

반면에 SpEL을 사용하는 방법은 능동적이다. SpEL로 property-placeholder를 대체하면 BFPP를 사용하지 않아도 된다. <util:properties>를 이용해서 프로퍼티 파일을 Properties 타입의 빈으로 생성하게 하고 다른 빈 오브젝트에 접근할 수 있는 SpEL을 이용해서 원하는 프로퍼티 값을 찾아오게 만들면 된다.

<util:properties id=”dbpr” location=”…” /> 이라고 되어있다면,

<property name=”username” value=”#{dbpr[‘username’]}” /> 으로 만들어주면된다. []는 Map 오브젝트의 get()을 호출해주는 SpEL의 표현이다.

SpEL은 능동적이다. 자기가 필요한 정보를 원하는 프로퍼티 정보를 담은 빈에 가서 직접 찾아오는 것이다. Properties빈이 존재하지 않으면 에러도 발생시켜준다. 물론 Map의 get()이라 키에 해당하는 값이 없어도 그냥 null이 들어간다는 한계는 있다. 수식을 좀 길게 쓰면 null인 경우에 오류가 발생하게 만드는 것도 가능할 것이다.

${}는 기존 설정의 호환성과 익숙한 방식의 집착 때문에라도 앞으로 오랜동안 사용될 것이다. context 스키마에서 직접 지원해주는 기능이기도 하고. 하지만 나는 SpEL을 사용하는 능동적인 방식으로 모두 바꿀 생각이다. 더 명시적이고, 구체적이고, 이해하기 쉽고, 오류도 잘 잡아주는 SpEL 방식이 더 맘에 들기 때문이다.

Related posts:

  1. Spring 3.0 EL (Spel)을 이용한 AssertThrows 확장 (3)
  2. Spring 3.0 EL (Spel)을 이용한 AssertThrows 확장 (2)
  3. Spring Expressions(SpEL)를 이용한 Mockito Argument Matcher 만들기
  4. Spring 3.0 EL (Spel)을 이용한 AssertThrows 확장 (1)
  5. 스프링 컨테이너에는 설정파일이 없다
  6. 톰캣 앞에 아파치 웹 서버(Httpd)를 두어야 할까?
  7. Maven archetype 설정파일 자동생성기 – ArchetypeXmlWriter
  8. 파이썬 완벽 가이드 전자책
  9. Spring 2.0의 XML확장기능 (1)
  10. 스프링 3.1 (7) 프로퍼티 소스 추상화와 PropertySourcePlaceholderConfigurer
  11. Inside Spring (5) PropertyPlaceholderConfigurer를 @Bean으로 정의해서는 안되는 이유
  12. Spring 3.0 (28) R-669 Update
  13. Spring 3.0 (52) 반쪽짜리 3.0 RC1 공개
  14. Spring 3.0 (36) Field Marker와 Field Default
  15. Spring 3.0 (2) R-518 스프링의 새 모듈 OXM(Object/XML Mapping)

Facebook comments:

to “Spring 3.0 (59) 프로퍼티 파일 이용하기 – placeholder vs SpEL”

  1. I can’t get a signal dapoxetine tablets side effects fatigue And he is the co-sponsor of a bill that calls for Congress to have a say on any nuclear deal.

  2. Have you seen any good films recently? buy nizagara sildenafil zentiva In a statement earlier in the day, Cutrale-Safra said it wassubmitting a letter to Chiquita’s board confirming its offerwill be binding through Oct

  3. I’m not interested in football http://xxxxxxx.in.net/ xxx photos
    Jesse James’ marriage proposal to Kat Von D didn’t just come with a promise to be together forever. It also included a 4-carat-plus engagement ring designed by Neil Lane. Unfortunately, the two have since split up … TWICE.

  4. I need to charge up my phone para que es el medicamento valium Which is why the very best Countdown players often have a bizarre, faintly sociopathic taint to them

  5. Not available at the moment cabazitaxel 60mg inj Bankruptcy Judge Kevin Gross approved the debtor-in-possession financing Wednesday over the objection of the company’s unsecured creditors committee, which argued that it came with too many strings and would give Icahn more control over Trump Entertainment’s fate than he already has.

  6. How do I get an outside line? where to buy xpi syntheroid Its main “organic service revenue”, which excludes handset sales and currency movements, fell 0.4%.

  7. I’ve been made redundant zerodol sp drug 25, and the left-wingopposition Syriza party — which wants to cancel a chunk ofGreek debt and austerity measures imposed on the country afteran international bailout — is narrowly ahead in opinion polls.

  8. I’m in a band methocarbamol tablets 750 mg gnc authorities needed to review the other six governments, including Britain and Australia, she said, citing various reasons.

  9. Here are a few of the sites we suggest for our visitors

  10. You produced some decent points there. I looked on the internet for just about any issue and discovered most of the people may perhaps go in conjunction with with your web page.

  11. that is the end of this post. Right here you will find some web pages that we consider youll value, just click the hyperlinks over

  12. The manager http://xxxxxx.in.net/ xxx free There’s also the story of a Michigan Goodwill, which at one point had hired 57 underprivileged kids to work at a local training center over the summer. Yet following a statewide wage hike in 2007, they could only afford to hire less than half that original number.

  13. I was made redundant two months ago viprofina “Existing software has been adapted and enhanced in Dubai with the help of our local strategic partner Emaratech,” explains Captain Khalid Al Falasi, assistant general director of Dubai Immigration.

  14. I’d like a phonecard, please dapoxetine uk price t mobile “We shall have the strange spectacle of two federal judicial establishments within three miles of each other in competition for business,” the senator remarked according to “A History of the United States Court for the Eastern District of New York.”

  15. This site is crazy :) kanzomin injection Donnell’s third came on another 6-yard play, and it capped a 12-yard, 67-play drive that drained 6:17 off the second-quarter clock and sucked energy from the crowd.

  16. What sort of music do you listen to? cetuximab colorectal cancer We need to learn how to say sorry because that will often avoid what can be catastrophic consequences,” he added.

  17. The line’s engaged skinny fox detox scrub reviews Department of Transportation Secretary Anthony Foxx reminds fans to enjoy the festivities responsibly and designate a driver if they intend to drink.

  18. Could you please repeat that? sisu watches facebook He said the current system in the eurozone made it stand out from federal countries like the US, Canada and Germany, where a central government has the ability to transfer significant financial resources to constituent states as-and-when those states run into severe difficulties.

  19. I’d like to open an account http://sextube.in.net/ sextubes When permafrost can’t be avoided, his center designs homes that have adjustable foundation piers and can be moved if local conditions deteriorate. To reduce fossil fuel emissions, the center promotes lower

  20. How many would you like? does prolatis 2.0 work In so many ways, the Giants are the model franchise of New York and New Jersey sports

  21. Have you got any ? valium angry Many wandered along a 15-km (9-mile) former “death strip” where the Wall once stood, and 7,000 illuminated helium balloons were perched 3.6 meters (11.8 feet) high on poles – matching the height of the barrier built in 1961 by Communist East Germany.

  22. I’ve been made redundant buy lovely skin glycolic gel pepe Nowotny said the weaker currency would be positive forinflation, which remains well below the ECB’s 2 percent ceilingat an estimated 0.3 percent in September, fanning fears of adamaging deflation cycle.

  23. I saw your advert in the paper buprenorphine 8 mg price Eurostar, the operator of passenger train services throughthe tunnel between Paris, London and Brussels, said on Twitterits passenger trains would not be running on Saturday and thatall trains halted en route would return to their originalstations.

  24. Could I have an application form? dalacin c suspension precio en mexico “It's relatively flat, but there are still some cliffs in this terrain; there are still boulders

  25. Where did you go to university? dapoxetine tablets price in india ljubljana Dounreay's two experimental reactors – the Dounreay Fast Reactor (DFR), which is housed under the plant's landmark white dome, and the Prototype Fast Reactor (PFR) – are among the facilities which are being cleaned up and dismantled.

  26. one of our visitors a short while ago suggested the following website

  27. check below, are some completely unrelated web-sites to ours, having said that, they are most trustworthy sources that we use

  28. I’d like to apply for this job http://beeg-xxx.in.net/ beeg ass “We are aware that a U.S. citizen has been detained inShanghai. We are in contact with the individual and areproviding all appropriate consular assistance,” U.S. embassyspokesman Nolan Barkhouse said on Tuesday, when asked about theinvolvement of U.S. citizens in the widening probe.

  29. I didn’t go to university sex essentials womensense Brooks says Hall “seemed high and was looking for a date” while walking up and down a Baltimore strip known as a hotspot for sex work.

  30. I came here to work estrace cream lowest price Some see arming Ukraine, and making it a NATO member, as the best way of achieving stability

  31. A financial advisor methocarbamol 500 mg street price florida Swift’s looming figures are even more impressive given the general depression of the music market

  32. good material thanks nemozole generic This outlook along with the possibility the Federal Reserve will raise interest rates in the middle of 2015 make TIPS a sensible choice, bond managers said

  33. Can I take your number? bodytech electrolyte fizz reviews
    Nissan declined to confirm when its next-generation Titanwill go into production, but industry suppliers familiar withthe company’s plans said they expect the new truck to arrivenext year as a 2015 model.

  34. magic story very thanks buy vaso prophin Vancouver Canucks’ Alexandre Burrows(14) collides with Ottawa Senator goaltender Craig Anderson (41) during NHL first period action in Ottawa Sunday, December 7, 2014

  35. Where are you calling from? tongkat ali hair growth
    The pencil skirt is one of the most useful items to have in your wardrobe as it's crazy-flattering and will always have you looking polished to perfection. Shop our pick of classic skirts below and wear yours with a sheer blouse or plain T-shirt for plain librarian turn sassy lady.

  36. A few months what stores sell kratom in ohio (Fisher favours this over Victoria sponge because it is so “forgiving when frozen”, staying fresh but firm instead of developing a texture “of dry toast”)

  37. Insufficient funds organic apoteke detox face mask
    “These cells are most sensitive to blue wavelengths and least sensitive to red wavelengths,” said Prof Nelson “We wanted to see how exposure to these different colour wavelengths affected the hamsters.”

  38. I saw your advert in the paper taking morphine and valium Stamford, Conn.-based hotel brand Starwood Hotels & Resorts Worldwide on Monday began rolling out technology that will let guests bypass the front desk and enter their rooms with a smartphone

  39. Can you hear me OK? broccomax reddit
    But Boxed faces plenty of competition, including the warehouse clubs and retail powerhouse Amazon.com. A delivery service serving Manhattan, Monstersavings.com, already delivers products from Costco and other wholesalers. The minimum order is $250.

  40. Cool site goodluck :) used lmm duramax engine for sale It is amazing that after all these years better tests for both cattle and badgers have not been found.

  41. I enjoy travelling sust deca
    If the Giants played like a team that had little to prove last season and they often seemed that way, routinely shaking off their early season losses until things spiraled out of control they’re aiming to be a hungry squad that has everything to prove in 2013, perhaps even more than that. Safety Antrel Rolle said the defense started laying a foundation for consistency during offseason OTAs and workouts, and, at least defensively, he expects an aggressive unit.

  42. How do you know each other? dapoxetine buy in singapore wmcq Rodriguez confirmed, according to the Herald, reports in the media that he paid fake Florida doctor Anthony Bosch $12,000 a month for steroid cream, edible testosterone “gummies,” and human growth hormone injections; that Bosch coached him on how to beat MLB drug tests; and that the go-between linking Rodriguez to Bosch was A-Rod’s cousin Yuri Sucart.

  43. I love the theatre stimulash fusion beauty Dr Shamez Ladhani, paediatric infectious diseases consultant at Public Health England, said: “It’s crucial that we all remain alert to the signs and symptoms of the disease and seek urgent medical attention if there is any concern.”

  44. International directory enquiries pareri xtrasize
    Dish Chairman Charlie Ergen has previously complained aboutthe rising cost of sports programming. ESPN is the mostexpensive TV network, costing pay TV operators about $5.54 onaverage per subscriber each month, according to research firmSNL Kagan. Disney says it is getting paid for the value ESPNoffers.

  45. I’m a trainee estrace canada pharmacy school The Kaiser analysis found that the premiums for the second lowest cost “silver” tier plan, upon which government tax credit subsidies are based, will fall compared with 2014 prices by an average of 0.8 percent in 7 of 16 major cities.

  46. How many days will it take for the cheque to clear? sildenafil actavis pris
    At least, don’t fan yourself with your hands. Although this will create a rush of air and make you feel temporarily cooler, the vigorous action uses a lot of energy and will raise your body temperature in the long run. If you’re going to fan yourself, use a piece of paper or flexible object with a large surface area to create a fanning movement without putting in much effort yourself.

  47. A company car hairstyles for fine short hair pictures “I was completely down after I got hurt but my knee was the biggest blessing,” Kauppila said

  48. I’d like to change some money sildenafil actavis pris
    “Basically, what we are going to be doing is kidnapping a guy for a couple of hours and beating him up and torturing him and then getting him to give the get,” Rabbi Epstein is quoted as saying during the conversation, according to the complaint.

  49. I’ve come to collect a parcel benzocaine vs lidocaine hair removal Politicians are fighting these elections on a vast range of local and national concerns

  50. Which year are you in? alfuzosin biverkningar
    But understand why the onetime front-runner’s campaign for New York mayor imploded, first as Anthony Weiner stormed into the race, then as Weiner’s fall became Bill de Blasio’s rise, then as Bill Thompson’s late surge even crowded Quinn out of what had seemed a certain spot in a runoff.

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