You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jcs-users@jakarta.apache.org by cj22 <ch...@gmail.com> on 2009/06/11 03:26:49 UTC
variables in cache.ccf?
Is there a way to use environment variables in the config file? I would like
to use the same config file on 2 different systems that need a different
diskpath...
Thanks!
--
View this message in context: http://www.nabble.com/variables-in-cache.ccf--tp23973861p23973861.html
Sent from the JCS - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: jcs-users-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jcs-users-help@jakarta.apache.org
Re: variables in cache.ccf?
Posted by cj22 <ch...@gmail.com>.
Works Perfectly. Thanks!
Aaron Smuts:
JCS will look for a system property for any name inside the delimiters ${}.
Also, JCS will check to see if any property key in the cache.ccf is defined
in the system properties. If so, the system value will be used.
--
View this message in context: http://www.nabble.com/variables-in-cache.ccf--tp23973861p23988328.html
Sent from the JCS - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: jcs-users-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jcs-users-help@jakarta.apache.org
Re: variables in cache.ccf?
Posted by Aaron Smuts <as...@yahoo.com>.
JCS will look for a system property for any name inside the delimiters ${}. Also, JCS will check to see if any property key in the cache.ccf is defined in the system properties. If so, the system value will be used.
----- Original Message ----
From: Jan Swaelens <ja...@sofico.be>
To: JCS Users List <jc...@jakarta.apache.org>
Sent: Thursday, June 11, 2009 8:16:03 AM
Subject: Re: variables in cache.ccf?
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);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: jcs-users-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jcs-users-help@jakarta.apache.org
Re: variables in cache.ccf?
Posted by Jan Swaelens <ja...@sofico.be>.
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);
}