How To Write A Service For A Java Class
Invoking a Coffee Class from a BPMN 2.0 Service Job
In the last section of this tutorial nosotros learn how to invoke a Java class from a BPMN 2.0 service task.
Add a Service Task to the Procedure
Use the Camunda Modeler to add a service chore afterwards the user task. To practise then, select the activity shape (rectangle) and drag it onto a sequence period (run across screenshot). Name information technology Process Request. Change the activeness type to Service Task by clicking on it and using the wrench button.


Add together a JavaDelegate Implementation
Now we need to add the bodily service task implementation. In the Eclipse project, add a course into the package org.camunda.bpm.getstarted.loanapproval
named ProcessRequestDelegate
implementing the JavaDelegate
interface:
package org.camunda.bpm.getstarted.loanapproval; import java.util.logging.Logger; import org.camunda.bpm.engine.consul.DelegateExecution; import org.camunda.bpm.engine.consul.JavaDelegate; public class ProcessRequestDelegate implements JavaDelegate { private final static Logger LOGGER = Logger.getLogger("LOAN-REQUESTS"); public void execute(DelegateExecution execution) throws Exception { LOGGER.info("Processing request by '" + execution.getVariable("customerId") + "'..."); } }
Configure the Class in the Procedure
Use the properties view to reference the service task in the process (encounter screenshot). You need to provide the fully qualified classname of your grade in the Java Form property field. In our case this is org.camunda.bpm.getstarted.loanapproval.ProcessRequestDelegate
.

Save the process model and update it in Eclipse. Build, deploy and execute the process application. Afterward completing the Approve Loan pace, check the logfile of the Apache Tomcat server:
INFO org.camunda.bpm.getstarted.loanapproval.ProcessRequestDelegate.execute Processing request by 'GFPE-23232323'...
Classloading with a shared process engine
The process engine resolves the ProcessRequestDelegate class from the application classloader. This allows you to
- have a different classloader for each Process Application,
- bundle libraries inside your awarding,
- (re-)deploy the application at runtime (without stopping / restarting the process engine).
Catch up: Get the Sources of Step-v.
Download as .zip or checkout the corresponding tag with Git.
Y'all tin checkout the current land from the GitHub repository.
If yous have not cloned the repository all the same, please execute the following command:
git clone https://github.com/camunda/camunda-become-started-java.git
To checkout the current state of the process awarding please execute the following control:
git checkout -f Step-5
Or download as archive from here.
Source: https://docs.camunda.org/get-started/java-process-app/service-task/
Posted by: parksmusere1980.blogspot.com
0 Response to "How To Write A Service For A Java Class"
Post a Comment