Difference between revisions of "Eclipse:osgiDS"

From RifidiWiki

Jump to: navigation, search
m (Reverted edits by Amesycyxa (Talk); changed back to last version by Jochen)
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
==Intro==
 
==Intro==
 +
Here is a little series about osgi (including declarative services, look at part 7 and 8) [http://neilbartlett.name/blog/osgi-articles/]<br/>
 
Getting declarative services into Eclipse RCP was quite a fight but with the help of some fellows from the #eclipse irc channel I finally managed to get 'em up and running.
 
Getting declarative services into Eclipse RCP was quite a fight but with the help of some fellows from the #eclipse irc channel I finally managed to get 'em up and running.
 +
 
==Prerequisites==
 
==Prerequisites==
 
First we need to get some missing plugins.<br/>
 
First we need to get some missing plugins.<br/>
Line 27: Line 29:
 
Opening it up should give you something like this:<br/>
 
Opening it up should give you something like this:<br/>
 
<br/>
 
<br/>
#Configuration File
+
#Configuration File
#Mon May 05 23:09:09 CEST 2008
+
#Mon May 05 23:09:09 CEST 2008
  osgi.bundles=reference\:file\:/home/jochen/bin/eclipse/plugins/org.eclipse.equinox.ds_1.0.0.v20070226.jar@4\:start,reference\:file\:/home/jochen/bin/eclipse/plugins/org.eclipse.equinox.common_3.3.0.v20070426.jar@2\:start,reference\:file\:/home/jochen/bin/eclipse/plugins/org.eclipse.update.configurator_3.2.101.R33x_v20070810.jar@3\:start,reference\:file\:/home/jochen/bin/eclipse/plugins /org.eclipse.core.runtime_3.3.100.v20070530.jar@start,org.rifidi.designer.rcp.gpioeditor@5
+
  osgi.bundles=reference\:file\:/home/jochen/bin/eclipse/plugins/org.eclipse.equinox.common_3.3.0.v20070426.jar@2\:start,reference\:file\:/home/jochen
 +
/bin/eclipse/plugins/org.eclipse.update.configurator_3.2.101.R33x_v20070810.jar@3\:start
 +
osgi.bundles.defaultStartLevel=4
 +
osgi.install.area=file\:/home/jochen/bin/eclipse
 +
osgi.framework=file\:/home/jochen/bin/eclipse/plugins/org.eclipse.osgi_3.3.2.R33x_v20080105.jar
 +
osgi.configuration.cascaded=false
 +
osgi.splashPath=file\:/home/jochen/workspace/org.rifidi.designer.rcp
 +
<br/>
 +
To be save I changed the default start level of the bundles to 5 and I will ad a statement to start the ds bundle at level 4.<br/>
 +
This allows ds to start before any of the other bundles get initialized.<br/>
 +
I am not 100 percent sure if this is really required but I figured it might be good to make sure when things get started.<br/>
 +
<br/>
 +
#Configuration File
 +
#Mon May 05 23:09:09 CEST 2008
 +
osgi.bundles=reference\:file\:/home/jochen/bin/eclipse/plugins/org.eclipse.equinox.ds_1.0.0.v20070226.jar@4\:start,reference\:file\:/home/jochen
 +
/bin/eclipse/plugins/org.eclipse.equinox.common_3.3.0.v20070426.jar@2\:start,reference\:file\:/home/jochen/bin/eclipse/plugins
 +
/org.eclipse.update.configurator_3.2.101.R33x_v20070810.jar@3\:start
 
  osgi.bundles.defaultStartLevel=5
 
  osgi.bundles.defaultStartLevel=5
 
  osgi.install.area=file\:/home/jochen/bin/eclipse
 
  osgi.install.area=file\:/home/jochen/bin/eclipse
Line 35: Line 53:
 
  osgi.configuration.cascaded=false
 
  osgi.configuration.cascaded=false
 
  osgi.splashPath=file\:/home/jochen/workspace/org.rifidi.designer.rcp
 
  osgi.splashPath=file\:/home/jochen/workspace/org.rifidi.designer.rcp
 +
<br/>
 +
After editing this file store it in any directory and adjust the area that within the red box.<br/>
 +
Switch from the default config.ini to a custom one and point eclipse to the location of your file.<br/>
 +
Now hit run and watch the magic unfold.

Latest revision as of 19:41, 26 November 2010

Intro

Here is a little series about osgi (including declarative services, look at part 7 and 8) [1]
Getting declarative services into Eclipse RCP was quite a fight but with the help of some fellows from the #eclipse irc channel I finally managed to get 'em up and running.

Prerequisites

First we need to get some missing plugins.
The declarative services spec is part of the services for OSGI R4 but it is not part of the equinox that is distributed with eclipse 3.3.
So we need to go here:[2]

  • Under latest releases select 3.3.2
  • Scroll down to "Incubator" bundles
  • download org.eclipse.equinox.ds<whateverversionisthere>.jar (this is the declarative services plugin)
  • download org.eclipse.equinox.cm<whateverversionisthere>.jar (this is the OSGI admin service)
  • add the downlaoded packages to your plugins directory
  • restart eclipse

How to get it into your RCP

Now comes the tricky part.
Being used to eclipse you would think adding the plugins to your run config and then firing up your app should do the trick.
Nope, as you might have guessed, it's not that easy.
Right now we need to get our hands dirty as we have to directly have to modify the config.ini.
For a regular RCP application you don't have to touch this file and eclipse will create one for you on every run.
But we actually want to use some fairly advanced features of the underlying osgi implementation and that's where we leave the default way.
Open up the run configuration for your RCP app.

Runconfiguration.jpg

The red box shows where you have to edit.
But before it starts to get messy we need a config.ini template tow ork on.
Above the red box you can see a hook at default location. Go to the specified directory and pick the config.ini that is in there.
Opening it up should give you something like this:

#Configuration File
#Mon May 05 23:09:09 CEST 2008
osgi.bundles=reference\:file\:/home/jochen/bin/eclipse/plugins/org.eclipse.equinox.common_3.3.0.v20070426.jar@2\:start,reference\:file\:/home/jochen
/bin/eclipse/plugins/org.eclipse.update.configurator_3.2.101.R33x_v20070810.jar@3\:start
osgi.bundles.defaultStartLevel=4
osgi.install.area=file\:/home/jochen/bin/eclipse
osgi.framework=file\:/home/jochen/bin/eclipse/plugins/org.eclipse.osgi_3.3.2.R33x_v20080105.jar
osgi.configuration.cascaded=false
osgi.splashPath=file\:/home/jochen/workspace/org.rifidi.designer.rcp


To be save I changed the default start level of the bundles to 5 and I will ad a statement to start the ds bundle at level 4.
This allows ds to start before any of the other bundles get initialized.
I am not 100 percent sure if this is really required but I figured it might be good to make sure when things get started.

#Configuration File
#Mon May 05 23:09:09 CEST 2008
osgi.bundles=reference\:file\:/home/jochen/bin/eclipse/plugins/org.eclipse.equinox.ds_1.0.0.v20070226.jar@4\:start,reference\:file\:/home/jochen
/bin/eclipse/plugins/org.eclipse.equinox.common_3.3.0.v20070426.jar@2\:start,reference\:file\:/home/jochen/bin/eclipse/plugins
/org.eclipse.update.configurator_3.2.101.R33x_v20070810.jar@3\:start
osgi.bundles.defaultStartLevel=5
osgi.install.area=file\:/home/jochen/bin/eclipse
osgi.framework=file\:/home/jochen/bin/eclipse/plugins/org.eclipse.osgi_3.3.2.R33x_v20080105.jar
osgi.configuration.cascaded=false
osgi.splashPath=file\:/home/jochen/workspace/org.rifidi.designer.rcp


After editing this file store it in any directory and adjust the area that within the red box.
Switch from the default config.ini to a custom one and point eclipse to the location of your file.
Now hit run and watch the magic unfold.

Personal tools