|
From: Stefan K. <st...@kl...> - 2007-01-01 12:55:03
|
Axel, imho this looks great. Maybe you can also open an issue in Jira, so that everyone can vote for it. :) Cheers, -Stefan On 12/28/06, Axel Wienberg <axe...@go...> wrote: > Hi all, > We're using the PropertyPlaceholderConfigurer quite a bit at work, and > I was thinking about ways to handle default values more elegantly. > When a property is not configured by a customer, usually some default > should be used. > The standard spring way seems to be to put a property map inside the > XML configuration file (as in > http://www.kleineikenscheidt.de/stefan/archives/2005/06/default-configuration-with-spring.html), > or to have two properties files, one with the defaults, and one for > customer customization. > However, that means some redundancy: Each placeholder is listed two or > three times, once in the list of defaults, once when it is assigned to > a bean property, and once when it is customized. > What I've come up with is this: > > <bean id="propertyConfigurer" > class="net.wuenschenswert.spring.DefaultPropertyPlaceholderConfigurer"> > <property name="location" value="file:custom/my.properties"/> > </bean> > > <bean id="mybean"> > <property name="cachesize" value="${my.cache.size=100}"/> > </bean> > > If "my.properties" contains a value for my.cache.size, that value is > used, otherwise, the default "100" is assigned. The idea is to have > the default value just where the placeholder and the bean property > are, using a syntax like ${placeholder=defaultvalue}. > > I would love to see this in the springframework proper, I'm just not > sure how to go about submitting it. If you're interested in the > source, please visit > http://www.wuenschenswert.net/wunschdenken/archives/107 > > Regards, > Axel > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer > -- Stefan Kleineikenscheidt tel. +49 (711) 99 33 035 Rosenbergstr. 58 mob. +49 (172) 130 54 77 70176 Stuttgart (GERMANY) st...@kl... |