Package org.springframework.expression.spel.support

Examples of org.springframework.expression.spel.support.StandardEvaluationContext


            throw new ExpressionEvaluationException(this, exchange, e);
        }
    }

    private EvaluationContext createEvaluationContext(Exchange exchange) {
        StandardEvaluationContext evaluationContext = new StandardEvaluationContext(new RootObject(exchange));
        if (exchange.getContext() instanceof SpringCamelContext) {
            // Support references (like @foo) in expressions to beans defined in the Registry/ApplicationContext
            ApplicationContext applicationContext = ((SpringCamelContext) exchange.getContext()).getApplicationContext();
            evaluationContext.setBeanResolver(new BeanFactoryResolver(applicationContext));
        }
        return evaluationContext;
    }
View Full Code Here


            throw new ExpressionEvaluationException(this, exchange, e);
        }
    }

    private EvaluationContext createEvaluationContext(Exchange exchange) {
        StandardEvaluationContext evaluationContext = new StandardEvaluationContext(new RootObject(exchange));
        if (exchange.getContext() instanceof SpringCamelContext) {
            // Support references (like @foo) in expressions to beans defined in the Registry/ApplicationContext
            ApplicationContext applicationContext = ((SpringCamelContext) exchange.getContext()).getApplicationContext();
            evaluationContext.setBeanResolver(new BeanFactoryResolver(applicationContext));
        }
        return evaluationContext;
    }
View Full Code Here

    }
  }

  public void setValue(Object rootObject, Object value) throws EvaluationException {
    try {
      StandardEvaluationContext evaluationContext = createEvaluationContext(rootObject);
      expression.setValue(evaluationContext, value);
    } catch (SpelEvaluationException e) {
      if (e.getMessageCode().equals(SpelMessage.PROPERTY_OR_FIELD_NOT_WRITABLE)) {
        throw new PropertyNotFoundException(rootObject.getClass(), getExpressionString(), e);
      }
View Full Code Here

  /**
   * Create a new Spring EL evaluation context for the given rootObject.
   */
  private StandardEvaluationContext createEvaluationContext(Object rootObject) {
    StandardEvaluationContext context = new StandardEvaluationContext(rootObject);
    context.setVariables(getVariableValues(rootObject));
    context.setTypeConverter(new StandardTypeConverter(conversionService));
    context.getPropertyAccessors().addAll(propertyAccessors);
    extendEvaluationContext(context);
    return context;
  }
View Full Code Here

  }

  public void testGetValue() throws Exception {
    Object bean = new Object();
    requestContext.getConversationScope().put("myBean", bean);
    TypedValue actual = accessor.read(new StandardEvaluationContext(), requestContext, "myBean");
    assertSame(bean, actual.getValue());

    bean = new Object();
    requestContext.getFlowScope().put("myBean", bean);
    actual = accessor.read(new StandardEvaluationContext(), requestContext, "myBean");
    assertSame(bean, actual.getValue());

    bean = new Object();
    initView(requestContext);
    requestContext.getViewScope().put("myBean", bean);
    actual = accessor.read(new StandardEvaluationContext(), requestContext, "myBean");
    unsetView(requestContext);
    assertSame(bean, actual.getValue());

    bean = new Object();
    requestContext.getFlashScope().put("myBean", bean);
    actual = accessor.read(new StandardEvaluationContext(), requestContext, "myBean");
    assertSame(bean, actual.getValue());

    bean = new Object();
    requestContext.getRequestScope().put("myBean", bean);
    actual = accessor.read(new StandardEvaluationContext(), requestContext, "myBean");
    assertSame(bean, actual.getValue());
  }
View Full Code Here

    setExpressionParser(new OAuth2ExpressionParser(getExpressionParser()));
  }

  @Override
  public StandardEvaluationContext createEvaluationContextInternal(Authentication authentication, MethodInvocation mi) {
    StandardEvaluationContext ec = super.createEvaluationContextInternal(authentication, mi);
    ec.setVariable("oauth2", new OAuth2SecurityExpressionMethods(authentication));
    return ec;
  }
View Full Code Here

  }

  @Override
  protected StandardEvaluationContext createEvaluationContextInternal(Authentication authentication,
      FilterInvocation invocation) {
    StandardEvaluationContext ec = super.createEvaluationContextInternal(authentication, invocation);
    ec.setVariable("oauth2", new OAuth2SecurityExpressionMethods(authentication));
    return ec;
  }
View Full Code Here

*/
public class OAuthMethodSecurityExpressionHandler extends DefaultMethodSecurityExpressionHandler {

  @Override
  public StandardEvaluationContext createEvaluationContextInternal(Authentication auth, MethodInvocation mi) {
    StandardEvaluationContext ec = super.createEvaluationContextInternal(auth, mi);
    ec.addMethodResolver(new OAuthMethodResolver());
    return ec;
  }
View Full Code Here

     * Subclasses can override this methode if they want to use a different EL root context
     *
     * @return EL root context which is used to evaluate the expression
     */
    public EvaluationContext createELContext(HttpServletRequest request) {
        return new StandardEvaluationContext(new ELRequestMatcherContext(request));
    }
View Full Code Here

    public ExpressionParser getExpressionParser() {
        return expressionParser;
    }

    public EvaluationContext createEvaluationContext(Authentication authentication, FilterInvocation fi) {
        StandardEvaluationContext ctx = new StandardEvaluationContext();
        SecurityExpressionRoot root = new WebSecurityExpressionRoot(authentication, fi);
        root.setTrustResolver(trustResolver);
        root.setRoleHierarchy(roleHierarchy);
        ctx.setRootObject(root);

        return ctx;
    }
View Full Code Here

TOP

Related Classes of org.springframework.expression.spel.support.StandardEvaluationContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.