jQuery in Action, 3rd edition
The moose likes Spring and the fly likes ClasspathResource with property placeholders? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "ClasspathResource with property placeholders?" Watch "ClasspathResource with property placeholders?" New topic

ClasspathResource with property placeholders?

Sol Mayer-Orn
Ranch Hand

Joined: Nov 13, 2002
Posts: 311

Does anyone please know of an implementation of ClasspathResource which supports "property placeholders" inside resource text?
For example, say I have the following text resource in my classpath:

Now I'd like to inject this "ClasspathResource" into a bean that reads it, but it should read "Hello mister JOHN" , replacing "${username}" with "JOHN" (based on some properties file).

Is there such an implementation? Or should I write my own ("MyResource implements Resource")?
Saifuddin Merchant
Ranch Hand

Joined: Feb 08, 2009
Posts: 607

Not that I can think off. Seems like a pretty rare off use case to me ....

Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
Sol Mayer-Orn
Ranch Hand

Joined: Nov 13, 2002
Posts: 311
Sam Mercs wrote:Seems like a pretty rare off use case to me ....

Thanks for replying.
I actually suspect many people run into this problem....
The "greeting text" example was just for simplicity. In reality, our resources are vendor-specific configuration files, required for various 3rd-party tools.
E.g. you may have some 3rd party called "AnnoyingCacheManager", and in order to configure itself it expects an InputStream to a vendor-specific xml file, such as:

Naturally I'd <thePort> to be configurable through Spring.
Now if I'm lucky, AnnoyingCacheManager might be "Spring ready" (have explicit Spring support, or some useful setters).
But some of our esoteric vendors just expect this rigid XML format
So I'd like Spring to prepare the required stream based on some template.

Thanks anyway for replying.
I agree. Here's the link: http://aspose.com/file-tools
subject: ClasspathResource with property placeholders?
It's not a secret anymore!