Search in sources :

Example 1 with ScriptFactory

use of org.camunda.bpm.engine.impl.scripting.ScriptFactory in project camunda-bpm-platform by camunda.

the class ProcessEngineConfigurationImpl method initScripting.

protected void initScripting() {
    if (resolverFactories == null) {
        resolverFactories = new ArrayList<ResolverFactory>();
        resolverFactories.add(new MocksResolverFactory());
        resolverFactories.add(new VariableScopeResolverFactory());
        resolverFactories.add(new BeansResolverFactory());
    }
    if (scriptingEngines == null) {
        scriptingEngines = new ScriptingEngines(new ScriptBindingsFactory(resolverFactories));
        scriptingEngines.setEnableScriptEngineCaching(enableScriptEngineCaching);
    }
    if (scriptFactory == null) {
        scriptFactory = new ScriptFactory();
    }
    if (scriptEnvResolvers == null) {
        scriptEnvResolvers = new ArrayList<ScriptEnvResolver>();
    }
    if (scriptingEnvironment == null) {
        scriptingEnvironment = new ScriptingEnvironment(scriptFactory, scriptEnvResolvers, scriptingEngines);
    }
}
Also used : MocksResolverFactory(org.camunda.bpm.engine.test.mock.MocksResolverFactory) ScriptEnvResolver(org.camunda.bpm.engine.impl.scripting.env.ScriptEnvResolver) ScriptingEngines(org.camunda.bpm.engine.impl.scripting.engine.ScriptingEngines) BeansResolverFactory(org.camunda.bpm.engine.impl.scripting.engine.BeansResolverFactory) ScriptBindingsFactory(org.camunda.bpm.engine.impl.scripting.engine.ScriptBindingsFactory) ScriptingEnvironment(org.camunda.bpm.engine.impl.scripting.env.ScriptingEnvironment) VariableScopeResolverFactory(org.camunda.bpm.engine.impl.scripting.engine.VariableScopeResolverFactory) BeansResolverFactory(org.camunda.bpm.engine.impl.scripting.engine.BeansResolverFactory) MocksResolverFactory(org.camunda.bpm.engine.test.mock.MocksResolverFactory) ResolverFactory(org.camunda.bpm.engine.impl.scripting.engine.ResolverFactory) ScriptFactory(org.camunda.bpm.engine.impl.scripting.ScriptFactory) VariableScopeResolverFactory(org.camunda.bpm.engine.impl.scripting.engine.VariableScopeResolverFactory)

Example 2 with ScriptFactory

use of org.camunda.bpm.engine.impl.scripting.ScriptFactory in project camunda-bpm-platform by camunda.

the class JuelFormEngine method executeScript.

protected Object executeScript(String scriptSrc, VariableScope scope) {
    ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
    ScriptFactory scriptFactory = processEngineConfiguration.getScriptFactory();
    ExecutableScript script = scriptFactory.createScriptFromSource(ScriptingEngines.DEFAULT_SCRIPTING_LANGUAGE, scriptSrc);
    ScriptInvocation invocation = new ScriptInvocation(script, scope);
    try {
        processEngineConfiguration.getDelegateInterceptor().handleInvocation(invocation);
    } catch (RuntimeException e) {
        throw e;
    } catch (Exception e) {
        throw new ProcessEngineException(e);
    }
    return invocation.getInvocationResult();
}
Also used : ExecutableScript(org.camunda.bpm.engine.impl.scripting.ExecutableScript) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) ScriptFactory(org.camunda.bpm.engine.impl.scripting.ScriptFactory) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) ScriptInvocation(org.camunda.bpm.engine.impl.delegate.ScriptInvocation)

Aggregations

ScriptFactory (org.camunda.bpm.engine.impl.scripting.ScriptFactory)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)1 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)1 ScriptInvocation (org.camunda.bpm.engine.impl.delegate.ScriptInvocation)1 ExecutableScript (org.camunda.bpm.engine.impl.scripting.ExecutableScript)1 BeansResolverFactory (org.camunda.bpm.engine.impl.scripting.engine.BeansResolverFactory)1 ResolverFactory (org.camunda.bpm.engine.impl.scripting.engine.ResolverFactory)1 ScriptBindingsFactory (org.camunda.bpm.engine.impl.scripting.engine.ScriptBindingsFactory)1 ScriptingEngines (org.camunda.bpm.engine.impl.scripting.engine.ScriptingEngines)1 VariableScopeResolverFactory (org.camunda.bpm.engine.impl.scripting.engine.VariableScopeResolverFactory)1 ScriptEnvResolver (org.camunda.bpm.engine.impl.scripting.env.ScriptEnvResolver)1 ScriptingEnvironment (org.camunda.bpm.engine.impl.scripting.env.ScriptingEnvironment)1 MocksResolverFactory (org.camunda.bpm.engine.test.mock.MocksResolverFactory)1