...
For such cases the OSGi Core Specification provides a functionality to declare such class sharing. The functionality is defined in terms of two Framework properties org.osgi.framework.system.packages
and org.osgi.framework.bootdelegation
:
org.osgi.framework.bootdelegation
– - All classes matching any entry in this list are always loaded from the parent class loader and not through the OSGi framework infrastructure. This property is a comma separated list of package names. A package name may be terminated by a wildcard character such that any package starting with the list entry matches the entry and thus will be used from the parent class loader.org.osgi.framework.system.packages
– - Additional package declarations for packages to be exported from the system bundle. This property is a simple package declaration list just like anyExport-Package
manifest header. In a sense theorg.osgi.framework.system.packages
property may be seen as theExport-Package
manifest header of the system bundle. Namely these entries may not contain wildcards (as is allowed for thebootdelegation
property) and may contain directives and attributes such as theuses
directive and theversion
attribute. It is recommended to provide this additional information to help in resolving the bundles. The OSGi Core Specification even prescribes the use of theuses
directive.
...
If on the other hand you cannot prevent the installation of such bundles and hence the export of the respective packages, you might want to set the org.osgi.framework.bootdelegation
property conditionally as described above in the answer to how this property is supported in Sling. This ensures the property is only set, if the classes are actually available. This should be used as a fall back only, if the org.osgi.framework.system.packages
method does not work.
Is there an easy way to update bundles in a running installation during development?
The Sling Maven Plugin provides an install goal which is able to install or update a bundle in a running Sling application (if the Sling web console is deployed). If the plugin properties are configured accordingly you can just mvn clean package org.apache.sling:maven-sling-plugin:install
and the bundle is uploaded.
You can use the settings.xml
to set the url to your Sling application. See the Sling Maven Plugin for more information.