How to access PublicAPI through the Rule-Utility-Function
Summary
Function rules (Rule-Utility-Function rule type) extend the power of Process Commander expressions. An expression can contain calls to built-in, standard, and custom functions.
Use a function rule to define a Java function that is accessed through rule resolution. Function rules can be referenced in expressions and directly in Java.
This PublicAPI is the supported public interface to the rules engine.
The keyword tools identifies the PublicAPI interface in Java calls. The PublicAPI includes the following classes:
com.pega.pegarules.pub.*; // Classes common to most public interfaces.
com.pega.pegarules.pub.clipboard.*; //Clipboard, Page, and Property
com.pega.pegarules.pub.context.*; // Requestor, Thread, and Node
com.pega.pegarules.pub.database.*; // Relational database access
com.pega.pegarules.pub.dictionary.*; // Dictionary validation interface
com.pega.pegarules.pub.generator.*; // Java generation
com.pega.pegarules.pub.pal.*; // Reports statistics about a Thread
com.pega.pegarules.pub.runtime.*; //Activities, Models, Whens, Streams
com.pega.pegarules.pub.util.*; // Miscellaneous utilities
For performance reasons, you may not want to pass PublicAPI through an activity. Instead, you can access the PublicAPI through function rules.
Suggested Approach
You can access PublicAPI facilities by Including the following Java code to a function rule::
PublicAPI api = (PublicAPI) ThreadContainer.get().getPublicAPI();