List of usage examples for org.springframework.expression ParseException getMessage
@Override
public String getMessage()
From source file:com.massfords.maven.spel.SpelPlugin.java
/** * Scans the classpath looking for instances of the annotation on methods * to validate the expressions on the annotation if present. * * @param reflections//from w w w.ja va2 s .c om * @param sa * @return * @throws Exception */ private int validateAllAnnotationExpressions(Reflections reflections, SpelAnnotation sa) throws Exception { int processedCount = 0; Class<? extends Annotation> annoType = sa.getClazz(); Set<Method> set = reflections.getMethodsAnnotatedWith(annoType); for (Method m : set) { Annotation anno = m.getAnnotation(annoType); Method attrGetter = annoType.getDeclaredMethod(sa.getAttribute()); Object expressionObj = attrGetter.invoke(anno); if (expressionObj instanceof String) { getLog().debug(String.format("Validating expression: %s", expressionObj)); String expression = (String) attrGetter.invoke(anno); try { processedCount++; validator.validate(expression, sa.getExpressionRootClass()); report.success(); } catch (ParseException e) { String pattern = "Spel annotation %s.%s with expression %s failed to parse. Error message: %s"; String formatted = String.format(pattern, sa.getName(), sa.getAttribute(), expression, e.getMessage()); reportError(formatted); } catch (ExpressionValidationException e) { String message = "Spel annotation %s.%s with expression %s has validation errors. Validation error message: %s"; String formatted = String.format(message, sa.getName(), sa.getAttribute(), expression, e.getMessage()); reportError(formatted); } } else if (expressionObj != null) { String message = "Spel annotation %s.%s is not configured with a string."; reportError(String.format(message, sa.getName(), sa.getAttribute())); } } return processedCount; }