How to call external java methods from Policy Xpress
search cancel

How to call external java methods from Policy Xpress


Article ID: 49105


Updated On:


CA Identity Manager CA Identity Governance CA Identity Portal CA Identity Suite


 How to call external java methods from Policy Xpress?






You need to package and deploy your class correctly, then invoke it from PX using the Run Java Code -> Execute Main function option.

The following information expands on the documentation:

In order to call a java class from Policy Xpress you will need to do the following:

1.  Create a java class that has a Main method. The arguments to the class are passed as string arguments (var is args - see below).

Here is an example of such a class.

/** * */
import com.netegrity.imapi.IMContext;
/** */
public class PxExternalCode {    
    /**     * @param args     */    
    public static void main(String[] args) {
          System.out.println("Main - Entered.");
          System.out.println("Main - Calling invoke method.");
          new PxExternalCode().invoke(null, args);
          System.out.println("Main - exit. DONE");
  public static void invoke(IMContext context, String[] args) {  
          System.out.println("invoke - Entered");
          System.out.println("invoke - printing the received arguments");    
          System.out.println("invoke - Exit");


2. After compiling the class you need to deploy it. You have two options:

   a.  If the class is packaged as a jar file then you need to place your jar file under: user_console.war\web-inf\lib
   b.  If the class file is not packaged as a jar file then you need to place your class under its respective package folder structure under user_console.war\web-inf\classes.

So, for the example above it will be under: user_console.war\web-inf\classes\com\ca\px\example (where you'll place the class file).

Note: the 'classes' folder under user_console.war\web-inf does not exist by default and you'll need to create it.

3. If your Identity Manager server is clustered then this should be deployed to all nodes of your cluster.

4. If your using Virtual Appliance Suite, the Path for custom code should be: /opt/CA/VirtualAppliance/custom/IdentityManager/iam_im.ear_user_console.war_WEB-INF_lib

5. Restart the Identity Manager server, or the IM component of VAPP.  If clustered, restart all nodes.

6. Create a PX Policy. Choose the trigger you need.
In Action Rules -> create an action rule -> Choose the Execute Java Method -> Main method option. There you should specify the full name of your class. In our example you should use:
You can add parameters in this screen using the Data elements you have in your policy. These parameters will be passed onto your java class as arguments in the 'args' variable. Your class can use them via the args variable.