use of org.camunda.bpm.engine.impl.scripting.ExecutableScript in project camunda-bpm-platform by camunda.
the class EnvScriptCachingTest method testEnabledPaEnvScriptCaching.
public void testEnabledPaEnvScriptCaching() {
// given
EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication();
ProcessApplicationDeployment deployment = repositoryService.createDeployment(processApplication.getReference()).addClasspathResource(PROCESS_PATH).deploy();
// when
executeScript(processApplication);
// then
Map<String, List<ExecutableScript>> environmentScripts = processApplication.getEnvironmentScripts();
assertNotNull(environmentScripts);
List<ExecutableScript> groovyEnvScripts = environmentScripts.get(SCRIPT_LANGUAGE);
assertNotNull(groovyEnvScripts);
assertFalse(groovyEnvScripts.isEmpty());
assertEquals(processEngineConfiguration.getEnvScriptResolvers().size(), groovyEnvScripts.size());
repositoryService.deleteDeployment(deployment.getId(), true);
}
use of org.camunda.bpm.engine.impl.scripting.ExecutableScript in project camunda-bpm-platform by camunda.
the class BpmnParse method parseExecutionListener.
/**
* Parses an {@link ExecutionListener} implementation for the given
* executionListener element.
*
* @param executionListenerElement
* the XML element containing the executionListener definition.
*/
public ExecutionListener parseExecutionListener(Element executionListenerElement) {
ExecutionListener executionListener = null;
String className = executionListenerElement.attribute(PROPERTYNAME_CLASS);
String expression = executionListenerElement.attribute(PROPERTYNAME_EXPRESSION);
String delegateExpression = executionListenerElement.attribute(PROPERTYNAME_DELEGATE_EXPRESSION);
Element scriptElement = executionListenerElement.elementNS(CAMUNDA_BPMN_EXTENSIONS_NS, "script");
if (className != null) {
executionListener = new ClassDelegateExecutionListener(className, parseFieldDeclarations(executionListenerElement));
} else if (expression != null) {
executionListener = new ExpressionExecutionListener(expressionManager.createExpression(expression));
} else if (delegateExpression != null) {
executionListener = new DelegateExpressionExecutionListener(expressionManager.createExpression(delegateExpression), parseFieldDeclarations(executionListenerElement));
} else if (scriptElement != null) {
try {
ExecutableScript executableScript = parseCamundaScript(scriptElement);
if (executableScript != null) {
executionListener = new ScriptExecutionListener(executableScript);
}
} catch (BpmnParseException e) {
addError(e);
}
} else {
addError("Element 'class', 'expression', 'delegateExpression' or 'script' is mandatory on executionListener", executionListenerElement);
}
return executionListener;
}
use of org.camunda.bpm.engine.impl.scripting.ExecutableScript in project camunda-bpm-platform by camunda.
the class BpmnParse method parseTaskListener.
protected TaskListener parseTaskListener(Element taskListenerElement) {
TaskListener taskListener = null;
String className = taskListenerElement.attribute(PROPERTYNAME_CLASS);
String expression = taskListenerElement.attribute(PROPERTYNAME_EXPRESSION);
String delegateExpression = taskListenerElement.attribute(PROPERTYNAME_DELEGATE_EXPRESSION);
Element scriptElement = taskListenerElement.elementNS(CAMUNDA_BPMN_EXTENSIONS_NS, "script");
if (className != null) {
taskListener = new ClassDelegateTaskListener(className, parseFieldDeclarations(taskListenerElement));
} else if (expression != null) {
taskListener = new ExpressionTaskListener(expressionManager.createExpression(expression));
} else if (delegateExpression != null) {
taskListener = new DelegateExpressionTaskListener(expressionManager.createExpression(delegateExpression), parseFieldDeclarations(taskListenerElement));
} else if (scriptElement != null) {
try {
ExecutableScript executableScript = parseCamundaScript(scriptElement);
if (executableScript != null) {
taskListener = new ScriptTaskListener(executableScript);
}
} catch (BpmnParseException e) {
addError(e);
}
} else {
addError("Element 'class', 'expression', 'delegateExpression' or 'script' is mandatory on taskListener", taskListenerElement);
}
return taskListener;
}
use of org.camunda.bpm.engine.impl.scripting.ExecutableScript in project camunda-bpm-platform by camunda.
the class BpmnParse method parseScriptTaskElement.
/**
* Returns a {@link ScriptTaskActivityBehavior} for the script task element
* corresponding to the script source or resource specified.
*
* @param scriptTaskElement
* the script task element
* @return the corresponding {@link ScriptTaskActivityBehavior}
*/
protected ScriptTaskActivityBehavior parseScriptTaskElement(Element scriptTaskElement) {
// determine script language
String language = scriptTaskElement.attribute("scriptFormat");
if (language == null) {
language = ScriptingEngines.DEFAULT_SCRIPTING_LANGUAGE;
}
String resultVariableName = parseResultVariable(scriptTaskElement);
// determine script source
String scriptSource = null;
Element scriptElement = scriptTaskElement.element("script");
if (scriptElement != null) {
scriptSource = scriptElement.getText();
}
String scriptResource = scriptTaskElement.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, PROPERTYNAME_RESOURCE);
try {
ExecutableScript script = ScriptUtil.getScript(language, scriptSource, scriptResource, expressionManager);
return new ScriptTaskActivityBehavior(script, resultVariableName);
} catch (ProcessEngineException e) {
addError("Unable to process ScriptTask: " + e.getMessage(), scriptElement);
return null;
}
}
use of org.camunda.bpm.engine.impl.scripting.ExecutableScript in project camunda-bpm-platform by camunda.
the class BpmnParse method parseConditionExpression.
protected Condition parseConditionExpression(Element conditionExprElement) {
String expression = conditionExprElement.getText().trim();
String type = conditionExprElement.attributeNS(XSI_NS, TYPE);
String language = conditionExprElement.attribute(PROPERTYNAME_LANGUAGE);
String resource = conditionExprElement.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, PROPERTYNAME_RESOURCE);
if (type != null) {
String value = type.contains(":") ? resolveName(type) : BpmnParser.BPMN20_NS + ":" + type;
if (!value.equals(ATTRIBUTEVALUE_T_FORMAL_EXPRESSION)) {
addError("Invalid type, only tFormalExpression is currently supported", conditionExprElement);
}
}
Condition condition = null;
if (language == null) {
condition = new UelExpressionCondition(expressionManager.createExpression(expression));
} else {
try {
ExecutableScript script = ScriptUtil.getScript(language, expression, resource, expressionManager);
condition = new ScriptCondition(script);
} catch (ProcessEngineException e) {
addError("Unable to process condition expression:" + e.getMessage(), conditionExprElement);
}
}
return condition;
}
Aggregations