Package com.et.mvc.filter

Examples of com.et.mvc.filter.Filter


  private boolean afterInvokeAroundFilters(Controller controller,
      List<Filter> arounds) throws Exception {
    boolean result = true;
    Exception exception = null;
    for (int i = arounds.size() - 1; i >= 0; i--) {
      Filter filter = arounds.get(i);
      try {
        boolean ret = filter.afterInvoke(controller);
        if (!ret) {
          result = false;
        }
      } catch (Exception ex) {
        if (exception == null) {
View Full Code Here


    List<Filter> arounds = new ArrayList<Filter>(); // 已执行的Around过滤器
    List<Filter> chains = FilterUtils.getFilterChain(controller);
    boolean chainBroken = false;
    try {
      for (int i = 0; i < chains.size(); i++) {
        Filter filter = chains.get(i);
        if (filter.canInvoke(controller.getActionName())) {
          boolean ret = filter.beforeInvoke(controller);
          if (ret == true && filter.getAroundFilter() != null) {
            arounds.add(filter);
          }
          if (!ret) {
            chainBroken = true;
            break;
          }
        }
      }
    } catch (Exception ex) {
      try {
        afterInvokeAroundFilters(controller, arounds);
      } catch (Exception ex2) {
      }
      throw ex;
    }
    if (chainBroken == true) { // 过滤器链执行中断
      afterInvokeAroundFilters(controller, arounds);
      return;
    }

    // 执行控制器方法
    Object actionResult = null;
    try {
      actionResult = controller.invoke();
    } catch (Exception ex) {
      controller.exception = ex;
    }

    // Around过滤器after方法,反序执行
    if (afterInvokeAroundFilters(controller, arounds) == false) {
      return; // 不继续执行后续代码
    }

    if (controller.exception != null) {
      throw controller.exception;
    }

    // After过滤器,顺序执行
    for (int i = 0; i < chains.size(); i++) {
      Filter filter = chains.get(i);
      if (filter.canInvoke(controller.getActionName())
          && filter.getAfterFilter() != null) {
        boolean ret = filter.afterInvoke(controller);
        if (!ret) {
          return;
        }
      }
    }
View Full Code Here

TOP

Related Classes of com.et.mvc.filter.Filter

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.