Hello readers, today we are going to explain how to create an OSGi fragment project using Eclipse IDE.
The first step to create OSGi fragment is to understand the need of the OSGi fragment and select a host bundle using which this OSGi fragment is going to access and resolved within your application. To understand the OSGi fragment please go through by our previous OSGi fragment posts.
Once we have the clear picture about fragment and you have opted the host bundle to register the fragment then, follow the below steps to create OSGi fragment project. For example we have a sample OSGi bundle with name "OSGitestBundle" and for this bundle we will create an OSGi fragment which helps this bundle to work as an extension of host bundle and provide additional information to host bundle.
Step 1: Go to File >> New >> Other >> Plug-in Development >> Fragment Project and then click on the next button.
Select OSGi fragment project from other project section in Eclipse |
Step 2: Now put a valid name OSGi fragment name in Project name text-box, and click on the next button. for example we have given project name OSGiFragment
OSGi fragment project name |
Step 3: In this step you will see, few fields are auto filled with the name of your OSGi fragment project, as you have given the project name in the previous step. In this step you have to add the plug-in ID information or host name information of this fragment, so this get merge with host bundle. here we will put the project name OSGitestBundle and then click on the finish button.
Plug in or host name information OSGi fragment |
Step 4: Now open the project explorer in your Eclipse and open the manifest file "MANIFEST.MF" at location [Fragment-PROJECT-NAME] >> META-INF >> MANIFEST.MF
Manifest file location |
In manifest file you will see the following entries:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: OSGiFragmen
Bundle-SymbolicName: OSGiFragmen
Bundle-Version: 1.0.0.qualifier
Fragment-Host: OSGitestBundle
Automatic-Module-Name: OSGiFragment
Bundle-RequiredExecutionEnvironment: JavaSE-1.8