...
- The Greeter Interface bundle
- The Greeter Service Implementation bundle
- The Greeter Service Consumer bundle
The Greeter Interface bundle exports theGreeterService
interface which both other bundles depend on. This is the interface:
TheCode Block java java public interface GreeterService { Map<GreetingPhrase, String> greetMe(String name) throws GreeterException; }
GreetingPhase
andGreeterException
classes are also defined by this bundle.
The Server Side
The Greeter Service bundle provides a trivial implementation of the GreeterService interface. Additionally, it has an Activator:
...
- The
osgi.remote.interfaces
property is set to '*', which means that all the interfaces passes to registerService are good for remoting. In this case it's just theGreeterService
interface. - The
osgi.remote.configuration.type
is set topojo
, which is a CXF specific configuration type that can be used to set the URL at which the service is to be exposed. This is done via theosgi.remote.configuration.pojo.address
property.
Let's run the server in Felix 1.4.1. 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 distribution, the Felix bundle with these interfaces is pulled in via Maven and put in the target/deps directory.
To set up my Felix environment, I'm running the following commands:
Code Block |
---|
C:\felix-1.4.1>java -jar bin\felix.jar
Welcome to Felix.
=================
-> ps
START LEVEL 1
ID State Level Name
[ 0] [Active ] [ 0] System Bundle (1.4.1)
[ 1] [Active ] [ 1] Apache Felix Shell Service (1.0.2)
[ 2] [Active ] [ 1] Apache Felix Shell TUI (1.0.2)
[ 3] [Active ] [ 1] Apache Felix Bundle Repository (1.2.1)
-> start file:/<dosgi-root>/distribution/single-bundle/target/deps/org.osgi.compendium-1.2.0.jar
-> start file:/<dosgi-root>/distribution/single-bundle/target/cxf-dosgi-ri-singlebundle-distribution-1.0-SNAPSHOT.jar
|
Some log meesages 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.
Code Block |
---|
-> start file:/<dosgi-root>/samples/greeter/interface/target/cxf-dosgi-ri-samples-greeter-interface-1.0-SNAPSHOT.jar
-> start file:/<dosgi-root>/samples/greeter/impl/target/cxf-dosgi-ri-samples-greeter-impl-1.0-SNAPSHOT.jar
-> ps
START LEVEL 1
ID State Level Name
[ 0] [Active ] [ 0] System Bundle (1.4.1)
[ 1] [Active ] [ 1] Apache Felix Shell Service (1.0.2)
[ 2] [Active ] [ 1] Apache Felix Shell TUI (1.0.2)
[ 3] [Active ] [ 1] Apache Felix Bundle Repository (1.2.1)
[ 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
|
Some more log messages come up. When it says INFO: Remote org.apache.cxf.dosgi.samples.greeter.GreeterService endpoint has been published into Discovery service you know that the service is exposed remotely, and you can verify this by requesting the WSDL: