Search code examples
javaosgiapache-felix

Felix ConfigAdmin (File) | Does my file needs to include service.pid?


I'm using Felix ConfigurationAdmin 1.8.6 (which is included in OSGI enRoute) and i'm not able to get it working with files in a folder.

I downloaded the sources to see what's going on, but i still can't figure out...

First, I added the run property felix.cm.dir, specifying the folder I want to configure my services. From what i see debugging, it's working fine, but my managed service get a null properties map.

Next, i discovered my properties must have the following format to be read (with doublequotes):

key="value"

Still, i get a null properties map...

Then i discovered that after reading my properties, the FilePersistenceManager.seek() only returns the Dictionary if it DOESN'T contains service.pid property, OR it contains that property and it equals the filename. Before comparing, it replaces the dots with slashes, so it never equals... I better not specify service.pid property anyway, i don't see the point.

When the Dictionary comes back to CachingPersistenceManagerProxy, it only get cached if the Dictionary contains the service.pid ou factory.pid property; which never happens.

Am i missing something?


Solution

  • I don't know if enRoute brings Apache Felix FileInstall with it, but without this bundle configuration admin services doesn't pick up configuration files. FileInstall usually takes care of that. And in that case, yes you'll need to make sure your cfg file does have a name matching your PID. So for a configuration with pid: my.conf.foo you'd need a file my.conf.foo.cfg in a folder monitored by the FileInstaller Bundle. It'll pick up this file and make sure your configuration is updated with the content of the file.