Importing custom XML files for input streams
Use custom XML files for use as an input stream by importing the XML files as a Java archive (JAR) and extracting the files using an activity.
- Using the command line on your local system, create a JAR file with your
selected XML files using the following Java method:
jar cf jar-file-name-or-directory chosen-xml-files-or-directories -c /directory
- In the header of Dev Studio, click .
- In the Import Wizard, select a location from which to
import the JAR file you created in step 1. Select from the following
locations:
- Local File
- From Repository
- File on Server
- Click Next.
- Confirm the details of the JAR file, then click Next.
- In the Code Archive page, enter
Pega-EngineCode and the codeset version of your
current release in which to integrate the XML.
If your application uses a unique codeset for the input stream, enter the unique codeset name and codeset version.
- Click Next.
- Confirm Java archive content, then click Next.
- Restart your environment.
- For Pega Cloud environments, file a service request from My Support Portal to restart the application server of your Pega Cloud instance.
- For on-premises environments, restart the application server.
After the restart, Pega Platform imports the JAR file into the version of the codeset.
- In the header of Dev Studio, click .
- In the Label field, add a name for the activity.
- In the Context section, select the application, class, and ruleset on which the codeset version resides.
- Click Create and open.
- In the Label field, enter a unique identifier for the step.
- In the Method list, select Java.
- To the left of the Method list, click the expand icon.
- In the Method Parameters section, in the Java
source field, enter a Java method that you want to use to access
the XML file integrated into your source code and Pega Platform database similar
to the one below.
String fileName = (String) tools.getParameterPage().getParameterValue("fileName"); java.io.InputStream theInputStream = null; ClassLoader ctxCL = Thread.currentThread().getContextClassLoader(); ClassLoader loader = com.pega.pegarules.pub.PegaRULES.class.getClassLoader(); if (theInputStream == null && ctxCL != null) { theInputStream = ctxCL.getResourceAsStream(fileName); } if (theInputStream == null && loader != null) { theInputStream = loader.getResourceAsStream(fileName); } if (theInputStream == null) { theInputStream = ClassLoader.getSystemResourceAsStream(fileName); } if (theInputStream == null) { throw new PRRuntimeException("Unable to locate resource '" + fileName + "'"); }
- Click Save.
- Create a new parameter for use as an input field that calls the Java method
when running the activity with the following task:
- Select the Parameters tab.
- Enter a name and description for the parameter.
- In Data type, select String.
- In Required, select Yes.
- In the Actions list,
select Run to run the activity.
Pega Platform displays the activity window containing the field you created from the Parameters tab.
- In the field of the activity, enter the name of the XML file.
- Run the activity to complete the import process.
Previous topic Ensuring that users migrate applications with a pipeline by restricting the Import wizard Next topic Importing custom Java archives and classes