use of org.springframework.expression.ExpressionParser in project spring-security by spring-projects.
the class ExpressionBasedAnnotationAttributeFactory method createPostInvocationAttribute.
public PostInvocationAttribute createPostInvocationAttribute(String postFilterAttribute, String postAuthorizeAttribute) {
try {
ExpressionParser parser = getParser();
Expression postAuthorizeExpression = postAuthorizeAttribute == null ? null : parser.parseExpression(postAuthorizeAttribute);
Expression postFilterExpression = postFilterAttribute == null ? null : parser.parseExpression(postFilterAttribute);
if (postFilterExpression != null || postAuthorizeExpression != null) {
return new PostInvocationExpressionAttribute(postFilterExpression, postAuthorizeExpression);
}
} catch (ParseException e) {
throw new IllegalArgumentException("Failed to parse expression '" + e.getExpressionString() + "'", e);
}
return null;
}
use of org.springframework.expression.ExpressionParser in project opennms by OpenNMS.
the class PersistRegexSelectorStrategyTest method testSpringEl.
@Test
public void testSpringEl() throws Exception {
ExpressionParser parser = new SpelExpressionParser();
Expression exp = parser.parseExpression("#name matches '^Alejandro.*'");
StandardEvaluationContext context = new StandardEvaluationContext();
context.setVariable("name", "Alejandro Galue");
boolean result = (Boolean) exp.getValue(context, Boolean.class);
Assert.assertTrue(result);
}
Aggregations