Wednesday, September 6, 2017

OSGi Bundle MANIFEST Headers

OSGi bundle MANIFEST file is core resource of bundle and we can say its bundle deployment configuration file. OSGi containers will read the information from MANIFEST file and do subsequent actions. We can use many standard OSGi bundle headers in bundle MANIFEST file. Each header have their own significant meaning. Bundle header and its value separated with colon:

The following are headers which proposed by OSGi Alliance. We have other vendor specific headers like Eclipse Foundation, Spring Source and aQute.

OSGi Alliance Standard Headers

The headers proposes by OSGi alliance supported by all OSGi implementation environments like Apache Felix, Equinox and Knopflerfish.

Bundle-ActivationPolicy

Bundle-ActivationPolicy will notify to the container when should bundle available to use or activated. Usually when we deploy bundle, it is immediately available.

Bundle-ActivationPolicy value is lazy it means when bundle will get first request then bundle will be activated.

Example:


Bundle-ActivationPolicy: lazy 


Bundle-Activator

Bundle-Activator header specify the bundle activator java class. Bundle Activator is java class, which manage the bundle life cycle. Each bundle must have activator class and OSGi container invoke the lifecycle methods based on bundle lifecycle stages.

Example:


Bundle-Activator : com.liferaysavvy.bundle.Activator


Bundle-Classpath

Bundle-Classpath is list of values separated by comma delimiter. The values may be jar files or directories and directories have jar files or java classes. Bundle will look for required classes in the given location.

Example:


Bundle-Classpath : apache-commons.jar, apache-logs.jar

OR

Bundle-Classpath : .,WEB-INF/classes,foo1.jar

OR

Bundle-ClassPath: ., A.jar, B.jar, C.jar



Note:

The values separated by comma and dot will specify the current bundle directory.

Bundle-ContactAddress

Bundle-ContactAddress its just information which will use to contact bundle vendors. It’s some text or may be company URL

Example:


Bundle-ContactAddress : Liferay Savvy India

OR

Bundle-ContactAddress : http://www.liferaysavvy.com


Bundle-Copyright

Bundle-Copyright is just copyright information.

Bundle-Description

Bundle-Description is description about bundle and its simple human readable text.

Bundle-License

Bundle-License specify the license information of bundle and it is a text.

Bundle-ManifestVersion:

This header is required and marks the jar as a bundle, the value is always 2 (newer OSGi specifications might add more features in which case the number would be increased).

Value 1 indicates OSGi release 3

Value 2 indicate OSGi release 4

Example:


Bundle-ManifestVersion : 2


Bundle-Name:

Bundle-Name is human readable name for bundle.

Example:


Bundle-Name: LSServiceProvider


Bundle-SymbolicName

Bundle-SymbolicName is unique identification name for bundle. This name will used by other bundle when they have dependency.

Example:


Bundle-SymbolicName: com.ls.de.LSServiceProvider


Bundle-Vendor

Bundle-Vendor is vendor name who implemented the bundle.

Example:


Bundle-Vendor : Liferay Savvy


Bundle-RequiredExecutionEnvironment

Bundle-RequiredExecutionEnvironment is specify the JRE execution environment.

Example:


Bundle-RequiredExecutionEnvironment:  JavaSE-1.8

OR

Bundle-RequiredExecutionEnvironment:  JavaSE-1.7

OR

Bundle-RequiredExecutionEnvironment:  JavaSE-1.6



Bundle-Version

Bundle-Version specify the version number for bundle.

Example:


Bundle-Version: 1.0.0.qualifier

OR

Bundle-Version: 1.0.0


Export-Package

Export-Package contains list of java packages separated by comma delimiter that will be exported and available to other bundles. Only the packages specified by the header will be exported, the rest will be private and will not be seen outside the bundle.

Example:


Export-Package: com.ls.de.lsserviceprovider.services

OR

Export-Package:org.springframework.core.task;uses:="org.springframework.core,org.springframework.util";version=2.5.1 org.springframework.core.type;uses:=org.springframework.core.annotation;version=2.5.1[...]


Export-Service

Export-Service specify the services, which are exported from the bundle, and it will be available to other bundles. List separated by comma delimiter. This header will work when we work with multiple bundles and there is dependency between each other.

Example:


Export-Service: org.osgi.service.log.LogService,org.osgi.service.log.LogReaderService


Import-Package

Import-Package specify the list of bundle packages, which required in the current working bundle. What are the packages exported by other bundles, can import in the current bundle with help of Import-Package header. This header will work when we work with multiple bundles and there is dependency between each other.

Example:


Import-Package: com.ls.de.lsserviceprovider.services

OR

Import-Package:org.apache.commons.logging,edu.emory.mathcs.backport.java.util.concurrent;resolution:=optional[...]


Import-Service

Import-Service is similar to Export-service but it is vice versa. The list of service class names which required by the bundle. Services which are already exported can use in the list.

Example:


Import-Service: org.osgi.service.log.LogService,org.osgi.service.log.LogReaderService


Provide-Capability


More details you can found here



Require-Bundle

Require-Bundle specify the dependency on other bundle. The bundle we specified in the header must be required to activate current bundle. This bundle similar to Import-Bundle header proposed by Spring Source.

Example:


Require-Bundle: org.example.foo; bundle-version=3.0,org.example.bar; bundle-version=1.0



The following are very important headers and we use very regular in the OSGi bundle development.


Manifest-Version
Bundle-ManifestVersion
Bundle-Name
Bundle-SymbolicName
Bundle-Version
Bundle-Activator
Bundle-Vendor
Bundle-RequiredExecutionEnvironment
Export-Package
Import-Package



Spring Source MANIFEST headers

The following are Spring Source proposed MANIFEST headers. To use these headers we must have vendor specific implementation bundle in the OSGi container.

Import-Bundle

Import-Bundle is similar to Require-Bundle proposed by OSGi Alliance and both are same meaning.

Example:

Import-Bundle: org.example.foo; bundle-version=3.0,org.example.bar; bundle-version=1.0


Web-ContextPath.

The default context from which the web content is hosted. You must set the value of the Web-ContextPath header to the value of the <context-root> element for the corresponding web module in the application.xml file. The presence of this header identifies this bundle as a web application bundle.

Example:


Web-ContextPath: /contextRoot


Web-DispatcherServletUrlPatterns

Web-DispatcherServletUrlPatterns specify the URL patterns for Dispatcher servlet.

Example:


Web-DispatcherServletUrlPatterns : /spring/*


Web-FilterMappings

Web-FilterMappings specify the application filter mappings

Example:


Web-FilterMappings  : /secure/*


aQute MANIFEST headers

The following are aQute proposed MANIFEST headers. To use these headers we must have vendor specific implementation bundle in the OSGi container.

Include-Resource

Include-Resource is path where bundle resource files are available like properties files

Example


Include-Resource: src/main/resources


Private-Package

List of packages, which are specific, the current bundle and it will not be available outside. Other bundles cannot access these packages. This header will used in bnd tools developed OSGi environment. Usually we specify the bundle services implementation packages in the list.

Example:


Private-Package: com.ls.de.lsserviceprovider.services.impl



Eclipse Foundation MANIFEST headers

The following are Eclipse Foundation proposed MANIFEST headers. To use these headers we must have vendor specific implementation bundle in the OSGi container. Equinox implementation support these headers.

The following are headers proposed by Eclipse Foundation.


Eclipse-BuddyPolicy
Eclipse-BundleShape
Eclipse-ExtensibleAPI
Eclipse-PlatformFilter
Eclipse-RegisterBuddy


Reference Links


Author

0 comments :

Post a Comment

Recent Posts

Recent Posts Widget

Popular Posts