Search in sources :

Example 11 with ELException

use of javax.el.ELException in project tomcat70 by apache.

the class TestELParser method testJavaKeyWordIdentifier.

@Test
public void testJavaKeyWordIdentifier() {
    ExpressionFactory factory = ExpressionFactory.newInstance();
    ELContext context = new ELContextImpl();
    TesterBeanA beanA = new TesterBeanA();
    beanA.setInt("five");
    ValueExpression var = factory.createValueExpression(beanA, TesterBeanA.class);
    context.getVariableMapper().setVariable("this", var);
    // Should fail
    Exception e = null;
    try {
        factory.createValueExpression(context, "${this}", String.class);
    } catch (ELException ele) {
        e = ele;
    }
    Assert.assertNotNull(e);
}
Also used : ELContext(javax.el.ELContext) ExpressionFactory(javax.el.ExpressionFactory) ValueExpression(javax.el.ValueExpression) ELContextImpl(org.apache.jasper.el.ELContextImpl) ELException(javax.el.ELException) ELException(javax.el.ELException) Test(org.junit.Test)

Example 12 with ELException

use of javax.el.ELException in project Activiti by Activiti.

the class JuelScriptEngine method importFunctions.

public static void importFunctions(ScriptContext ctx, String namespace, Object obj) {
    Class<?> clazz = null;
    if (obj instanceof Class) {
        clazz = (Class<?>) obj;
    } else if (obj instanceof String) {
        try {
            clazz = ReflectUtil.loadClass((String) obj);
        } catch (ActivitiException ae) {
            throw new ELException(ae);
        }
    } else {
        throw new ELException("Class or class name is missing");
    }
    Method[] methods = clazz.getMethods();
    for (Method m : methods) {
        int mod = m.getModifiers();
        if (Modifier.isStatic(mod) && Modifier.isPublic(mod)) {
            String name = namespace + ":" + m.getName();
            ctx.setAttribute(name, m, ScriptContext.ENGINE_SCOPE);
        }
    }
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) ELException(javax.el.ELException) Method(java.lang.reflect.Method)

Example 13 with ELException

use of javax.el.ELException in project Activiti by Activiti.

the class DynamicBeanPropertyELResolver method getValue.

@Override
public Object getValue(ELContext context, Object base, Object property) {
    if (base == null || this.getCommonPropertyType(context, base) == null) {
        return null;
    }
    String propertyName = property.toString();
    try {
        Object value = ReflectUtil.invoke(base, this.readMethodName, new Object[] { propertyName });
        context.setPropertyResolved(true);
        return value;
    } catch (Exception e) {
        throw new ELException(e);
    }
}
Also used : ELException(javax.el.ELException) ELException(javax.el.ELException)

Example 14 with ELException

use of javax.el.ELException in project oxCore by GluuFederation.

the class ValueExpressionAnalyzer method getValueReference.

public ValueReference getValueReference(ELContext elContext) {
    InterceptingResolver resolver = new InterceptingResolver(elContext.getELResolver());
    try {
        expression.setValue(decorateELContext(elContext, resolver), null);
    } catch (ELException ele) {
        return null;
    }
    ValueReference reference = resolver.getValueReference();
    if (reference != null) {
        Object base = reference.getBase();
        if (base instanceof CompositeComponentExpressionHolder) {
            ValueExpression ve = ((CompositeComponentExpressionHolder) base).getExpression((String) reference.getProperty());
            if (ve != null) {
                this.expression = ve;
                reference = getValueReference(elContext);
            }
        }
    }
    return reference;
}
Also used : CompositeComponentExpressionHolder(javax.faces.el.CompositeComponentExpressionHolder) ValueExpression(javax.el.ValueExpression) ELException(javax.el.ELException) ValueReference(javax.el.ValueReference)

Example 15 with ELException

use of javax.el.ELException in project sonar-web by SonarSource.

the class UnifiedExpressionCheck method validateExpression.

private void validateExpression(TagNode element, Attribute attribute) {
    ExpressionLanguageContext context = new ExpressionLanguageContext(element);
    ExpressionBuilder builder = new ExpressionBuilder(attribute.getValue(), context);
    try {
        builder.createValueExpression(Object.class);
    } catch (ELException e) {
        if (e.getMessage().startsWith("Error")) {
            createViolation(element.getStartLinePosition(), "Fix this expression: " + (e.getMessage() == null ? "" : e.getMessage()));
        }
    }
}
Also used : ELException(javax.el.ELException) ExpressionBuilder(org.jboss.el.lang.ExpressionBuilder)

Aggregations

ELException (javax.el.ELException)23 ValueExpression (javax.el.ValueExpression)6 Method (java.lang.reflect.Method)5 ELContext (javax.el.ELContext)4 Test (org.junit.Test)4 ExpressionFactory (javax.el.ExpressionFactory)3 ELContextImpl (org.apache.jasper.el.ELContextImpl)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 FunctionMapper (javax.el.FunctionMapper)2 ExpressionBuilder (org.jboss.el.lang.ExpressionBuilder)2 BeansException (org.springframework.beans.BeansException)2 WebApplicationContext (org.springframework.web.context.WebApplicationContext)2 ExpressionFactoryImpl (de.odysseus.el.ExpressionFactoryImpl)1 AuthorizationException (fi.otavanopisto.security.AuthorizationException)1 FileNotFoundException (java.io.FileNotFoundException)1 StringReader (java.io.StringReader)1 BigDecimal (java.math.BigDecimal)1 BigInteger (java.math.BigInteger)1 Properties (java.util.Properties)1 EJBException (javax.ejb.EJBException)1