Search in sources :

Example 1 with VariableMapper

use of org.camunda.bpm.engine.impl.javax.el.VariableMapper in project camunda-bpm-platform by camunda.

the class JuelScriptEngine method createElContext.

private ELContext createElContext(final ScriptContext scriptCtx) {
    // Check if the ELContext is already stored on the ScriptContext
    Object existingELCtx = scriptCtx.getAttribute("elcontext");
    if (existingELCtx instanceof ELContext) {
        return (ELContext) existingELCtx;
    }
    scriptCtx.setAttribute("context", scriptCtx, ScriptContext.ENGINE_SCOPE);
    // Built-in function are added to ScriptCtx
    scriptCtx.setAttribute("out:print", getPrintMethod(), ScriptContext.ENGINE_SCOPE);
    SecurityManager securityManager = System.getSecurityManager();
    if (securityManager == null) {
        scriptCtx.setAttribute("lang:import", getImportMethod(), ScriptContext.ENGINE_SCOPE);
    }
    ELContext elContext = new ELContext() {

        ELResolver resolver = createElResolver();

        VariableMapper varMapper = new ScriptContextVariableMapper(scriptCtx);

        FunctionMapper funcMapper = new ScriptContextFunctionMapper(scriptCtx);

        @Override
        public ELResolver getELResolver() {
            return resolver;
        }

        @Override
        public VariableMapper getVariableMapper() {
            return varMapper;
        }

        @Override
        public FunctionMapper getFunctionMapper() {
            return funcMapper;
        }
    };
    // Store the elcontext in the scriptContext to be able to reuse
    scriptCtx.setAttribute("elcontext", elContext, ScriptContext.ENGINE_SCOPE);
    return elContext;
}
Also used : ELContext(org.camunda.bpm.engine.impl.javax.el.ELContext) BeanELResolver(org.camunda.bpm.engine.impl.javax.el.BeanELResolver) ResourceBundleELResolver(org.camunda.bpm.engine.impl.javax.el.ResourceBundleELResolver) ListELResolver(org.camunda.bpm.engine.impl.javax.el.ListELResolver) CompositeELResolver(org.camunda.bpm.engine.impl.javax.el.CompositeELResolver) ELResolver(org.camunda.bpm.engine.impl.javax.el.ELResolver) ArrayELResolver(org.camunda.bpm.engine.impl.javax.el.ArrayELResolver) MapELResolver(org.camunda.bpm.engine.impl.javax.el.MapELResolver) VariableMapper(org.camunda.bpm.engine.impl.javax.el.VariableMapper) FunctionMapper(org.camunda.bpm.engine.impl.javax.el.FunctionMapper)

Aggregations

ArrayELResolver (org.camunda.bpm.engine.impl.javax.el.ArrayELResolver)1 BeanELResolver (org.camunda.bpm.engine.impl.javax.el.BeanELResolver)1 CompositeELResolver (org.camunda.bpm.engine.impl.javax.el.CompositeELResolver)1 ELContext (org.camunda.bpm.engine.impl.javax.el.ELContext)1 ELResolver (org.camunda.bpm.engine.impl.javax.el.ELResolver)1 FunctionMapper (org.camunda.bpm.engine.impl.javax.el.FunctionMapper)1 ListELResolver (org.camunda.bpm.engine.impl.javax.el.ListELResolver)1 MapELResolver (org.camunda.bpm.engine.impl.javax.el.MapELResolver)1 ResourceBundleELResolver (org.camunda.bpm.engine.impl.javax.el.ResourceBundleELResolver)1 VariableMapper (org.camunda.bpm.engine.impl.javax.el.VariableMapper)1