Search

Chapter 63. Registering custom tasks

download PDF

Red Hat Process Automation Manager must know how to associate a custom task work item with the code executed by the work item handler. The work item definition file links the custom task with the work item handler by name and Java class. The work item handler’s Java class has to be registered as usable in Red Hat Process Automation Manager.

Note

Service repositories contain domain-specific services that provide integration of your processes with different types of systems. Registering a custom task is not necessary when using a service repository because the import process registers the custom task.

Red Hat Process Automation Manager creates a WID file by default for projects that contain at least one business process. You can create a WID file when registering a work item handler or edit the default WID file. For more information about WID file locations or formatting, see Chapter 61, Work item definitions.

For non-service repository deployments, work item handlers can be registered in two ways:

  • Registering using the deployment descriptor.
  • Registering using the spring component registration.

63.1. Registering custom tasks using the deployment descriptor inside Business Central

You can register a custom task work item with the work item handler using the deployment descriptor in Business Central.

Procedure

  1. In Business Central, go to Menu Design Projects and select the project name.
  2. In the project pane, select Settings Deployments Work Item Handlers.
  3. Click Add Work Item Handler.
  4. In the Name field, enter the display name for the custom task.
  5. From the Resolver list, select MVEL, Reflection or Spring.
  6. In the Value field, enter the value based on the resolver type:

    Note

    The value fields may be filled automatically.

    • For MVEL, use the format new <full Java package>.<Java work item handler class name>()

      Example: new com.redhat.MyWorkItemWorkItemHandler()

    • For Reflection, use the format <full Java package>.<Java work item handler class name>

      Example: com.redhat.MyWorkItemWorkItemHandler

    • For Spring, use the format <Spring bean identifier>

      Example: workItemSpringBean

  7. Click Save to save your changes

63.2. Registering custom tasks using the deployment descriptor outside Business Central

You can register a custom task work item with the work item handler using the deployment descriptor outside Business Central.

Procedure

  1. In your Git project directory, open the file src/main/resources/META-INF/kie-deployment-descriptor.xml.
  2. Add the following content based on the resolver type under <work-item-handlers>:

    • For MVEL, add the following:

      <work-item-handler>
        <resolver>mvel</resolver>
        <identifier>new com.redhat.MyWorkItemWorkItemHandler()</identifier>
        <parameters/>
        <name>MyWorkItem</name>
      </work-item-handler>
    • For Reflections, add the following:

      <work-item-handler>
        <resolver>reflection</resolver>
        <identifier>com.redhat.MyWorkItemWorkItemHandler</identifier>
        <parameters/>
        <name>MyWorkItem</name>
      </work-item-handler>
    • For Spring, add the following and ensure the identifier is the identifier of a Spring bean:

      <work-item-handler>
        <resolver>spring</resolver>
        <identifier>beanIdentifier</identifier>
        <parameters/>
        <name>MyWorkItem</name>
      </work-item-handler>
      Note

      If you are using Spring to discover and configure Spring beans, it is possible to use an annotation of the org.springframework.stereotype.Component class to automatically register work item handlers.

      Within a work item handler, add the annotation @Component("<Name>") before the declaration of the work item handler class. For example: @Component("MyWorkItem") public class MyWorkItemWorkItemHandler extends AbstractLogOrThrowWorkItemHandler {

Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.