(work in progess)
Abstract
This artcile shows how to build a domain specific Spring OSGi bundle (dynamic module), which can be customized in projects using fragment bundles. Of course one can use the RCP extension points conecpt etc. to provide customization and extensibility, but in my opinion the Spring way is much more convenient, powerful and dynamic.
The following ideas could be used to inspire a product like application based on a lightweight RCP application framework, wich can be customized and extended in projects to customer needs.
Example case
A bundle provides a view showing data columns of a database table. A project has the requirement to change the columns to be displayed and to change behavior of the view components itself. The view itself is a Spring bean. Lets have a look to the MANIFEST.MF of the host bundle providing the standard view and behavior.
Architecture fundamentals
The following sub chapters describe briefly the fundamental parts of the architecture for dynamic extensible Spring OSGi bundles.
The MANIFEST.MF - Spring application context loading
Manifest-Version: 1.0
Unversioned-Imports: *
Bundle-Name: acme.bundle
Bundle-Vendor: acme
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: acme.CommonFrameWorkBundleActivator
Spring-Context: META-INF/spring/*-init.xml,
META-INF/spring/*.xml,
META-INF/spring-ext/*-init.xml,
META-INF/spring-ext/*.xml
Important is the value of Spring-Context. It defines the order in which the Spring OSGi framework loads the configuration files.
- META-INF/spring/*-init.xml - this file is loaded first. Put any bootstrap beans here
- META-INF/spring/*.xml - all remaining xml files in META-INF/spring/ are loaded
- now META-INF/spring-ext/*-init.xml is loaded. This file is not provided by the host bundle, but later by the fragment bundle, which extends the host bundle
- META-INF/spring-ext/*.xml - all other xml files of the fragment are loaded