{"id":31703,"date":"2015-11-25T20:03:12","date_gmt":"2015-11-26T04:03:12","guid":{"rendered":"https:\/\/ephesoft.com\/docs\/2019-1-2\/developers\/custom-plugins\/how-to-create-a-custom-plugin\/"},"modified":"2021-02-18T11:24:10","modified_gmt":"2021-02-18T18:24:10","slug":"how-to-create-a-custom-plugin","status":"publish","type":"docs","link":"https:\/\/ephesoft.com\/docs\/products\/transact\/developers\/custom-plugins\/how-to-create-a-custom-plugin\/","title":{"rendered":"Creating Custom Plugins"},"content":{"rendered":"
Important: <\/strong>Before proceeding, read and agree to the Developer Disclaimer<\/a>.<\/p>\n To create a custom plugin for Ephesoft Transact, you will need the following installed on your system:<\/p>\n To install Maven, perform the following steps:<\/p>\n <\/p>\n Figure 1. Create a Maven Project<\/em><\/p>\n <\/p>\n Figure 2. Use Default Workspace Location<\/em><\/p>\n <\/p>\n Figure 3. Select Quickstart Maven Archetype<\/em><\/p>\n <\/p>\n Figure 4. Enter Group ID and Artifact ID<\/em><\/p>\n <\/p>\n Figure 5. Sample Eclipse Project<\/em><\/p>\n Perform the following steps to add the Ephesoft Libraries to your Eclipse project.<\/p>\n Note:<\/strong> Custom script class files should not be added to any custom JAR files. Adding a custom script class file into any JAR file will cause issues, as the default location for the custom script class file is [Ephesoft_Directory]<\/em>\\JavaAppServer\\temp\\DynamicCodeCompiler.<\/p>\n Perform the following steps to create a new Java interface for your custom plugin.<\/p>\n <\/p>\n Figure 6. New Java Interface<\/em><\/p>\n <\/p>\n Figure 7. Replace File Contents<\/em><\/p>\n Perform the following steps to create a Java class to implement the CustomPlugin interface.<\/p>\n <\/p>\n Figure 8. New Java Class<\/em><\/p>\n <\/p>\n Figure 9. Replace File Contents<\/em><\/p>\n Perform the following steps to create a folder structure for your XML resources.<\/p>\n <\/p>\n Figure 10. New Source Folder<\/em><\/p>\n Perform the following steps to create the XML resources.<\/p>\n Note: <\/strong>If \u201cXML File\u201d is not available, click Other <\/strong>and search for \u201cXML File\u201d.<\/p>\n\n
\n
<\/a>Create a Custom Plugin<\/h2>\n
<\/a>Create a New Project<\/h3>\n
\n
\n
\n
\n
\n
\n
<\/a>Add Ephesoft Libraries<\/h3>\n
\n
<\/a>Create a New Interface<\/h3>\n
\n
\n
package com.ephesoft.customplugin.ephesoft_custom_plugin;\r\nimport com.ephesoft.dcma.core.DCMAException;\r\nimport com.ephesoft.dcma.da.id.BatchInstanceID;\r\npublic interface CustomPlugin \r\n{\r\n void helloWorld(final BatchInstanceID batchInstanceID, final String pluginWorkflow) throws DCMAException;\r\n}<\/pre>\n
<\/a>Create a Java Class<\/h3>\n
\n
\n
package com.ephesoft.customplugin.ephesoft_custom_plugin;\r\nimport org.springframework.util.Assert;\r\nimport com.ephesoft.dcma.core.DCMAException;\r\nimport com.ephesoft.dcma.core.annotation.PostProcess;\r\nimport com.ephesoft.dcma.core.annotation.PreProcess;\r\nimport com.ephesoft.dcma.core.component.ICommonConstants;\r\nimport com.ephesoft.dcma.da.id.BatchInstanceID;\r\nimport com.ephesoft.dcma.da.service.BatchClassPluginConfigService;\r\nimport com.ephesoft.dcma.util.BackUpFileService;\r\npublic class CustomPluginImpl implements CustomPlugin, ICommonConstants {\r\n private BatchClassPluginConfigService batchClassPluginConfigService;\r\n @PreProcess\r\n public void preProcess(final BatchInstanceID batchInstanceID, String pluginWorkflow) {\r\n Assert.notNull(batchInstanceID);\r\n BackUpFileService.backUpBatch(batchInstanceID.getID());\r\n }\r\n @PostProcess\r\n public void postProcess(final BatchInstanceID batchInstanceID, String pluginWorkflow) {\r\n Assert.notNull(batchInstanceID);\r\n }\r\n public void helloWorld(BatchInstanceID batchInstanceID, String pluginWorkflow) throws DCMAException {\r\n \/\/TODO Auto-generated method stub\r\n String name = \"\";\r\n String propertyName = \"app.name\";\r\n name = batchClassPluginConfigService.getPluginPropertiesForBatch(batchInstanceID.getID(), \"EPHESOFT_CUSTOM_PLUGIN\").get(propertyName);\r\n System.out.println(\"**** Ephesoft Custom Plugin: Hello \" + name + \" \" + batchInstanceID.getID() + \" *****\");\r\n }\r\n public BatchClassPluginConfigService getBatchClassPluginService() {\r\n return batchClassPluginConfigService;\r\n }\r\n public void setBatchClassPluginConfigService(BatchClassPluginConfigService batchClassPluginConfigService) {\r\n this.batchClassPluginConfigService = batchClassPluginConfigService;\r\n }<\/pre>\n
<\/a>Create Folder Structure for XML Resources<\/h3>\n
\n
\n
\n
\n
<\/a>Create XML Files<\/h3>\n
<\/a>ephesoft-custom-plugin.xml<\/h4>\n
\n
\n
<?xml version=\"1.0\" encoding=\"UTF-8\"?><\/span>\r\n<<\/span>plugin><\/span><\/span>\r\n <<\/span>jar-name><\/span><\/span>ephesoft-custom-plugin.jar<\/<\/span>jar-name><\/span><\/span>\r\n <<\/span>plugin-name><\/span><\/span>EPHESOFT_CUSTOM_PLUGIN<\/<\/span>plugin-name><\/span><\/span>\r\n <<\/span>plugin-desc><\/span><\/span>Ephesoft Custom Plugin<\/<\/span>plugin-desc><\/span><\/span>\r\n <<\/span>plugin-workflow-name><\/span><\/span>CUSTOM_PLUGIN<\/<\/span>plugin-workflow-name><\/span><\/span>\r\n <<\/span>plugin-service-instance><\/span><\/span>CustomPlugin<\/<\/span>plugin-service-instance><\/span><\/span>\r\n <<\/span>method-name><\/span><\/span>helloWorld<\/<\/span>method-name><\/span><\/span>\r\n <<\/span>is-scripting><\/span><\/span>FALSE<\/<\/span>is-scripting><\/span><\/span>\r\n <<\/span>back-up-file-name><\/span><\/span>EphesoftCustomPlugin<\/<\/span>back-up-file-name><\/span><\/span>\r\n <<\/span>script-name><\/span><\/span>N\/A<\/<\/span>script-name><\/span><\/span>\r\n <<\/span>application-context-path><\/span><\/span>applicationContext-ephesoft-custom-plugin.xml<\/<\/span>application-context-path><\/span><\/span>\r\n <<\/span>plugin-properties><\/span><\/span>\r\n <<\/span>plugin-property><\/span><\/span>\r\n <<\/span>name><\/span><\/span>app.name<\/<\/span>name><\/span><\/span>\r\n <<\/span>type><\/span><\/span>STRING<\/<\/span>type><\/span><\/span>\r\n