Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0
Note

This is a draft of possible migration to OSGi

Manifest attributes

Sonar Plugin - https://github.com/SonarSource/sonar-update-center/blob/master/sonar-update-center-common/src/main/java/org/sonar/updatecenter/common/PluginManifest.java
OSGi Bundle - http://www.osgi.org/javadoc/r4v42/index.html?org/osgi/framework/Constants.html

Sonar Plugin

OSGi Bundle

Notes

Plugin-Key

Bundle-SymbolicName

Plugin-Version

Bundle-Version

Plugin-Class

Bundle-Activator ?

Plugin-Name

Bundle-Name

Plugin-Description

Bundle-Description

Plugin-Homepage

Bundle-DocURL

Plugin-Dependencies

Bundle-ClassPath

Plugin-ChildFirstClassLoader

not needed

Plugin-Base

Fragment-Host

Fragment bundle can't be referenced from another manifest. Fragment bundle cannot load classes. Fragment treated as optional bundle.

Sonar-Version

Require-Bundle

"org.sonar.plugin.<key>.api.*"

Export-Package

Plugin-License

Bundle-Copyright

Plugin-BuildDate

 

Plugin-IssueTrackerUrl

Bundle-ContactAddress

Plugin-Organization
Plugin-OrganizationUrl

Bundle-Vendor

Plugin-TermsConditionsUrl

 

 

Bundle-UpdateLocation

Usage

We have a lot of routines for installation and uninstallation of plugins and for creation of classloaders.

Here is example how to launch embedded Equinox ( org.eclipse.osgi:org.eclipse.osgi:3.6.0.v20100517 - no additional dependencies, size about 1 Mb ) :

Code Block
xml
EquinoxFactory factory = new EquinoxFactory();
Map<String, Object> config = new HashMap<String, Object>();
config.put("osgi.configuration.area", "/tmp/osgi-dir/");
Framework framework = factory.newFramework(config);
framework.start();

BundleContext context = framework.getBundleContext();
Bundle bundle = context.installBundle("file:/..."); // Jar file or directory, seems that "http://" supported too
...
Class<?> cls = bundle.loadClass("...");
...

framework.stop();

OSGi also provides routines to correctly compare versions - see http://www.osgi.org/javadoc/r4v42/index.html?org/osgi/framework/Version.html.