Enable integration of OSGi application services

Use the osgiAppIntegration-1.0 feature, the OSGi applications available within the same Java virtual machine (JVM) can share their services with each other. To enable communication between the OSGi applications, we 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. 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 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, we must include the feature in server.xml. To use the feature, we need to use the appropriate headers, such as the Application-ImportService and Application-ExportService.

See Application manifest files. We 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.

  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: We 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 server.xml.

      <feature>osgiAppIntegration-1.0</feature>