Java in dynamic scripting applications

Dynamic scripting applications can contain PHP scripts that call native Java™ functions, in addition to the JCICS Java library, to interact with CICS® assets. You can explicitly commit or roll back units of work by using JCICS methods in your applications.

Using Java in dynamic scripting applications

Because the PHP engine provides support for Java, you can import Java packages and call Java interfaces in your PHP scripts. However, if you want to import the Java packages, such as JCICS APIs, you must use the java_import function instead of import, as shown in the following example:
<?php 
    java_import("com.ibm.cics.server.Region");
    echo "Your CICS Dynamic Scripting Example (PHP) is now running in CICS Region " . Region::getAPPLID() . ".";
?>

You can use the JCICS API to interact with CICS assets. However, a small subset of the JCICS API is not supported. For more information, see Restrictions.

When you use JCICS, be aware of potential encoding issues. For more information, see Character encoding in dynamic scripting applications.

Custom Java

To call your own Java classes, you can use one of the following methods:
  • Package your Java classes with the PHP files. These classes can then be accessed directly by the PHP run time.
  • Package the Java classes into another OSGi bundle and export them in the MANIFEST.MF file. You can then use these classes in your PHP application by importing this OSGi bundle.

Explicitly committing and rolling back units of work

Dynamic scripting application tasks are subject to CICS committing and rolling back work in units of work (UOW). You can also use JCICS to explicitly commit or roll back units of work in your applications. Scripts can explicitly commit and roll back units of work at any point while they are running, by starting methods Task.getTask().commit() and Task.getTask().rollback(). For more information, see JCICS class reference.



using_java.html | Timestamp icon Last updated: Sunday, 4 June 2017