コード例 #1
0
  private void initMethods() {
    Class clazz = getClass();
    for (Method method : clazz.getMethods()) {
      if (!Modifier.isPublic(method.getModifiers())) continue;

      WebMethod ann = method.getAnnotation(WebMethod.class);
      if (ann == null) continue;

      String url = ann.value();
      if (invokers.containsKey(url)) throw new WebException("Repetitive url '%s'", url);

      for (Class pt : method.getParameterTypes()) {
        if (!pt.isAssignableFrom(HttpServletRequest.class)
            && !pt.equals(HttpServletResponse.class)
            && !pt.equals(QueryParams.class))
          throw new WebException("Invalid parameter type '%s'", pt.getName());
      }

      invokers.put(url, new Invoker(this, method));
    }
  }