Package org.springframework.expression

Examples of org.springframework.expression.EvaluationContext


    }
  }

  private void writeProperty(ExpressionState state, String name, Object newValue) throws SpelEvaluationException {
    TypedValue contextObject = state.getActiveContextObject();
    EvaluationContext eContext = state.getEvaluationContext();
   
    if (contextObject.getValue() == null && nullSafe) {
      return;
    }
View Full Code Here


  }

  public boolean isWritableProperty(String name, ExpressionState state) throws SpelEvaluationException {
    Object contextObject = state.getActiveContextObject().getValue();
    // TypeDescriptor td = state.getActiveContextObject().getTypeDescriptor();
    EvaluationContext eContext = state.getEvaluationContext();
    List<PropertyAccessor> resolversToTry = getPropertyAccessorsToTry(getObjectClass(contextObject), state);
    if (resolversToTry != null) {
      for (PropertyAccessor pfResolver : resolversToTry) {
        try {
          if (pfResolver.canWrite(eContext, contextObject, name)) {
View Full Code Here

  private MethodExecutor findAccessorForMethod(String name, List<TypeDescriptor> argumentTypes, ExpressionState state)
      throws SpelEvaluationException {

    TypedValue context = state.getActiveContextObject();
    Object contextObject = context.getValue();
    EvaluationContext eContext = state.getEvaluationContext();

    List<MethodResolver> mResolvers = eContext.getMethodResolvers();
    if (mResolvers != null) {
      for (MethodResolver methodResolver : mResolvers) {
        try {
          MethodExecutor cEx = methodResolver.resolve(
              state.getEvaluationContext(), contextObject, name, argumentTypes);
View Full Code Here

    return EVAL_BODY_INCLUDE;
  }

  @Override
  public int doEndTag() throws JspException {
    EvaluationContext evaluationContext =
        (EvaluationContext) this.pageContext.getAttribute(EVALUATION_CONTEXT_PAGE_ATTRIBUTE);
    if (evaluationContext == null) {
      evaluationContext = createEvaluationContext(this.pageContext);
      this.pageContext.setAttribute(EVALUATION_CONTEXT_PAGE_ATTRIBUTE, evaluationContext);
    }
View Full Code Here

            .append("')").toString();//如果权限控制表达式为空,判断时按root来判断
    }
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    HttpServletRequest request = ServletActionContext.getRequest();
    CustomWebSecurityExpressionHandler filterSecurityInterceptor = (CustomWebSecurityExpressionHandler)StorageService.ctx.getBean("customExpressionHandler");
    EvaluationContext ctx = filterSecurityInterceptor.createEvaluationContext(authentication, request);
    Expression expr = new SpelExpressionParser().parseExpression(expression);
    if(ExpressionUtils.evaluateAsBoolean(expr, ctx))
    {
      result = true;
    }
View Full Code Here

        bean.set("status", rs.getBoolean(3));
        return bean;
      }     
    },UI_RESOURCE_NAME);
    CustomWebSecurityExpressionHandler filterSecurityInterceptor = (CustomWebSecurityExpressionHandler)StorageService.ctx.getBean("customExpressionHandler");
    EvaluationContext ctx = filterSecurityInterceptor.createEvaluationContext(authentication, request);
    List<String>UIs = new ArrayList<String>();
    for(LazyDynaBean bean:beans)
    {
      Boolean status = (Boolean)bean.get("status");
      String path = (String)bean.get("path");
View Full Code Here

    if(functions==null){
      resultInfo.setFailed();
    }else{
      Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
      CustomWebSecurityExpressionHandler filterSecurityInterceptor = (CustomWebSecurityExpressionHandler)StorageService.ctx.getBean("customExpressionHandler");
      EvaluationContext ctx = filterSecurityInterceptor.createEvaluationContext(authentication, request);
      for(String function:functions){
        String expression = "hasRole('ROLE_USER') and hasIpAddress('localhost')";
        Expression expr = PARSER.parseExpression(expression);
            LazyDynaBean bean = new LazyDynaBean();
            bean.set(function, ExpressionUtils.evaluateAsBoolean(expr, ctx));
View Full Code Here

  private MethodExecutor findAccessorForMethod(String name, Class<?>[] argumentTypes, ExpressionState state)
      throws SpelEvaluationException {

    TypedValue context = state.getActiveContextObject();
    Object contextObject = context.getValue();
    EvaluationContext eContext = state.getEvaluationContext();

    List<MethodResolver> mResolvers = eContext.getMethodResolvers();
    if (mResolvers != null) {
      for (MethodResolver methodResolver : mResolvers) {
        try {
          MethodExecutor cEx = methodResolver.resolve(
              state.getEvaluationContext(), contextObject, name, argumentTypes);
View Full Code Here

      }
    }

    Class<?> contextObjectClass = getObjectClass(contextObject.getValue());
    List<PropertyAccessor> accessorsToTry = getPropertyAccessorsToTry(contextObjectClass, state);
    EvaluationContext eContext = state.getEvaluationContext();

    // Go through the accessors that may be able to resolve it. If they are a cacheable accessor then
    // get the accessor and use it. If they are not cacheable but report they can read the property
    // then ask them to read it
    if (accessorsToTry != null) {
View Full Code Here

    }
  }

  private void writeProperty(ExpressionState state, String name, Object newValue) throws SpelEvaluationException {
    TypedValue contextObject = state.getActiveContextObject();
    EvaluationContext eContext = state.getEvaluationContext();
   
    if (contextObject.getValue() == null && nullSafe) {
      return;
    }
View Full Code Here

TOP

Related Classes of org.springframework.expression.EvaluationContext

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.