1 16 17 package org.springframework.web.context; 18 19 import java.io.IOException ; 20 21 import javax.servlet.ServletException ; 22 import javax.servlet.http.HttpServlet ; 23 import javax.servlet.http.HttpServletRequest ; 24 import javax.servlet.http.HttpServletResponse ; 25 26 72 public class ContextLoaderServlet extends HttpServlet { 73 74 private ContextLoader contextLoader; 75 76 77 80 public void init() throws ServletException { 81 this.contextLoader = createContextLoader(); 82 this.contextLoader.initWebApplicationContext(getServletContext()); 83 } 84 85 89 protected ContextLoader createContextLoader() { 90 return new ContextLoader(); 91 } 92 93 97 public ContextLoader getContextLoader() { 98 return this.contextLoader; 99 } 100 101 102 105 public void destroy() { 106 if (this.contextLoader != null) { 107 this.contextLoader.closeWebApplicationContext(getServletContext()); 108 } 109 } 110 111 112 117 public void service(HttpServletRequest request, HttpServletResponse response) throws IOException { 118 getServletContext().log( 119 "Attempt to call service method on ContextLoaderServlet as [" + 120 request.getRequestURI() + "] was ignored"); 121 response.sendError(HttpServletResponse.SC_BAD_REQUEST); 122 } 123 124 125 public String getServletInfo() { 126 return "ContextLoaderServlet for Servlet API 2.2/2.3 " + 127 "(deprecated in favor of ContextLoaderListener for Servlet API 2.4)"; 128 } 129 130 } 131 | Popular Tags |