Controlling which version of an OSGi program is linked to

Applies to 6.2 and later. CICS® programs can target Java classes that are contained within OSGi bundles. The JVMCLASS program attribute controls which class is targeted and provides options for controlling which OSGi bundle the class is loaded from.

Before you begin

Prepare an OSGi application to be called by CICS.

Procedure

  1. Identify the service name of link target. Either a class that is defined in the CICS-MainClass manifest header, or a method annotated @CICSProgram.
    • For CICS-MainClass targets, the service name is the fully qualified class name.
    • For @CICSProgram targets, the service name is osgi:package.Class#method, where package.Class is the fully qualified class name.
  2. Identify the bundle version that contains the link target. Defined by the Bundle-Version header in the manifest.
  3. To target a class in a specific bundle version, define the JVMCLASS attribute in the form: servicename;version=version.
    For more information about the JVMCLASS attribute, see JVMCLASS syntax for Java programs.
  4. Optional: To target a class in a range of bundle versions, define the JVMCLASS attribute in the form: servicename;version=minVersion,maxVersion or servicename;minVersion=minVersion;maxVersion=maxVersion.
    minVersion
    The minimum version to target, inclusive of the defined version, such that minVersiontargetVersion. To make the maximum version exclusive of the defined version, prefix minVersion with the > character.
    maxVersion
    The maximum version to target, inclusive of the defined version, such that maxVersiontargetVersion. To make the maximum version exclusive of the defined version, prefix maxVersion with the < character.

Results

Java code in an OSGi bundle can be run at a specific version of that bundle.

Example

Figure 1. CICS program JOMCPRV1, targeting the main method of the class com.example.App, in the OSGi bundle with a version of 1.0.0
PROGRAM(JOMCPRV1)
    JVM(YES)
    JVMSERVER(OSGIJVMS)
    JVMCLASS(com.example.App;version="1.0.0")
Figure 2. CICS program JOCPPRV1, targeting the myTarget method in the class com.example.App, in the OSGi bundle with a version of 1.0.0
PROGRAM(DOCPPRV1)
    JVM(YES)
    JVMSERVER(OSGIJVMS)
    JVMCLASS(osgi:com.example.App#myTarget;version="1.0.0")