Home Projects DA-Launcher
DA-Launcher Overview Print E-mail

Dynamic Application Launcher (DA-Launcher) is a project that simplifies launching and managing OSGi-based applications by handling common tasks and problems that face developers who work on launching OSGi based applications. As long as application's bundles exist, creating an OSGi-based application that is consumable by end users with DA-Launcher is a matter of seconds if the developer is familiar with DA-Launcher or a matter of minutes if not. DA-Launcher is designed to be extensible and very lightweight (it weighs less than 250 kilobytes), so it wouldn't affect the size or the performance of the application.

It's worth mentioning that all of the examples and applications on DynamicJava.org are launched using DA-Launcher so visitors of this site could run the examples with a double click if they have a GUI or by typing a single command in the command line interface.

Why Use DA-Launcher?

Why you might find DA-Launcher the best solution for launching your OSGi-based application?

  • User Friendly Launcher: If your application is consumed by end users then you need to provide them with simple means to launch the application. Writing your own script or launcher application would be more time consuming, harder to maintain by other developers and more error prone than using an existing solution which focus solely on this task.
  • Development Efficiency: The facts that with DA-Launcher installing bundles is done by simply copying them to a specific directory, the OSGi Framework to be used (Felix, Equinox or Knopflerfish) is configurable, logging is done by the launcher and OSGi incompliant class libraries are automatically converted into bundles at runtime reduce the time needed to develop a launcher for an OSGi-based application significantly since these are the most common tasks that developers have to deal with when running their OSGi-based applications. Actually, one of the main reasons DA-Launcher is used to launch all of the examples at DynamicJava.org is because as soon as example's bundles are ready it takes in average less than one minute to create an application for the example that can easily be run by site visitors.
  • Resource Efficiency: Using an OSGi-based Application Server for the sole reason of running an OSGi-based application in a managed environment is a resource-inefficient solution. While a typical OSGi-based Application Server would weigh tens of megabytes if not more, DA-Launcher weighs less than 250 kilobytes. Based on the huge difference in size alone one could guess which of the solutions performs much faster.
  • Embedability: DA-Launcher can be easily embedded in non-OSGi applications, especially Web Applications. With the use of DynamicJava.org projects like DynamicServlet-Bridge and API-Bridge, it's by far the simplest solution for running and integrating an OSGi-based application inside a non-osgi Web Application.

Use Cases

Below are some of the use cases where DA-Launcher can prove to be very useful compared to other approaches for launching OSGi-based applications.

  • OSGi-based Applications which are consumed by end users. DA-Launcher can be used because it provides end users with executable files to run the application, it's very light and has no performance overhead on the application. An example application can be downloaded from here. (The program might have some OSGi-inrelated problems when run in Mac OS)
  • OSGi-based Applications that use Spring Dynamic Modules. Since bundles in DA-Launcher are managed by copying bundle archives into a certain directory, creating a runnable and lightweight application that uses Spring Dynamic Modules is a matter of seconds. An application that uses Spring Dynamic Modules can be downloaded from here.
  • OSGi-based Applications embedded inside Web Applications. All DA-Launcher requires to run an OSGi-based application inside a Web Application is copying DA-Launcher's Home Directory to the “/WEB-INF” directory of the Web Application and adding a context listener to the web.xml file. The WAR file for an example application can be downloaded from here. A Tomcat instance that contains the application can be downloaded from here.
  • OSGi-based Applications that use OSGi-incompliant 3rd party components. Using DA-Launcher, no special effort is required from the developers to use OSGi-non compliant libraries in an OSGi Environment since DA-Launcher automatically generates bundles from them at runtime. Compared to other solutions, DA-Launcher is the only one that doesn't require any additional efforts from developers to use OSGi-incompliant libraries in their OSGi-based applications. An example application that uses JPA, Toplink and H2 database (all of them are OSGi-incompliant) can be downloaded from here.

DA-Launcher's Directory Structure

If you've downloaded one of the examples above you would probably have noticed the uniformed directory structure of OSGi-based applications run using DA-Launcher. Application's root directory which contains the directories (bin, lib, bundles, etc.) is called “DA-Launcher Home Dir”. Every Application that is run using DA-Launcher has a home directory. For standalone OSGi-based applications, it will be the root directory of the application, for ones embedded in Web Applications it will be the “/WEB-INF/da-launcher” directory of the Web Application by default.

Bundles exist in the “/bundles” directory – For the rest of the article I will refer to “DA-Launcher Home Dir” by “/”. There are three categories of bundles in DA-Launcher:

  • Application bundles “/bundles/application-bundles”: The bundles that a typical OSGi-based application will consist of, these provide the functionality of the application.
  • System Bundles “/bundles/system-bundles”: The bundles that usually provide infrastructural services and has nothing to do with application's logic, such bundles need to be installed and started before application bundles. Examples of such bundles are: Spring Dynamic Modules bundles, OBR bundles, Logging service bundles, etc.
  • Non-bundled libraries “/bundles/non-bundled-libraries”: OSGi-incompliant JAR files (JAR files that has no OSGi headers in their manifest) from which DA-Launcher will generate bundles at runtime.

Bundles can be installed and uninstalled at runtime by simply copying them to the specified directory or removing them from there. It's up to you to decide whether to place a bundle in the system or the application bundles directory, you just need to take into account that Non-bundled libraries are run and installed first, System Bundles second and Application Bundles third.

The “/config” directory contains DA-Launcher's configuration files. From there you can configure the behavior of different bundles categories, the OSGi framework, logging behavior and extensions to DA-Launcher. New configuration files for future releases of DA-Launcher will be placed in this directory.

The “/logs” directory contains the log files, the “/lib” directory contains library files needed for the DA-Launcher to run and the “/runtime” directory contains files generated at runtime (caches for example). These three directories plus the “/bin” directory are not intended to be modified by developers.

When DA-Launcher is embedded in a Web Application, the directory structure differs in that the “DA-Launcher Home Dir” doesn't contain the “/bin” directory which is not needed and the contents of the “/lib” directory are moved to Web Application's directory “/WEB-INF/lib”.

How DA-Launcher works?

The batch/script files in the “/bin” directory are intended for users to run the application. The script/batch files run the application from JAR files in the “/lib” directory. DA-Launcher first verifies the existence of needed directories and files then loads the configuration files and based on the OSGi Framework configuration file it runs the OSGi Framework (Equinox or Felix). Having the OSGi Environment ready, it generates bundles from non-bundled libraries and installs them in the environment, then installs System bundles and starts them (unless configured not to start them automatically) followed by Application bundles. Having the bundles installed and running, the directory watchers are started to detect any changes to bundle archives so bundles could be installed, updated and uninstalled at runtime.

When DA-Launcher is embedded in a Web Application, a Servlet Context Listener provided by DA-Launcher need to be registered in the web.xml file. The context listener interacts with DA-Launcher's internals to launch the OSGi-based application and provide the Bundle Context of the launched application to Web Application's Servlets using the Servlet Context object.

Getting Started

Getting started with DA-Launcher usually takes less than three minutes. If you would like to try DA-Launcher for your own application, please check the Getting Started page.