private ArrayList<Interceptor> getInterceptors() {
    Map<String, InterceptorHolder> interceptorMap =
        this.applicationContext.getBeansOfType(InterceptorHolder.class);
    if (interceptorMap != null && interceptorMap.size() > 0) {
      ArrayList<Interceptor> interceptors = new ArrayList<Interceptor>(interceptorMap.size());

      // 从Spring容器中获取Interceptor
      for (InterceptorHolder interceptorHolder : interceptorMap.values()) {
        interceptors.add(interceptorHolder.getInterceptor());
      }

      // 根据getOrder()值排序
      Collections.sort(
          interceptors,
          new Comparator<Interceptor>() {
            public int compare(Interceptor o1, Interceptor o2) {
              if (o1.getOrder() > o2.getOrder()) {
                return 1;
              } else if (o1.getOrder() < o2.getOrder()) {
                return -1;
              } else {
                return 0;
              }
            }
          });
      return interceptors;
    } else {
      return null;
    }
  }
  public void afterPropertiesSet() throws Exception {
    // 实例化一个AnnotationServletServiceRouter
    serviceRouter = new AnnotationServletServiceRouter();

    // 设置国际化错误资源
    if (extErrorBasename != null) {
      serviceRouter.setExtErrorBasename(extErrorBasename);
    }

    if (extErrorBasenames != null) {
      serviceRouter.setExtErrorBasenames(extErrorBasenames);
    }

    DefaultSecurityManager securityManager = BeanUtils.instantiate(DefaultSecurityManager.class);

    securityManager.setSessionManager(sessionManager);
    securityManager.setAppSecretManager(appSecretManager);
    securityManager.setServiceAccessController(serviceAccessController);
    securityManager.setInvokeTimesController(invokeTimesController);
    securityManager.setFileUploadController(buildFileUploadController());

    serviceRouter.setSecurityManager(securityManager);
    serviceRouter.setThreadPoolExecutor(threadPoolExecutor);
    serviceRouter.setSignEnable(signEnable);
    serviceRouter.setServiceTimeoutSeconds(serviceTimeoutSeconds);
    serviceRouter.setFormattingConversionService(formattingConversionService);
    serviceRouter.setSessionManager(sessionManager);
    serviceRouter.setThreadFerryClass(threadFerryClass);
    serviceRouter.setInvokeTimesController(invokeTimesController);

    // 注册拦截器
    ArrayList<Interceptor> interceptors = getInterceptors();
    if (interceptors != null) {
      for (Interceptor interceptor : interceptors) {
        serviceRouter.addInterceptor(interceptor);
      }
      if (logger.isInfoEnabled()) {
        logger.info("register total {} interceptors", interceptors.size());
      }
    }

    // 注册监听器
    ArrayList<RopEventListener> listeners = getListeners();
    if (listeners != null) {
      for (RopEventListener listener : listeners) {
        serviceRouter.addListener(listener);
      }
      if (logger.isInfoEnabled()) {
        logger.info("register total {} listeners", listeners.size());
      }
    }

    // 设置Spring上下文信息
    serviceRouter.setApplicationContext(this.applicationContext);

    // 启动之
    serviceRouter.startup();
  }
  private ArrayList<RopEventListener> getListeners() {
    Map<String, RopEventListenerHodler> listenerMap =
        this.applicationContext.getBeansOfType(RopEventListenerHodler.class);
    if (listenerMap != null && listenerMap.size() > 0) {
      ArrayList<RopEventListener> ropEventListeners =
          new ArrayList<RopEventListener>(listenerMap.size());

      // 从Spring容器中获取Interceptor
      for (RopEventListenerHodler listenerHolder : listenerMap.values()) {
        ropEventListeners.add(listenerHolder.getRopEventListener());
      }
      return ropEventListeners;
    } else {
      return null;
    }
  }