OSGiAndNetBeans

Contents

NetBeans and OSGi

NetBeans Module System and OSGi are kind of similar. They provide a way to write modular applications. They encode their metadata in MANIFEST.MF, etc. This page has been created to host the "alignment" effort to allow NetBeans Platform 6.9 to reuse and execute OSGi bundles next to native NetBeans modules. This would allow NetBeans to benefit from existing packaged bundles available elsewhere. See live demo screencast to understand the possibilities this project opens.

Image:133-build-netigso-1_OSGiAndNetBeans.png

Resources

Plan, Status & ToDo list

There are few different directions that this project can span. Not all of them need to be implemented. Some may be implemented partially, some not at all. Here is the list of currently known areas.

Quality

Runtime

The inter operability and backward compatibility is achieved by running both runtimes next to each other. Read motivation behind this decision.

There will be one new module core.netigso part of NetBeans platform 6.9. This module will provide the bridge between NetBeans module system and OSGi bundles by plugging into NetBeans Runtime Container and by embedding Felix to handle the OSGi bundles (alternative containers may be supported elsewhere).

There is an excellent 1:1 mapping provided by Richard Hall, yet it is bit too complex due to the attempt to support implementation dependencies. This is not really needed in the dual system which has both containers running in parallel. If one needs implementation dependency one can write NetBeans modules. If one wants OSGi, then one can depend just on public exported packages. As such the actual mapping is simplified:

NetBeans OSGi Comment Status
OpenIDE-Module: org.mymodule
 Bundle-SymbolicName: org.mymodule 
Image:Yes.png
OpenIDE-Module-Specification-Version: 7.3
 Bundle-Version: 7.3 
for org.mymodule Image:Yes.png
OpenIDE-Module: org.mymodule/2
 Bundle-SymbolicName: org.mymodule 
Image:Yes.png
OpenIDE-Module-Specification-Version: 7.3
 Bundle-Version: 207.3 
for org.mymodule/2 Image:Yes.png
OpenIDE-Module-Public-Packages: x.y.z
 Export-Package: x.y.z 
Image:Yes.png
OpenIDE-Module-Module-Dependencies: another.module > 2.1
 Require-Bundle: another.module;version="[2.1, 100.0)" 
Image:Yes.png
OpenIDE-Module-Module-Dependencies: another.module/2 > 2.1
 Require-Bundle: another.module;version="[202.1, 300.0)" 
Image:Yes.png
OpenIDE-Module-Module-Dependencies: another.module/1-2 > 1.38
 Require-Bundle: another.module;version="[101.38,300)" 
Image:Yes.png
OpenIDE-Module-Module-Dependencies: mysistermodule = 1.0-release-g not supported Image:No.png
OpenIDE-Module-Layer: Recognized Image:Yes.png


There are also other tasks related to runtime aspects of the NetBeans and OSGi synergy:

  • Image:Yes.png: Extend Felix to eliminate current use of reflection (0days of work, convince Richard Hall to integrate FELIX-1991 the patch)
  • Image:Yes.png Lookup.getDefault() exposes what is registered via BundleContext.registerService(...)
  • Image:No.png Expose in BundleContext.getServides what is in Lookup.getDefault()
  • Image:Yes.png, 3hours, jtulach: BundleActivator.stop is never called

Development via Ant

  • Image:Yes.png Automate creation of OSGi clusters: ant -f $NETIGSO/harness/suite.xml clusterize -Dcluster=`pwd` -Dincludes=modules/**
  • Image:Yes.png I can import the cluster, See the module, Set a dependency on it from another module
  • Image:Yes.png 42efcb3cdfa5: UI for clusterizing set of bundles
  • Image:Yes.png 8e15557466f2, jtulach: Modules can now be only in direct subdirectory under the cluster - allow them to be anywhere under the cluster
  • Image:Yes.png Verify by importing GlassFish and Eclipse bundles
  • Image:Yes.png New OSGi module project template
  • Image:Yes.png Make apisupport specific templates work in OSGi module project

The current apisupport harness has been extended to allow generation of both NetBeans as well as OSGi modules/bundles. Each project has its own manifest.mf file. In case there is OpenIDE-Module tag, the build injects NetBeans metadata into the final JAR's manifest. In case the previous tag is missing, and there is Bundle-SymbolicName tag, the OSGi like dependencies are injected instead. This allows people to easily switch between both systems with just a single line change in the manifest.mf file.

Image:RCP-devel-architecture-ant-with-bridge.png

Picture taken from RcpDevelWithBridgedOSGi.

Development via Maven

No need for special handling of OSGi bundles. There exist plugins that support creation of OSGi JARs. However we need to fix the final plugin that packages the NetBeans based application to allow proper reuse of OSGi bundles from Maven repositories:

  • Image:Yes.png, mkleint: The NBM plugin needs to understand OSGi metadata like the Ant task does


Image:RCP-devel-architecture-maven-with-bridge.png

More info about the diagram is available at RcpDevelWithBridgedOSGi.

Can NetBeans run inside OSGi container?

Create common ground for those who want to adopt NetBeans libraries and APIs in other OSGi containers (GlassFish, Eclipse, etc.).

  • Image:Yes.png: Eliminate implementation dependencies in platform issue #179289
  • Image:Yes.png: Create an OSGi extender module to:
  • Make sure Lookup.getDefault() sees all META-INF/services
  • Make sure FileUtil.getConfigRoot() sees all layers
  • Make sure ModuleInstall methods are called properly

More info at NetBeansInOSGi page.

Delayed ideas

One of the goal of the OSGiAndNetBeans project is to benefit from reusing other technologies in OSGi form. The show case is supposed to be Mylyn used via OSGi. This has been implemented in NetBeans 7.1.

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo