09-14-2011 05:01 AM
<serviceTask id="javaService" name="Read voltage"
activiti:expression="#{ServiceDelegate.execute()}"
activiti:resultVariable="voltage">
<extensionElements>
<activiti:field name="serviceName">
<activiti:string>READ_VOLTAGE</activiti:string>
</activiti:field>
</extensionElements>
</serviceTask>
<sequenceFlow id="flow2" sourceRef="exclusiveGw" targetRef="theTask1">
<conditionExpression xsi:type="tFormalExpression">{voltage == 12.1}</conditionExpression>
</sequenceFlow>
09-14-2011 07:42 AM
#{ServiceDelegate.execute(yourVariableName)}
It's also possible to pass the whole execution instance by using #{ServiceDelegate.execute(execution)}
09-14-2011 08:01 AM
#{ServiceDelegate.execute(execution)}
09-14-2011 08:22 AM
public void execute(DelegateExecution execution) {
#{ServiceDelegate.execute(execution)}
line will pass the DelegateExection instance to this method.09-14-2011 08:43 AM
public class ServiceDelegate implements JavaDelegate, Serializable {
…
public void execute(DelegateExecution execution) throws Exception {
String serviceNameString = (String) serviceName.getValue(execution);
if(serviceNameString.equals("READ_VOLTAGE")){
…
The serviceName field is null. With my "activiti:class" process the serviceName is injected with: public void setText(Expression serviceNameExpression){
this.serviceName = serviceNameExpression;
}
With this process part passing the serviceName works : <serviceTask id="javaServiceReadVoltage" name="Read voltage"
activiti:class="com.bosch.wfe.activity.delegate.ServiceDelegate">
<extensionElements>
<activiti:field name="serviceName">
<activiti:string>READ_VOLTAGE</activiti:string>
</activiti:field>
</extensionElements>
</serviceTask>
With this process part it is _not_ working: <serviceTask id="javaService" name="Read voltage"
activiti:expression="${ServiceDelegate.execute(execution)}"
activiti:resultVariable="voltage">
<extensionElements>
<activiti:field name="serviceName">
<activiti:string>READ_VOLTAGE</activiti:string>
</activiti:field>
</extensionElements>
</serviceTask>
09-15-2011 07:30 AM
The serviceName field is null. With my "activiti:class" process the serviceName is injected with:This was not true. Service parameter is injected without this method. I must have been confused.public void setText(Expression serviceNameExpression){
this.serviceName = serviceNameExpression;
}
…
<serviceTask id="javaServiceReadVoltage" name="Read voltage"
activiti:class="com.bigcompany.wfe.activiti.delegate.ServiceDelegate">
<extensionElements>
<activiti:field name="serviceName">
<activiti:string>READ_VOLTAGE</activiti:string>
</activiti:field>
</extensionElements>
</serviceTask>
<sequenceFlow id="flow3" sourceRef="javaServiceReadVoltage" targetRef="exclusiveGw" />
<exclusiveGateway id="exclusiveGw" name="Exclusive Gateway" />
<sequenceFlow id="flow4" sourceRef="exclusiveGw" targetRef="theTask1">
<conditionExpression xsi:type="tFormalExpression">${ServiceResult == 12.0}</conditionExpression>
</sequenceFlow>
The process variable "ServiceResult" is set within the delegate service: double result = ServiceFacade.readVoltage();
execution.setVariable("ServiceResult", result);
But this solution is based on the "knowledge" that the variable name is "ServiceResult". If the editor has no possibility to look in the source this has to be documentated elsewhere.09-15-2011 09:49 AM
09-15-2011 10:00 AM
This is inheritly so for the Activiti engine, as it is a Java worflow engine in the first place.Thank you for the clarification. I was confused because "activiti:resultVariable" let one introduce such a process variable in the process. I was wondering why this seems forbidden with an "activiti:class"-Element.
There is currently no way of providing process variables in the process.
03-20-2012 05:07 PM
This is inheritly so for the Activiti engine, as it is a Java worflow engine in the first place.Thank you for the clarification. I was confused because "activiti:resultVariable" let one introduce such a process variable in the process. I was wondering why this seems forbidden with an "activiti:class"-Element.
There is currently no way of providing process variables in the process.
<serviceTask id="serviceTask1" name="Service Taks" activiti:class="org.example.activi.servicetasks.MyService">
<extensionElements>
<activiti:field name="param1"><activiti:expression>${whatever}</activiti:expression></activiti:field>
<activiti:field name="param2" activiti:resultVariable="processVariable1" />
</serviceTask>
03-20-2012 05:27 PM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.