An OSGi Application Project (EBA) groups
together a set of bundles. The application can consist of different OSGi bundles types.
About this task
If you are using the IBM CICS SDK for Java or IBM CICS SDK for Enterprise Java (Liberty) in CICS Explorer (as shown in the following
instructions) or IBM Developer for z/OS (IDz), you can
refer to the CICS Explorer help, which
provides full details on how you can complete each of the following steps to develop and package
OSGi applications.
If you are using a build toolchain such as Apache Maven or Gradle, you can use CICS-provided artifacts on Maven Central to define Java dependencies.
Procedure
- CICS Explorer If you're using CICS Explorer, set up a target platform for
your Java development, using the CICS TS
5.6
with Enterprise Java and Liberty template. You might get a warning that the
target is a newer version than the current Eclipse installation, but you can ignore this warning
message.
- Create an OSGi Bundle Project for your
application.
- CICS Explorer If you're using CICS Explorer, the target platform effectively
makes the packages available, so you must include the appropriate Import statements in the bundle
manifest. A web-enabled OSGi Bundle Project is the
bundle equivalent of a Dynamic Web Project. You can
use a web-enabled OSGi Bundle Project to deploy an
application within an OSGi Application Project (an
Enterprise Bundle Archive, or EBA file). You can mix web-enabled OSGi Bundle Projects (WAB files) and non-web-enabled
OSGi Bundle Projects in your OSGi Application Project. A web-enabled OSGi Bundle Project would typically implement the
front end of the application, and interact with the non-web OSGi bundles, which contain the business
logic.
Restriction: EBA files are not supported in Java EE 8 and upwards.
- Gradle For Gradle users,
create a Gradle-enabled OSGi project using the BND Gradle Plugins, and then declare dependencies on CICS-provided artifacts.
- Maven For Maven users,
create a Maven project. In the pom.xml file, specify
<packaging>bundle</packaging>
and the following dependency:
<dependency>
<groupId>net.wasdev.maven.tools.targets</groupId>
<artifactId>liberty-target</artifactId>
<version><your_liberty_version></version>
<type>pom</type>
<scope>provided</scope>
</dependency>
Instead of specifying the dependency above, you can start with an
OSGi bundle archetype, for example, the osgi-web31-liberty artifact, and modify it.
Then declare dependencies on CICS-provided artifacts.
-
Develop your web application. You can use the JCICS API to access CICS services and JDBC to connect to Db2®. The IBM CICS SDK for Java includes examples of web
components and OSGi bundles that use JCICS and Db2. Create OSGi bundles that
use JCICS to separate the business from the presentation logic. You can also use semantic versioning
in OSGi bundles to manage updates to the business logic of the application. For each WAB or OSGi
bundle that uses Db2
through the JDBC DriverManager interface, include an Import-Package header for
com.ibm.db2.jcc in the bundle manifest. Omitting this import will result in the
error message java.sql.SQLException: No suitable driver found for
jdbc:default:connection. The import is not required when using the JDBC
DataSource interface.
- Optional:
If you want to authenticate users of the web application, create a
web.xml file in the web project to contain a security constraint. The IBM CICS SDK for Java includes a template for this
file that contains the correct information for CICS. See
Authenticating users in a Liberty JVM server for further information.
-
Create an OSGi Application Project that references
your OSGi bundles.
-
Create a CICS bundle project that references the OSGi Application Project. You can also add definitions and
imports for CICS resources. Each CICS bundle contains an ID and version so you can manage changes in a granular
way.
- Optional:
Add a URIMAP and TRANSACTION resource to a CICS bundle
if you want to map inbound web requests from a URI to run under a specific transaction. If you do
not define these resources, all work runs under a supplied transaction, which is called CJSA. These
resources are installed dynamically and managed as part of the bundle in CICS.
Results
You set up your development environment, created a OSGi web application, and packaged it for
deployment.
What to do next
When you are ready to deploy your application, export the CICS bundle projects to zFS. The referenced projects are built and included in
the transfer to zFS. Alternatively, you can follow a development deployment model by exporting the
application as an EBA file and deploying it to the dropins directory of a running Liberty JVM
server. You should be aware that Security and other qualities of service are not configurable using
dropins.