Search in sources :

Example 1 with VariableMapper

use of org.activiti.engine.impl.javax.el.VariableMapper in project Activiti by Activiti.

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.activiti.engine.impl.javax.el.ELContext) MapELResolver(org.activiti.engine.impl.javax.el.MapELResolver) ArrayELResolver(org.activiti.engine.impl.javax.el.ArrayELResolver) BeanELResolver(org.activiti.engine.impl.javax.el.BeanELResolver) ResourceBundleELResolver(org.activiti.engine.impl.javax.el.ResourceBundleELResolver) DynamicBeanPropertyELResolver(org.activiti.engine.impl.javax.el.DynamicBeanPropertyELResolver) ELResolver(org.activiti.engine.impl.javax.el.ELResolver) JsonNodeELResolver(org.activiti.engine.impl.javax.el.JsonNodeELResolver) ListELResolver(org.activiti.engine.impl.javax.el.ListELResolver) CompositeELResolver(org.activiti.engine.impl.javax.el.CompositeELResolver) VariableMapper(org.activiti.engine.impl.javax.el.VariableMapper) FunctionMapper(org.activiti.engine.impl.javax.el.FunctionMapper)

Aggregations

ArrayELResolver (org.activiti.engine.impl.javax.el.ArrayELResolver)1 BeanELResolver (org.activiti.engine.impl.javax.el.BeanELResolver)1 CompositeELResolver (org.activiti.engine.impl.javax.el.CompositeELResolver)1 DynamicBeanPropertyELResolver (org.activiti.engine.impl.javax.el.DynamicBeanPropertyELResolver)1 ELContext (org.activiti.engine.impl.javax.el.ELContext)1 ELResolver (org.activiti.engine.impl.javax.el.ELResolver)1 FunctionMapper (org.activiti.engine.impl.javax.el.FunctionMapper)1 JsonNodeELResolver (org.activiti.engine.impl.javax.el.JsonNodeELResolver)1 ListELResolver (org.activiti.engine.impl.javax.el.ListELResolver)1 MapELResolver (org.activiti.engine.impl.javax.el.MapELResolver)1 ResourceBundleELResolver (org.activiti.engine.impl.javax.el.ResourceBundleELResolver)1 VariableMapper (org.activiti.engine.impl.javax.el.VariableMapper)1