This page (revision-13) was last changed on 23-Apr-2022 17:05 by Harry Metske

This page was created on 23-Apr-2022 17:05 by Harry Metske

Only authorized users are allowed to rename pages.

Only authorized users are allowed to delete pages.

Page revision history

Version Date Modified Size Author Changes ... Change note
13 23-Apr-2022 17:05 7 KB Harry Metske to previous
12 23-Apr-2022 17:05 6 KB Harry Metske to previous | to last
11 23-Apr-2022 17:05 6 KB Harry Metske to previous | to last
10 23-Apr-2022 17:05 6 KB Harry Metske to previous | to last
9 23-Apr-2022 17:05 4 KB Harry Metske to previous | to last
8 23-Apr-2022 17:05 3 KB Harry Metske to previous | to last
7 23-Apr-2022 17:05 3 KB Harry Metske to previous | to last
6 23-Apr-2022 17:05 2 KB Harry Metske to previous | to last
5 23-Apr-2022 17:05 2 KB Harry Metske to previous | to last
4 23-Apr-2022 17:05 1 KB Harry Metske to previous | to last
3 23-Apr-2022 17:05 1 KB Harry Metske to previous | to last
2 23-Apr-2022 17:05 598 bytes Harry Metske to previous | to last
1 23-Apr-2022 17:05 525 bytes Harry Metske to last

Page References

Incoming links Outgoing links
OSGi...nobody

Version management

Difference between version and

At line 3 added 4 lines
[{TableOfContents }]
\\
At line 25 added 2 lines
* [bnd tool|http://www.aqute.biz/Bnd/Bnd]
* [Apache Felix downloads (bundles)|http://mirror.switch.ch/mirror/apache/dist/felix/]
At line 22 removed one line
At line 41 added 122 lines
You also need a {{configuration/config.ini}} file with (example) the following contents to be able to run a basic OSGi runtime:
{{{
# contents of config.ini
osgi.bundles=\
/usr/local/equinox-sdk-keplersr1/plugins/org.apache.felix.gogo.command_0.10.0.v201209301215.jar,\
/usr/local/equinox-sdk-keplersr1/plugins/org.apache.felix.gogo.runtime_0.10.0.v201209301036.jar,\
/usr/local/equinox-sdk-keplersr1/plugins/org.apache.felix.gogo.shell_0.10.0.v201212101605.jar,\
/usr/local/equinox-sdk-keplersr1/plugins/org.eclipse.equinox.console_1.0.100.v20130429-0953.jar,\
/usr/local/equinox-sdk-keplersr1/plugins/org.eclipse.osgi_3.9.1.v20130814-1242.jar@-1:start
}}}
All parameters for the config.ini are documented on the [Eclipse Help platform|http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fmisc%2Fruntime-options.html]
Install the bndtools from Eclipse update site [http://bndtools-updates.s3.amazonaws.com/]
Create the HelloWorldActivator.java file :
%%prettify
{{{
package org.osgi.tutorial;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
public class HelloWorldActivator implements BundleActivator {
public void start(BundleContext context) throws Exception {
System.out.println(" Hello , World ! ");
}
public void stop(BundleContext context) throws Exception {
System.out.println(" Goodbye , World ! ");
}
}
}}} &&
And the helloworld.bnd file (in root of project) :
%%prettify
{{{
# helloworld . bnd
Private-Package: org.osgi.tutorial
Bundle-Activator: org.osgi.tutorial.HelloWorldActivator
Bundle-Version: 1.0
Bundle-Name: HelloWorld Sampletje
Bundle-Description: Wat een prachtvoorbeeld !
Bundle-Category: Tutor
Bundle-License: Apache
Bundle-Vendor: DirtyHarry
Bundle-ContactAddress: NL
Bundle-DocURL: http://www.computerhok.nl
}}} %%
!! Switch to IntelliJ and maven-bundle-plugin
Import the same project in IntelliJ and add framework support for maven.
This is the basic [pom.xml] file to use
Then run {{mvn clean install org.apache.felix:maven-bundle-plugin:bundle}} to create the first bundle in ./target.
Fire up the Felix shell : {{cd /usr/local/felix && java -jar bin/felix.jar}}
The {{lb}} command lists the currently installed bundles, and we install our bundle with :
{{{
g! install file:/home/metskem/workspace/OSGiTutorial/target/OSGiTutorial-1.0-SNAPSHOT.jar
Bundle ID: 13
g! lb
START LEVEL 1
ID|State |Level|Name
0|Active | 0|System Bundle (4.2.1)
1|Active | 1|Apache Felix Bundle Repository (1.6.6)
2|Active | 1|Apache Felix Gogo Command (0.12.0)
3|Active | 1|Apache Felix Gogo Runtime (0.10.0)
4|Active | 1|Apache Felix Gogo Shell (0.10.0)
13|Installed | 1|file:/home/metskem/workspace/OSGiTutorial/target/OSGiTutorial-1.0-SNAPSHOT.jar (0.0.0)
g! start 13
g!
}}}
Install __Felix web console__ with {{g! install http://mirror.switch.ch/mirror/apache/dist/felix/org.apache.felix.webconsole-4.2.0.jar}} and the Felix log service with {{g! install http://mirror.switch.ch/mirror/apache/dist/felix/org.apache.felix.log-1.0.1.jar}}
{{{
g! install http://mirror.switch.ch/mirror/apache/dist/felix/org.apache.felix.log-1.0.1.jar
Bundle ID: 15
g! lb
START LEVEL 1
ID|State |Level|Name
0|Active | 0|System Bundle (4.2.1)
1|Active | 1|Apache Felix Bundle Repository (1.6.6)
2|Active | 1|Apache Felix Gogo Command (0.12.0)
3|Active | 1|Apache Felix Gogo Runtime (0.10.0)
4|Active | 1|Apache Felix Gogo Shell (0.10.0)
13|Active | 1|file:/home/metskem/workspace/OSGiTutorial/target/OSGiTutorial-1.0-SNAPSHOT.jar (0.0.0)
14|Installed | 1|Apache Felix Web Management Console (4.2.0)
15|Installed | 1|Apache Felix Log Service (1.0.1)
}}}
!! Apache Felix Web Console
Doing everything from the (very limited) felix command shell is tedious, so we try to get the web console working.\\
The primary bundle is the [full webconsole bundle|http://mirror.switch.ch/mirror/apache/dist/felix/org.apache.felix.webconsole-4.2.0.jar]
After fiddling a lot with required bundles I finally got it working. The required bundles in addition to the webconsole were:
[OSGi Compendium|http://mirror.switch.ch/mirror/apache/dist/felix/org.osgi.compendium-1.4.0.jar] and the [Jetty http service|http://mirror.switch.ch/mirror/apache/dist/felix/org.apache.felix.http.jetty-2.2.2.jar] and I also installed the [Log service|http://mirror.switch.ch/mirror/apache/dist/felix/org.apache.felix.webconsole-4.2.0.jar], this is not required however.
This makes up the following bundle list :
{{{
g! lb
START LEVEL 1
ID|State |Level|Name
0|Active | 0|System Bundle (4.2.1)
1|Active | 1|Apache Felix Bundle Repository (1.6.6)
2|Active | 1|Apache Felix Gogo Command (0.12.0)
3|Active | 1|Apache Felix Gogo Runtime (0.10.0)
4|Active | 1|Apache Felix Gogo Shell (0.10.0)
15|Active | 1|Apache Felix Log Service (1.0.1)
19|Active | 1|OSGiTutorial (1.0.0.SNAPSHOT)
25|Active | 1|Apache Felix Web Management Console (All In One) (4.2.0.all)
41|Active | 1|Apache Felix Http Jetty (2.2.2)
42|Resolved | 1|OSGi R4 Compendium Bundle (4.1.0)
}}}
And there we have our [web console|http://localhost:8080/system/console] . user=admin, password=admin.