示例#1
0
 public RootParamNode getRootParamNode() {
   checkAndParse();
   if (!rootParamsNodeIsGenerated) {
     rootParamNode = ParamNode.convert(data);
     rootParamsNodeIsGenerated = true;
   }
   return rootParamNode;
 }
示例#2
0
  public static Object[] getActionMethodArgs(Method method, Object o) throws Exception {
    String[] paramsNames = Java.parameterNames(method);
    if (paramsNames == null && method.getParameterTypes().length > 0) {
      throw new UnexpectedException("Parameter names not found for method " + method);
    }

    // Check if we have already performed the bind operation
    Object[] rArgs = CachedBoundActionMethodArgs.current().retrieveActionMethodArgs(method);
    if (rArgs != null) {
      // We have already performed the binding-operation for this method
      // in this request.
      return rArgs;
    }

    rArgs = new Object[method.getParameterTypes().length];
    for (int i = 0; i < method.getParameterTypes().length; i++) {

      Class<?> type = method.getParameterTypes()[i];
      Map<String, String[]> params = new HashMap<String, String[]>();

      // In case of simple params, we don't want to parse the body.
      if (type.equals(String.class) || Number.class.isAssignableFrom(type) || type.isPrimitive()) {
        params.put(paramsNames[i], Scope.Params.current().getAll(paramsNames[i]));
      } else {
        params.putAll(Scope.Params.current().all());
      }
      Logger.trace(
          "getActionMethodArgs name ["
              + paramsNames[i]
              + "] annotation ["
              + Utils.join(method.getParameterAnnotations()[i], " ")
              + "]");

      RootParamNode root = ParamNode.convert(params);
      rArgs[i] =
          Binder.bind(
              root,
              paramsNames[i],
              method.getParameterTypes()[i],
              method.getGenericParameterTypes()[i],
              method.getParameterAnnotations()[i],
              new Binder.MethodAndParamInfo(o, method, i + 1));
    }

    CachedBoundActionMethodArgs.current().storeActionMethodArgs(method, rArgs);
    return rArgs;
  }
示例#3
0
 public RootParamNode getRootParamNodeFromRequest() {
   return ParamNode.convert(data);
 }