The talk tackles the problem of adding/removing applications at runtime in an OSGi-based product solution, e.g. an application server. The problem occurs any time you have a running solution, and you are not allowed to stop your solution for a moment. Thereby, an application is a well defined set of bundles. Such a set of bundles have to be added or be removed consistently in a running system. Best practice guidelines are given to solve this kind of problems for your solution. Patterns for starting and stopping of bundles during runtime are provided including loading and unloading of application bundles dynamically. A special focus is set on bundle start order execution at runtime. Guidelines how to avoid duplicated as well as unresolved bundles are given. Finally, an application loader implementation which is freely available is shortly introduced.
2. Problem Space
• What is the scope?
• Set of bundle which form an application.
• Running multiple applications at one time.
• Install and start applications at runtime.
• Stop and uninstall applications at runtime.
• Solutions with large uptime.
• What is not the scope?
• Configuration of start and stop of an static OSGi solution.
• Application admin service.
3. Instruments of Bundle Lifecycle
• Interface BundleContext
• public Bundle installBundle(String location);
• Interface Bundle
• public void start();
• public int getState();
• public void stop();
• public void uninstall();
4. Maintaining Applications
Application
install() and
Start start() each
Bundle 1
bundle
Bundle 2
...
Bundle n stop() and
Stop uninstall()
each bundle
6. Maintaining Applications: Pitfalls
Application
install()
Start bundle
Bundle 1
Bundle 2
... Be aware of
Bundle n overlapping
bundles in
applications!
7. Maintaining Applications: Pitfalls
Application
start() bundle
Start
Bundle 1
Bundle 2
...
Bundle n Required bundles
are not started
(installed)!
8. Maintaining Applications: Pitfalls
Application
start() bundle
Start
Bundle 1
Bundle 2
...
Bundle n Bundle started but not
used by application!
(reason:
bundle/package
versioning)
9. Maintaining Applications: Pitfalls
Application
Other application will
not work!
Bundle 1
(reason:overlapping)
Bundle 2
...
Bundle n stop() bundle
Stop
10. Maintaining Applications: Pitfalls
Application
Other application
Bundle 1 will not work!
Bundle 2 (overlapping)
...
Bundle n uninstall()
Stop
bundle
11. Maintaining Applications: Best
Practice
• Overall: Take care of bundle and package versions
• Start application:
• first install all bundles of an application then start bundles
• use the right start order of bundles
• don’t install and start bundles already installed by other running applications
• Stop application:
• first stop all bundles of an application then uninstall
• use the right stop order of bundles for optimized application shut down
• don’t stop and uninstall bundles in use by other running applications
• Build application manager:
• performs start/stop of all applications
• keeps track of bundle overlapping between applications
• application prepares information to application manager about application bundle
relationship and bundle order
• use it also for pre-installed applications for system start and shutdown
12. Roots Application Manager
• Free available for private, academic, and commercial
use
• Implements introduced best practice methods
• Provides application management at runtime via
service
• Manages start/shutdown of system
• Manages application orders
• See http://kachel.biz/files/public-docs/Software/Roots/
for RootsApplicationManager*.zip
• Use support@kachel.biz for feedback or help
13. Application Provided in Folder
• Boot application starts application manager
• Application manager starts pre-installed other applications
• Runtime application maintained by service or graphical console
17. Summary
• Bundle lifecycle instruments introduced
• Managing of multiple applications at runtime discussed
• Best practice provided
• Free available implementation shortly introduced