Hi,
In ProcessVariables.java the producer for process variables returns Object, leaving the cast to the client.
@ Produces
@ ProcessVariable
protected Object getProcessVariable(InjectionPoint ip) {
String processVariableName = getVariableName(ip);
…
return businessProcess.getVariable(processVariableName);
}
I wonder, why this could not be extended to type-safe injects by replicating the producer to all possible return values
@ Produces
@ ProcessVariable
protected Boolean getProcessVariable(InjectionPoint ip) {
String processVariableName = getVariableName(ip);
…
return businessProcess.getVariable(processVariableName);
}
@ Produces
@ ProcessVariable
protected String getProcessVariable(InjectionPoint ip) {
String processVariableName = getVariableName(ip);
…
return businessProcess.getVariable(processVariableName);
}
etc. The underlying businessProcess.getVariable() supports this. Playing around with this approach in Wildfly 10 (Weld 2.3.5) it works, I can inject all my process variables with the expected type.
@ Inject
@ ProcessVariable
Boolean approved;
I’m not an expert in CDI, so this may a dependency on the CDI spec and implementation version; but if not, I would like to see these producers added to camunda-engine-cdi
Cheers
Johannes