Examples of ExpressionFactory


Examples of javax.el.ExpressionFactory

public class BenchmarkEl {
    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);
                }
            }
View Full Code Here

Examples of javax.el.ExpressionFactory

        assertTrue(found[2] > 250);
        assertTrue(found[2] < 400);
    }

    static RandomTestChooser initializeRandomTestChooser(final List<Range> ranges, final List<TestBucket> buckets) {
        final ExpressionFactory expressionFactory = new ExpressionFactoryImpl();

        final FunctionMapper functionMapper = RuleEvaluator.FUNCTION_MAPPER;

        final ConsumableTestDefinition testDefinition = new ConsumableTestDefinition();
        testDefinition.setConstants(Collections.<String, Object>emptyMap());
View Full Code Here

Examples of org.apache.cocoon.el.ExpressionFactory

                        Token module = (Token)stack.pop();
                        stack.pop(); // Pop the OPEN
                        result = processModule(module, expr, objectModel, context, mapStack, stackSize);
                    } else if (lastButOne.hasType(VariableExpressionTokenizer.TokenReciever.NEW_EXPRESSION)) {
                        stack.pop(); // Pop the OPEN
                        ExpressionFactory expressionFactory = null;
                        ObjectModel newObjectModel = null;
                        try {
                            expressionFactory = (ExpressionFactory)manager.lookup(ExpressionFactory.ROLE);
                            newObjectModel = (ObjectModel)manager.lookup(ObjectModel.ROLE);
                            result = processNewExpression(lastButOne, expressionFactory, newObjectModel);
View Full Code Here

Examples of org.apache.commons.jelly.expression.ExpressionFactory

        String tagName,
        String attributeName,
        String attributeValue)
        throws Exception {

        ExpressionFactory myFactory = getExpressionFactory();
        if (myFactory == null) {
            myFactory = factory;
        }
        if (myFactory != null) {
            return CompositeExpression.parse(attributeValue, myFactory);
View Full Code Here

Examples of org.apache.openjpa.kernel.exps.ExpressionFactory

            }

            // need to parse orderings?
            synchronized (this) {
                if (_inMemOrdering == null) {
                    ExpressionFactory factory = new InMemoryExpressionFactory();
                    _inMemOrdering = _parser.eval(_exps[0].orderingClauses,
                        (ExpressionStoreQuery) q, factory, _meta);
                }
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.