-
1. Re: Configuration file with maps
brimstedt Feb 16, 2011 4:20 AM (in response to brimstedt)Im not sure if my question wasn't understandable or if it's not possible to do what Im asking.
An alternative for me would be to read the configuration files from etc dir myself.
Is there an easy way to get hold of them?
br
/B
-
2. Re: Configuration file with maps
brimstedt Feb 22, 2011 3:21 AM (in response to brimstedt)Ok, this is how I did it in the end:
Implement BundleContextAware
public class XxxRouteBuilder extends RouteBuilder implements BundleContextAware
Implement the required method and assign bundleContext to a local field:
public void setBundleContext(BundleContext bundleContext)
{
this.bundleContext = bundleContext;
}
In the configure() method, you now have access to the properties in the config file:
ServiceReference ref = bundleContext.getServiceReference(ConfigurationAdmin.class.getName());
ConfigurationAdmin admin = (ConfigurationAdmin) bundleContext.getService(ref);
try
{
Configuration config = admin.getConfiguration("com.viskan.integration.moveexecutearchive");
properties = (Dictionary<String, String>) config.getProperties();
}...
You can loop and get the properties and build you map or whatever you want:
Enumeration<String> keys = properties.keys();
while (keys.hasMoreElements())
{
String key = keys.nextElement();
String value = properties.get(key);
storeSetting(key, value);
}
In the end I decided I didnt need this right now anyway, but I wanted to post here for future reference..