public static EvaluationContext buildEvaluationContext( Map<String, Method> functionMethodMap, Map<String, Object> attributeMap) { VariableMapper vMapper = buildVariableMapper(attributeMap); FunctionMapper fMapper = buildFunctionMapper(functionMethodMap); EsfingeELContext context = new EsfingeELContext(fMapper, vMapper, new ArrayELResolver(), new ListELResolver(), new MapELResolver(), new BeanELResolver()); return new EvaluationContext(context, fMapper, vMapper); }
public ELContextImpl() { resolver.add(this.vars); resolver.add(new MapELResolver()); resolver.add(new ArrayELResolver()); resolver.add(new ListELResolver()); resolver.add(new BeanELResolver()); }
private static FacesContext createMockFacesContext () throws MalformedURLException { FacesContext ctx = Mockito.mock(FacesContext.class); CompositeELResolver cer = new CompositeELResolver(); FacesELContext elc = new FacesELContext(cer, ctx); ServletRequest requestMock = Mockito.mock(ServletRequest.class); ServletContext contextMock = Mockito.mock(ServletContext.class); URL url = new URL("file:///"); Mockito.when(contextMock.getResource(Matchers.anyString())).thenReturn(url); Mockito.when(requestMock.getServletContext()).thenReturn(contextMock); Answer<?> attrContext = new MockRequestContext(); Mockito.when(requestMock.getAttribute(Matchers.anyString())).thenAnswer(attrContext); Mockito.doAnswer(attrContext).when(requestMock).setAttribute(Matchers.anyString(), Matchers.any()); cer.add(new MockELResolver(requestMock)); cer.add(new BeanELResolver()); cer.add(new MapELResolver()); Mockito.when(ctx.getELContext()).thenReturn(elc); return ctx; }
public JasperELResolver(List<ELResolver> appResolvers) { appResolversSize = appResolvers.size(); resolvers = new ELResolver[appResolversSize + 7]; size = 0; add(new ImplicitObjectELResolver()); for (ELResolver appResolver : appResolvers) { add(appResolver); } add(new MapELResolver()); add(new ResourceBundleELResolver()); add(new ListELResolver()); add(new ArrayELResolver()); add(new BeanELResolver()); add(new ScopedAttributeELResolver()); }
private ELResolver createELResolver() { this.instantiated = true; if (this.resolver == null) { CompositeELResolver r = new CompositeELResolver(); r.add(new ImplicitObjectELResolver()); for (Iterator itr = this.resolvers.iterator(); itr.hasNext();) { r.add((ELResolver) itr.next()); } r.add(new MapELResolver()); r.add(new ResourceBundleELResolver()); r.add(new ListELResolver()); r.add(new ArrayELResolver()); r.add(new BeanELResolver()); r.add(new ScopedAttributeELResolver()); this.resolver = r; } return this.resolver; }
private ELResolver getELResolver() { if (elResolver == null) { // Create a CompositeELResolver CompositeELResolver celResolver = new CompositeELResolver(); celResolver.add(new ImplicitObjectELResolver()); // Add ELResolvers registered in JspApplicationContext JspApplicationContextImpl jaContext = getJspApplicationContext(); Iterator<ELResolver> it = jaContext.getELResolvers(); while (it.hasNext()) { celResolver.add(it.next()); } ELResolver streamELResolver = getExpressionFactory(this).getStreamELResolver(); if (streamELResolver != null) { celResolver.add(streamELResolver); } celResolver.add(new StaticFieldELResolver()); celResolver.add(new MapELResolver()); celResolver.add(new ResourceBundleELResolver()); celResolver.add(new ListELResolver()); celResolver.add(new ArrayELResolver()); celResolver.add(new BeanELResolver()); celResolver.add(new ScopedAttributeELResolver()); elResolver = celResolver; } return elResolver; }
public static ELResolver getDefaultResolver() { if (Constants.IS_SECURITY_ENABLED) { CompositeELResolver defaultResolver = new CompositeELResolver(); defaultResolver.add(new MapELResolver()); defaultResolver.add(new ResourceBundleELResolver()); defaultResolver.add(new ListELResolver()); defaultResolver.add(new ArrayELResolver()); defaultResolver.add(new BeanELResolver()); return defaultResolver; } else { return DefaultResolver; } }
@Override public ELResolver getELResolver() { if (elResolver == null) { final CompositeELResolver resolver = new CompositeELResolver(); customResolver = new CompositeELResolver(); resolver.add(customResolver); resolver.add(factory.getStreamELResolver()); resolver.add(new StaticFieldELResolver()); resolver.add(new MapELResolver()); resolver.add(new ResourceBundleELResolver()); resolver.add(new ListELResolver()); resolver.add(new ArrayELResolver()); resolver.add(new BeanELResolverEx()); elResolver = resolver; } return elResolver; }
private CompositeELResolver createELResolver(ConstantResolver constantResolver) { CompositeELResolver resolver = new CompositeELResolver(); resolver.add(constantResolver); resolver.add(beanManager.getELResolver()); FacesContext facesContext = FacesContext.getCurrentInstance(); if (facesContext != null) { resolver.add(facesContext.getELContext().getELResolver()); } resolver.add(new MapELResolver()); resolver.add(new ListELResolver()); resolver.add(new ArrayELResolver()); resolver.add(new ResourceBundleELResolver()); resolver.add(new BeanELResolver()); return resolver; }
private ELResolver createELResolver() { this.instantiated = true; if (this.resolver == null) { CompositeELResolver r = new CompositeELResolver(); r.add(new ImplicitObjectELResolver()); for (Iterator<ELResolver> itr = this.resolvers.iterator(); itr.hasNext();) { r.add(itr.next()); } r.add(new MapELResolver()); r.add(new ResourceBundleELResolver()); r.add(new ListELResolver()); r.add(new ArrayELResolver()); r.add(new BeanELResolver()); r.add(new ScopedAttributeELResolver()); this.resolver = r; } return this.resolver; }
@Override public ELResolver getELResolver() { CompositeELResolver result = new CompositeELResolver(); result.add(new MapELResolver()); result.add(new ArrayELResolver()); result.add(new ListELResolver()); result.add(new BeanELResolver()); return result; }
public static ELResolver getDefaultResolver() { if (Globals.IS_SECURITY_ENABLED) { ELResolver defaultResolver = new CompositeELResolver(); ((CompositeELResolver) defaultResolver).add(new MapELResolver()); ((CompositeELResolver) defaultResolver).add(new ResourceBundleELResolver()); ((CompositeELResolver) defaultResolver).add(new ListELResolver()); ((CompositeELResolver) defaultResolver).add(new ArrayELResolver()); ((CompositeELResolver) defaultResolver).add(new BeanELResolver()); return defaultResolver; } else { return DefaultResolver; } }
public CompositeELResolverImpl() { add(new ScopeELResolver()); add(new TilesContextELResolver(new TilesContextBeanELResolver())); add(new TilesContextBeanELResolver()); add(new ArrayELResolver(false)); add(new ListELResolver(false)); add(new MapELResolver(false)); add(new ResourceBundleELResolver()); add(new BeanELResolver(false)); }
/** * Factory method to create the EL context */ protected ELContext createContext() { ELResolver resolver = new CompositeELResolver() { { add(new ArrayELResolver(false)); add(new ListELResolver(false)); add(new MapELResolver(false)); add(new ResourceBundleELResolver()); add(new BeanAndMethodELResolver()); } }; return new SimpleContext(resolver); }
@Override public ELResolver getELResolver() { if (resolver == null) { CompositeELResolver cr = new CompositeELResolver(); cr.add(new CompositeELResolver()); cr.add(new ResourceBundleELResolver()); cr.add(new MapELResolver(false)); cr.add(new SimpleResolver()); resolver = cr; } return resolver; }
protected static ELResolver createDefaultResolver() { CompositeELResolver resolver = new CompositeELResolver(); resolver.add(new VariableContextElResolver()); resolver.add(new ArrayELResolver(true)); resolver.add(new ListELResolver(true)); resolver.add(new MapELResolver(true)); resolver.add(new ResourceBundleELResolver()); resolver.add(new BeanELResolver()); return resolver; }
public SimpleELContext() { this.compositeELResolver = new CompositeELResolver(); this.compositeELResolver.add(new ArrayELResolver()); this.compositeELResolver.add(new ListELResolver()); this.compositeELResolver.add(new BeanELResolver()); this.compositeELResolver.add(new MapELResolver()); this.functionMapper = new ELFunctionMapper(); this.variableMapper = new ELVariableMapper(); this.expressionFactory = ExpressionFactory.newInstance(); }
public ELContextImpl(FunctionMapper fm) { resolver.add(this.vars); resolver.add(new MapELResolver()); resolver.add(new ArrayELResolver()); resolver.add(new ListELResolver()); resolver.add(new BeanELResolver()); this.fm = fm; }
@Nonnull private static CompositeELResolver constructStandardElResolver() { final CompositeELResolver elResolver = new CompositeELResolver(); elResolver.add(new ArrayELResolver()); elResolver.add(new ListELResolver()); elResolver.add(new BeanELResolver()); elResolver.add(new MapELResolver()); return elResolver; }
/** * @return a default ELResolver with functionality needed by all * expression evaluation. */ private ELResolver createDefaultELResolver() { CompositeELResolver resolver = new CompositeELResolver(); // Resolvers, in the order they will be most commonly accessed. // Moving JsonELResolver to the end makes JSON property resolution twice // as slow, so this is quite important. resolver.add(new JsonELResolver()); resolver.add(new MapELResolver()); resolver.add(new ListELResolver()); resolver.add(new ArrayELResolver()); // TODO: bean el resolver? return resolver; }
ElMetricName(ELResolver resolver, ExpressionFactory expressionFactory, Set<MetricsParameter> parameters) { super(parameters); CompositeELResolver composite = new CompositeELResolver(); composite.add(resolver); composite.add(new MapELResolver()); composite.add(new ListELResolver()); composite.add(new ArrayELResolver()); composite.add(new ResourceBundleELResolver()); composite.add(new BeanELResolver(true)); this.elResolver = composite; this.expressionFactory = expressionFactory; }
public static void main(final String[] args) { final FunctionMapper functionMapper = new LibraryFunctionMapperBuilder().add("proctor", ProctorRuleFunctions.class).build(); final ExpressionFactory expressionFactory = new ExpressionFactoryImpl(); final CompositeELResolver elResolver = new CompositeELResolver(); elResolver.add(new ArrayELResolver()); elResolver.add(new ListELResolver()); elResolver.add(new BeanELResolver()); elResolver.add(new MapELResolver()); final Map<String, Object> values = Maps.newLinkedHashMap(); values.put("countries", Sets.newHashSet("AA", "BB", "CC", "DD", "EE", "FF", "GG", "HH", "II", "JJ", "KK", "LL", "MM")); values.put("AA", "AA"); values.put("CC", "CC"); values.put("NN", "NN"); values.put("ZZ", "ZZ"); values.put("I1", 239235); values.put("I2", 569071142); values.put("I3", -189245); values.put("D1", 129835.12512); values.put("D2", -9582.9385); values.put("D3", 98982223.598731412); values.put("BT", Boolean.TRUE); values.put("BF", Boolean.FALSE); values.put("GLOOP", ""); final String[] expressions = { "${proctor:contains(countries, AA) || proctor:contains(countries, CC) || D2 < I3 && BF}", "${! proctor:contains(countries, ZZ) && I1 < I2 && empty GLOOP}", "${I2 - I3 + D3 - D1}", "${NN == '0' && ZZ == 'ZZ'}", "${BT != BF}", }; final int iterations = 100*1000; long elapsed = -System.currentTimeMillis(); for (int i = 0; i < iterations; i++) { final Map<String, ValueExpression> localContext = ProctorUtils.convertToValueExpressionMap(expressionFactory, values); final VariableMapper variableMapper = new MulticontextReadOnlyVariableMapper(localContext); final ELContext elContext = new ELContext() { @Override public ELResolver getELResolver() { return elResolver; } @Override public FunctionMapper getFunctionMapper() { return functionMapper; } @Override public VariableMapper getVariableMapper() { return variableMapper; } }; for (int j = 0; j < expressions.length; j++) { final ValueExpression ve = expressionFactory.createValueExpression(elContext, expressions[j], Object.class); final Object result = ve.getValue(elContext); if (i % 10000 == 0) { System.out.println(result); } } } elapsed += System.currentTimeMillis(); final int total = iterations * expressions.length; System.out.println(total + " expressions in " + elapsed + " ms (average " + (elapsed/(((double) total))) + " ms/expression)"); }