Enable OSGi Applications with Java EE 7 technologies
We can enable OSGi Applications with key Java Platform, Enterprise Edition (Java EE) 7 technologies. WebSphere Application Server Liberty Version 8.5.5.6 and later, is a production ready server certified for Java EE 7 Full Platform. 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 achieve zero migrations, new features are created and existing features remain unaltered. For example, when support for servlet 3.1 was added, a servlet-3.1 feature was created, and servlet-3.0 was kept to ensure behavior did not change for an existing server deployment.
In an environment before Java EE 7 support, you were required to configure blueprint-1.0, or something that depends on it, to be able to deploy OSGi applications. You then either configured other OSGi-specific features, like wab-1.0, or generic ones, like jpa-2.0, to get other capabilities. In a Java EE 7 environment, OSGi configuration is in two steps:
- Decide we want to deploy OSGi Bundles.
- Decide what technologies we want to use to implement those OSGi Bundles.
Telling the server we want to deploy OSGi Bundles
The first step is to add the osgiBundle-1.0 feature to the server.xml:<featureManager> <feature>osgiBundle-1.0</feature> </featureManager>
Add the osgiBundle-1.0 feature enables OSGi Bundles to be deployed as part of an OSGi application.
Telling the server what component models we want to use
Rather than having OSGi-specific features, like wab-1.0, you now configure the same component models you would for Java EE. This configuration enables the use of servlets in Bundles, for example, Web Application Bundles or Http Whiteboard servlets:<featureManager> <feature>osgiBundle-1.0</feature> <feature>servlet-3.1</feature> </featureManager>
See OSGi Web Application Bundles and OSGi Http Whiteboard. This server configuration adds the ability to use jpa-2.1 in a Persistence Bundle:
<featureManager> <feature>osgiBundle-1.0</feature> <feature>servlet-3.1</feature> <feature>jpa-2.1</feature> </featureManager>
See Access data using Java Persistence API . Optionally, we can still include blueprint-1.0:
<featureManager> <feature>osgiBundle-1.0</feature> <feature>servlet-3.1</feature> <feature>jpa-2.1</feature> <feature>blueprint-1.0</feature> </featureManager>
Which Java EE 7 component models are supported?
We can see the full list of Java EE 7 technologies enabled for OSGi applications.