Source Code Cross Referenced for DwrJaxerServlet.java in  » Ajax » dwr » org » directwebremoting » jaxer » servlet » 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 » Ajax » dwr » org.directwebremoting.jaxer.servlet 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005 Joe Walker
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:        package org.directwebremoting.jaxer.servlet;
017:
018:        import java.io.IOException;
019:
020:        import javax.servlet.ServletConfig;
021:        import javax.servlet.ServletContext;
022:        import javax.servlet.ServletException;
023:        import javax.servlet.http.HttpServlet;
024:        import javax.servlet.http.HttpServletRequest;
025:        import javax.servlet.http.HttpServletResponse;
026:
027:        import org.apache.commons.logging.Log;
028:        import org.apache.commons.logging.LogFactory;
029:        import org.directwebremoting.WebContextFactory.WebContextBuilder;
030:        import org.directwebremoting.extend.DwrConstants;
031:        import org.directwebremoting.extend.ServerLoadMonitor;
032:        import org.directwebremoting.impl.ContainerUtil;
033:        import org.directwebremoting.impl.DwrXmlConfigurator;
034:        import org.directwebremoting.impl.StartupUtil;
035:        import org.directwebremoting.jaxer.impl.JaxerContainer;
036:        import org.directwebremoting.servlet.UrlProcessor;
037:
038:        /**
039:         * This is the main servlet for the DWR/Jaxer integration.
040:         * It handles all the requests to DWR from the Jaxer server. Currently this
041:         * communication looks just like normal DWR, however as this project evolves
042:         * it is likely that some of the processing done by {@link UrlProcessor} will
043:         * be superseded by a protocol that takes advantage of a single connection.
044:         * @author Joe Walker [joe at getahead dot ltd dot uk]
045:         * @noinspection RefusedBequest
046:         */
047:        public class DwrJaxerServlet extends HttpServlet {
048:            /* (non-Javadoc)
049:             * @see javax.servlet.GenericServlet#init(javax.servlet.ServletConfig)
050:             */
051:            @Override
052:            public void init(ServletConfig servletConfig)
053:                    throws ServletException {
054:                super .init(servletConfig);
055:                ServletContext servletContext = servletConfig
056:                        .getServletContext();
057:
058:                try {
059:                    ContainerUtil.resolveContainerAbstraction(container,
060:                            servletConfig);
061:                    container.setupFinished();
062:
063:                    StartupUtil.initContainerBeans(servletConfig,
064:                            servletContext, container);
065:                    webContextBuilder = container
066:                            .getBean(WebContextBuilder.class);
067:
068:                    ContainerUtil.prepareForWebContextFilter(servletContext,
069:                            servletConfig, container, webContextBuilder, this );
070:
071:                    DwrXmlConfigurator system = new DwrXmlConfigurator();
072:                    system.setClassResourceName(DwrConstants.FILE_DWR_XML);
073:                    system.configure(container);
074:
075:                    DwrXmlConfigurator custom = new DwrXmlConfigurator();
076:                    custom
077:                            .setClassResourceName("/org/directwebremoting/jaxer/dwr.xml");
078:                    custom.configure(container);
079:
080:                    ContainerUtil.publishContainer(container, servletConfig);
081:                } catch (ExceptionInInitializerError ex) {
082:                    log.fatal("ExceptionInInitializerError. Nested exception:",
083:                            ex.getException());
084:                    throw new ServletException(ex);
085:                } catch (Exception ex) {
086:                    log.fatal("DwrServlet.init() failed", ex);
087:                    throw new ServletException(ex);
088:                } finally {
089:                    if (webContextBuilder != null) {
090:                        webContextBuilder.unset();
091:                    }
092:                }
093:            }
094:
095:            /* (non-Javadoc)
096:             * @see javax.servlet.GenericServlet#destroy()
097:             */
098:            @Override
099:            public void destroy() {
100:                shutdown();
101:                super .destroy();
102:            }
103:
104:            /**
105:             * Kill all comet polls.
106:             * <p>Technically a servlet engine ought to call this only when all the
107:             * threads are already removed, however at least Tomcat doesn't do this
108:             * properly (it waits for a while and then calls destroy anyway).
109:             * <p>It would be good if we could get {@link #destroy()} to call this
110:             * method however destroy() is only called once all threads are done so it's
111:             * too late.
112:             */
113:            public void shutdown() {
114:                ServerLoadMonitor monitor = container
115:                        .getBean(ServerLoadMonitor.class);
116:                monitor.shutdown();
117:            }
118:
119:            /* (non-Javadoc)
120:             * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
121:             */
122:            @Override
123:            protected void doGet(HttpServletRequest req,
124:                    HttpServletResponse resp) throws IOException,
125:                    ServletException {
126:                doPost(req, resp);
127:            }
128:
129:            /* (non-Javadoc)
130:             * @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
131:             */
132:            @Override
133:            protected void doPost(HttpServletRequest request,
134:                    HttpServletResponse response) throws IOException,
135:                    ServletException {
136:                try {
137:                    webContextBuilder.set(request, response,
138:                            getServletConfig(), getServletContext(), container);
139:
140:                    UrlProcessor processor = container
141:                            .getBean(UrlProcessor.class);
142:                    processor.handle(request, response);
143:                } finally {
144:                    webContextBuilder.unset();
145:                }
146:            }
147:
148:            /**
149:             * Our IoC container
150:             */
151:            private JaxerContainer container = new JaxerContainer();
152:
153:            /**
154:             * The WebContext that keeps http objects local to a thread
155:             */
156:            private WebContextBuilder webContextBuilder = null;
157:
158:            /**
159:             * The log stream
160:             */
161:            private static final Log log = LogFactory
162:                    .getLog(DwrJaxerServlet.class);
163:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.