Source Code Cross Referenced for ContextLoaderServlet.java in  » J2EE » spring-framework-2.5 » 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.5 » 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:         *
040:         * <p>Servlet 2.3 containers known to work with bootstrap listeners are:
041:         * <ul>
042:         * <li>Apache Tomcat 4.x+
043:         * <li>Jetty 4.x+
044:         * <li>Resin 2.1.8+
045:         * <li>Orion 2.0.2+
046:         * <li>BEA WebLogic 8.1 SP3
047:         * </ul>
048:         * For working with any of them, ContextLoaderListener is recommended.
049:         *
050:         * <p>Servlet 2.3 containers known <i>not</i> to work with bootstrap listeners are:
051:         * <ul>
052:         * <li>BEA WebLogic up to 8.1 SP2
053:         * <li>IBM WebSphere 5.x
054:         * <li>Oracle OC4J 9.0.3
055:         * </ul>
056:         * If you happen to work with such a server, this servlet has to be used.
057:         *
058:         * <p>So unfortunately, the only context initialization option that is compatible
059:         * with <i>all</i> Servlet 2.3 containers is this servlet.
060:         *
061:         * <p>Note that a startup failure of this servlet will not stop the rest of the
062:         * web application from starting, in contrast to a listener failure. This can
063:         * lead to peculiar side effects if other servlets get started that depend on
064:         * initialization of the root web application context.
065:         *
066:         * @author Juergen Hoeller
067:         * @author Darren Davison
068:         * @see ContextLoaderListener
069:         * @see org.springframework.web.util.Log4jConfigServlet
070:         */
071:        public class ContextLoaderServlet extends HttpServlet {
072:
073:            private ContextLoader contextLoader;
074:
075:            /**
076:             * Initialize the root web application context.
077:             */
078:            public void init() throws ServletException {
079:                this .contextLoader = createContextLoader();
080:                this .contextLoader
081:                        .initWebApplicationContext(getServletContext());
082:            }
083:
084:            /**
085:             * Create the ContextLoader to use. Can be overridden in subclasses.
086:             * @return the new ContextLoader
087:             */
088:            protected ContextLoader createContextLoader() {
089:                return new ContextLoader();
090:            }
091:
092:            /**
093:             * Return the ContextLoader used by this servlet. 
094:             * @return the current ContextLoader
095:             */
096:            public ContextLoader getContextLoader() {
097:                return this .contextLoader;
098:            }
099:
100:            /**
101:             * Close the root web application context.
102:             */
103:            public void destroy() {
104:                if (this .contextLoader != null) {
105:                    this .contextLoader
106:                            .closeWebApplicationContext(getServletContext());
107:                }
108:            }
109:
110:            /**
111:             * This should never even be called since no mapping to this servlet should
112:             * ever be created in web.xml. That's why a correctly invoked Servlet 2.3
113:             * listener is much more appropriate for initialization work ;-)
114:             */
115:            public void service(HttpServletRequest request,
116:                    HttpServletResponse response) throws IOException {
117:                getServletContext().log(
118:                        "Attempt to call service method on ContextLoaderServlet as ["
119:                                + request.getRequestURI() + "] was ignored");
120:                response.sendError(HttpServletResponse.SC_BAD_REQUEST);
121:            }
122:
123:            public String getServletInfo() {
124:                return "ContextLoaderServlet for Servlet API 2.3 "
125:                        + "(deprecated in favor of ContextLoaderListener for Servlet API 2.4)";
126:            }
127:
128:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.