My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
DirInstaller  
Updated Sep 18, 2008 by roman.ro...@gmail.com

Introduction

DirInstaller is a bundle and configuration management tool. It permanently scans a load directory for bundles and configurations. For example, by copying and removing bundle files, you install, update and delete bundles. The default directory is "

<modulefusionroot>
/load". DirInstaller can expand your build and deployment system by supporting a hot deployment for OSGi bundles and configuration. E.g. it helps to test bundles or to evaluate downloaded example bundles by simply using drag & drop.

DirInstaller scans the complete directory structure including subdirectories of the configured load directory.

Bundle Management

The following operations are supported for bundles:

Install and Start By copying a bundle into the load directory, DirInstaller will install and start the bundle
Update By replacing the bundle file in the directory, DirInstaller will update the bundle and call PackageAdmin.refreshPackages(null)
Delete By removing the bundle file from the directory, DirInstaller will stop and remove the bundle

Example

To test the delete operation, you can move the bundle file "

<modulefusionroot>
/load/examples/org.modulefusion.example.servlet.helloworld.jar" to a backup directory outside of "
<modulefusionroot>
/load". You should see following message in the OSGi console:

osgi> Removing bundle 'org.modulefusion.example.servlet.helloworld'
[Thread-6|HttpServiceProxy.java:68]  INFO  org.ops4j.pax.web.service.internal.HttpServiceProxy  - Unregistering [/helloworld]

To install the bundle again, just copy the bundle backup file to "

<modulefusionroot>
/load/examples" directory:

osgi> Installing bundle from file: .../modulefusion/load/examples/org.modulefusion.example.servlet.helloworld.jar
[Thread-6|HttpServiceProxy.java:74]  INFO  org.ops4j.pax.web.service.internal.HttpServiceProxy  - Creating adefault context
[Thread-6|HttpServiceProxy.java:52]  INFO  org.ops4j.pax.web.service.internal.HttpServiceProxy  - Registering servlet: [/helloworld] -> org.modulefusion.example.servlet.helloworld.HelloWorldServlet@1d2f117
[Thread-6|JettyServerWrapper.java:109]  INFO  org.ops4j.pax.web.service.internal.JettyServerWrapper  - added servlet context: HttpServiceContext{httpContext=org.ops4j.pax.web.extender.whiteboard.internal.HttpContextProxy@1d22104}
[Thread-6|AbstractTracker.java:267]  INFO  org.ops4j.pax.web.extender.whiteboard.internal.AbstractTracker  - Registered [org.modulefusion.example.servlet.helloworld.HelloWorldServlet@1d2f117] -> [AliasBasedRegistration{httpContextId=default,alias=/helloworld}]

To update the existing bundle, touch the backup file (to get a new timestamp) and copy it to the "

<modulefusionroot>
/load/examples" directory:

osgi> Updating bundle 'org.modulefusion.example.servlet.helloworld'
[Thread-5|HttpServiceProxy.java:68]  INFO  org.ops4j.pax.web.service.internal.HttpServiceProxy  - Unregistering [/helloworld]
[Thread-5|HttpServiceProxy.java:52]  INFO  org.ops4j.pax.web.service.internal.HttpServiceProxy  - Registering servlet: [/helloworld] -> org.modulefusion.example.servlet.helloworld.HelloWorldServlet@5e9e34
[Thread-5|AbstractTracker.java:267]  INFO  org.ops4j.pax.web.extender.whiteboard.internal.AbstractTracker  - Registered [org.modulefusion.example.servlet.helloworld.HelloWorldServlet@5e9e34] -> [AliasBasedRegistration{httpContextId=default,alias=/helloworld}]

Configuration Management

The following operations are supported for configurations:

Activate a configuration By copying a configuration file into the load directory, DirInstaller will update the corresponding ManagedService
Updating a configuration By replacing the configuration file in the directory, DirInstaller will update the corresponding ManagedService

Configuration files are plain property files (Properties.load(FileInputStream(f) - details). and consist of simple key/value pairs.

Example

A valid configuration file:

hibernate.connection.driver_class=org.hsqldb.jdbcDriver
hibernate.connection.url=jdbc:hsqldb:file:data/database
hibernate.connection.username=sa
hibernate.connection.password=
hibernate.dialect=org.hibernate.dialect.HSQLDialect
hibernate.current_session_context_class=thread
hibernate.cache.provider_class=org.hibernate.cache.NoCacheProvider
hibernate.show_sql=false
hibernate.hbm2ddl.auto=update

The filename of the configuration file is used to determine the corresponding ManagedService. DirInstaller will use the filename as the PID value.

filename ::=
<pid>
.'cfg'

For example, the ModuleFusion JPA bundle registers a ManagedService instance and sets the PID value:

JpaService jpaService = injector.getInstance(JpaService.class);
String[] ifaces = { ManagedService.class.getName(), JpaService.class.getName() };
Properties props = new Properties();
props.put(Constants.SERVICE_PID, "org.modulefusion.hibernate.jpaservicehibernate");
context.registerService(ifaces, jpaService, props);

Therefore, you configure this managed service with the configuration file "org.modulefusion.hibernate.jpaservicehibernate.cfg". The location of this file within the load directory will not influence the properties or PID value.

DirInstaller Settings

You can use the following system/framework properties to configure DirInstaller:

Property Default Description
dirinstaller.poll 2000 Number of milliseconds between 2 polls of the directory
dirinstaller.dir load The name of the directory to watch


Special thanks to Peter Kriens and his tool fileinstall.


Sign in to add a comment
Powered by Google Project Hosting