...
It uses the CXF/DOSGi multi bundle distribution since that provides Spring-DM as a dependency. By installing the multi bundle distribution, you have all the prerequisites to run this demo. See here for instructions on installing the multi bundle distribution.
Demo design
From a high level the demo is very similar to the greeter demo. It comprises of 3 bundles:
...
Code Block | ||||
---|---|---|---|---|
| ||||
<beans xmlns:osgi="..."> <osgi:service interface="org.apache.cxf.dosgi.samples.springdm.DinnerService"> <osgi:service-properties> <entry key="osgiservice.remoteexported.interfaces" value="*" /> </osgi:service-properties> <bean class="org.apache.cxf.dosgi.samples.springdm.impl.DinnerServiceImpl" /> </osgi:service> </beans> |
Unlike in the Greeter demo osgi.remote.configuration...
properties are not set in the configuration, this means that the service is exposed on the default location of http://localhost:9000/org/apache/cxf/dosgi/samples/springdm/DinnerService
. The default location is based on the interface name of the service being remoted.
...
Code Block |
---|
-> start http://repo2.maven.org/maven2/org/apache/cxf/dosgi/samples/cxf-dosgi-ri-samples-spring-dm-interface/1.12/cxf-dosgi-ri-samples-spring-dm-interface-1.12.jar -> start http://repo2.maven.org/maven2/org/apache/cxf/dosgi/samples/cxf-dosgi-ri-samples-spring-dm-impl/1.12/cxf-dosgi-ri-samples-spring-dm-impl-1.12.jar ... log messages may appear ... -> ps START LEVEL 32 ID State Level Name [ 0] [Active ] [ 0] System Bundle (1.8.0) ... bundles ... [ 35] [Active ] [ 1] CXF Distributed OSGi Spring-DM Sample Interface Bundle [ 36] [Active ] [ 1] CXF Distributed OSGi Spring-DM Sample Implementation Bundle |
...
Like in the Greeter demo, the client side needs to be configured to know where the remote service actually is. When using a Discovery system this configuration is provided dynamically via Discovery (, see the Discovery demo - TODO) DOSGi Discovery Demo page. In this demo this information is provided statically in a OSGI-INF/remote-service/remote-services.xml
file.
Code Block | ||||
---|---|---|---|---|
| ||||
<service<endpoint-descriptions xmlns="http://www.osgi.org/xmlns/sdrsa/v1.0.0"> <service<endpoint-description> <provide<property interfacename="org"objectClass"> <array> <value>org.apache.cxf.dosgi.samples.springdm.DinnerService" DinnerService</>value> <property name="osgi.remote.interfaces">* </property>array> <property name="osgi.remote.configuration.type">pojo<</property> <property name="osgi.remote.configuration.pojo.addressendpoint.id">http://localhost:9000/org/apache/cxf/dosgi/samples/springdm/DinnerService</property> <property name="service.imported.configs">org.apache.cxf.ws</property> </serviceendpoint-description> </serviceendpoint-descriptions> |
Install and run the consumer side of the demo in a separate Felix instance:
Code Block |
---|
-> start http://repo2.maven.org/maven2/org/apache/cxf/dosgi/samples/cxf-dosgi-ri-samples-spring-dm-interface/1.12/cxf-dosgi-ri-samples-spring-dm-interface-1.12.jar -> start http://repo2.maven.org/maven2/org/apache/cxf/dosgi/samples/cxf-dosgi-ri-samples-spring-dm-client/1.12/cxf-dosgi-ri-samples-spring-dm-client-1.12.jar ... log messages may appear, at some point the consumer will make an invocation on the remote service, you will see: Found the following restaurants: Jojo's (1 food way) Rating: 3 Boohaa's (95 forage ave) Rating: 1 MicMac (Plastic Plaza) Rating: 1 |
...