Source Code Cross Referenced for ChainingInterceptor.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:        import com.opensymphony.xwork.Unchainable;
009:        import com.opensymphony.xwork.util.CompoundRoot;
010:        import com.opensymphony.xwork.util.OgnlUtil;
011:        import com.opensymphony.xwork.util.OgnlValueStack;
012:
013:        import java.util.*;
014:
015:        import org.apache.commons.logging.Log;
016:        import org.apache.commons.logging.LogFactory;
017:
018:        /**
019:         * <!-- START SNIPPET: description -->
020:         *
021:         * An interceptor that copies all the properties of every object in the value stack to the currently executing object,
022:         * except for any object that implements {@link Unchainable}. A collection of optional <i>includes</i> and
023:         * <i>excludes</i> may be provided to control how and which parameters are copied. Only includes or excludes may be
024:         * specified. Specifying both results in undefined behavior. See the javadocs for {@link OgnlUtil#copy(Object, Object,
025:         * java.util.Map, java.util.Collection, java.util.Collection)} for more information.
026:         *
027:         * <p/> It is important to remember that this interceptor does nothing if there are no objects already on the stack.
028:         * This means two things: One, you can safely apply it to all your actions without any worry of adverse affects. Two, it
029:         * is up to you to ensure an object exists in the stack prior to invoking this action. The most typical way this is done
030:         * is through the use of the <b>chain</b> result type, which combines with this interceptor to make up the action
031:         * chaining feature.
032:         *
033:         * <!-- END SNIPPET: description -->
034:         *
035:         * <p/> <u>Interceptor parameters:</u>
036:         *
037:         * <!-- START SNIPPET: parameters -->
038:         *
039:         * <ul>
040:         *
041:         * <li>excludes (optional) - the list of parameter names to exclude from copying (all others will be included).</li>
042:         *
043:         * <li>includes (optional) - the list of parameter names to include when copying (all others will be excluded).</li>
044:         *
045:         * </ul>
046:         *
047:         * <!-- END SNIPPET: parameters -->
048:         *
049:         * <p/> <u>Extending the interceptor:</u>
050:         *
051:         * <p/>
052:         *
053:         * <!-- START SNIPPET: extending -->
054:         *
055:         * There are no known extension points to this interceptor.
056:         *
057:         * <!-- END SNIPPET: extending -->
058:         *
059:         * <p/> <u>Example code:</u>
060:         *
061:         * <pre>
062:         * <!-- START SNIPPET: example -->
063:         * 
064:         * &lt;action name="someAction" class="com.examples.SomeAction"&gt;
065:         *     &lt;interceptor-ref name="basicStack"/&gt;
066:         *     &lt;result name="success" type="chain"&gt;otherAction&lt;/result&gt;
067:         * &lt;/action&gt;
068:         *
069:         * &lt;action name="otherAction" class="com.examples.OtherAction"&gt;
070:         *     &lt;interceptor-ref name="chain"/&gt;
071:         *     &lt;interceptor-ref name="basicStack"/&gt;
072:         *     &lt;result name="success"&gt;good_result.ftl&lt;/result&gt;
073:         * &lt;/action&gt;
074:         * 
075:         * <!-- END SNIPPET: example -->
076:         * </pre>
077:         *
078:         * @author $Author: rainerh $
079:         * @author tm_jee ( tm_jee(at)yahoo.co.uk )
080:         * @version $Revision: 860 $
081:         */
082:        public class ChainingInterceptor extends AroundInterceptor {
083:
084:            private static final Log _log = LogFactory
085:                    .getLog(ChainingInterceptor.class);
086:
087:            Collection excludes;
088:            Collection includes;
089:
090:            protected void after(ActionInvocation invocation, String result)
091:                    throws Exception {
092:            }
093:
094:            protected void before(ActionInvocation invocation) throws Exception {
095:                OgnlValueStack stack = invocation.getStack();
096:                CompoundRoot root = stack.getRoot();
097:
098:                if (root.size() > 1) {
099:                    List list = new ArrayList(root);
100:                    list.remove(0);
101:                    Collections.reverse(list);
102:
103:                    Map ctxMap = invocation.getInvocationContext()
104:                            .getContextMap();
105:                    Iterator iterator = list.iterator();
106:                    int index = 1; // starts with 1, 0 has been removed
107:                    while (iterator.hasNext()) {
108:                        index = index + 1;
109:                        Object o = iterator.next();
110:                        if (o != null) {
111:                            if (!(o instanceof  Unchainable)) {
112:                                OgnlUtil.copy(o, invocation.getAction(),
113:                                        ctxMap, excludes, includes);
114:                            }
115:                        } else {
116:                            _log.warn("compound root element at index " + index
117:                                    + " is null");
118:                        }
119:                    }
120:                }
121:            }
122:
123:            public Collection getExcludes() {
124:                return excludes;
125:            }
126:
127:            public void setExcludes(Collection excludes) {
128:                this .excludes = excludes;
129:            }
130:
131:            public Collection getIncludes() {
132:                return includes;
133:            }
134:
135:            public void setIncludes(Collection includes) {
136:                this.includes = includes;
137:            }
138:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.