Enabling integration of OSGi application services

Using the osgiAppIntegration-1.0 feature, the OSGi applications that are available within the same Java virtual machine (JVM) can share their services with each other. To enable communication between the OSGi applications, you must declare the appropriate service headers in the application manifest file, META-INF/APPLICATION.MF. An application that wants to import services from other applications must include the Application-ImportService header, and an application that wants to export services to other applications must include the Application-ExportService header. If an application wants to export and import services, then both headers must be used.

About this task

Stabilized feature: Support for OSGi applications is stabilized. Java™ Platform, Enterprise Edition (Java EE) 8 technologies are not enabled for OSGi applications and features that support OSGi development. As an alternative, develop applications by using the Java Platform, Enterprise Edition (Java EE) or Microprofile features. For more information, see Stabilized Liberty features and feature capabilities.

To enable the osgiAppIntegration-1.0 feature, you must include the feature in the server.xml file. To use the feature, you need to use the appropriate headers, such as the Application-ImportService and Application-ExportService. You must add the binding:=local directive in the headers to specify the integration of applications that are within the same JVM. The binding directive is specific only to the osgiAppIntegration-1.0 Liberty feature.

Procedure

  1. Based on your requirement, add one or both application headers to your MANIFEST.MF file as given in the following example:
    Application-ExportService: com.acme.Foo;binding:=local
    Application-ImportService: com.acme.Foo;binding:=local
    where com.acme.Foo is the name of the Java interface or class associated with the OSGi service.
    Note: You must add the binding:=local directive along with the application import and export service headers to allow the applications within the same JVM to communicate with each other.
  2. Add the feature in the server.xml file.
    <feature>osgiAppIntegration-1.0</feature>