Package org.springframework.expression

Examples of org.springframework.expression.ConstructorExecutor


      Object value = childValue.getValue();
      arguments[i] = value;
      argumentTypes.add(TypeDescriptor.forObject(value));
    }

    ConstructorExecutor executorToUse = this.cachedExecutor;
    if (executorToUse != null) {
      try {
        return executorToUse.execute(state.getEvaluationContext(), arguments);
      }
      catch (AccessException ae) {
        // Two reasons this can occur:
        // 1. the method invoked actually threw a real exception
        // 2. the method invoked was not passed the arguments it expected and has become 'stale'

        // In the first case we should not retry, in the second case we should see if there is a
        // better suited method.

        // To determine which situation it is, the AccessException will contain a cause.
        // If the cause is an InvocationTargetException, a user exception was thrown inside the constructor.
        // Otherwise the constructor could not be invoked.
        if (ae.getCause() instanceof InvocationTargetException) {
          // User exception was the root cause - exit now
          Throwable rootCause = ae.getCause().getCause();
          if (rootCause instanceof RuntimeException) {
            throw (RuntimeException) rootCause;
          } else {
            String typename = (String) this.children[0].getValueInternal(state).getValue();
            throw new SpelEvaluationException(getStartPosition(), rootCause,
                SpelMessage.CONSTRUCTOR_INVOCATION_PROBLEM, typename, FormatHelper
                    .formatMethodForMessage("", argumentTypes));
          }         
        }

        // at this point we know it wasn't a user problem so worth a retry if a better candidate can be found
        this.cachedExecutor = null;
      }
    }

    // either there was no accessor or it no longer exists
    String typename = (String) this.children[0].getValueInternal(state).getValue();
    executorToUse = findExecutorForConstructor(typename, argumentTypes, state);
    try {
      this.cachedExecutor = executorToUse;
      return executorToUse.execute(state.getEvaluationContext(), arguments);
    }
    catch (AccessException ae) {
      throw new SpelEvaluationException(getStartPosition(), ae, SpelMessage.CONSTRUCTOR_INVOCATION_PROBLEM,
          typename, FormatHelper.formatMethodForMessage("", argumentTypes));
View Full Code Here


    EvaluationContext eContext = state.getEvaluationContext();
    List<ConstructorResolver> cResolvers = eContext.getConstructorResolvers();
    if (cResolvers != null) {
      for (ConstructorResolver ctorResolver : cResolvers) {
        try {
          ConstructorExecutor cEx = ctorResolver.resolve(state.getEvaluationContext(), typename,
              argumentTypes);
          if (cEx != null) {
            return cEx;
          }
        }
View Full Code Here

      Object value = childValue.getValue();
      arguments[i] = value;
      argumentTypes[i] = (value==null?null:value.getClass());
    }

    ConstructorExecutor executorToUse = this.cachedExecutor;
    if (executorToUse != null) {
      try {
        return executorToUse.execute(state.getEvaluationContext(), arguments);
      }
      catch (AccessException ae) {
        // this is OK - it may have gone stale due to a class change,
        // let's try to get a new one and call it before giving up
        this.cachedExecutor = null;
      }
    }

    // either there was no accessor or it no longer exists
    String typename = (String) children[0].getValueInternal(state).getValue();
    executorToUse = findExecutorForConstructor(typename, argumentTypes, state);
    try {
      this.cachedExecutor = executorToUse;
      TypedValue result = executorToUse.execute(state.getEvaluationContext(), arguments);
      return result;
    } catch (AccessException ae) {
      throw new SpelEvaluationException(getStartPosition(), ae, SpelMessage.CONSTRUCTOR_INVOCATION_PROBLEM, typename,
          FormatHelper.formatMethodForMessage("", argumentTypes));
View Full Code Here

    EvaluationContext eContext = state.getEvaluationContext();
    List<ConstructorResolver> cResolvers = eContext.getConstructorResolvers();
    if (cResolvers != null) {
      for (ConstructorResolver ctorResolver : cResolvers) {
        try {
          ConstructorExecutor cEx = ctorResolver.resolve(state.getEvaluationContext(), typename,
              argumentTypes);
          if (cEx != null) {
            return cEx;
          }
        } catch (AccessException ex) {
View Full Code Here

      Object value = childValue.getValue();
      arguments[i] = value;
      argumentTypes[i] = (value==null?null:value.getClass());
    }

    ConstructorExecutor executorToUse = this.cachedExecutor;
    if (executorToUse != null) {
      try {
        return executorToUse.execute(state.getEvaluationContext(), arguments);
      }
      catch (AccessException ae) {
        // Two reasons this can occur:
        // 1. the method invoked actually threw a real exception
        // 2. the method invoked was not passed the arguments it expected and has become 'stale'
       
        // In the first case we should not retry, in the second case we should see if there is a
        // better suited method.
       
        // To determine which situation it is, the AccessException will contain a cause - this
        // will be the exception thrown by the reflective invocation.  Inside this exception there
        // may or may not be a root cause.  If there is a root cause it is a user created exception.
        // If there is no root cause it was a reflective invocation problem.
       
        Throwable causeOfAccessException = ae.getCause();
        Throwable rootCause = (causeOfAccessException==null?null:causeOfAccessException.getCause());
        if (rootCause!=null) {
          // User exception was the root cause - exit now
          if (rootCause instanceof RuntimeException) {
            throw (RuntimeException)rootCause;
          } else {
            String typename = (String) children[0].getValueInternal(state).getValue();
            throw new SpelEvaluationException(getStartPosition(), rootCause, SpelMessage.CONSTRUCTOR_INVOCATION_PROBLEM,
                typename,FormatHelper.formatMethodForMessage("", argumentTypes));
          }
        }
       
        // at this point we know it wasn't a user problem so worth a retry if a better candidate can be found
        this.cachedExecutor = null;
      }
    }

    // either there was no accessor or it no longer exists
    String typename = (String) children[0].getValueInternal(state).getValue();
    executorToUse = findExecutorForConstructor(typename, argumentTypes, state);
    try {
      this.cachedExecutor = executorToUse;
      TypedValue result = executorToUse.execute(state.getEvaluationContext(), arguments);
      return result;
    } catch (AccessException ae) {
      throw new SpelEvaluationException(getStartPosition(), ae, SpelMessage.CONSTRUCTOR_INVOCATION_PROBLEM, typename,
          FormatHelper.formatMethodForMessage("", argumentTypes));
View Full Code Here

    EvaluationContext eContext = state.getEvaluationContext();
    List<ConstructorResolver> cResolvers = eContext.getConstructorResolvers();
    if (cResolvers != null) {
      for (ConstructorResolver ctorResolver : cResolvers) {
        try {
          ConstructorExecutor cEx = ctorResolver.resolve(state.getEvaluationContext(), typename,
              argumentTypes);
          if (cEx != null) {
            return cEx;
          }
        } catch (AccessException ex) {
View Full Code Here

      Object value = childValue.getValue();
      arguments[i] = value;
      argumentTypes[i] = (value == null ? null : value.getClass());
    }

    ConstructorExecutor executorToUse = this.cachedExecutor;
    if (executorToUse != null) {
      try {
        return executorToUse.execute(state.getEvaluationContext(), arguments);
      } catch (AccessException ae) {
        // Two reasons this can occur:
        // 1. the method invoked actually threw a real exception
        // 2. the method invoked was not passed the arguments it expected and has become 'stale'

        // In the first case we should not retry, in the second case we should see if there is a
        // better suited method.

        // To determine which situation it is, the AccessException will contain a cause - this
        // will be the exception thrown by the reflective invocation. Inside this exception there
        // may or may not be a root cause. If there is a root cause it is a user created exception.
        // If there is no root cause it was a reflective invocation problem.

        Throwable causeOfAccessException = ae.getCause();
        Throwable rootCause = (causeOfAccessException == null ? null : causeOfAccessException.getCause());
        if (rootCause != null) {
          // User exception was the root cause - exit now
          if (rootCause instanceof RuntimeException) {
            throw (RuntimeException) rootCause;
          } else {
            String typename = (String) children[0].getValueInternal(state).getValue();
            throw new SpelEvaluationException(getStartPosition(), rootCause,
                SpelMessage.CONSTRUCTOR_INVOCATION_PROBLEM, typename, FormatHelper
                    .formatMethodForMessage("", argumentTypes));
          }
        }

        // at this point we know it wasn't a user problem so worth a retry if a better candidate can be found
        this.cachedExecutor = null;
      }
    }

    // either there was no accessor or it no longer exists
    String typename = (String) children[0].getValueInternal(state).getValue();
    executorToUse = findExecutorForConstructor(typename, argumentTypes, state);
    try {
      this.cachedExecutor = executorToUse;
      TypedValue result = executorToUse.execute(state.getEvaluationContext(), arguments);
      return result;
    } catch (AccessException ae) {
      throw new SpelEvaluationException(getStartPosition(), ae, SpelMessage.CONSTRUCTOR_INVOCATION_PROBLEM,
          typename, FormatHelper.formatMethodForMessage("", argumentTypes));
View Full Code Here

    EvaluationContext eContext = state.getEvaluationContext();
    List<ConstructorResolver> cResolvers = eContext.getConstructorResolvers();
    if (cResolvers != null) {
      for (ConstructorResolver ctorResolver : cResolvers) {
        try {
          ConstructorExecutor cEx = ctorResolver.resolve(state.getEvaluationContext(), typename,
              argumentTypes);
          if (cEx != null) {
            return cEx;
          }
        } catch (AccessException ex) {
View Full Code Here

      Object value = childValue.getValue();
      arguments[i] = value;
      argumentTypes.add(TypeDescriptor.forObject(value));
    }

    ConstructorExecutor executorToUse = this.cachedExecutor;
    if (executorToUse != null) {
      try {
        return executorToUse.execute(state.getEvaluationContext(), arguments);
      }
      catch (AccessException ex) {
        // Two reasons this can occur:
        // 1. the method invoked actually threw a real exception
        // 2. the method invoked was not passed the arguments it expected and has become 'stale'

        // In the first case we should not retry, in the second case we should see if there is a
        // better suited method.

        // To determine which situation it is, the AccessException will contain a cause.
        // If the cause is an InvocationTargetException, a user exception was thrown inside the constructor.
        // Otherwise the constructor could not be invoked.
        if (ex.getCause() instanceof InvocationTargetException) {
          // User exception was the root cause - exit now
          Throwable rootCause = ex.getCause().getCause();
          if (rootCause instanceof RuntimeException) {
            throw (RuntimeException) rootCause;
          }
          else {
            String typeName = (String) this.children[0].getValueInternal(state).getValue();
            throw new SpelEvaluationException(getStartPosition(), rootCause,
                SpelMessage.CONSTRUCTOR_INVOCATION_PROBLEM, typeName,
                FormatHelper.formatMethodForMessage("", argumentTypes));
          }
        }

        // At this point we know it wasn't a user problem so worth a retry if a better candidate can be found
        this.cachedExecutor = null;
      }
    }

    // Either there was no accessor or it no longer exists
    String typeName = (String) this.children[0].getValueInternal(state).getValue();
    executorToUse = findExecutorForConstructor(typeName, argumentTypes, state);
    try {
      this.cachedExecutor = executorToUse;
      if (this.cachedExecutor instanceof ReflectiveConstructorExecutor) {
        this.exitTypeDescriptor = CodeFlow.toDescriptor(
            ((ReflectiveConstructorExecutor) this.cachedExecutor).getConstructor().getDeclaringClass());
       
      }
      return executorToUse.execute(state.getEvaluationContext(), arguments);
    }
    catch (AccessException ex) {
      throw new SpelEvaluationException(getStartPosition(), ex,
          SpelMessage.CONSTRUCTOR_INVOCATION_PROBLEM, typeName,
          FormatHelper.formatMethodForMessage("", argumentTypes));
View Full Code Here

    EvaluationContext evalContext = state.getEvaluationContext();
    List<ConstructorResolver> ctorResolvers = evalContext.getConstructorResolvers();
    if (ctorResolvers != null) {
      for (ConstructorResolver ctorResolver : ctorResolvers) {
        try {
          ConstructorExecutor ce = ctorResolver.resolve(state.getEvaluationContext(), typeName, argumentTypes);
          if (ce != null) {
            return ce;
          }
        }
        catch (AccessException ex) {
View Full Code Here

TOP

Related Classes of org.springframework.expression.ConstructorExecutor

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.