Source Code Cross Referenced for ServletConfigInterceptor.java in  » J2EE » webwork-2.2.6 » com » opensymphony » webwork » interceptor » 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 » webwork 2.2.6 » com.opensymphony.webwork.interceptor 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2002-2003 by OpenSymphony
003:         * All rights reserved.
004:         */
005:        package com.opensymphony.webwork.interceptor;
006:
007:        import com.opensymphony.webwork.WebWorkStatics;
008:        import com.opensymphony.webwork.util.ServletContextAware;
009:        import com.opensymphony.xwork.ActionContext;
010:        import com.opensymphony.xwork.ActionInvocation;
011:        import com.opensymphony.xwork.interceptor.AroundInterceptor;
012:
013:        import javax.servlet.http.HttpServletRequest;
014:        import javax.servlet.http.HttpServletResponse;
015:        import javax.servlet.ServletContext;
016:
017:        /**
018:         * <!-- START SNIPPET: description -->
019:         *
020:         * An interceptor which sets action properties based on the interfaces an action implements. For example, if the action
021:         * implements {@link ParameterAware} then the action context's parameter map will be set on it.
022:         *
023:         * <p/> This interceptor is designed to set all properties an action needs if it's aware of servlet parameters, the
024:         * servlet context, the session, etc. Interfaces that it supports are:
025:         *
026:         * <ul>
027:         *
028:         * <li>{@link ServletContextAware}</li>
029:         *
030:         * <li>{@link ServletRequestAware}</li>
031:         *
032:         * <li>{@link ServletResponseAware}</li>
033:         *
034:         * <li>{@link ParameterAware}</li>
035:         *
036:         * <li>{@link SessionAware}</li>
037:         *
038:         * <li>{@link ApplicationAware}</li>
039:         *
040:         * <li>{@link PrincipalAware}</li>
041:         *
042:         * </ul>
043:         *
044:         * <!-- END SNIPPET: description -->
045:         *
046:         * <p/> <u>Interceptor parameters:</u>
047:         *
048:         * <!-- START SNIPPET: parameters -->
049:         *
050:         * <ul>
051:         *
052:         * <li>None</li>
053:         *
054:         * </ul>
055:         *
056:         * <!-- END SNIPPET: parameters -->
057:         *
058:         * <p/> <u>Extending the interceptor:</u>
059:         *
060:         * <p/>
061:         *
062:         * <!-- START SNIPPET: extending -->
063:         *
064:         * There are no known extension points for this interceptor.
065:         *
066:         * <!-- END SNIPPET: extending -->
067:         *
068:         * <p/> <u>Example code:</u>
069:         *
070:         * <pre>
071:         * <!-- START SNIPPET: example -->
072:         * &lt;action name="someAction" class="com.examples.SomeAction"&gt;
073:         *     &lt;interceptor-ref name="servlet-config"/&gt;
074:         *     &lt;interceptor-ref name="basicStack"/&gt;
075:         *     &lt;result name="success"&gt;good_result.ftl&lt;/result&gt;
076:         * &lt;/action&gt;
077:         * <!-- END SNIPPET: example -->
078:         * </pre>
079:         *
080:         * @author Patrick Lightbody
081:         * @author Bill Lynch (docs)
082:         * @see ServletContextAware
083:         * @see ServletRequestAware
084:         * @see ServletResponseAware
085:         * @see ParameterAware
086:         * @see SessionAware
087:         * @see ApplicationAware
088:         * @see PrincipalAware
089:         */
090:        public class ServletConfigInterceptor extends AroundInterceptor
091:                implements  WebWorkStatics {
092:
093:            private static final long serialVersionUID = -1226074297258786788L;
094:
095:            protected void after(ActionInvocation dispatcher, String result)
096:                    throws Exception {
097:            }
098:
099:            /**
100:             * Sets action properties based on the interfaces an action implements. Things like application properties,
101:             * parameters, session attributes, etc are set based on the implementing interface.
102:             *
103:             * @param invocation an encapsulation of the action execution state.
104:             * @throws Exception if an error occurs when setting action properties.
105:             */
106:            protected void before(ActionInvocation invocation) throws Exception {
107:                final Object action = invocation.getAction();
108:                final ActionContext context = invocation.getInvocationContext();
109:
110:                if (action instanceof  ServletRequestAware) {
111:                    HttpServletRequest request = (HttpServletRequest) context
112:                            .get(HTTP_REQUEST);
113:                    ((ServletRequestAware) action).setServletRequest(request);
114:                }
115:
116:                if (action instanceof  ServletResponseAware) {
117:                    HttpServletResponse response = (HttpServletResponse) context
118:                            .get(HTTP_RESPONSE);
119:                    ((ServletResponseAware) action)
120:                            .setServletResponse(response);
121:                }
122:
123:                if (action instanceof  ParameterAware) {
124:                    ((ParameterAware) action).setParameters(context
125:                            .getParameters());
126:                }
127:
128:                if (action instanceof  SessionAware) {
129:                    ((SessionAware) action).setSession(context.getSession());
130:                }
131:
132:                if (action instanceof  ApplicationAware) {
133:                    ((ApplicationAware) action).setApplication(context
134:                            .getApplication());
135:                }
136:
137:                if (action instanceof  PrincipalAware) {
138:                    HttpServletRequest request = (HttpServletRequest) context
139:                            .get(HTTP_REQUEST);
140:                    ((PrincipalAware) action)
141:                            .setPrincipalProxy(new PrincipalProxy(request));
142:                }
143:                if (action instanceof  ServletContextAware) {
144:                    ServletContext servletContext = (ServletContext) context
145:                            .get(SERVLET_CONTEXT);
146:                    ((ServletContextAware) action)
147:                            .setServletContext(servletContext);
148:                }
149:            }
150:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.