/**
* Parses a serviceTask declaration.
*/
public ActivityImpl parseServiceTask(Element serviceTaskElement, ScopeImpl scope) {
ActivityImpl activity = createActivityOnScope(serviceTaskElement, scope);
String type = serviceTaskElement.attributeNS(BpmnParser.ACTIVITI_BPMN_EXTENSIONS_NS, "type");
String className = serviceTaskElement.attributeNS(BpmnParser.ACTIVITI_BPMN_EXTENSIONS_NS, "class");
String expression = serviceTaskElement.attributeNS(BpmnParser.ACTIVITI_BPMN_EXTENSIONS_NS, "expression");
String delegateExpression = serviceTaskElement.attributeNS(BpmnParser.ACTIVITI_BPMN_EXTENSIONS_NS, "delegateExpression");
String resultVariableName = serviceTaskElement.attributeNS(BpmnParser.ACTIVITI_BPMN_EXTENSIONS_NS, "resultVariable");
if (resultVariableName == null) {
resultVariableName = serviceTaskElement.attributeNS(BpmnParser.ACTIVITI_BPMN_EXTENSIONS_NS, "resultVariableName");
}
String implementation = serviceTaskElement.attribute("implementation");
String operationRef = this.resolveName(serviceTaskElement.attribute("operationRef"));
activity.setAsync(isAsync(serviceTaskElement));
activity.setExclusive(isExclusive(serviceTaskElement));
if (type != null) {
if (type.equalsIgnoreCase("mail")) {
parseEmailServiceTask(activity, serviceTaskElement, parseFieldDeclarations(serviceTaskElement));
} else if (type.equalsIgnoreCase("mule")) {
parseMuleServiceTask(activity, serviceTaskElement, parseFieldDeclarations(serviceTaskElement));
} else if (type.equalsIgnoreCase("shell")) {
parseShellServiceTask(activity, serviceTaskElement, parseFieldDeclarations(serviceTaskElement));
} else {
addError("Invalid usage of type attribute: '" + type + "'", serviceTaskElement);
}
} else if (className != null && className.trim().length() > 0) {
if (resultVariableName != null) {
addError("'resultVariableName' not supported for service tasks using 'class'", serviceTaskElement);
}
activity.setActivityBehavior(new ClassDelegate(className, parseFieldDeclarations(serviceTaskElement)));
} else if (delegateExpression != null) {
if (resultVariableName != null) {
addError("'resultVariableName' not supported for service tasks using 'delegateExpression'", serviceTaskElement);
}
activity.setActivityBehavior(new ServiceTaskDelegateExpressionActivityBehavior(expressionManager.createExpression(delegateExpression), parseFieldDeclarations(serviceTaskElement)));
} else if (expression != null && expression.trim().length() > 0) {
activity.setActivityBehavior(new ServiceTaskExpressionActivityBehavior(expressionManager.createExpression(expression), resultVariableName));
} else if (implementation != null && operationRef != null && implementation.equalsIgnoreCase("##WebService")) {
if (!this.operations.containsKey(operationRef)) {
addError(operationRef + " does not exist", serviceTaskElement);
} else {
Operation operation = this.operations.get(operationRef);
WebServiceActivityBehavior webServiceActivityBehavior = new WebServiceActivityBehavior(operation);
Element ioSpecificationElement = serviceTaskElement.element("ioSpecification");
if (ioSpecificationElement != null) {
IOSpecification ioSpecification = this.parseIOSpecification(ioSpecificationElement);
webServiceActivityBehavior.setIoSpecification(ioSpecification);
}
for (Element dataAssociationElement : serviceTaskElement.elements("dataInputAssociation")) {
AbstractDataAssociation dataAssociation = this.parseDataInputAssociation(dataAssociationElement);
webServiceActivityBehavior.addDataInputAssociation(dataAssociation);
}
for (Element dataAssociationElement : serviceTaskElement.elements("dataOutputAssociation")) {
AbstractDataAssociation dataAssociation = this.parseDataOutputAssociation(dataAssociationElement);
webServiceActivityBehavior.addDataOutputAssociation(dataAssociation);
}
activity.setActivityBehavior(webServiceActivityBehavior);
}
} else {
addError("One of the attributes 'class', 'delegateExpression', 'type', 'operation', or 'expression' is mandatory on serviceTask.", serviceTaskElement);
}