2
2
3
3
import static org .apache .commons .lang3 .StringUtils .*;
4
4
5
+ import io .camunda .zeebe .client .api .response .ActivatedJob ;
5
6
import io .camunda .zeebe .spring .client .annotation .Variable ;
6
7
import io .camunda .zeebe .spring .client .annotation .VariablesAsType ;
7
8
import io .camunda .zeebe .spring .client .annotation .ZeebeVariable ;
@@ -44,6 +45,12 @@ public void customize(ZeebeWorkerValue zeebeWorker) {
44
45
}
45
46
46
47
private void applyFetchVariables (ZeebeWorkerValue zeebeWorkerValue ) {
48
+ if (hasActivatedJobInjected (zeebeWorkerValue )) {
49
+ LOG .debug (
50
+ "Worker '{}': ActivatedJob is injected, no variable filtering possible" ,
51
+ zeebeWorkerValue .getName ());
52
+ return ;
53
+ }
47
54
if (zeebeWorkerValue .isForceFetchAllVariables ()) {
48
55
LOG .debug ("Worker '{}': Force fetch all variables is enabled" , zeebeWorkerValue .getName ());
49
56
zeebeWorkerValue .setFetchVariables (new String [0 ]);
@@ -54,7 +61,7 @@ private void applyFetchVariables(ZeebeWorkerValue zeebeWorkerValue) {
54
61
}
55
62
variables .addAll (
56
63
readZeebeVariableParameters (zeebeWorkerValue .getMethodInfo ()).stream ()
57
- .map (ParameterInfo :: getParameterName )
64
+ .map (this :: extractVariableName )
58
65
.collect (Collectors .toList ()));
59
66
variables .addAll (readVariablesAsTypeParameters (zeebeWorkerValue .getMethodInfo ()));
60
67
zeebeWorkerValue .setFetchVariables (variables .toArray (new String [0 ]));
@@ -65,6 +72,24 @@ private void applyFetchVariables(ZeebeWorkerValue zeebeWorkerValue) {
65
72
}
66
73
}
67
74
75
+ private boolean hasActivatedJobInjected (ZeebeWorkerValue zeebeWorkerValue ) {
76
+ return zeebeWorkerValue .getMethodInfo ().getParameters ().stream ()
77
+ .anyMatch (p -> p .getParameterInfo ().getType ().equals (ActivatedJob .class ));
78
+ }
79
+
80
+ private String extractVariableName (ParameterInfo parameterInfo ) {
81
+ Variable annotation = parameterInfo .getParameterInfo ().getAnnotation (Variable .class );
82
+ if (annotation != null ) {
83
+ if (Variable .DEFAULT_NAME .equals (annotation .name ())) {
84
+ return parameterInfo .getParameterName ();
85
+ } else {
86
+ return annotation .name ();
87
+ }
88
+ } else {
89
+ return parameterInfo .getParameterName ();
90
+ }
91
+ }
92
+
68
93
private List <ParameterInfo > readZeebeVariableParameters (MethodInfo methodInfo ) {
69
94
List <ParameterInfo > result = methodInfo .getParametersFilteredByAnnotation (Variable .class );
70
95
result .addAll (methodInfo .getParametersFilteredByAnnotation (ZeebeVariable .class ));
0 commit comments