Example: Sharing Java classes between solutions
When you need to use the same Java™ classes in multiple solutions, store those Java classes in a shared library. You can access the Java classes in the shared library by using JavaCompute nodes in your applications.
About this task
If you update those Java classes and redeploy the shared library, those changes are automatically available to all applications that reference that shared library. You do not need to redeploy the referencing applications.
Java classes that are deployed in a shared library are not available to the integration server-wide class loader. When you deploy a shared library that contains Java files, a new class loader is created for that shared library. This class loader contains all Java classes in the shared library, as well as the Java classes from all referenced shared libraries. Java classes in shared library class loaders are isolated from Java classes in the integration server-wide class loader.
A Java class can exist in multiple class loaders if that Java class is contained in a shared library that is referenced by other shared libraries. When you update that Java class by redeploying the shared library that contains it, all class loaders for all shared libraries that contain that Java class are deleted and re-created.
you include a JavaCompute node
in a subflow in a shared library, that node can access the Java classes in that shared library
and any referenced shared libraries. If you include a JavaCompute node in a flow
or subflow in an application, that node can access the Java classes in a shared library and any shared
libraries that are referenced by that shared library. In this case,
you must specify a shared library qualifier in the form
the Java configurable service. Java classes in applications, static
libraries, or independent projects cannot access Java classes in shared libraries.
The order in which you create your resources is flexible. The following steps describe one way to share Java classes between multiple applications.
- In the IBM® Integration Toolkit, create a shared library.
- If you have existing Java classes, add them to the shared library. Otherwise, you can create your Java classes when you add a JavaCompute node to a message flow.
- Create one or more applications to contain the message flows and other resources for your solutions.
- Ensure that your applications refer to the shared library that contains the Java classes.
- Create one or more message flows in your applications that contain JavaCompute nodes.
- Configure each JavaCompute node to point to
the Java classes in the shared
library. Double-click the JavaCompute node and set the Source folder field to the shared library that contains the Java classes.
- If you have existing Java classes, click Finish.
- If you have not yet created your Java classes, click Next and select a template for your class. Define the Java build settings, then click Finish.
What to do next
You can deploy your resources by dragging the shared library and the applications onto the integration server. If you use this method, you must deploy the shared library before the applications that reference it. Alternatively, you can add the applications and shared library to a BAR file, then deploy that BAR file.