Red Hat Training
A Red Hat training course is available for Red Hat Fuse
D.4. OSGi service discovery
The OSGi registry typically stores references to local services. However, it is also relatively easy to configure Fabric to store remote OSGi services in the Fabric registry, so that you can realize invisible remoting of OSGi services, with support for dynamic discovery, load balancing and fail over. Fabric follows the OSGi Remote Services specification: any service exported to the OSGi registry with the
service.exported.interfacesproperty (having a value of
*or an explicit list of interfaces to export) is automatically exported to the Fabric registry and becomes accessible to other remote containers in the same fabric.
For example, to expose an OSGi service in the fabric using Blueprint XML, define the OSGi service as follows:
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"> <bean id="theBean" class="foo.bar.Example" /> <service ref="theBean" auto-export="interfaces"> <service-properties> <entry key="service.exported.interfaces" value="*"/> </service-properties> </service> </blueprint>
To import an OSGi service from the fabric, simply reference the OSGi service in the usual way (for example, using Blueprint XML or through the OSGi Java API).