Blog

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Updated to karaf 4

...

Our example is again the tasklist example from Part 1 of this tutorial. The only difference is that we now deploy the model and the persistence service on container A and model and UI to container B and we install the dosgi runtime on bother containers.

Gliffy Diagram
nameDeployment
version2

As DOSGi should not be active for all services on a system the spec defines that the service property "osgi.remote.interfaces" triggers if DOSGi should process the service. It expects the interface names that this service should export remotely. Setting the property to "*" means that all interfaces the service implements should be exported. The tasklist persistence service already sets the property so the service is exported with defaults.

...

To keep things simple we will install container A and B on the same system.

Code Block
languagebash
titleInstall Service
config:property-set -p org.apache.cxf.dosgi.discovery.zookeeper zookeeper.port 2181

...


config:property-set -p org.apache.cxf.dosgi.discovery.zookeeper.server clientPort 2181

...


feature:repo-add cxf-dosgi 1.

...

7.0

...


feature:install cxf-dosgi-discovery-distributed cxf-dosgi-zookeeper-server

...


feature:repo-add mvn:net.lr.tasklist/tasklist-features/1.0.0-SNAPSHOT/xml

...


feature:install example-tasklist-persistence

After these commands the tasklist persistence service should be running and be published on zookeeper.

...

  • Unpack into folder container_b
  • Start bin/karaf

 

Code Block
languagebash
titleInstall Client
config:property-set -p org.ops4j.pax.web org.osgi.service.http.port 8182

...


config:property-set -p org.apache.cxf.dosgi.discovery.zookeeper zookeeper.port 2181

...


feature:repo-add cxf-dosgi 1.

...

7.0

...


feature:install cxf-dosgi-discovery-distributed

...


feature:repo-add mvn:net.lr.tasklist/tasklist-features/1.0.0-SNAPSHOT/xml

...


feature:install example-tasklist-ui

 

The tasklist client ui should be in status Active/Created and the servlet should be available on http://localhost:8182/tasklist. If the ui bundle stays in status graceperiod then DOSGi did not provide a local proxy for the persistence service.

How does it work

Gliffy Diagram
namedosgi_in_details
version3

The Remote Service Admin spec defines an extension of the OSGi service model. Using special properties when publishing OSGi services you can tell the DOSGi runtime to export a service for remote consumption. The CXF DOSGi runtime listens for all services deployed on the local container. It only processes services that have the "osgi.remote.interfaces" property. If the property is found then the service is either exported with the named interfaces or with all interfaces it implements.The way the export works can be fine tuned using the CXF DOSGi configuration options.

...