Implementing a Custom Activity Package

There are many tools you can use to develop a custom activity as well as multiple ways to configure and control the data flow which the custom activity will use. The following procedure provides an example of how to create an activity package using Eclipse as the developer tool.


  1. To get started, copy the following .jar files located in the software_installation_path/WFEngine folder to a folder of your choice:
    • cte.jar
    • cte_tools.jar
    • workflowEgine.jar

    These .jar files give you the basic functionality needed to develop your custom activities.

  2. From the Java - Eclipse tool menu, click File > New > Java Project to create a JRE project.
  3. Type a name for the project in the Project name box and click Next.
  4. On the Libraries tab, click Add External JARs to add the Commvault .jar files that you copied in Step 1.

  5. From the Java - Eclipse tool menu, click File > New > Class to create an activity class for your project. Your project may have more than one activity class.
  6. From the New Java Class dialog box do the following:
    1. Enter the package name of your project in the Package box.
    2. Enter a name for your activity class in the Name box.
    3. Select any other applicable option and then click Finish.
  7. Develop your activity class, having the following points in consideration:
    • Each activity class must implement the company.cte.workflow.activity.Activity interface interface and return AttemptStatus.SUCCESS or AttemptStatus.FAILED depending on the activity outcome.
    • Each input and output defined in the activity should have get/set functions implemented in order to be configured with a public or private modifier. Input/Output annotations are optional.
    • The ActivityContext property contains a lot of data which can be used in your activity. For example, you can modify the runtime of the ActivityContext with the context.setFailureReason() function in the try/catch block in order to show the pending reason message in the CommCell Console.

    See the following sample activity class implemented to import files. For your convenience, you can copy the code of the sample activity class from the following box:

    package custom.activities;

    import java.io.BufferedInputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import commvault.cte.workflow.ActivityContext;
    import commvault.cte.workflow.AttemptStatus;
    import commvault.cte.workflow.activity.Activity;
    import commvault.cte.workflow.annotations.Input;
    import commvault.cte.workflow.annotations.Output;
    import commvault.cte.workflow.logger.CTELogger;
    import commvault.cte.workflow.logger.LoggerLevel;
    import commvault.cte.workflow.logger.CTELogger.LoggerInstance;

    public class ImportFile implements Activity {
    private static final LoggerInstance logger = CTELogger.getLogger(ImportFile.class);

    public String fileName;

    public String fileContents;

    public AttemptStatus execute(ActivityContext context) throws InterruptedException {
    File file = new File(fileName);

    if (file.exists() && file.isFile()) {
    try {
    final BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
    final byte [] bytes = new byte[(int) file.length()];
    fileContents = new String(bytes);
    return AttemptStatus.SUCCESS;
    } catch (Exception excep) {
    logger.debugJob(LoggerLevel.ERROR, context.getJobId(), "failed to read file [%s]", fileName);
    return AttemptStatus.FAILED;
    } else {
    logger.debugJob(LoggerLevel.ERROR, context.getJobId(), "file [%s] does not exist or is a directory", fileName);
    context.setFailureReason("file [%s] does not exist or is a directory", fileName);
    return AttemptStatus.FAILED;


  8. After your activity class is implemented, you need to create the activities.xml file at the base folder of your project as shown in the image below:

    The XML must have the <activity> element and the following parameters defined for each activity:

    • name, which specifies the name of the activity.
    • displayName, which specifies the activity name to be displayed in the Activities pane of the workflow editor window.
    • group, which specifies the category where the activity will be placed in the Activities pane.
    • icon, which specifies the path to the image that will be used by the activity in the Activities pane.
    • className, which specifies the name of the activity class that you implemented.

    For your convenience, a sample file for the activities.xml is provided for download: sample_activities.xml

  9. Export the project to a JAR file using the steps below:
    1. From the Java - Eclipse tool menu, click File > Export.
    2. From the Export dialog box, select Java > JAR file.
    3. Specify the name of the .jar file and the folder where it should be exported in the JAR file box.
    4. Click Finish.

    For your convenience, a sample activity .jar file is provided below for download:


  10. Copy the activity .jar file to the software_installation_path/WFEngine/classpath folder on the computer where the Workflow engine resides.

    Note: If you have multiple workflow engines in your environment, place the activity .jar file in the classpath folder for each workflow engine. The package needs to be imported on only one of the workflow engines.

Last modified: 10/18/2018 7:53:10 PM