• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ClasspathResource with property placeholders?

 
Sol Mayer-Orn
Ranch Hand
Posts: 311
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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")?
Thanks
 
Saifuddin Merchant
Ranch Hand
Posts: 607
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not that I can think off. Seems like a pretty rare off use case to me ....
 
Sol Mayer-Orn
Ranch Hand
Posts: 311
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
<annoyingManager><thePort>8000</thePort></annoyingManager>

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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic