NetBeans and Distributed OSGi
There’s a lot of interest in Distributed OSGi, part of OSGi Spec 4.2. The idea is to make it transparent to your bundle if a service is local or remote. That’s nice, because you can use the same code e.g. on the server where you can access a local service as on the client, where you access the service on the server remotely. The Apache CFX installation also exposes the service as a webservice, so you could call it from a regular webservice client, e.g. from a NetBeans platform app.
But why make it so complicated, with netigso around the corner it should be a breeze to get this working in NetBeans directly without the need to create webservice clients at all… To get started I downloaded the single bundle version (I’m lazy) of the reference implementation and followed the tutorial for setting it up on felix. So I downloaded the compendium interfaces and put both files in a directory named “DOSGi” in folder modules. Then I used the clusterize ANT task (ant -f /<netigso>/harness/suite.xml clusterize -Dcluster=DOSGi -Dincludes=modules/** ) and imported the cluster to a NetBeans Platform application (application project -> properties-> libraries-> add Cluster).
Next I replaced the version 1.4.1 felix.jar in my netigso platform build with a version 1.8. To see if everything is fine I also installed the remote shell (thanks Sven!) and fired up my app. Connected to the shell (telnet localhost 6666), then issued a “ps” and voila:
Felix Remote Shell Console:
============================
-> ps
START LEVEL 1
ID State Level Name
[ 0] [Active ] [ 0] System Bundle (1.8.0)
[ 1] [Installed ] [ 1] org.netbeans.bootstrap/1 (2.18)
[ 2] [Installed ] [ 1] org.openide.modules (7.10)
[ 3] [Installed ] [ 1] org.openide.util (7.22.0)
[ 4] [Installed ] [ 1] org.netbeans.core.startup/1 (1.15.0)
[ 5] [Installed ] [ 1] org.netbeans.core.netigso (1.0)
[ 6] [Installed ] [ 1] org.openide.filesystems (7.21.0)
[ 7] [Installed ] [ 1] org.jdesktop.layout/1 (1.7.0)
[ 8] [Installed ] [ 1] org.netbeans.api.annotations.common/1 (1.0)
[ 9] [Installed ] [ 1] org.netbeans.api.progress/1 (1.13.0)
[ 10] [Installed ] [ 1] org.netbeans.core.windows/2 (2.14.0)
[ 11] [Installed ] [ 1] org.netbeans.core/2 (3.11.0)
[ 12] [Installed ] [ 1] org.netbeans.libs.jna/1 (1.2)
[ 13] [Installed ] [ 1] org.netbeans.libs.junit4 (1.4)
[ 14] [Installed ] [ 1] org.netbeans.modules.editor.mimelookup/1 (1.11)
[ 15] [Installed ] [ 1] org.netbeans.modules.javahelp/1 (2.12)
[ 16] [Installed ] [ 1] org.netbeans.modules.masterfs/2 (2.16)
[ 17] [Installed ] [ 1] org.netbeans.modules.options.api/1 (1.12)
[ 18] [Installed ] [ 1] org.netbeans.modules.options.keymap (1.5)
[ 19] [Installed ] [ 1] org.netbeans.modules.print (7.0)
[ 20] [Installed ] [ 1] org.netbeans.modules.queries/1 (1.14)
[ 21] [Installed ] [ 1] org.netbeans.modules.sendopts/2 (2.4)
[ 22] [Installed ] [ 1] org.netbeans.modules.settings/1 (1.18.0)
[ 23] [Installed ] [ 1] org.netbeans.modules.spi.actions/1 (1.0)
[ 24] [Installed ] [ 1] org.netbeans.spi.quicksearch (1.1)
[ 25] [Installed ] [ 1] org.netbeans.swing.outline (1.4)
[ 26] [Installed ] [ 1] org.netbeans.swing.plaf (1.9)
[ 27] [Installed ] [ 1] org.netbeans.swing.tabcontrol (1.15)
[ 28] [Installed ] [ 1] org.openide.actions (6.9.0)
[ 29] [Installed ] [ 1] org.openide.awt (7.8.0)
[ 30] [Installed ] [ 1] org.openide.dialogs (7.10)
[ 31] [Installed ] [ 1] org.openide.explorer (6.18.0)
[ 32] [Installed ] [ 1] org.openide.io (1.16)
[ 33] [Installed ] [ 1] org.openide.loaders (7.5)
[ 34] [Installed ] [ 1] org.openide.nodes (7.9.0)
[ 35] [Installed ] [ 1] org.openide.text (6.22)
[ 36] [Installed ] [ 1] org.openide.windows (6.26)
[ 37] [Active ] [ 1] OSGi R4 Compendium Bundle (4.1.0)
[ 38] [Active ] [ 1] Apache Felix Remote Shell (1.0.4)
[ 39] [Active ] [ 1] Apache Felix Shell Service (1.2.0)
[ 40] [Active ] [ 1] Distributed OSGi Distribution Software Single-Bundle Distribution (1.0)
DOSGi is running. Since I was eager to see if things work without digging into the details of DOSGi configuration I simply installed one of the samples:
-> start http://repo2.maven.org/maven2/org/apache/cxf/dosgi/samples/cxf-dosgi-ri-samples-greeter-interface/1.0/cxf-dosgi-ri-samples-greeter-interface-1.0.jar
-> start http://repo2.maven.org/maven2/org/apache/cxf/dosgi/samples/cxf-dosgi-ri-samples-greeter-impl/1.0/cxf-dosgi-ri-samples-greeter-impl-1.0.jar
…and now I’ve got this:

So enough for today… Tomorrow I’ll try to install that on glassfish and make my NetBeans app a client. (Or in case Glassfish’s felix version is too old, I’ll use NetBeans as client and server)



GlassFish v3 Preview ships with Felix 1.8.0
Comment by Alexis MP
— 20. June 2009 @ 12:56
You are always welcome! Hope we’ll have another hack in - it was so productive!
Comment by Sven Reimers
— 20. June 2009 @ 18:37
[...] I know there are some, really, somewhere in the back of the classroom . Hopefully for you guys, people from the Netbeans community are doing some research to make OSGI bundle first class citizen in your favorite RCP [...]
Pingback by Alkpone.com» Blog Archive » Distributed OSGi, an elegant way to distribute software
— 30. August 2009 @ 18:40