Source Code Cross Referenced for ContextLoaderServlet.java in  » J2EE » spring-framework-2.0.6 » org » springframework » web » context » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » spring framework 2.0.6 » org.springframework.web.context 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2002-2007 the original author or authors.
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:
017:        package org.springframework.web.context;
018:
019:        import java.io.IOException;
020:
021:        import javax.servlet.ServletException;
022:        import javax.servlet.http.HttpServlet;
023:        import javax.servlet.http.HttpServletRequest;
024:        import javax.servlet.http.HttpServletResponse;
025:
026:        /**
027:         * Bootstrap servlet to start up Spring's root {@link WebApplicationContext}.
028:         * Simply delegates to {@link ContextLoader}.
029:         *
030:         * <p>This servlet should have a lower <code>load-on-startup</code> value
031:         * in <code>web.xml</code> than any servlets that access the root web
032:         * application context.
033:         *
034:         * <p><i>Note that this class has been deprecated for containers implementing
035:         * Servlet API 2.4 or higher, in favor of {@link ContextLoaderListener}.</i><br>
036:         * According to Servlet 2.4, listeners must be initialized before load-on-startup
037:         * servlets. Many Servlet 2.3 containers already enforce this behavior. If you
038:         * use such a container, this servlet can be replaced with ContextLoaderListener.
039:         * Else or if working with a Servlet 2.2 container, stick with this servlet.
040:         *
041:         * <p>Servlet 2.3 containers known to work with bootstrap listeners are:
042:         * <ul>
043:         * <li>Apache Tomcat 4.x+
044:         * <li>Jetty 4.x+
045:         * <li>Resin 2.1.8+
046:         * <li>Orion 2.0.2+
047:         * <li>BEA WebLogic 8.1 SP3
048:         * </ul>
049:         * For working with any of them, ContextLoaderListener is recommended.
050:         *
051:         * <p>Servlet 2.3 containers known <i>not</i> to work with bootstrap listeners are:
052:         * <ul>
053:         * <li>BEA WebLogic up to 8.1 SP2
054:         * <li>IBM WebSphere 5.x
055:         * <li>Oracle OC4J 9.0.3
056:         * </ul>
057:         * If you happen to work with such a server, this servlet has to be used.
058:         *
059:         * <p>So unfortunately, the only context initialization option that is compatible
060:         * with <i>all</i> Servlet 2.3 containers is this servlet.
061:         *
062:         * <p>Note that a startup failure of this servlet will not stop the rest of the
063:         * web application from starting, in contrast to a listener failure. This can
064:         * lead to peculiar side effects if other servlets get started that depend on
065:         * initialization of the root web application context.
066:         *
067:         * @author Juergen Hoeller
068:         * @author Darren Davison
069:         * @see ContextLoaderListener
070:         * @see org.springframework.web.util.Log4jConfigServlet
071:         */
072:        public class ContextLoaderServlet extends HttpServlet {
073:
074:            private ContextLoader contextLoader;
075:
076:            /**
077:             * Initialize the root web application context.
078:             */
079:            public void init() throws ServletException {
080:                this .contextLoader = createContextLoader();
081:                this .contextLoader
082:                        .initWebApplicationContext(getServletContext());
083:            }
084:
085:            /**
086:             * Create the ContextLoader to use. Can be overridden in subclasses.
087:             * @return the new ContextLoader
088:             */
089:            protected ContextLoader createContextLoader() {
090:                return new ContextLoader();
091:            }
092:
093:            /**
094:             * Return the ContextLoader used by this servlet. 
095:             * @return the current ContextLoader
096:             */
097:            public ContextLoader getContextLoader() {
098:                return this .contextLoader;
099:            }
100:
101:            /**
102:             * Close the root web application context.
103:             */
104:            public void destroy() {
105:                if (this .contextLoader != null) {
106:                    this .contextLoader
107:                            .closeWebApplicationContext(getServletContext());
108:                }
109:            }
110:
111:            /**
112:             * This should never even be called since no mapping to this servlet should
113:             * ever be created in web.xml. That's why a correctly invoked Servlet 2.3
114:             * listener is much more appropriate for initialization work ;-)
115:             */
116:            public void service(HttpServletRequest request,
117:                    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:            public String getServletInfo() {
125:                return "ContextLoaderServlet for Servlet API 2.2/2.3 "
126:                        + "(deprecated in favor of ContextLoaderListener for Servlet API 2.4)";
127:            }
128:
129:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.