List of usage examples for org.springframework.expression.spel.standard SpelExpressionParser SpelExpressionParser
public SpelExpressionParser()
From source file:de.hybris.platform.addonsupport.config.SpelBeanFactory.java
@Override public void onApplicationEvent(final ContextRefreshedEvent event) { final ExpressionParser parser = new SpelExpressionParser(); final StandardEvaluationContext context = new StandardEvaluationContext(); context.setBeanResolver(new BeanFactoryResolver(applicationContext)); final String[] beanNames = applicationContext.getBeanNamesForType(AbstractConverter.class); for (final String beanName : beanNames) { final BeanDefinition def = beanFactory.getBeanDefinition(beanName); final PropertyValue pv = def.getPropertyValues().getPropertyValue("targetClass"); if (pv != null) { if (pv.getValue() instanceof TypedStringValue) { String expr = StringUtils.strip(((TypedStringValue) pv.getValue()).getValue()); if (expr.startsWith("#{")) { expr = StringUtils.replaceOnce(expr, "#{", "@"); expr = StringUtils.stripEnd(expr, "}"); final Object result = parser.parseExpression(expr).getValue(context); if (result != null) { try { applicationContext.getBean(beanName, AbstractConverter.class) .setTargetClass(ClassUtils.getClass(result.toString())); } catch (final ClassNotFoundException e) { LOG.error(beanName + " target class instantiation failed", e); }// w w w . j av a 2 s .c o m } } } } } }
From source file:org.springjutsu.validation.spel.SPELResolver.java
/** * Resets SPEL resolver to an initial state, * in order to clear any customization or contexts * added by validation contexts, etc.//from w w w .j a v a 2s . com */ public void reset() { scopedContext = new NamedScopeEvaluationContext(); expressionParser = new SpelExpressionParser(); // init named contexts scopedContext.addContext("model", model); }
From source file:com.oneops.controller.cms.ExpressionEvalTest.java
@BeforeClass public void setup() { expressionEvaluator = new ExpressionEvaluator(); expressionEvaluator.setExprParser(new SpelExpressionParser()); expressionEvaluator.setCmsUtil(new CmsUtil()); }
From source file:org.apache.camel.language.spel.SpelExpression.java
public SpelExpression(Object language, String expressionString, Class<?> type) { this.expressionString = expressionString; this.type = type; this.expressionParser = new SpelExpressionParser(); }
From source file:com.joyveb.dbpimpl.cass.prepare.mapping.BasicCassandraPersistentEntity.java
/** * Creates a new {@link BasicCassandraPersistentEntity} with the given {@link TypeInformation}. Will default the table * name to the entities simple type name. * //from ww w .j a va 2s . c o m * @param typeInformation */ public BasicCassandraPersistentEntity(TypeInformation<T> typeInformation) { super(typeInformation, CassandraPersistentPropertyComparator.INSTANCE); this.parser = new SpelExpressionParser(); this.context = new StandardEvaluationContext(); Class<?> rawType = typeInformation.getType(); String fallback = rawType.getSimpleName().toLowerCase(); if (rawType.isAnnotationPresent(Table.class)) { Table d = rawType.getAnnotation(Table.class); this.table = StringUtils.hasText(d.name()) ? d.name() : fallback; } else { this.table = fallback; } }
From source file:org.gerzog.jstataggr.expressions.spel.SpelExpressionHandler.java
@PostConstruct public void initialize() { final StandardEvaluationContext context = new StandardEvaluationContext(); context.setBeanResolver(new BeanFactoryResolver(beanFactory)); this.context = context; this.expressionParser = new SpelExpressionParser(); }
From source file:org.springdata.ehcache.mapping.BasicEhcachePersistentEntity.java
@SuppressWarnings("unchecked") public BasicEhcachePersistentEntity(TypeInformation<T> typeInformation) { super(typeInformation); this.parser = new SpelExpressionParser(); this.context = new StandardEvaluationContext(); Class<T> rawType = typeInformation.getType(); if (rawType.isAnnotationPresent(Entity.class)) { Entity annotation = rawType.getAnnotation(Entity.class); this.cacheName = StringUtils.hasText(annotation.cacheName()) ? annotation.cacheName() : null; } else {// w w w . j a v a 2 s .c o m this.cacheName = null; } if (this.cacheName == null) { throw new BeanInitializationException( "entity class " + rawType + " does not specify cache name by Cache annotation"); } if (DataSerializable.class.isAssignableFrom(rawType)) { serializer = new DataSerializer<T>(); deserializer = new DataDeserializer<T>(rawType); } else { serializer = (Serializer<T>) new DefaultSerializer(); deserializer = (Deserializer<T>) new DefaultDeserializer(); } }
From source file:app.web.InterpreterController.java
@RequestMapping("/interpreter/run") public ModelAndView run(@RequestParam("script") String script) { Transaction transaction = Db.getSession().beginTransaction(); // Groovy Shell // Binding binding = new Binding(); // binding.setVariable("userService", userService); // FIXME: go through ApplicationContext or try to use SpEl instead? // Object result = new GroovyShell(binding).parse(script).run(); // Groovy Interpreter // Object result = GroovyInterpreter.run(script); // SpEl//from w w w . j a v a 2 s .c om ExpressionParser parser = new SpelExpressionParser(); StandardEvaluationContext ctx = new StandardEvaluationContext(); ctx.setBeanResolver(new BeanFactoryResolver(beanFactory)); Object result = parser.parseExpression(script).getValue(ctx); // Db.flush(); // can not flush here, we get org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here transaction.commit(); Map<String, Object> map = new HashMap<String, Object>(); map.put("script", script); map.put("result", result != null ? result.toString().replaceAll("\n", "<br/>").replaceAll(" ", " ") : Void.class.getSimpleName()); return new ModelAndView("/interpreter", map); }
From source file:org.craftercms.core.util.template.impl.spel.SpELStringTemplateCompiler.java
public SpELStringTemplateCompiler() { parser = new SpelExpressionParser(); parserContext = new TemplateParserContext(); expressionCache = new ConcurrentHashMap<String, Expression>(); }
From source file:cz.jirutka.spring.exhandler.interpolators.SpelMessageInterpolator.java
ExpressionParser parser() {
return new SpelExpressionParser();
}