List of usage examples for org.springframework.expression.spel.support StandardEvaluationContext StandardEvaluationContext
public StandardEvaluationContext()
From source file:com.frank.search.solr.core.mapping.SimpleSolrPersistentEntity.java
public SimpleSolrPersistentEntity(TypeInformation<T> typeInformation) { super(typeInformation); this.context = new StandardEvaluationContext(); this.typeInformation = typeInformation; this.solrCoreName = derivateSolrCoreName(); this.boost = derivateDocumentBoost(); }
From source file:org.arrow.model.gateway.impl.ExclusiveGateway.java
@Override public List<EventMessage> fork(Execution execution, ExecutionService service) { ExpressionParser parser = new SpelExpressionParser(); for (Flow flow : getOutgoingFlows()) { // handle multiple outgoing flows ConditionExpression ce = ((SequenceFlow) flow).getConditionExpression(); if (ce == null) { continue; }//from w w w. j a v a2 s. c o m StandardEvaluationContext context = new StandardEvaluationContext(); context.setVariables(execution.getVariables()); Expression expr = parser.parseExpression(ce.getCondition()); Boolean result = expr.getValue(context, Boolean.class); if ((result != null) && (result)) { flow.enableRelation(execution); break; } } // mark gateway as finished execution.setState(State.SUCCESS); finish(execution, service); return Arrays.asList(); }
From source file:org.icescrum.core.security.WebScrumExpressionHandler.java
public EvaluationContext createEvaluationContext(Authentication authentication, FilterInvocation fi) { StandardEvaluationContext ctx = new StandardEvaluationContext(); WebScrumExpressionRoot root = new WebScrumExpressionRoot(authentication, fi); root.setTrustResolver(trustResolver); root.setRoleHierarchy(roleHierarchy); root.setSecurityService(securityService); ctx.setRootObject(root);//from w w w . j a va 2 s . co m return ctx; }
From source file:org.arrow.model.gateway.impl.InclusiveGateway.java
/** * {@inheritDoc}//from w w w .j av a 2s. co m */ @Override public List<EventMessage> fork(Execution execution, ExecutionService service) { ExpressionParser parser = new SpelExpressionParser(); for (Flow flow : getOutgoingFlows()) { // handle multiple outgoing flows ConditionExpression ce = ((SequenceFlow) flow).getConditionExpression(); notNull(ce, "no condition detected on flow " + flow.getId()); StandardEvaluationContext context = new StandardEvaluationContext(); context.setVariables(execution.getVariables()); Expression expression = parser.parseExpression(ce.getCondition()); Boolean result = expression.getValue(context, Boolean.class); if ((result != null) && result) { flow.enableRelation(execution); } } // mark gateway as finished execution.setState(State.SUCCESS); finish(execution, service); return Arrays.asList(); }
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.mule.module.spel.EvaluationContextFactory.java
public EvaluationContext create(MuleMessage message) { Assert.notNull(message, "Message cannot be null"); StandardEvaluationContext simpleContext = new StandardEvaluationContext(); simpleContext.setVariable(CONTEXT_VAR_NAME, muleContext); simpleContext.setVariable(REGISTRY_VAR_NAME, muleRegistry); simpleContext.setVariable(MESSAGE_VAR_NAME, message); simpleContext.setVariable(ORIGINAL_PAYLOAD_VAR_NAME, message.getOriginalPayload()); simpleContext.setVariable(PAYLOAD_VAR_NAME, message.getPayload()); simpleContext.setVariable(ID_VAR_NAME, message.getUniqueId()); /* systemProperties and systemEnvironment are spring beans already registered in the mule registry, and thus available as @systemEnvironment and @systemProperties. But this is collateral, so to properly to mimic Spring framework behavior both beans will be added as variables. //from w w w . j a v a 2s.c om */ if (muleRegistry != null) { simpleContext.setVariable(SYSTEM_PROPERTIES_VAR_NAME, muleRegistry.get(ConfigurableApplicationContext.SYSTEM_PROPERTIES_BEAN_NAME)); simpleContext.setVariable(ENVIRONMENT_VAR_NAME, muleRegistry.get(ConfigurableApplicationContext.SYSTEM_ENVIRONMENT_BEAN_NAME)); } simpleContext.setRootObject(message.getPayload()); simpleContext.setBeanResolver(beanResolver); return simpleContext; }
From source file:net.asfun.jangod.interpret.FloorBindings.java
public Object get(String key, int level) { checkKey(key);/* w w w. jav a 2 s .c o m*/ Map<String, Object> bindings = getBindings(level); try { StandardEvaluationContext context = new StandardEvaluationContext(); context.addPropertyAccessor(new ReflectivePropertyAccessor()); context.addPropertyAccessor(new MapAccessor()); context.setRootObject(bindings); return parser.parseExpression(key).getValue(context); } catch (Exception e) { return bindings.get(key); } }
From source file:cz.jirutka.spring.exhandler.interpolators.SpelMessageInterpolator.java
/** * Creates a new instance with {@link StandardEvaluationContext} including * {@link org.springframework.expression.spel.support.ReflectivePropertyAccessor ReflectivePropertyAccessor} * and {@link MapAccessor}.//from w ww . j av a2 s . com */ public SpelMessageInterpolator() { StandardEvaluationContext ctx = new StandardEvaluationContext(); ctx.addPropertyAccessor(new MapAccessor()); this.evalContext = ctx; }
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 w w w . ja v a 2s .com*/ * @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:io.dyn.core.handler.GuardedHandlerMethodInvoker.java
@Override public Object invoke(HandlerMethod method, Object handler, EvaluationContext evalCtx, Object... args) throws Exception { if (null == evalCtx) { StandardEvaluationContext ec = new StandardEvaluationContext(); if (null != applicationContext) { ec.setBeanResolver(new BeanFactoryResolver(applicationContext)); }//from w w w . ja v a2 s. c o m evalCtx = ec; } HandlerMethodArgument[] handlerMethodArguments = method.arguments(); int argc = handlerMethodArguments.length; Object[] argv = new Object[argc]; for (int i = 0; i < argc; i++) { HandlerMethodArgument handlerArg = handlerMethodArguments[i]; if (ClassUtils.isAssignable(EvaluationContext.class, handlerArg.targetType())) { argv[i] = evalCtx; } else if (null != handlerArg.valueExpression()) { try { argv[i] = handlerArg.valueExpression().getValue(evalCtx, handlerArg.targetType()); } catch (SpelEvaluationException e) { argv[i] = null; } } else { try { Object o = args[handlerArg.index()]; if (ClassUtils.isAssignable(handlerArg.targetType(), o.getClass())) { argv[i] = o; } else if (null != customConversionService && customConversionService.canConvert(o.getClass(), handlerArg.targetType())) { argv[i] = customConversionService.convert(o, handlerArg.targetType()); } else { argv[i] = Sys.DEFAULT_CONVERSION_SERVICE.convert(o, handlerArg.targetType()); } } catch (IndexOutOfBoundsException e) { } } evalCtx.setVariable(handlerArg.name(), argv[i]); } InvocationHandler invoker = method.invocationHandler(); Method m = method.methodToInvoke(); if (null != method.guard()) { if (method.guard().checkGuard(null, evalCtx)) { if (null != invoker) { try { invoker.invoke(handler, m, argv); } catch (Throwable throwable) { throw new IllegalStateException(throwable); } } else { return m.invoke(handler, argv); } } else { //LOG.debug("Guard expression %s failed", method.guard().expression().getExpressionString()); } } else { if (null != invoker) { try { return invoker.invoke(handler, m, argv); } catch (Throwable throwable) { throw new IllegalStateException(throwable); } } else { return m.invoke(handler, argv); } } return null; }