Saturday, December 09, 2006

Hidden Gems Notes

"classpath:" vs "classpath*:"
In the first, it gets the first classpath root only.
The second will check all classpath roots.

Both support patterns
"classpath:mypackage/*.xml"
"classpath*:mypackage/*.xml"
I will probably avoid the wild card pattern bit because of my preference for explicit definitions. Still, good stuff for parallel classpaths and resource roots.
---

Advanced Resource Bundles


ResourceBundleMessageSource: uses java.util.ResourceBundle, can load from multiple bundle basenames, can handle message arguments via java.text.MessageFormat
ReloadableResourceBundleMessageSource, think resource bundles that can be reloaded at runtime. woohoo! has configurable caching and refresh.
Sample definition:

<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="classpath:myBundle1,classpath:myBundle2" />
<property name="cacheSeconds" value="1" />
<property name="defaultEncoding" value="UTF-8" />
<property name="fileEncodings">
<value>
/WEB-INF/myBundle2_en=ISO-8859-1
</value>
</property>
</bean>

Note: storing reloadable resources in the classpath may not be the best practice. But, probably use in a dev environment tied to a server. Just change before go-live.
The encoding stuf is good but, anybody working for me will save EVERYTHING as UTF-8 if they know whats good for them
;)

ServletRequestDataBinder - I need to investigate this more

permalink
Links to this post

2 Comments:

At 09 December, 2006 20:22, Anonymous doyle said...

You can probably tie the reload to the logging level so you don't have to mess with removing the configuration. Sorta what the rails kids do with the dev > test > prod settings.

We should do that in our app.

 
At 10 December, 2006 14:00, Blogger willCode4Beer said...

For log4J, its a good idea.
I'd recommend getting the configuration properties out of the classpath though.

 

Post a Comment

Subscribe to Post Comments [Atom]

<< Home

Links to this post on:

Create link here by posting on Blogger