|
DirInstaller
IntroductionDirInstaller 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 ManagementThe following operations are supported for bundles:
ExampleTo 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 ManagementThe following operations are supported for configurations:
Configuration files are plain property files (Properties.load(FileInputStream(f) - details). and consist of simple key/value pairs. ExampleA 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 ::= 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 SettingsYou can use the following system/framework properties to configure DirInstaller:
Special thanks to Peter Kriens and his tool fileinstall. | |||||||||||||||||||