CXF DOSGi in Apache Karaf
Since version 1.4.0 of CXF DOSGi there is a feature for Apache Karaf which makes installing DOSGi really easy. Using the descriptions below a working demo should be up in less than 10 minutes.
Download and unpack Apache Karaf
- Download apache karafCopy etc/jre.properties.cxf to etc/jre.properties -> This is needed in karaf 2.2.x to adjust the system package exports so CXF can install correctly 4
- Unpack and start it
...
Installation of CXF-DOSGi
Code Block |
---|
|
feature:repo-add aries-rsa
features:chooseurl cxf-dosgi 1.49.0
featuresfeature:installrepo-add cxf-dosgi-discovery-distributed
|
Create config "etc/org.apache.cxf.dosgi.discovery.zookeeper.cfg" with the following content:
Code Block |
---|
zookeeper.port=2181
zookeeper.host=localhost
|
Installation of the zookeeper Server
Code Block |
---|
features 1.8.0
feature:install cxf-dosgi-zookeeper-server
|
Create config "etc/org.apache.cxf.dosgi.discovery.zookeeper.server.cfg" with the following content:
Code Block |
---|
zookeeper.host:127.0.0.1
clientPort:2181
zookeeper.port:2181
provider-cxf |
Test installation with greeter demo
Code Block |
---|
|
install -s mvn:org.apache.cxf.dosgi.samples/cxf-dosgi-ri-samples-greeter-interface/1.48.0
install -s mvn:org.apache.cxf.dosgi.samples/cxf-dosgi-ri-samples-greeter-impl/1.48.0
|
log:display endpoints should show the greeter service being exported:
Code Block |
---|
|
Endpoints for framework 346376f5-ef56-4bda-b238-0a905ce99342
id | interfaces
2013-01-07 10:50:52,108 | INFO | pool-13-thread-1 | TopologyManagerExport | r.exporter.TopologyManagerExportframework 257 | 114 - cxf-dosgi-ri-topology-manager - 1.4.0 | TopologyManager: export sucessful Endpoints: [Endpoint Desctiption for ServiceReference [org.apache.cxf.dosgi.samples.greeter.GreeterService]
*** EndpointDescription: ****
endpoint.framework.uuid | => 74455213-0926-4fa8-b3eb-0f9b4d15f119
endpoint.id => comp name
----------------------------------------------------------------------------------------------------------------------------------------
http://localhost:9090/greeter
endpoint.package.version.org.apache.cxf.dosgi.samples.greeter => 0.0.0
endpoint.service.id => 252
objectClass =>greeter | [org.apache.cxf.dosgi.samples.greeter.GreeterService]
org.apache.cxf.ws.address => | 346376f5-ef56-4bda-b238-0a905ce99342 |
|
Now try to access the service using
http://localhost:9090/greeter
...
Access the service transparently from a second container
- Unpack karaf in a second directory and also start it.
- Do the installation steps from "Installation of CXF-DOSGi"
- Install a client to a service that is published in the first container.
- DOSGi will automatically install a proxy for you service that calls the published service remotely over CXF