Source Code Cross Referenced for ComponentControllerSupport.java in  » J2EE » spring-framework-2.0.6 » org » springframework » web » servlet » view » tiles » 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.servlet.view.tiles 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2002-2005 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.servlet.view.tiles;
018:
019:        import java.io.File;
020:        import java.io.IOException;
021:
022:        import javax.servlet.ServletContext;
023:        import javax.servlet.ServletException;
024:        import javax.servlet.http.HttpServletRequest;
025:        import javax.servlet.http.HttpServletResponse;
026:
027:        import org.apache.struts.tiles.ComponentContext;
028:        import org.apache.struts.tiles.ControllerSupport;
029:
030:        import org.springframework.beans.BeansException;
031:        import org.springframework.context.ApplicationContext;
032:        import org.springframework.context.support.MessageSourceAccessor;
033:        import org.springframework.web.context.WebApplicationContext;
034:        import org.springframework.web.servlet.support.RequestContextUtils;
035:        import org.springframework.web.util.NestedServletException;
036:        import org.springframework.web.util.WebUtils;
037:
038:        /**
039:         * Convenience class for Spring-aware Tiles component controllers.
040:         * Provides a reference to the current Spring application context,
041:         * e.g. for bean lookup or resource loading.
042:         *
043:         * <p>Derives from Tiles' ControllerSupport class rather than
044:         * implementing Tiles' Controller interface to be compatible with
045:         * Struts 1.1 and 1.2. Implements both Struts 1.1's <code>perform</code>
046:         * and Struts 1.2's <code>execute</code> method accordingly.
047:         *
048:         * @author Juergen Hoeller
049:         * @author Alef Arendsen
050:         * @since 22.08.2003
051:         * @see org.springframework.web.context.support.WebApplicationObjectSupport
052:         */
053:        public abstract class ComponentControllerSupport extends
054:                ControllerSupport {
055:
056:            private WebApplicationContext webApplicationContext;
057:
058:            private MessageSourceAccessor messageSourceAccessor;
059:
060:            /**
061:             * This implementation delegates to <code>execute</code>,
062:             * converting non-Servlet/IO Exceptions to ServletException.
063:             * <p>This is the only execution method available in Struts 1.1.
064:             * @see #execute
065:             */
066:            public final void perform(ComponentContext componentContext,
067:                    HttpServletRequest request, HttpServletResponse response,
068:                    ServletContext servletContext) throws ServletException,
069:                    IOException {
070:
071:                try {
072:                    execute(componentContext, request, response, servletContext);
073:                } catch (ServletException ex) {
074:                    throw ex;
075:                } catch (IOException ex) {
076:                    throw ex;
077:                } catch (Throwable ex) {
078:                    throw new NestedServletException(
079:                            "Execution of component controller failed", ex);
080:                }
081:            }
082:
083:            /**
084:             * This implementation delegates to <code>doPerform</code>,
085:             * lazy-initializing the application context reference if necessary.
086:             * <p>This is the preferred execution method in Struts 1.2.
087:             * When running with Struts 1.1, it will be called by <code>perform</code>.
088:             * @see #perform
089:             * @see #doPerform
090:             */
091:            public final void execute(ComponentContext componentContext,
092:                    HttpServletRequest request, HttpServletResponse response,
093:                    ServletContext servletContext) throws Exception {
094:
095:                synchronized (this ) {
096:                    if (this .webApplicationContext == null) {
097:                        this .webApplicationContext = RequestContextUtils
098:                                .getWebApplicationContext(request,
099:                                        servletContext);
100:                        this .messageSourceAccessor = new MessageSourceAccessor(
101:                                this .webApplicationContext);
102:                    }
103:                }
104:                doPerform(componentContext, request, response);
105:            }
106:
107:            /**
108:             * Subclasses can override this for custom initialization behavior.
109:             * Gets called on initialization of the context for this controller.
110:             * @throws org.springframework.context.ApplicationContextException in case of initialization errors
111:             * @throws org.springframework.beans.BeansException if thrown by application context methods
112:             */
113:            protected void initApplicationContext() throws BeansException {
114:            }
115:
116:            /**
117:             * Return the current Spring ApplicationContext.
118:             */
119:            protected final ApplicationContext getApplicationContext() {
120:                return this .webApplicationContext;
121:            }
122:
123:            /**
124:             * Return the current Spring WebApplicationContext.
125:             */
126:            protected final WebApplicationContext getWebApplicationContext() {
127:                return this .webApplicationContext;
128:            }
129:
130:            /**
131:             * Return a MessageSourceAccessor for the application context
132:             * used by this object, for easy message access.
133:             */
134:            protected final MessageSourceAccessor getMessageSourceAccessor() {
135:                return this .messageSourceAccessor;
136:            }
137:
138:            /**
139:             * Return the current ServletContext.
140:             */
141:            protected final ServletContext getServletContext() {
142:                return this .webApplicationContext.getServletContext();
143:            }
144:
145:            /**
146:             * Return the temporary directory for the current web application,
147:             * as provided by the servlet container.
148:             * @return the File representing the temporary directory
149:             */
150:            protected final File getTempDir() {
151:                return WebUtils.getTempDir(getServletContext());
152:            }
153:
154:            /**
155:             * Perform the preparation for the component, allowing for any Exception to be thrown.
156:             * The ServletContext can be retrieved via getServletContext, if necessary.
157:             * The Spring WebApplicationContext can be accessed via getWebApplicationContext.
158:             * <p>This method will be called both in the Struts 1.1 and Struts 1.2 case,
159:             * by <code>perform</code> or <code>execute</code>, respectively.
160:             * @param componentContext current Tiles component context
161:             * @param request current HTTP request
162:             * @param response current HTTP response
163:             * @throws Exception in case of errors
164:             * @see org.apache.struts.tiles.Controller#perform
165:             * @see #getServletContext
166:             * @see #getWebApplicationContext
167:             * @see #perform
168:             * @see #execute
169:             */
170:            protected abstract void doPerform(
171:                    ComponentContext componentContext,
172:                    HttpServletRequest request, HttpServletResponse response)
173:                    throws Exception;
174:
175:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.