Overview

This plug-in reads the batch’s batch.xml file and works upon the given document as per the scripts given in the scripts folder. All the scripts are placed inside “{SharedFolder}\batch class folder (ex:-BC1)\scripts”.

For any script there are two ways to write it, either it could be written in “IScript” or “JDOM”. For running any type of script user needs to place the script inside the “scripts” folder inside batch class folder for the respective batch class on which the script needs to be run.

A new feature with name “Application Level Script” has been added to provide user with an option to execute a script repeatedly at some configurable interval of time to get some application level work done. Folder name where application level script resides, script file name and execution interval all these properties are fully configurable and can be configured in dcma-scripting-plugin.properties file under META-INF/dcma-scripting-plugin folder. Folder having script must be present under Ephesoft Share Folder. Script java class file must has to implement an ApplicationScripts interface. This feature also works in multi-server environment, it means at a time application script execution will take place in a single server in a cluster of servers. It also have restore mechanism which helps in restoring a service on another server in the cluster in case the present server executing service went down.

Configuration

Configurable properties

Following are the configurable properties available for the Fuzzy Db plug-in in the dcma-scripting-plugin properties file in META_INF\dcma-scripting-plugin:

 

Configurable property Type of value Value options Description
Script Parser Type String jdom
script
This value defines the type of scripts that will run. There could be two types of scripts that could be run i.e. JDOM and ISCRIPT. For script to run in JDOM user has to give the parser type as 'jdom'. For script to run in ISCRIPT user has to give the value as 'script'.

Default jdom.
Script Switch String ON

OFF
This switch is used to set the execution of scripts on or off. If this switch is off then no script will run otherwise scripts will run.

Default ON.

 

This is shown in the screen shot given below:

 

400px-3.1_ScriptingPlugin_10001

 

 

Following are the configurable properties for Application Level Scripts

 

Configurable property Type of value Value options Description
Script Class Name

(script.application.scriptClassName)
String A valid java class name.(without .java or .class extension) This values tell the name of java script file present under a folder in Ephesoft Share folder.

Default value is: MyApplicationLevelScript
Script Folder Name

(script.application.scriptFolderName)
String An valid folder name inside Ephesoft Share folder This values specify the folder name that contains application level script file.

Default value is: application-script
Execution interval cron job

(dcma.applicationLevelScript.cronExpression)
String Valid Cron expression This cron expression specify the interval at which the script need to be executed.

This is shown in the screenshot given below:

 

400px-3.1_ScriptingPlugin_10002

 

Steps for configuring the plugin

  • User can set the script switch to on/off for running the scripts and for skipping the execution of scripts respectively.
  • If the script switch is on then the parser type mentioned in the “Script Parser Type” property defines the type of scripts given.
  • If the parser type is jdom then the JDOM scripts will run and if any script is present that runs for ISCRIPT then it will give errors and vice versa.
  • For executing application level scripts specify the script file name, folder name and cron expression in META-INF/dcma-scripting-plugin/dcma-scripting-plugin.properties. Save and close the file.
    • After configuring file name, folder name, cron expression in properties file, go to Ephesoft Shared folder and create a folder with name same as configured in property file.

Note: The script on/off switch (script.scriptSwitch) available in properties file does not control execution of application level script. The switch is just to enable/disable execution of batch class level scripts. Application level scripts are enables by default.

  • Create a script file with the same name as specified in property file above. Save the file with .java extension.
  • Create a directory/folder in Ephesoft Share folder with the same name as specified in property file above and copy the script file inside that.
  • After completing above steps start the Ephesoft server and script will start getting executed repeatedly.

 

Steps for configuring the script file

The script file is a simple java class implementing an interface named ApplicationScripts. This interface declare following method that every application level script has to implement.

public Object execute(String shareFolderPath);

Input to execute method will be share folder path that a script can use to do some action on share folder content.

Following is a sample structure of script file:

import com.ephesoft.dcma.script.ApplicationScripts;

 

public class MyApplicationLevelScript implements ApplicationScripts {

public Object execute(String shareFolderPath) {

/**************task to done **************/

}

}

 

The file needs to be saved with .java extension.

 

A default script file will be available under application-script folder in Ephesoft Share folder for reference.

Steps of execution

  • Configure the plugin switch in the below configuration file i.e.

META-INF/dcma-scripting-plugin/dcma-scripting-plugin.properties file. Also give the parser type for the script to run.

  • Enter the desired script in the scripts folder of the batch class in which user wants to run the script in. There are predefined scripts present in the scripts folder for each batch class. These are the dummy scripts.
  • There is a set format for the naming of the scripts which will be picked as their names are configured. Therefore the names of the scripts need to be the same as in the scripts folder. For running any custom script, user needs to make changes to the present script or make its own custom script with same name as predefined scripts and replace the existing script.

Dependency

  • The “import-batch-folder” plug-in needs to be executed before “scripting-plugin” to generate the files required for processing of “scripting-plugin”. If the batch goes into “Error” state then proper logs will be generated in log file kept at {Application}\dcma-all.log.
  • To get Application Level Script feature on multi-server environment with restore mechanism, heart beat module should be running on all the servers.

NOTE: There are some scripts placed in the “scripts” folder which are required for the system.

 

Troubleshooting

Following are few common error messages seen due to mal-functioning of the plugin:

 

S no. Error message Possible root cause
1 Script not found = (Script Path), throwing batch to error. The script whose path is given is not present. The batch will be send to ERROR state.
2 Script not found. Either script file or folder doesn't exist as specified in property file. Verify script folder and folder name present in Ephesoft Share folder.
3 Script error out. Script file was not correct. Verify the script file syntax. It needs to implement an interface ApplicationScripts.
4 Failed to compile Some java compilation error in Script file. Verify java code in java code editor.
5 Script having invalid parser type or invalid arguments. Throwing workflow in error This occurs when the entered parser type and the present script types does not match for ex. If parser given is dom and user puts in an iscript script then this error occurs.
6 Script error out. Throwing workflow in error. This happens when the custom script that has been put error out and needs to be corrected.

 

Was this article helpful to you?

wikiadmin

Comments are closed.