• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ClasspathResource with property placeholders?

 
Ranch Hand
Posts: 311
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 608
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic