📄 contextloaderservlet.java
字号:
/* * Copyright 2002-2004 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package de.mindmatters.faces.spring.context;import java.io.IOException;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;/** * Bootstrap servlet to start up Spring's root WebApplicationContext. Simply * delegates to ContextLoader. * * <p> * For further informtion please have a look at the documentation of * {@link org.springframework.web.context.ContextLoaderServlet}. * </p> * * @author Andreas Kuhrwahl */public class ContextLoaderServlet extends HttpServlet { /** */ private static final long serialVersionUID = 911567464553588852L; /** * The ConfigLoader loading the <i>jsf-spring-config</i> root * ConfigWebApplicationContext. */ private ContextLoader contextLoader; /** * Creates the ConfigLoader to use. Can be overridden in subclasses. * * @return the new ConfigLoader */ protected ContextLoader createContextLoader() { return new ContextLoader(); } /** * Initializes the <i>jsf-spring-config</i> root web application context. * * @throws ServletException * in cases of errors * @see javax.servlet.GenericServlet#init() */ public final void init() throws ServletException { this.contextLoader = createContextLoader(); this.contextLoader.initWebApplicationContext(getServletContext()); } /** * Closes the <i>jsf-spring-config</i> root web application context. * * @see javax.servlet.Servlet#destroy() */ public final void destroy() { if (this.contextLoader != null) { this.contextLoader.closeWebApplicationContext(getServletContext()); } } /** * This should never even be called since no mapping to this servlet should * ever be created in web.xml. That's why a correctly invoked Servlet 2.3 * listener is much more appropriate for initialization work ;-) * * @param request * the request * @param response * the response * @throws IOException * in cases of i/o errors * @see javax.servlet.http.HttpServlet#service(javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse) */ public final void service(final HttpServletRequest request, final HttpServletResponse response) throws IOException { getServletContext().log( "Attempt to call service method on ConfigLoaderServlet as [" + request.getRequestURI() + "] was ignored"); response.sendError(HttpServletResponse.SC_BAD_REQUEST); } /** * {@inheritDoc} */ public final String getServletInfo() { return "ConfigLoaderServlet for Servlet API 2.2/2.3 " + "(deprecated in favor of ConfigLoaderListener for Servlet API 2.4)"; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -