I have a bundle installed in Apache servicemix that is using apache blueprint for configuration. I am using an external properties file abc.cfg located in /config folder and is being loaded as follows:
via blueprint
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel-cxf="http://camel.apache.org/schema/blueprint/cxf"
xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:cxf="http://cxf.apache.org/blueprint/core"
xsi:schemaLocation="
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd
http://cxf.apache.org/blueprint/core http://cxf.apache.org/schemas/blueprint/core.xsd
http://camel.apache.org/schema/blueprint/cxf http://camel.apache.org/schema/blueprint/cxf/camel-cxf.xsd"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0">
<cm:property-placeholder id="myProperties" persistent-id="abc" />
via java DSL
public class MyActivator implements BundleActivator {
@Override
public void start(final BundleContext context) throws Exception {
final ServiceReference serviceReference = context.getServiceReference(ConfigurationAdmin.class.getName());
if (serviceReference != null) {
final ConfigurationAdmin admin = (ConfigurationAdmin) context.getService(serviceReference);
final Configuration configuration = admin.getConfiguration("abc");
final Dictionary<String, Object> configurations = configuration.getProperties();
if (configurations == null) {
throw new CustomException("Exception in loading properties file");
}
populateProperties(configurations);
}
}
}
Everything works fine but now i need to move the property file in custom location to segregate property files from different bundles. So i moved abc.cfg in /config/myFolder/ but i am unable to specify the new location to my bundle in either ways. I tried using ext:property-placeholder but it didn't work, probably because i am using it wrong(couldn't find anything comprehensive to understand it). So please guide me on how can i specify location for my properties file in cm:property-placeholder and through configuration admin service in java DSL. Also, i am not sure if it is ok to load the same properties file in two different ways in my bundle.