Alien Invasion
OSGi Guru Peter Kriens has created a nice example application for Equinox a while ago. The idea is to find out how web based UI’s can benefit OSGi applications. It uses the OSGi HTTP Service as a web server. The web app serves a SUDOKU game with an SVG and Javascript UI. Time intense calculations are invoked on the server via Remote Procedure Calls. Peter has created a webrpc bundle that handles the remote procedure calls between the GUI and the server. The example is described in more detail in his blog.
After my first success in loading alien bundles in project netigso, I decided to port this example to the NetBeans platform. It involves some hacking, because there are some overlaps between the packages in one of the bundles with felix.
1. To get started clone the netigso repository ( http://hg.netbeans.org/netigso/ ) , open module core.netigso, modify the NetigsoModuleFactory and modify the configMap in getContainer():
configMap.put(Constants.FRAMEWORK_SYSTEMPACKAGES,
“org.osgi.framework; version=1.3.0,” +
“org.osgi.service.packageadmin; version=1.2.0,” +
“org.osgi.service.startlevel; version=1.0.0,” +
“org.osgi.service.url; version=1.0.0″);
2. To build the platform, open the project nbbuild, right click the build.xml and invoke the target build-platform.
3. Go to Tools -> Platform manager choose add a new Platform, and point it to the netbeans folder inside the nbbuild folder.
4. Create a new NetBeans Platform Application, right-click it and select your newly added platform in the library section.
5. Download and unpack Equinox ( Yes… real Aliens )
6. Create a folder “sudoku_plugin/modules” somewhere in your filesystem and copy:
org.eclipse.osgi_….jar
org.eclipse.osgi.services_…..jar
org.eclipse.equinox.util_…..jar
org.eclipse.equinox.ds_….jar
javax.servlet_…..jar
org.eclipse.equinox.http_….jar
there.
7. Next download webrpc.jar and sudoku.jar and also copy them to the modules dir.
8. Now unzip your org.eclipse.osgi_….jar and delete folder org/osgi.
Those are the packages that would clash with the Felix System bundle.
9. create a file called MANIFEST.MF with this content:
Manifest-Version: 1.0
Eclipse-ExtensibleAPI: true
Main-Class: org.eclipse.core.runtime.adaptor.EclipseStarter
Bundle-SymbolicName: org.eclipse.osgi; singleton:=true
Bundle-DocUrl: http://www.eclipse.org
Bundle-Description: %systemBundle
Bundle-ManifestVersion: 2
Eclipse-SystemBundle: true
Bundle-Version: 3.4.0.v20080605-1900
Bundle-Vendor: %eclipse.org
Bundle-RequiredExecutionEnvironment: J2SE-1.4,OSGi/Minimum-1.1
Bundle-Copyright: %copyright
Bundle-Localization: systembundle
Bundle-Name: %systemBundle
Export-Package: org.eclipse.osgi.service.debug;version=”1.0″,org.eclipse.osgi.util;version=”1.1″
10. Pack it again with the jar tool:
jar cmf MANIFEST.MF org.eclipse.util.jar org
11. In your sudoku folder invoke:
ant -f $NETIGSO/harness/suite.xml clusterize -Dcluster=`pwd` -Dincludes=modules/**
This will create folder config/Modules in your directory with an xml configuration file for each bundle
12. By default the bundles are set on autoload, but we need them to be installed and started, so we change the autoload parameter in all of the files to “false” and add:
<param name=”enabled”>true</param>
13. Now right-click your module suite, go to the library section and click “add cluster”. Point the FileChooser to your sudoku_cluster directory and confirm. You now can see a new cluster “sudoku_cluster” in the list.
14. Open cluster platform10 and disable all modules except for Bootstrap, File System API, Module System API, NetBeans OSGi Integration, org.apache.felix.main, Startup and Utilities API. This is the minimum Platform for OSGi based applications with NetBeans
15. In your Platform Application open the “Important Files” folder and add this to “Project Properties”:
run.args.extra=–nosplash
That also hides the splashscreen on startup
16. Now run your application, go to
http://localhost/rpc
and enjoy a pure Server Application based on NetBeans Platform and OSGi
17. Wait for more news, because Sven Reimers is sitting right next to me trying to embedd Glassfish into netigso, so stay tuned for more news on NB and OSGi.



Congrats. I am amazed by your progress. Looks like Netigso started a snowball.
Comment by Jaroslav Tulach
— 1. June 2009 @ 07:40