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,7 +45,11 @@ public void customize(ZeebeWorkerValue zeebeWorker) {
44
45
}
45
46
46
47
private void applyFetchVariables (ZeebeWorkerValue zeebeWorkerValue ) {
47
- if (zeebeWorkerValue .isForceFetchAllVariables ()) {
48
+ if (hasActivatedJobInjected (zeebeWorkerValue )) {
49
+ LOG .debug (
50
+ "Worker '{}': ActivatedJob is injected, no variable filtering possible" ,
51
+ zeebeWorkerValue .getName ());
52
+ } else if (zeebeWorkerValue .isForceFetchAllVariables ()) {
48
53
LOG .debug ("Worker '{}': Force fetch all variables is enabled" , zeebeWorkerValue .getName ());
49
54
zeebeWorkerValue .setFetchVariables (new String [0 ]);
50
55
} else {
@@ -54,7 +59,7 @@ private void applyFetchVariables(ZeebeWorkerValue zeebeWorkerValue) {
54
59
}
55
60
variables .addAll (
56
61
readZeebeVariableParameters (zeebeWorkerValue .getMethodInfo ()).stream ()
57
- .map (ParameterInfo :: getParameterName )
62
+ .map (this :: extractVariableName )
58
63
.collect (Collectors .toList ()));
59
64
variables .addAll (readVariablesAsTypeParameters (zeebeWorkerValue .getMethodInfo ()));
60
65
zeebeWorkerValue .setFetchVariables (variables .toArray (new String [0 ]));
@@ -65,12 +70,25 @@ private void applyFetchVariables(ZeebeWorkerValue zeebeWorkerValue) {
65
70
}
66
71
}
67
72
73
+ private boolean hasActivatedJobInjected (ZeebeWorkerValue zeebeWorkerValue ) {
74
+ return zeebeWorkerValue .getMethodInfo ().getParameters ().stream ()
75
+ .anyMatch (p -> p .getParameterInfo ().getType ().isAssignableFrom (ActivatedJob .class ));
76
+ }
77
+
68
78
private List <ParameterInfo > readZeebeVariableParameters (MethodInfo methodInfo ) {
69
79
List <ParameterInfo > result = methodInfo .getParametersFilteredByAnnotation (Variable .class );
70
80
result .addAll (methodInfo .getParametersFilteredByAnnotation (ZeebeVariable .class ));
71
81
return result ;
72
82
}
73
83
84
+ private String extractVariableName (ParameterInfo parameterInfo ) {
85
+ Variable variableAnnotation = parameterInfo .getParameterInfo ().getAnnotation (Variable .class );
86
+ if (variableAnnotation != null && !Variable .DEFAULT_NAME .equals (variableAnnotation .name ())) {
87
+ return variableAnnotation .name ();
88
+ }
89
+ return parameterInfo .getParameterName ();
90
+ }
91
+
74
92
private List <String > readVariablesAsTypeParameters (MethodInfo methodInfo ) {
75
93
List <String > result = new ArrayList <>();
76
94
List <ParameterInfo > parameters =
0 commit comments