Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The greeter demo can be found in the samples/greeter directory of the SVN code base and implements a simple OSGi Greeter Service and a consumer to that service with a trivial UI.

In this walkthrough all the required bundles are installed straight from the maven release repository, so no need to check out SVN and build anything to get started with the Greeter Demo.

The Greeter demo design

The demo is composed of 3 bundles:

...

Let's run the server in Felix 1.48.10. As a prerequisite it requires some of the OSGi Compendium Specification interfaces. These don't come with the Felix download but are built as part of the Felix build. When building a CXF DOSGi distribution, the Felix bundle with these interfaces is pulled in via Maven and put in the target/deps directory, but you can install a bundle that contains these interfaces straight from the Felix download area.
In this walkthrough I'm using the single-bundle distribution of CXF/DOSGi which can be installed straight from the Maven release repository.

To set up my Felix environment, I'm running the following commands:

Code Block
C:\felix-1.48.1>java0>java -jar bin\felix.jar

Welcome to Felix.
=================

-> ps
START LEVEL 1
   ID   State         Level  Name
[   0] [Active     ] [    0] System Bundle (1.48.10)
[   1] [Active     ] [    1] Apache Felix Shell Service (1.2.0.2)
[   2] [Active     ] [    1] Apache Felix Shell TUI (1.2.0.2)
[   3] [Active     ] [    1] Apache Felix Bundle Repository (1.24.10)
-> start filehttp:/<dosgi-root>/distribution/single-bundle/target/deps/www.apache.org/dist/felix/org.osgi.compendium-1.2.0.jar
-> start filehttp:/<dosgi-root>/distribution/single-bundle/target//repo2.maven.org/maven2/org/apache/cxf/dosgi/cxf-dosgi-ri-singlebundle-distribution/1.0/cxf-dosgi-ri-singlebundle-distribution-1.0-SNAPSHOT.jar

Some log messages may come up now.
Note that instead of manually adding these bundles to the Felix container, you can also append the target/felix.config.properties.append file to the <felix-root>/conf/config.properties file. This will automatically load these two bundles when Felix starts up.

Now let's start up the server-side greeter bundles. Like with the DOSGi bundle itself, I'm installing these straight from the Maven release repository.

Code Block

-> start file:/<dosgi-root>/samples/greeter/interface/targethttp://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-SNAPSHOT.jar
-> start file:/<dosgi-root>/samples/greeter/impl/targethttp://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-SNAPSHOT.jar
-> ps
START LEVEL 1
   ID   State         Level  Name
[   0] [Active     ] [    0] System Bundle (1.48.10)
[   1] [Active     ] [    1] Apache Felix Shell Service (1.2.0.2)
[   2] [Active     ] [    1] Apache Felix Shell TUI (1.2.0.2)
[   3] [Active     ] [    1] Apache Felix Bundle Repository (1.24.10)
[   4] [Active     ] [    1] OSGi R4 Compendium Bundle (4.1.0)
[   5] [Active     ] [    1] Distributed OSGi Distribution Software Single-Bundle Distribution
[   8] [Active     ] [    1] CXF Distributed OSGi Greeter Demo Interface Bundle
[   9] [Active     ] [    1] CXF Distributed OSGi Greeter Demo Service Implementation Bundle

...

Code Block
java -jar plugins/org.eclipse.osgi_3.5.0.v20081201-1815.jar -configuration conf -console
osgi> install file:plugins/org.eclipse.osgi.services_3.2.0.v20081205-1800.jar
Bundle id is 1
osgi> start 1

osgi> install file:/<dosgi-root>/distribution/single-bundle/targethttp://repo2.maven.org/maven2/org/apache/cxf/dosgi/cxf-dosgi-ri-singlebundle-distribution/1.0/cxf-dosgi-ri-singlebundle-distribution-1.0-SNAPSHOT.jar
Bundle id is 2
osgi> start 2

Some logging messages may appear. You can also automatically load the DOSGi bundles by appending the target/equinox.config.ini.append to you equinox config.ini file.

Code Block
osgi> install file:/<dosgi-root>/samples/greeter/interface/targethttp://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-SNAPSHOT.jar
Bundle id is 3
osgi> install file:/<dosgi-root>/samples/greeter/client/targethttp://repo2.maven.org/maven2/org/apache/cxf/dosgi/samples/cxf-dosgi-ri-samples-greeter-client/1.0/cxf-dosgi-ri-samples-greeter-client-1.0-SNAPSHOT.jar
Bundle id is 4
osgi> ss

Framework is launched.

id      State       Bundle
0       ACTIVE      org.eclipse.osgi_3.5.0.v20081201-1815
1       ACTIVE      org.eclipse.osgi.services_3.2.0.v20081205-1800
2       ACTIVE      cxf-dosgi-ri-singlebundle-distribution
3       INSTALLED   cxf-dosgi-ri-samples-greeter-interface
4       INSTALLED   cxf-dosgi-ri-samples-greeter-client

osgi> start 4

...