Package javax.el

Examples of javax.el.ExpressionFactory


            listeners.addLast(listener);
        }
    }

    private static ExpressionFactory findExpressionFactoryImplementation() {
        ExpressionFactory ef = tryExpressionFactoryImplementation("com.sun");
        if(ef == null) {
            ef = tryExpressionFactoryImplementation("org.apache");
            if(ef == null) {
                logger.warn("Could not find any implementation for " +
                        ExpressionFactory.class.getName());
View Full Code Here


        expect(elContext.getVariableMapper()).andStubReturn(vm);

        bean = new Bean();


        ExpressionFactory expressionFactory = createMock(ExpressionFactory.class);
        JspApplicationContext applicationContext = createMock(JspApplicationContext.class);
        JspFactory jspFactory = createMock(JspFactory.class);
        expect(expressionFactory.coerceToType(VALUE, String.class)).andStubReturn(VALUE);
        expect(expressionFactory.coerceToType(null, String.class)).andStubReturn(null);
        expect(applicationContext.getExpressionFactory()).andStubReturn(expressionFactory);
        expect(jspFactory.getJspApplicationContext(null)).andStubReturn(applicationContext);
        replay(jspFactory, applicationContext, expressionFactory);
        JspFactory.setDefaultFactory(jspFactory);
    }
View Full Code Here

            validateFunctions(el, n);

            // test it out
            ELContextImpl ctx = new ELContextImpl(expressionFactory);
            ctx.setFunctionMapper(this.getFunctionMapper(el));
            ExpressionFactory ef = this.pageInfo.getExpressionFactory();
            try {
                ef.createValueExpression(ctx, expr, Object.class);
            } catch (ELException e) {

            }
        }
View Full Code Here

    public static Object proprietaryEvaluate(final String expression,
            final Class<?> expectedType, final PageContext pageContext,
            final ProtectedFunctionMapper functionMap)
            throws ELException {
        Object retValue;
        final ExpressionFactory exprFactory = jspf.getJspApplicationContext(pageContext.getServletContext()).getExpressionFactory();
        if (SecurityUtil.isPackageProtectionEnabled()) {
            try {
                retValue = AccessController
                        .doPrivileged(new PrivilegedExceptionAction<Object>() {

                            @Override
                            public Object run() throws Exception {
                                ELContextImpl ctx = (ELContextImpl) pageContext.getELContext();
                                ctx.setFunctionMapper(functionMap);
                                ValueExpression ve = exprFactory.createValueExpression(ctx, expression, expectedType);
                                return ve.getValue(ctx);
                            }
                        });
            } catch (PrivilegedActionException ex) {
                Exception realEx = ex.getException();
                if (realEx instanceof ELException) {
                    throw (ELException) realEx;
                } else {
                    throw new ELException(realEx);
                }
            }
        } else {
            ELContextImpl ctx = (ELContextImpl) pageContext.getELContext();
            ctx.setFunctionMapper(functionMap);
            ValueExpression ve = exprFactory.createValueExpression(ctx, expression, expectedType);
            retValue = ve.getValue(ctx);
        }

        return retValue;
    }
View Full Code Here

  public static Object proprietaryEvaluate(final String expression,
      final Class expectedType, final PageContext pageContext,
      final ProtectedFunctionMapper functionMap, final boolean escape)
      throws ELException {
    Object retValue;
        final ExpressionFactory exprFactory = JspFactory.getDefaultFactory().getJspApplicationContext(pageContext.getServletContext()).getExpressionFactory();
    if (SecurityUtil.isPackageProtectionEnabled()) {
      try {
        retValue = AccessController
            .doPrivileged(new PrivilegedExceptionAction() {

              public Object run() throws Exception {
                                ELContextImpl ctx = (ELContextImpl) pageContext.getELContext();
                                ctx.setFunctionMapper(new FunctionMapperImpl(functionMap));
                ValueExpression ve = exprFactory.createValueExpression(ctx, expression, expectedType);
                                return ve.getValue(ctx);
              }
            });
      } catch (PrivilegedActionException ex) {
        Exception realEx = ex.getException();
        if (realEx instanceof ELException) {
          throw (ELException) realEx;
        } else {
          throw new ELException(realEx);
        }
      }
    } else {
            ELContextImpl ctx = (ELContextImpl) pageContext.getELContext();
            ctx.setFunctionMapper(new FunctionMapperImpl(functionMap));
            ValueExpression ve = exprFactory.createValueExpression(ctx, expression, expectedType);
            retValue = ve.getValue(ctx);
    }
    if (escape && retValue != null) {
      retValue = XmlEscape(retValue.toString());
    }
View Full Code Here

            validateFunctions(el, n);

            // test it out
            ELContextImpl ctx = new ELContextImpl();
            ctx.setFunctionMapper(this.getFunctionMapper(el));
            ExpressionFactory ef = this.pageInfo.getExpressionFactory();
            try {
                ef.createValueExpression(ctx, expr, Object.class);
            } catch (ELException e) {

            }
        }
View Full Code Here

        testLocation("some_expression", "some_expression");
    }

    private void testLocation(String configuredValue, String expectedResolvedLocationExpression) {
        String expectedResolvedLocation = "evaluated_location";
        ExpressionFactory expressionFactory = mock(ExpressionFactory.class);
        ValueExpression valueExpression = mock(ValueExpression.class);

        // given
        configure(resourceMappingLocation, (String) expectedResolvedLocationExpression);
        when(application.getExpressionFactory()).thenReturn(expressionFactory);
        when(expressionFactory.createValueExpression(elContext, expectedResolvedLocationExpression, Object.class)).thenReturn(
                valueExpression);
        when(valueExpression.getValue(elContext)).thenReturn(expectedResolvedLocation);

        // when
        String location = ServiceTracker.getService(ResourceMappingConfiguration.class).getLocation();
View Full Code Here

            if (propertyObject instanceof String) {
                String property = (String) propertyObject;

                if (ELUtils.isValueReference(property)) {
                    ExpressionFactory expressionFactory = app.getExpressionFactory();

                    entry.setValue(expressionFactory.createValueExpression(elContext, property, Object.class));
                } else {
                    entry.setValue(property);
                }
            }
        }
View Full Code Here

        public PropertyDependencyInjector(PropertyDescriptor propertyDescriptor, ResourceParameter dependency) {
            super(propertyDescriptor, dependency);
        }

        private Object getExpressionValue(FacesContext context, String expressionString, Class<?> expectedType) {
            ExpressionFactory expressionFactory = context.getApplication().getExpressionFactory();
            ValueExpression expression = expressionFactory.createValueExpression(context.getELContext(), expressionString,
                expectedType);
            return expression.getValue(context.getELContext());
        }
View Full Code Here

    public void setUp() throws Exception {
        super.setUp();
        setupFacesRequest();
        extendedDataModel = new SequenceDataModel<User>(new ArrayDataModel<User>(users));
        arrangeableModel = new ArrangeableModel(extendedDataModel, "var", "filterVar");
        ExpressionFactory expressionFactory = facesContext.getApplication().getExpressionFactory();
        ELContext elContext = facesContext.getELContext();
        FilterField[] filterFields = {
                new FilterField(null, new Filter<User>() {
                    public boolean accept(User t) {
                        return t.getFname().indexOf('a') == -1;
                    }
                }, null),
                new FilterField(expressionFactory.createValueExpression(elContext, "#{var.lname != filterVar}", Object.class),
                    null, "b") };
        SortField[] sortFields = {
                new SortField(expressionFactory.createValueExpression(elContext, "#{var.fname}", Object.class), null,
                    SortOrder.ascending), new SortField(null, new Comparator<User>() {
                    public int compare(User o1, User o2) {
                        return o1.getLname().compareTo(o2.getLname());
                    }
                }, SortOrder.descending) };
View Full Code Here

TOP

Related Classes of javax.el.ExpressionFactory

Copyright © 2018 www.massapicom. 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.