Skip to content

Commit 84ff0b6

Browse files
authored
chore(code-conversion): fix sb code-examples (#1034)
Related to: /issues/540
1 parent f203bfc commit 84ff0b6

File tree

20 files changed

+314
-513
lines changed

20 files changed

+314
-513
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under
3+
* one or more contributor license agreements. See the NOTICE file distributed
4+
* with this work for additional information regarding copyright ownership.
5+
* Licensed under the Camunda License 1.0. You may not use this file
6+
* except in compliance with the Camunda License 1.0.
7+
*/
8+
package org.camunda.conversion.execution_listeners;
9+
10+
import java.util.Map;
11+
import org.camunda.bpm.engine.RuntimeService;
12+
import org.camunda.bpm.engine.runtime.ProcessInstance;
13+
import org.springframework.web.bind.annotation.PostMapping;
14+
import org.springframework.web.bind.annotation.RequestParam;
15+
import org.springframework.web.bind.annotation.RestController;
16+
17+
@RestController
18+
public class ExecutionListenerTestController {
19+
20+
private final RuntimeService runtimeService;
21+
22+
public ExecutionListenerTestController(RuntimeService runtimeService) {
23+
this.runtimeService = runtimeService;
24+
}
25+
26+
/**
27+
* Start the execution-listener-test process with variable "foo".
28+
*
29+
* Usage: curl -X POST "http://localhost:8080/test/execution-listener?foo=bar"
30+
*/
31+
@PostMapping("/test/execution-listener")
32+
public String startProcess(@RequestParam(name = "foo", defaultValue = "bar") String foo) {
33+
ProcessInstance pi = runtimeService.startProcessInstanceByKey(
34+
"execution-listener-test",
35+
Map.of("foo", foo)
36+
);
37+
return "Started process instance: " + pi.getId() + " with foo=" + foo;
38+
}
39+
}
40+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under
3+
* one or more contributor license agreements. See the NOTICE file distributed
4+
* with this work for additional information regarding copyright ownership.
5+
* Licensed under the Camunda License 1.0. You may not use this file
6+
* except in compliance with the Camunda License 1.0.
7+
*/
8+
package org.camunda.conversion.execution_listeners;
9+
10+
import org.camunda.bpm.engine.delegate.DelegateExecution;
11+
import org.camunda.bpm.engine.delegate.ExecutionListener;
12+
import org.slf4j.Logger;
13+
import org.slf4j.LoggerFactory;
14+
import org.springframework.stereotype.Component;
15+
16+
@Component
17+
public class MyExecutionListener implements ExecutionListener {
18+
19+
private static final Logger LOG = LoggerFactory.getLogger(MyExecutionListener.class);
20+
21+
@Override
22+
public void notify(DelegateExecution execution) {
23+
String someVar = (String) execution.getVariable("foo");
24+
LOG.info(">>> ExecutionListener triggered! foo = {}", someVar);
25+
}
26+
}
27+

code-conversion/patterns/code-examples/camunda-7/src/main/java/org/camunda/conversion/external_task_workers/handling_a_bpmn_error/RetrievePaymentWorkerBPMNErrorJavaObjectAPI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import java.util.Map;
1717

1818
@Configuration
19-
@ExternalTaskSubscription("retrievePaymentAdapter")
19+
@ExternalTaskSubscription("retrievePaymentAdapterBpmnErrorJavaObjectAPI")
2020
public class RetrievePaymentWorkerBPMNErrorJavaObjectAPI implements ExternalTaskHandler {
2121

2222
@Override

code-conversion/patterns/code-examples/camunda-7/src/main/java/org/camunda/conversion/external_task_workers/handling_a_bpmn_error/RetrievePaymentWorkerBPMNErrorTypedValueAPI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import org.springframework.context.annotation.Configuration;
1818

1919
@Configuration
20-
@ExternalTaskSubscription("retrievePaymentAdapter")
20+
@ExternalTaskSubscription("retrievePaymentAdapterBpmnErrorTypedValueAPI")
2121
public class RetrievePaymentWorkerBPMNErrorTypedValueAPI implements ExternalTaskHandler {
2222

2323
@Override

code-conversion/patterns/code-examples/camunda-7/src/main/java/org/camunda/conversion/external_task_workers/handling_a_failure/RetrievePaymentWorkerFailure.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import java.util.Map;
1717

1818
@Configuration
19-
@ExternalTaskSubscription("retrievePaymentAdapter")
19+
@ExternalTaskSubscription("retrievePaymentAdapterFailure")
2020
public class RetrievePaymentWorkerFailure implements ExternalTaskHandler {
2121

2222
@Override

code-conversion/patterns/code-examples/camunda-7/src/main/java/org/camunda/conversion/external_task_workers/handling_an_incident/RetrievePaymentWorkerIncident.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import java.util.Map;
1717

1818
@Configuration
19-
@ExternalTaskSubscription("retrievePaymentAdapter")
19+
@ExternalTaskSubscription("retrievePaymentAdapterIncident")
2020
public class RetrievePaymentWorkerIncident implements ExternalTaskHandler {
2121

2222
@Override

code-conversion/patterns/code-examples/camunda-7/src/main/java/org/camunda/conversion/external_task_workers/handling_process_variables/RetrievePaymentWorkerProcessVariablesJavaObjectAPI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import java.util.Map;
1717

1818
@Configuration
19-
@ExternalTaskSubscription("retrievePaymentAdapter")
19+
@ExternalTaskSubscription("retrievePaymentAdapterProcessVarsJavaObjectAPI")
2020
public class RetrievePaymentWorkerProcessVariablesJavaObjectAPI implements ExternalTaskHandler {
2121

2222
@Override

code-conversion/patterns/code-examples/camunda-7/src/main/java/org/camunda/conversion/external_task_workers/handling_process_variables/RetrievePaymentWorkerProcessVariablesTypedValueAPI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import org.springframework.context.annotation.Configuration;
1919

2020
@Configuration
21-
@ExternalTaskSubscription("retrievePaymentAdapter")
21+
@ExternalTaskSubscription("retrievePaymentAdapterProcessVarsTypedValueAPI")
2222
public class RetrievePaymentWorkerProcessVariablesTypedValueAPI implements ExternalTaskHandler {
2323

2424
@Override

code-conversion/patterns/code-examples/camunda-7/src/main/resources/application.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@ spring.datasource.url: jdbc:h2:file:./camunda-h2-database
22

33
camunda.bpm.admin-user:
44
id: demo
5-
password: demo
5+
password: demo
6+
7+
camunda.bpm.client:
8+
base-url: http://localhost:8080/engine-rest
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL"
3+
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
4+
xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"
5+
xmlns:di="http://www.omg.org/spec/DD/20100524/DI"
6+
xmlns:camunda="http://camunda.org/schema/1.0/bpmn"
7+
id="Definitions_el_test"
8+
targetNamespace="http://bpmn.io/schema/bpmn">
9+
10+
<bpmn:process id="execution-listener-test" name="Execution Listener Test" isExecutable="true" camunda:historyTimeToLive="180">
11+
12+
<bpmn:startEvent id="StartEvent_1">
13+
<bpmn:outgoing>Flow_1</bpmn:outgoing>
14+
</bpmn:startEvent>
15+
16+
<bpmn:sequenceFlow id="Flow_1" sourceRef="StartEvent_1" targetRef="ServiceTask_1" />
17+
18+
<bpmn:serviceTask id="ServiceTask_1" name="Task with Execution Listener" camunda:expression="${true}">
19+
<bpmn:extensionElements>
20+
<camunda:executionListener event="start" delegateExpression="${myExecutionListener}" />
21+
</bpmn:extensionElements>
22+
<bpmn:incoming>Flow_1</bpmn:incoming>
23+
<bpmn:outgoing>Flow_2</bpmn:outgoing>
24+
</bpmn:serviceTask>
25+
26+
<bpmn:sequenceFlow id="Flow_2" sourceRef="ServiceTask_1" targetRef="EndEvent_1" />
27+
28+
<bpmn:endEvent id="EndEvent_1">
29+
<bpmn:incoming>Flow_2</bpmn:incoming>
30+
</bpmn:endEvent>
31+
32+
</bpmn:process>
33+
34+
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
35+
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="execution-listener-test">
36+
<bpmndi:BPMNShape id="StartEvent_1_di" bpmnElement="StartEvent_1">
37+
<dc:Bounds x="179" y="99" width="36" height="36" />
38+
</bpmndi:BPMNShape>
39+
<bpmndi:BPMNShape id="ServiceTask_1_di" bpmnElement="ServiceTask_1">
40+
<dc:Bounds x="270" y="77" width="100" height="80" />
41+
</bpmndi:BPMNShape>
42+
<bpmndi:BPMNShape id="EndEvent_1_di" bpmnElement="EndEvent_1">
43+
<dc:Bounds x="432" y="99" width="36" height="36" />
44+
</bpmndi:BPMNShape>
45+
<bpmndi:BPMNEdge id="Flow_1_di" bpmnElement="Flow_1">
46+
<di:waypoint x="215" y="117" />
47+
<di:waypoint x="270" y="117" />
48+
</bpmndi:BPMNEdge>
49+
<bpmndi:BPMNEdge id="Flow_2_di" bpmnElement="Flow_2">
50+
<di:waypoint x="370" y="117" />
51+
<di:waypoint x="432" y="117" />
52+
</bpmndi:BPMNEdge>
53+
</bpmndi:BPMNPlane>
54+
</bpmndi:BPMNDiagram>
55+
</bpmn:definitions>
56+

0 commit comments

Comments
 (0)