Creating Exception Handler Script
Exception handler scripts are basically Java code, that is invoked if an exception or error occurred during the execution of a process flow. There are three types of Exception handler scripts:
- Service exception
- ProcessFlow exception
- Invalid data exception
These scripts can be created at the global level (for all the activities in the process flow) or at the activity level (for a specific activity). If an exception or error occurred during the execution of a process flow, the activity level exception handler script is invoked first. If an activity level exception handler script is not created for that activity, then only global level exception handler script is invoked.
These exception handlers scripts are invoked at different stages of the process flow that are defined below.
Exception | Description |
---|---|
Service exception | This exception handler script is invoked when an error related service (activity) occur. For example, File not found, Stream closed, and so on. |
ProcessFlow exception | This exception handler script is invoked when an error occurs at process flow level. The exception can only be declared at the global level. For example, JMX not found, Repository not found, and so on. |
Invalid data exception | This exception handler script is invoked when an error related to the processing of data occurs. For example, Incorrect record format, and so on. |
You can create the exception handler script either using the Script or Custom APIs. If you are creating the exception handler using a script then you need to define the Java code. If you are creating the exception handler using custom APIs then first you need to create a class with method(s) and put them in the .../<AdeptiaInstallFolder>/ServerKernel/customClasses/<ClassPackage> folder where <ClassPackage> is the package where you have defined the Java class. For example, if you have defined the Java class in the org.custom package then first create the org/custom folder in the .../<AdeptiaInstallFolder>/ServerKernel/customClasses folder and put the class in the custom folder. Ensure that:
The class must implement PluginExecutor interface.
public class <class_name> implements PluginExecutor
The method should accept only one parameter and that must have an object of ExecutionEvent.
public boolean <method_name>(ExecutionEvent event) throws Exception
- The method must be public.
Creating Global Exception Handler Script
To create a global exception handler script
In the Process Designer, click OnException Scripts tab from the bottom pane.
- Click the required exception handler option, for example, click Edit Service exception.
On the ServiceException Dialog window, select the interpreter type.
Interpreter Type Description Script In this option, you need to define the Java code for the execution of the process flow. Using this option will decrease the execution performance of the process flow.
Custom API It is recommended to use this option. Using this option will increase the execution performance of the process flow. In this option, you need to select the class and its method for the execution of the process flow. The process flow will be executed on the basis of the code implemented in the selected method.
You can use <CTRL>+<Space Bar> to view pre-defined template of Java Code that can be used while creating Java Condition. You can select any of them and edit it according to your requirement.
- Click Done.
Creating Activity Exception Handler Script
To create an Activity Exception Handler Script
In the Process Designer, right-click the activity in the Graph Canvas and select ServiceException Dialog.
On the Service Exception Dialog window, select the interpreter type.
Interpreter Type Description Script In this option, you need to define the Java code for the execution of the process flow. Using this option will decrease the execution performance of the process flow.
Custom API It is recommended to use this option. Using this option will increase the execution performance of the process flow. In this option, you need to select the class and its method for the execution of the process flow. The process flow will be executed on the basis of the code implemented in the selected method.
You can use <CTRL>+<Space Bar> to view pre-defined template of Java Code that can be used while creating Java Condition. You can select any of them and edit it according to your requirement.
- Click Done.