use of org.apache.camel.ExpressionEvaluationException in project camel by apache.
the class SpelExpression method evaluate.
public <T> T evaluate(Exchange exchange, Class<T> tClass) {
try {
Expression expression = parseExpression();
EvaluationContext evaluationContext = createEvaluationContext(exchange);
Object value = expression.getValue(evaluationContext);
// Let Camel handle the type conversion
return exchange.getContext().getTypeConverter().convertTo(tClass, value);
} catch (Exception e) {
throw new ExpressionEvaluationException(this, exchange, e);
}
}
use of org.apache.camel.ExpressionEvaluationException in project camel by apache.
the class OgnlExpression method evaluate.
public <T> T evaluate(Exchange exchange, Class<T> tClass) {
OgnlContext oglContext = new OgnlContext();
// setup the class resolver from camel
oglContext.setClassResolver(new CamelClassResolver(exchange.getContext().getClassResolver()));
try {
Object value = Ognl.getValue(expression, oglContext, new RootObject(exchange));
return exchange.getContext().getTypeConverter().convertTo(tClass, value);
} catch (OgnlException e) {
throw new ExpressionEvaluationException(this, exchange, e);
}
}
use of org.apache.camel.ExpressionEvaluationException in project camel by apache.
the class JXPathExpression method evaluate.
public <T> T evaluate(Exchange exchange, Class<T> tClass) {
try {
JXPathContext context = JXPathContext.newContext(exchange);
context.setLenient(lenient);
Object result = getJXPathExpression().getValue(context, type);
assertResultType(exchange, result);
return exchange.getContext().getTypeConverter().convertTo(tClass, result);
} catch (JXPathException e) {
throw new ExpressionEvaluationException(this, exchange, e);
}
}
Aggregations