Adding Java Task
Using the Java task you can add functionality to call and execute user-defined Java code.
Procedure
- Add the Java task from the palette to the process editor.
-
Under Properties for the Java task, select the
General
tab, and click on the
Java Resource hyperlink.
The New Java Task Class wizard is displayed.
-
Enter or select the parent Java source folder and specify the Java class file name in the
Java Source Name and click
OK.
A new Java class file is created with the specified name in the selected Java source folder. The Java Resource field for the Java task is populated with the Java class file path. The new Java class file is populated on the basic Java task method and annotation to get you started. You can also write your own methods similar to the default method using proper annotations, as identified in Table 3, Annotations for Java Task,.
- Use the Input Map tab, for passing the value similar to what is done in the Java method call. The values mapped in the input mapper are used as arguments for the called function.
- Use the Output Map to obtain the value returned by the function after execution. The mapping can be done to execute the job so as to use the value for future job execution.
-
To re-factor the Java class, right click the Java class from the studio explorer and select
Refactor
> Move or
Refactor
> Rename. Using this method you don’t have to clean build the project for the changes to be properly reflected.
Sample BPMN Java Task
package com.tibco import java.util.Calendar; import com.tibco.cep.bpmn.runtime.activity.tasks.JavaTaskContext; import com.tibco.cep.bpmn.runtime.activity.tasks.ModelType; import com.tibco.cep.bpmn.runtime.activity.tasks.ModelTypeMap; import com.tibco.cep.bpmn.runtime.activity.tasks.TaskContextType; import com.tibco.cep.bpmn.runtime.model.JavaTask; import com.tibco.cep.bpmn.runtime.model.JavaTaskMethod; import com.tibco.cep.runtime.model.element.Concept; import com.tibco.cep.runtime.session.RuleServiceProvider; import com.tibco.cep.runtime.session.RuleSession; @JavaTask public class TestJavaTask { @JavaTaskContext(TaskContextType.NAME) String taskName; @JavaTaskContext(TaskContextType.RULE_SERVICE_PROVIDER) RuleServiceProvider rsp; @JavaTaskContext(TaskContextType.RULE_SESSION) RuleSession ruleSession; @JavaTaskMethod @ModelTypeMap(type=ModelType.CONTAINED_CONCEPT, uri="/Concepts/ConceptA") public Concept taskFunction( @ModelTypeMap(type=ModelType.INT) int a, @ModelTypeMap(type=ModelType.STRING) String b, @ModelTypeMap(type=ModelType.DATETIME) Calendar c, @ModelTypeMap(type=ModelType.CONTAINED_CONCEPT, uri="/Concepts/ConceptA") Concept cc, @ModelTypeMap(type=ModelType.PROCESS, uri="/Processes/ProcessA") Concept pp) { return null; } }
Copyright © Cloud Software Group, Inc. All rights reserved.