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; } }
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; } }