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);
}
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);
}
}
}
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);
}
}
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;
}
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()));
}
}
}
Aggregations