I'm running Karaf and have a blueprint xml file that access a file from the Karaf etc directory (...apache-karaf/etc/SomeProperties.properties) for use in a bundle:
<ext:property-placeholder placeholder-prefix="$[" placeholder-suffix="]">
<ext:location>file:etc/SomeProperties.properties</ext:location>
</ext:property-placeholder>
<bean id="SomeBean" class="impl.com.package.SomeBean"
init-method="init" destroy-method="destroy">
<property name="beanvariable1" value="$[property1key]"/>
<property name="beanvariable2" value="$[property2key]"/>
</bean>
However, I also want to access not only all the properties in that one particular file, but all files from that same karaf/etc directory that end in .cfg (without naming any of the files individually). Can this be done?
Specifically, is there a way to specify a directory location instead of file location? And additionally filter on file type within that directory?
Or, for that matter, is there any way (using blueprint or otherwise) to access all the files in the apache-karaf/etc dir (not just particular properties contained in them) from within a bundle running in Karaf?
Get a handle to the Configuration Admin Service directly, you can then roll through all the stored configuration sets (called 'pid' for Persistent ID in OSGi)
You have a couple options, you can reference it using the blueprint built-in bean reference to your bundle (which has a way to traverse to the Config Admin Service). See this link for one of the more complete references to working with Blueprint: IBM's Blueprint Reference
Or you can set a reference and get wired directly to the Config Admin service
<reference id="configAdmin" interface="org.osgi.service.cm.ConfigurationAdmin">
Then wire the 'configAdmin' bean into your bean.