jakarta-jcs-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan Swaelens <jan.swael...@sofico.be>
Subject Re: variables in cache.ccf?
Date Thu, 11 Jun 2009 12:16:03 GMT
I don't think that it's possible out of the box but it's easily 
implemented by loading the properties and performing the substitution 
yourself.
The 'ConfigUtil.substituteProperties' call is a custom utility and must be 
replaced by somthing available in your environment.

// Get unconfigured instance
CompositeCacheManager ccm = 
CompositeCacheManager.getUnconfiguredInstance();

// Load properties from the ccf file
Properties props = new Properties();
is = 
ClassLoaderUtil.getInstance().getClassLoader().getResourceAsStream(JCS_PROPERTIES_FILE);
if (is != null) {

        // Load
        props.load(is);

        // Replace custom/env variables
        Iterator entries = props.entrySet().iterator();
        while (entries.hasNext()) {
                Entry e = (Entry) entries.next();
                e.setValue(ConfigUtil.substituteProperties((String) 
e.getValue(), true));
        }

        // Configure cache system with replaced props
        ccm.configure(props);
}
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message