Sfoglia il codice sorgente

优化URuleServlet中Spring上下文对象获取方式,以方便其它项目扩展

jacky6024 8 anni fa
parent
commit
857c30adb6

+ 5 - 1
urule-console/src/main/java/com/bstek/urule/console/servlet/URuleServlet.java

@@ -46,7 +46,7 @@ public class URuleServlet extends HttpServlet{
 	@Override
 	public void init(ServletConfig config) throws ServletException {
 		super.init(config);
-		WebApplicationContext applicationContext=WebApplicationContextUtils.getWebApplicationContext(config.getServletContext());
+		WebApplicationContext applicationContext=getWebApplicationContext(config);
 		Collection<ServletHandler> handlers=applicationContext.getBeansOfType(ServletHandler.class).values();
 		for(ServletHandler handler:handlers){
 			String url=handler.url();
@@ -57,6 +57,10 @@ public class URuleServlet extends HttpServlet{
 		}
 	}
 	
+	protected WebApplicationContext getWebApplicationContext(ServletConfig config){
+		return WebApplicationContextUtils.getWebApplicationContext(config.getServletContext());
+	}
+	
 	@Override
 	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
 		RequestHolder.set(req, resp);