use of javax.el.ELException in project spring-framework by spring-projects.
the class WebApplicationContextFacesELResolver method getType.
@Override
public Class<?> getType(ELContext elContext, Object base, Object property) throws ELException {
if (base != null) {
if (base instanceof WebApplicationContext) {
WebApplicationContext wac = (WebApplicationContext) base;
String beanName = property.toString();
if (logger.isDebugEnabled()) {
logger.debug("Attempting to resolve property '" + beanName + "' in root WebApplicationContext");
}
if (wac.containsBean(beanName)) {
if (logger.isDebugEnabled()) {
logger.debug("Successfully resolved property '" + beanName + "' in root WebApplicationContext");
}
elContext.setPropertyResolved(true);
try {
return wac.getType(beanName);
} catch (BeansException ex) {
throw new ELException(ex);
}
} else {
// Mimic standard JSF/JSP behavior when base is a Map by returning null.
return null;
}
}
} else {
if (WEB_APPLICATION_CONTEXT_VARIABLE_NAME.equals(property)) {
elContext.setPropertyResolved(true);
return WebApplicationContext.class;
}
}
return null;
}
use of javax.el.ELException in project spring-framework by spring-projects.
the class WebApplicationContextFacesELResolver method getValue.
@Override
public Object getValue(ELContext elContext, Object base, Object property) throws ELException {
if (base != null) {
if (base instanceof WebApplicationContext) {
WebApplicationContext wac = (WebApplicationContext) base;
String beanName = property.toString();
if (logger.isTraceEnabled()) {
logger.trace("Attempting to resolve property '" + beanName + "' in root WebApplicationContext");
}
if (wac.containsBean(beanName)) {
if (logger.isDebugEnabled()) {
logger.debug("Successfully resolved property '" + beanName + "' in root WebApplicationContext");
}
elContext.setPropertyResolved(true);
try {
return wac.getBean(beanName);
} catch (BeansException ex) {
throw new ELException(ex);
}
} else {
// Mimic standard JSF/JSP behavior when base is a Map by returning null.
return null;
}
}
} else {
if (WEB_APPLICATION_CONTEXT_VARIABLE_NAME.equals(property)) {
elContext.setPropertyResolved(true);
return getWebApplicationContext(elContext);
}
}
return null;
}
use of javax.el.ELException in project camunda-engine-dmn by camunda.
the class FeelEngineImpl method evaluateSimpleUnaryTests.
public boolean evaluateSimpleUnaryTests(String simpleUnaryTests, String inputName, VariableContext variableContext) {
try {
ELContext elContext = createContext(variableContext);
ValueExpression valueExpression = transformSimpleUnaryTests(simpleUnaryTests, inputName, elContext);
return (Boolean) valueExpression.getValue(elContext);
} catch (FeelMissingFunctionException e) {
throw LOG.unknownFunction(simpleUnaryTests, e);
} catch (FeelMissingVariableException e) {
if (inputName.equals(e.getVariable())) {
throw LOG.unableToEvaluateExpressionAsNotInputIsSet(simpleUnaryTests, e);
} else {
throw LOG.unknownVariable(simpleUnaryTests, e);
}
} catch (FeelConvertException e) {
throw LOG.unableToConvertValue(simpleUnaryTests, e);
} catch (ELException e) {
if (e.getCause() instanceof FeelMethodInvocationException) {
throw LOG.unableToInvokeMethod(simpleUnaryTests, (FeelMethodInvocationException) e.getCause());
} else {
throw LOG.unableToEvaluateExpression(simpleUnaryTests, e);
}
}
}
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()));
}
}
}
use of javax.el.ELException in project tomcat70 by apache.
the class ExpressionBuilder method visit.
/*
* (non-Javadoc)
*
* @see com.sun.el.parser.NodeVisitor#visit(com.sun.el.parser.Node)
*/
@Override
public void visit(Node node) throws ELException {
if (node instanceof AstFunction) {
AstFunction funcNode = (AstFunction) node;
if (this.fnMapper == null) {
throw new ELException(MessageFactory.get("error.fnMapper.null"));
}
Method m = fnMapper.resolveFunction(funcNode.getPrefix(), funcNode.getLocalName());
if (m == null) {
throw new ELException(MessageFactory.get("error.fnMapper.method", funcNode.getOutputName()));
}
int methodParameterCount = m.getParameterTypes().length;
int inputParameterCount = node.jjtGetNumChildren();
if (m.isVarArgs() && inputParameterCount < methodParameterCount - 1 || !m.isVarArgs() && inputParameterCount != methodParameterCount) {
throw new ELException(MessageFactory.get("error.fnMapper.paramcount", funcNode.getOutputName(), "" + methodParameterCount, "" + node.jjtGetNumChildren()));
}
} else if (node instanceof AstIdentifier && this.varMapper != null) {
String variable = ((AstIdentifier) node).getImage();
// simply capture it
this.varMapper.resolveVariable(variable);
}
}
Aggregations