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


001:        /*
002:         * Copyright (c) 2002-2006 by OpenSymphony
003:         * All rights reserved.
004:         */
005:        package com.opensymphony.xwork.interceptor;
006:
007:        import com.opensymphony.xwork.ActionInvocation;
008:
009:        import java.io.Serializable;
010:
011:        /**
012:         * <!-- START SNIPPET: introduction -->
013:         * 
014:         * An interceptor is a stateless class that follows the interceptor pattern, as
015:         * found in {@link  javax.servlet.Filter} and in AOP languages.
016:         * 
017:         * <p/>
018:         * 
019:         * Interceptors are objects that dynamically intercept Action invocations. 
020:         * They provide the developer with the opportunity to define code that can be executed 
021:         * before and/or after the execution of an action. They also have the ability 
022:         * to prevent an action from executing. Interceptors provide developers a way to 
023:         * encapulate common functionality in a re-usable form that can be applied to 
024:         * one or more Actions.
025:         * 
026:         * <p/>
027:         * 
028:         * Interceptors <b>must</b> be stateless and not assume that a new instance will be created for each request or Action.
029:         * Interceptors may choose to either short-circuit the {@link ActionInvocation} execution and return a return code
030:         * (such as {@link com.opensymphony.xwork.Action#SUCCESS}), or it may choose to do some processing before
031:         * and/or after delegating the rest of the procesing using {@link ActionInvocation#invoke()}.
032:         * 
033:         * <!-- END SNIPPET: introduction -->
034:         * 
035:         * <p/>
036:         * 
037:         * <!-- START SNIPPET: parameterOverriding -->
038:         * 
039:         * Interceptor's parameter could be overriden through the following ways :-
040:         * 
041:         * <p/>
042:         * 
043:         * <b>Method 1:</b>
044:         * <pre>
045:         * &lt;action name="myAction" class="myActionClass"&gt;
046:         *   &lt;interceptor-ref name="exception"/&gt;
047:         *     &lt;interceptor-ref name="alias"/&gt;
048:         *     &lt;interceptor-ref name="params"/&gt;
049:         *     &lt;interceptor-ref name="servlet-config"/&gt;
050:         *     &lt;interceptor-ref name="prepare"/&gt;
051:         *     &lt;interceptor-ref name="i18n"/&gt;
052:         *     &lt;interceptor-ref name="chain"/&gt;
053:         *     &lt;interceptor-ref name="model-driven"/&gt;
054:         *     &lt;interceptor-ref name="fileUpload"/&gt;
055:         *     &lt;interceptor-ref name="static-params"/&gt;
056:         *     &lt;interceptor-ref name="params"/&gt;
057:         *     &lt;interceptor-ref name="conversionError"/&gt;
058:         *     &lt;interceptor-ref name="validation"&gt;
059:         *       &lt;param name="excludeMethods"&gt;myValidationExcudeMethod&lt;/param&gt;
060:         *     &lt;/interceptor-ref&gt;
061:         *     &lt;interceptor-ref name="workflow"&gt;
062:         *       &lt;param name="excludeMethods"&gt;myWorkflowExcludeMethod&lt;/param&gt;
063:         *     &lt;/interceptor-ref&gt;
064:         * &lt;/action&gt;
065:         * </pre>
066:         * 
067:         * <b>Method 2:</b>
068:         * <pre>
069:         * &lt;action name="myAction" class="myActionClass"&gt;
070:         *   &lt;interceptor-ref name="defaultStack"&gt;
071:         *     &lt;param name="validation.excludeMethods"&gt;myValidationExcludeMethod&lt;/param&gt;
072:         *     &lt;param name="workflow.excludeMethods"&gt;myWorkflowExcludeMethod&lt;/param&gt;
073:         *   &lt;/interceptor-ref&gt;
074:         * &lt;/action&gt;
075:         * </pre>
076:         * 
077:         * <p/>
078:         * 
079:         * In the first method, the whole default stack is copied and the parameter then 
080:         * changed accordingly.
081:         * 
082:         * <p/>
083:         * 
084:         * In the second method, the <interceptor-ref .../> refer to an existing 
085:         * interceptor-stack, namely default-stack in this example, and override the validator
086:         * and workflow interceptor excludeMethods typically in this case. Note that in the
087:         * <param ... /> tag, the name attribute contains a dot (.) the word before the dot(.)
088:         * specifies the interceptor name whose parameter is to be overriden and the word after
089:         * the dot (.) specifies the parameter itself. Essetially it is as follows :-
090:         * 
091:         * <pre>
092:         *    &lt;interceptor-name&gt;.&lt;parameter-name&gt;
093:         * </pre>
094:         * 
095:         * <b>Note</b> also that in this case the <interceptor-ref ... > name attribute 
096:         * is used to indicate an interceptor stack which makes sense as if it is refering 
097:         * to the interceptor itself it would be just using Method 1 describe above.
098:         * 
099:         * <!-- END SNIPPET: parameterOverriding -->
100:         * 
101:         * <p/>
102:         * <b>Nested Interceptor param overriding</b>
103:         * <p/>
104:         * <!-- START SNIPPET: nestedParameterOverriding -->
105:         * 
106:         *  Interceptor stack parameter overriding could be nested into as many level as possible, though it would
107:         *  be advisable not to nest it too deep as to avoid confusion, For example, 
108:         * <pre>
109:         * &lt;interceptor name="interceptor1" class="foo.bar.Interceptor1" /&gt;
110:         * &lt;interceptor name="interceptor2" class="foo.bar.Interceptor2" /&gt;
111:         * &lt;interceptor name="interceptor3" class="foo.bar.Interceptor3" /&gt;
112:         * &lt;interceptor name="interceptor4" class="foo.bar.Interceptor4" /&gt;
113:         * &lt;interceptor-stack name="stack1"&gt;
114:         *     &lt;interceptor-ref name="interceptor1" /&gt;
115:         * &lt;/interceptor-stack&gt;
116:         * &lt;interceptor-stack name="stack2"&gt;
117:         *     &lt;interceptor-ref name="intercetor2" /&gt;
118:         *     &lt;interceptor-ref name="stack1" /&gt;
119:         * &lt;/interceptor-stack&gt;
120:         * &lt;interceptor-stack name="stack3"&gt;
121:         *     &lt;interceptor-ref name="interceptor3" /&gt;
122:         *     &lt;interceptor-ref name="stack2" /&gt;
123:         * &lt;/interceptor-stack&gt;
124:         * &lt;interceptor-stack name="stack4"&gt;
125:         *     &lt;interceptor-ref name="interceptor4" /&gt;
126:         *     &lt;interceptor-ref name="stack3" /&gt;
127:         *  &lt;/interceptor-stack&gt;
128:         * </pre>
129:         *  Assuming the interceptor has the following properties
130:         *  <table border="1" width="100%">
131:         *    <tr>
132:         *       <td>Interceptor</td>
133:         *       <td>property</td>
134:         *    </tr>
135:         *    <tr>	
136:         *    	   <td>Interceptor1</td>
137:         *        <td>param1</td>
138:         *    </tr>
139:         *    <tr>	
140:         *    	   <td>Interceptor2</td>
141:         *        <td>param2</td>
142:         *    </tr>
143:         *    <tr>	
144:         *    	   <td>Interceptor3</td>
145:         *        <td>param3</td>
146:         *    </tr>
147:         *    <tr>	
148:         *    	   <td>Interceptor4</td>
149:         *        <td>param4</td>
150:         *    </tr>
151:         *  </table>
152:         *  We could override them as follows :-
153:         *  <pre>
154:         *    &lt;action ... &gt;
155:         *        &lt;!-- to override parameters of interceptor located directly in the stack  --&gt;
156:         *        &lt;interceptor-ref name="stack4"&gt;
157:         *           &lt;param name="interceptor4.param4"&gt; ... &lt;/param&gt;
158:         *        &lt;/interceptor-ref&gt;
159:         *    &lt;/action&gt;
160:         *    &lt;action ... &gt;
161:         *        &lt;!-- to override parameters of interceptor located under nested stack --&gt;
162:         *        &lt;interceptor-ref name="stack4"&gt;
163:         *            &lt;param name="stack3.interceptor3.param3"&gt; ... &lt;/param&gt;
164:         *            &lt;param name="stack3.stack2.interceptor2.param2"&gt; ... &lt;/param&gt;
165:         *            &lt;param name="stack3.stack2.stack1.interceptor1.param1"&gt; ... &lt;/param&gt;
166:         *        &lt;/interceptor-ref&gt;
167:         *    &lt;/action&gt;
168:         *  </pre>
169:         * 
170:         * <!-- END SNIPPET: nestedParameterOverriding -->
171:         * 
172:         * 
173:         * @author Jason Carreira
174:         * @author tmjee
175:         * @version $Date: 2007-05-28 20:23:15 +0200 (Mon, 28 May 2007) $ $Id: Interceptor.java 1525 2007-05-28 18:23:15Z tm_jee $
176:         */
177:        public interface Interceptor extends Serializable {
178:
179:            /**
180:             * Called to let an interceptor clean up any resources it has allocated.
181:             */
182:            void destroy();
183:
184:            /**
185:             * Called after an interceptor is created, but before any requests are processed using
186:             * {@link #intercept(com.opensymphony.xwork.ActionInvocation) intercept} , giving
187:             * the Interceptor a chance to initialize any needed resources.
188:             */
189:            void init();
190:
191:            /**
192:             * Allows the Interceptor to do some processing on the request before and/or after the rest of the processing of the
193:             * request by the {@link ActionInvocation} or to short-circuit the processing and just return a String return code.
194:             *
195:             * @return the return code, either returned from {@link ActionInvocation#invoke()}, or from the interceptor itself.
196:             * @throws Exception any system-level error, as defined in {@link com.opensymphony.xwork.Action#execute()}.
197:             */
198:            String intercept(ActionInvocation invocation) throws Exception;
199:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.