Skip to main content

Using filesystem operations to manage OSGi bundles in GlassFish

Posted by ss141213 on May 3, 2009 at 11:51 PM PDT

A few days back, Jerome blogged about how to deploy OSGi bundles in GlassFish using "asadmin deploy --type=osgi" command. In his blog, he also mentioned why you should not copy your bundles to glassfish/modules directory. In this blog, I will talk about a filesystem based management agent that I have integrated in GlassFish and how you can take advantage of the same. We have integrated Apache Felix File Install in GlassFish v3. It is a simple yet very powerful bundle. It even takes care of the dependencies among bundles. It can use "configuration admin service" to configure bundles by reading configuration data from properties file placed in the watched dir. Quoting from File Install homepage verbatim: It uses a directory in the file system to install and start a bundle when it is first placed there. It updates the bundle when you update the bundle file in the directory and, when the file is deleted, it will stop and uninstall the bundle. File Install can do the same for configuration files. In the default installation of GlassFish v3, we have configured FileInstall to watch a directory called ${domain_dir}/autodeploy-bundles. ${domain_dir} typically expands to glassfish/domains/domain1, but it really depends how you have configured GlassFish. This is very similar to autodeploy directory that exists in GlassFish for non-OSGi JavaEE applications. Basically, it works like this: You copy a bundle (a .jar file) to the watched dir (autodeploy-bundles) -> the bundles gets installed and then get started. You modify the bundle in the watched dir -> the bundle gets updated. You remove the bundle from the watched dir -> the bundle gets stopped and uninstalled. To watch some other directory (let's say /tmp/bundles), create a properties file with following content and name it as org.apache.felix.fileinstall-something.cfg and copy it to autodeploy-bundles dir: # directory to watch felix.fileinstall.dir=/tmp/bundles/ # Time period of fileinstaller thread in ms. felix.fileinstall.poll=5000 # debug level felix.fileinstall.debug=1 # should new bundles be started or installed only? true => start, false => only install felix.fileinstall.bundles.new.start=true You will immediately see fileinstall creating /tmp/bundles and dedicating a thread to watch it. If you want to explore this feature, I suggest you take a look at File Install homepage. This feature is not available in any promoted builds yet; you will find it in trunk nightly builds of GlassFish v3 after 5th May 2009 or in promotion #b47a onwards. Watch out the nightly build area or promoted build area. Happy

Related Topics >>

Comments

Hi Sahoo, nice to see all the work done with FileInstall has found its way to the production server! I'm using FI exactly in the same way in my application, btw. -- Filippo