Implement a custom operation

To implement a custom operation, you must:

  • Create a custom operation
  • Define an operation
  • Define rules
  • Execute the custom operation

Create a custom operation

To create a custom operation, you must:

  1. Implement ExecuteOperation. For information on ExecuteOperation function, see ExecuteOperation function.
  2. Register the custom operation in your application.

Implement ExecuteOperation

To implement ExecuteOperation, create a java class that implements the Java interface com.axway.ais.evproc.api.ExecuteOperation and implement the following function:

Event execute(Event event, Map<String, Object> arguments);

Example

package operations;

public class MyCustomOperation implements ExecuteOperation {

@Override

public Event execute(Event event, Map<String, Object> arguments) {

 

// System.out.println("Execute operation");

 

return EventBuilder.create(event).build();

}

}

Register the operation

To register the operation in your web application:

  1. Navigate to the installation directory.
  2. Add the operation Java class to the war/WEB-INF/classes directory
  3. Register the operation as a bean XML element in the war/ WEB_INF/classes/ file as shown in the following example:
  4. <bean id="myCustomOperation" class="operation. MyCustomOperation"/>
Note   Save the identifier; it will be used as function identifier in the Designer.

Define an operation

To define an operation in Designer:

  1. Load the predefined interaction configuration:
    1. In the Designer, click Load configuration
    2. Select the Base for Flow Management configuration
  2. Create a new collection of type Library.
  3. Enter a name and release version and choose a service type
  4. In the new library, create a new function.
  5. Enter a name for the new function.
  6. You must use this name in your rule definition. See Define rules.
  7. Use the function type Execute Operation. Only a Java implementation is available for this type.
  8. Enter the registered identifier custom operation for Function Implementation Id.
  9. In our example use functionName myCustomFunction and myCustomOperation as Function Implementation Id
  10. Define a list of arguments for you function.

Define rules

After you define a function in the Designer, you must create a rule to execute the operation. To define the rule:

  1. Create a new rule
  2. Update the rule details:
    1. In Rule Type, select Interact.
    2. Input a flow identifier. For example, flowId.
    3. In Object Type, select an event that will trigger the rule. For example, a TimeEvent.
    4. In Libraries, select the library that contains the function created in Define an operation
    5. Call the operation in the Body of the rule:
    6. do myCustomFunction()
  3. Deploy the configuration into the Interaction application.

Execute a custom operation

After you configure the rule that calls you custom operation in the Designer, you must configure a listener for your component in Administration.

For details on how to configure a listener, see Manage listeners.

Related Links