Beispiel #1
0
 /**
  * アノテーションの要素の値を返します。
  *
  * @param beanDesc アノテーションを表す{@link BeanDesc}
  * @param annotation アノテーション
  * @param name 要素の名前
  * @return アノテーションの要素の値
  */
 public static Object getProperty(BeanDesc beanDesc, Annotation annotation, String name) {
   Method m = beanDesc.getMethodNoException(name);
   if (m == null) {
     return null;
   }
   Object v = MethodUtil.invoke(m, annotation, null);
   if (v != null && !"".equals(v)) {
     return v;
   }
   return null;
 }
  public void init(FilterConfig config) throws ServletException {
    String access = config.getInitParameter("jspDirectAccess");
    if (StringUtil.isNotBlank(access)) {
      jspDirectAccess = Boolean.valueOf(access);
    }

    String routesPath = config.getInitParameter("routes");
    if (StringUtil.isNotEmpty(routesPath)) {
      String realRoutesPath = config.getServletContext().getRealPath(routesPath);
      if (realRoutesPath != null) {
        routes = new File(realRoutesPath);
      }
      InputStream routesStream = config.getServletContext().getResourceAsStream(routesPath);
      try {
        Routes.load(routesStream);
      } finally {
        InputStreamUtil.close(routesStream);
      }
      lastLoaded = System.currentTimeMillis();
    }

    String interval = config.getInitParameter("checkInterval");
    if (StringUtil.isNotEmpty(interval)) {
      checkInterval = LongConversionUtil.toLong(interval);
    }
    if (checkInterval == null || checkInterval < 0) {
      checkInterval = -1L;
    }

    String contextSensitiveParam = config.getInitParameter("contextSensitive");
    if (StringUtil.isNotBlank(contextSensitiveParam)) {
      contextSensitive = Boolean.valueOf(contextSensitiveParam);
    }
    if (contextSensitive) {
      try {
        Method getContextPath = ReflectionUtil.getMethod(ServletContext.class, "getContextPath");
        UrlRewriter.contextPath =
            (String) MethodUtil.invoke(getContextPath, config.getServletContext(), null);
      } catch (NoSuchMethodRuntimeException e) {
        UrlRewriter.contextPath = config.getServletContext().getServletContextName();
      }
    }
    requestUriHeader = config.getInitParameter("requestUriHeader");

    String fallThroughParam = config.getInitParameter("fallThrough");
    if (StringUtil.isNotBlank(fallThroughParam)) {
      fallThrough = Boolean.valueOf(fallThroughParam);
    }
  }