You can store Java™ files
in shared libraries. JAR files are packaged inside shared libraries.
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. Delegation does not exist from one shared
library class loader to another shared library class loader. The following
diagram shows that a shared library,
shlib1,
contains a Java file called
JavaA.
Shared library
shlib1 refers to another shared
library,
shlib2, which contains a Java file called
JavaB.
When
shlib1 is deployed, a class loader is created
for the Java files in that shared
library as well as the referenced shared library.
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.
Java classes in the integration server-wide class loader are isolated
from the Java classes in any
shared library class loaders. Similarly, Java classes in shared library class loaders
are isolated from Java classes
in the integration server-wide class loader.
A
JavaCompute node in a message
flow or subflow can access the Java classes
in a shared library and any referenced shared libraries. The following
diagram shows a
JavaCompute node
in a message flow in an application, but the
JavaCompute node could be in
a subflow in a shared library.
To access these Java classes,
you specify a shared library qualifier for the Java configurable service on the
JavaCompute node. The shared
library qualifier is inside braces {}, as shown in the following example:
When you refer to a shared library that contains Java classes, all of the Java classes might be loaded into
multiple class loaders. The Java classes
can be loaded into the class loader for that shared library, and the
class loader for any other shared libraries that refer to that shared
library. The following diagram shows how three different applications
refer to three shared libraries. Application 1 refers to shared library
1, which also refers to shared library A. Application 2 refers to
shared library 2, which also refers to shared library A. Application
3 refers to shared library A only.
The
following diagram shows how the applications access the Java classes at run time. Shared libraries
1 and 2 have their own loaded copy of the classes from JAR_A in memory.
Applications 1, 2, and 3 all see different copies of JAR_A.
For applications 1 and 3 to access the same
loaded copy of the classes from JAR_A, application 1 would need to
use the shared library qualifier for shared library A. Static variables
in a shared library are duplicated for each shared library qualifier.
JavaCompute nodes access
the same static variables by using the same shared library qualifier.
However, when you redeploy a shared library, the Java class loaders for that shared library,
and any other shared libraries that reference that shared library,
reload the Java classes.
ESQL
code in applications or shared libraries can also call static Java methods in referenced shared
libraries by using the shared library qualifier in the CLASSLOADER
clause. For more information, see Java routine
example 4 in CREATE PROCEDURE statement.
Here are some
more examples of possible scenarios:
- A JavaCompute node
in a subflow in a shared library can access the Java classes in the same shared library or in
referenced shared libraries.
- If a message flow contains multiple JavaCompute nodes, each JavaCompute node can refer
to a different shared library.
- Multiple applications can use the Java classes
in a single shared library.
Java classes in
applications, static libraries, or independent projects cannot access Java classes in shared libraries.