Prerequisites

  1. Install Java JDK
  2. Download Apache Maven
  3. Install Eclipse
  4. Install Maven
    • Open Eclipse
    • Goto Help -> Eclipse Marketplace
    • Search “Maven”
    • Click “Install” button on “Maven Integration for Elcipse”
    • Follow Instructions
    • Goto Window -> Preferences, and you should see Maven listed in the left panel

Creating a Custom Plugin

  1. Open Eclipse
  2. Click File -> New and select Maven Project
    • SelectMavenProject2
  3. Select Default Workspace
    • DefautWorkSpace
  4. Select quickstart Maven archtype. The Artifact ID is maven-archtype-quickstart.
    • QuickStartMaven
  5. Type the Group Id and Artifact Id. The Group Id is the package structure for your project. The Artifact Id will be the name of your project, and the final source folder of your package. More information about the Java specification for package names can be found here: http://docs.oracle.com/javase/specs/.
    • Group Id : com.ephesoft.customplugin
    • Artifact Id : ephesoft-custom-plugin
    • GroupIdArticatId
  6. Your Eclipse Project workspace should now look like this
    • MavenProjectWorkspace
  7. Add the Ephesoft Libraries to your Project.
    1. Right Click on your project folder “ephesoft-custom-plugin”
    2. Select Build Path -> Configure Build Path
    3. Click on the Libraries Tab
    4. Click Add External Jars
    5. Navigate toEphesoft Installation Path “Application\WEB-INF\lib “
    6. Select All Jar Files
    7. Click Open
    8. Click OK
  8. Create a New Interface
    1. Right Click On your Package “com.ephesoft.customplugin.ephesoft.custom_plugin”
    2. Select -> New Interface
      • Name : CustomPlugin
      • MavenNewInterface
    3. Replace the file contes with the below code
  9. package com.ephesoft.customplugin.ephesoft_custom_plugin;
    import com.ephesoft.dcma.core.DCMAException;
    import com.ephesoft.dcma.da.id.BatchInstanceID;public interface CustomPlugin {
    void helloWorld(final BatchInstanceID batchInstanceID, final String pluginWorkflow) throws DCMAException;
    }

    • MavenCustomPlugin
  10. Create a Java class to Implemaent Interface CustomPlugin
    1. Right Click On your Package “com.ephesoft.customplugin.ephesoft.custom_plugin”
    2. Select New -> Class
      • Name : CustomPluginImpl
      • MavenCustomPluginImpl
      • Replace Code with below
        • package com.ephesoft.customplugin.ephesoft_custom_plugin;
          import org.springframework.util.Assert;
          import com.ephesoft.dcma.core.DCMAException;
          import com.ephesoft.dcma.core.annotation.PostProcess;
          import com.ephesoft.dcma.core.annotation.PreProcess;
          import com.ephesoft.dcma.core.component.ICommonConstants;
          import com.ephesoft.dcma.da.id.BatchInstanceID;
          import com.ephesoft.dcma.da.service.BatchClassPluginConfigService;
          import com.ephesoft.dcma.util.BackUpFileService;public class CustomPluginImpl implements CustomPlugin, ICommonConstants {private BatchClassPluginConfigService batchClassPluginConfigService;@PreProcess
          public void preProcess(final BatchInstanceID batchInstanceID, String pluginWorkflow)
          {
          Assert.notNull(batchInstanceID);
          BackUpFileService.backUpBatch(batchInstanceID.getID());
          }@PostProcess
          public void postProcess(final BatchInstanceID batchInstanceID, String pluginWorkflow)
          {
          Assert.notNull(batchInstanceID);
          }public void helloWorld(BatchInstanceID batchInstanceID, String pluginWorkflow) throws DCMAException {
          //TODO Auto-generated method stub
          String name = "";
          String propertyName = "app.name";
          name = batchClassPluginConfigService.getPluginPropertiesForBatch(batchInstanceID.getID(), "EPHESOFT_CUSTOM_PLUGIN").get(propertyName);
          System.out.println("**** Ephesoft Custom Plugin: Hello " + name + " " + batchInstanceID.getID() + " *****");
          }public BatchClassPluginConfigService getBatchClassPluginService()
          {
          return batchClassPluginConfigService;
          }public void setBatchClassPluginConfigService(BatchClassPluginConfigService batchClassPluginConfigService)
          {
          this.batchClassPluginConfigService = batchClassPluginConfigService;
          }
          }
        • MavenCustomPluginImplCode
  11. Create Folder Structure for XML Resources
    1. Right Click on you Project in Project Explorer Window
    2. Selct New -> Source Folder
      •  Folder Name : src/main/resources
      • MavenSRCXML
    3. Create a META-INF folder
      1. Right Click on “src/main/resources” in your Project folder you just created
      2. Select New -> Folder
        • Folder Name : META-INF
    4. Create Sub Folder under META-INF
      1. Right Click on META-INF
      2. Select New -> Folder
        • Set Folder name to your Project Name
          • Name : ephesoft-custom-plugin
  12. Create the XMLs
    1. Right Click on “src/main/resources”
    2. Select New -> XML File
      • If XML File is not available Click Other and look for XML File
      • Name this XML the same name as your  Project
        • Name : ephesoft-custom-plugin.xml
      • Description of Properties
        • <jar-name> – This is the name of the jar file containing your plugin code, when we build the project and get a jar file, we’ll need to rename it to match this value. This should be <name of the project>.jar.
        • <plugin-name> – This is the name of the plugin that will show in the workflow. In the CustomPluginImpl.java class, we used the name “EPHESOFT_CUSTOM_PLUGIN”, so we’ll need to put that here.
        • <plugin-service-instance> – This is the name of the bean identifier we will reference in the applicationContext.xml. My value is set to “CustomPlugin”.
        • <method-name> – This is the name of the method that will be first called when the plugin executes in the workflow.
        • <application-context-path> – This should set to the applicationContext-ephesoft-custom-plugin.xml.
        • <plugin-properties> – Here is where you indicate the properties of the plugin that will be configured in the UI. In the CustomPlugin.java class, we called on one property, called “app.name”.
      • Add Below code to ephesoft-custom-plugin.xml
      • <?xml version="1.0" encoding="UTF-8"?>
        <plugin>
        <jar-name>ephesoft-custom-plugin.jar</jar-name>
        <plugin-name>EPHESOFT_CUSTOM_PLUGIN</plugin-name>
        <plugin-desc>Ephesoft Custom Plugin</plugin-desc>
        <plugin-workflow-name>CUSTOM_PLUGIN</plugin-workflow-name>
        <plugin-service-instance>CustomPlugin</plugin-service-instance>
        <method-name>helloWorld</method-name>
        <is-scripting>FALSE</is-scripting>
        <back-up-file-name>EphesoftCustomPlugin</back-up-file-name>
        <script-name>N/A</script-name>
        <application-context-path>applicationContext-ephesoft-custom-plugin.xml</application-context-path>
        <plugin-properties>
        <plugin-property>
        <name>app.name</name>
        <type>STRING</type>
        <description>Name</description>
        <is-mandatory>FALSE</is-mandatory>
        <is-multivalue>FALSE</is-multivalue>
        </plugin-property>
        </plugin-properties>
        <dependencies>
        </dependencies>
        </plugin>
      • MavenprojectName
    3. Right Click on the META-INF folder you Created
    4. Select New -> XML File
      • Name this file applicationContext-<NAME OF YOUR PROJECT>
        • Name : applicationContext-ephesoft-custom-plugin.xml
      • Add below code to applicationContext-ephesoft-custom-plugin.xml
        • <?xml version="1.0" encoding="UTF-8"?>
          <beans xmlns="http://www.springframework.org/schema/beans"
          xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p"
          xmlns:util="http://www.springframework.org/schema/util" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
          xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
          http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
          http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
          http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"
          default-autowire="byName">
          <import resource="classpath:/META-INF/ephesoft-custom-plugin/applicationContext.xml" />
          </beans>
        • MavenApplicationContextProjectName
    5. Right Click on the Sub Folder of META-INF (should be the name of your project “ephesoft-custom-plugin”)
    6. Select New -> XML File
      • Name : applicationContext.xml
      • Replace applicationContext.xml with below Code
      • <?xml version="1.0" encoding="UTF-8"?>
        <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:tx="http://www.springframework.org/schema/tx"
        xmlns:p="http://www.springframework.org/schema/p"
        xmlns:util="http://www.springframework.org/schema/util"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:aop="http://www.springframework.org/schema/aop"
        xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/util
        http://www.springframework.org/schema/util/spring-util-3.0.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"
        default-autowire="byName">
        <import resource="classpath:/META-INF/applicationContext-data-access.xml"/>
        <import resource="classpath:/META-INF/applicationContext-batch.xml"/>
        <import resource="classpath:/META-INF/applicationContext-core.xml"/>
        <bean id="CustomPlugin"
        class="com.ephesoft.customplugin.ephesoft_custom_plugin.CustomPluginImpl" >
        <property name="batchClassPluginConfigService"
        ref="batchClassPluginConfigService"></property>
        </bean>
        <context:component-scan base-package="com.ephesoft.customplugin.ephesoft_custom_plugin" />
        </beans>
    7. You should have a folder structure that looks like below
      • MavenFolderStructure2
  13. Finishing Up
    1. We have one more XML File to modify
      • Locate the pom.xml under your project. It should already exisit
      • Replace contents with below code
      • <project xmlns="http://maven.apache.org/POM/4.0.0"
        

        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0

        http://maven.apache.org/xsd/maven-4.0.0.xsd">

        <modelVersion>4.0.0</modelVersion>

        <groupId>com.ephesoft.customplugin</groupId>

        <artifactId>ephesoft-custom-plugin</artifactId>

        <version>0.0.1-SNAPSHOT</version>

        <packaging>jar</packaging>

        <name>ephesoft-custom-plugin</name>

        <url>http://maven.apache.org</url>

        <properties>

        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        </properties>

        <dependencies>

        <dependency>

        <groupId>com.ephesoft.dcma</groupId>

        <artifactId>dcma-core</artifactId>

        <version>0.0.1</version>

        <scope>system</scope>

        <systemPath>${project.basedir}/src/main/resources/ephesoft.jar</systemPath>

        </dependency>

        <dependency>

        <groupId>org.springframework</groupId>

        <artifactId>spring-core</artifactId>

        <version>3.0.5.RELEASE</version>

        </dependency>

        <dependency>

        <groupId>junit</groupId>

        <artifactId>junit</artifactId>

        <version>4.8.1</version>

        <scope>test</scope>

        </dependency>

        <dependency>

        <groupId>org.springframework</groupId>

        <artifactId>spring-beans</artifactId>

        <version>3.0.5.RELEASE</version>

        </dependency>

        </dependencies>

        </project>

      • MavenpomXML
  14. Copy and Paste the ephesoft.jar file from Ephesoft\Application\WEB-INF\lib to your project “src/main/resources” Folder
  15. Compiling the Project
    1. Right Click on Project Folder
    2. Click RunAs Maven build
      1. Golas : clean install
      2. Click Apply
      3. Click OK
  16. Note After Compiling you may need to Right Click and Refresh your project to update the Folder structure
  17. Import The Plugin Into Ephesoft
    1. Locate the Created JAR file after compiling under your Project in Eclipse
      • Under target folder
      • Temporarily copy to Desktop
      • Rename Jar from “ephesoft-custom-plugin-0.0.1-SNAPSHOT.jar” To “ephesoft-custom-plugin.jar”
    2. Locate ephesoft-custom-plugin.xml under your project
      1. Temporarily copy to Desktop
    3. Zip these files together
      • Highlight both Files
      • Right Click
      • Send To -> Compressed Zip
      • ZIP name must equal same name as JAR file
        • Name : ephesoft-custom-plugin.zip
      • MavenCompresedZip
    4. Open Ephesoft in Web Browser
    5. Go to System Configuration
    6. Select Workflow Management
    7. Drag and drop your created Zip file into the Import Plugin Section
    8. Restart Ephesoft so it will reload in your new JAR on startup
  18. You should now have a working custom plugin.

 

Was this article helpful to you?

David Brennan

Comments are closed.