Blog / 2007-05-25 aQute - Software Consultancy
Search
*

Update to FileInstall

I was working on a larger web based system and I required configuration. data. I looked at Knopflerfish's Desktop but that required metatype information and felt one bridge too far for now.

I have a little command line utility, but that felt awkward because I was parameterizing Hibernate, which means around 20 different properties at least. Then it hit me that the nice little FileInstall bundle could be adapted to support configuration as well.

The FileInstall bundle is a tiny utility that is probably the most utility/size ration bundle I ever wrote. It allows you to manage bundles by copying them to a folder or deleting them from the folder. The FileInstall bundle watches this folder and reflects the file changes into the bundle's state. New files become installed and started bundles, removed files are uninstalled, and updated files are updated bundles. This allows you to use command line utilities, drag and drop, browser downloads or anything that writes files, to manage your bundles.

My initial hunch was to create a new utility that would work similarly for configuration files, just simple property files. After I could not think of a good name, it became clear that I could also just add this feature to FileInstall.

It actually works pretty nice now. For example, assume you have a bundle that registers a Managed Service with a PID of com.acme.mypid. This Managed Service will be updated with a Dictionary whenever the bundle starts or the configuration associated with this PID is changed.

With FileInstall, all you have to do is to create a file com.acme.mypid.cfg in the magic directory (usually ./load). This is a properties file. FileInstall will now automatically create a configuration for this bundle. Removing the file will remove the configuration.

I actually need a configuration for a Managed Service Factory. I therefore used the filename to denote factory pids:

   <pid>-<subname>.cfg

For example:

   com.acme.abc-aqute.cfg

Such a property file will create a Managed Service Factory configuration for the Managed Service Factory with a PID of com.acme.abc. Removing this file will delete the factory configuraiton. The <subname> is an alias for the real PID associatied with the factory configuration. If this is gabberdashtalk to you, don't worry. Just try it out and use it. It is extremely simple to use.

Some limitations:

  • Currently only String properties are supported. This can be changed if you want.
  • In certain cases old configurations can linger around. I'll fix this soon.

You can download FileInstall and run it on your framework. If you have any feedback, let me know.

  Peter Kriens
Copyright 2006 aQute SARL, All Rights Reserved