Overview
This feature provides user with an option to execute a script repeatedly at some configurable interval of time to get some application level work done. Earlier with scripting plugin we can execute scripts with batch class only, that forces user to initiate a batch class instance to get script executed in the workflow. Now with this implementation we can get a script executed at Application level without any need to initiate a batch.
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 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 application level script in the dcma-scripting-plugin properties file in META_INF\dcma-scripting-plugin:
Configurable property | Type | 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: MyApplicationLevelScript |
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. |
Above configuration properties are shown in screen shot given below:
Steps for creating 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 for configuring the feature
- 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.
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.
Steps of execution
- 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.
- 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.
Dependency
To get this feature work on multi-server environment with restore mechanism, heart beat module should be running on all the servers.
Troubleshooting
Following are few common error messages seen in log file due to improper configuration and execution:
S. No. | Error message | Possible root cause |
---|---|---|
1 | 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. |
2 | Script errored out. | Script file was not correct. Verify the script file syntax. It needs to implement an interface ApplicationScripts. |
3 | Failed to compile | Some java compilation error in Script file. Verify java code in java code editor. |