Source Code Cross Referenced for PrepareInterceptor.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 org.apache.commons.logging.Log;
008:        import org.apache.commons.logging.LogFactory;
009:
010:        import com.opensymphony.xwork.ActionInvocation;
011:        import com.opensymphony.xwork.Preparable;
012:
013:        /**
014:         * <!-- START SNIPPET: description -->
015:         *
016:         * This interceptor calls prepare() on actions which implement {@link Preparable}. This interceptor is very useful for
017:         * any situation where you need to ensure some logic runs before the actual execute method runs.
018:         *
019:         * <p/> A typical use of this is to run some logic to load an object from the database so that when parameters are set
020:         * they can be set on this object. For example, suppose you have a User object with two properties: <i>id</i> and
021:         * <i>name</i>. Provided that the params interceptor is called twice (once before and once after this interceptor), you
022:         * can load the User object using the id property, and then when the second params interceptor is called the parameter
023:         * <i>user.name</i> will be set, as desired, on the actual object loaded from the database. See the example for more
024:         * info.
025:         *
026:         * <!-- END SNIPPET: description -->
027:         *
028:         * <p/> <u>Interceptor parameters:</u>
029:         *
030:         * <!-- START SNIPPET: parameters -->
031:         *
032:         * <ul>
033:         *
034:         * <li>None</li>
035:         *
036:         * </ul>
037:         *
038:         * <!-- END SNIPPET: parameters -->
039:         *
040:         * <p/> <u>Extending the interceptor:</u>
041:         *
042:         * <p/>
043:         *
044:         * <!-- START SNIPPET: extending -->
045:         *
046:         * There are no known extension points to this interceptor.
047:         *
048:         * <!-- END SNIPPET: extending -->
049:         *
050:         * <p/> <u>Example code:</u>
051:         *
052:         * <pre>
053:         * <!-- START SNIPPET: example -->
054:         * &lt;!-- Calls the params interceptor twice, allowing you to
055:         *      pre-load data for the second time parameters are set --&gt;
056:         * &lt;action name="someAction" class="com.examples.SomeAction"&gt;
057:         *     &lt;interceptor-ref name="params"/&gt;
058:         *     &lt;interceptor-ref name="prepare"/&gt;
059:         *     &lt;interceptor-ref name="basicStack"/&gt;
060:         *     &lt;result name="success"&gt;good_result.ftl&lt;/result&gt;
061:         * &lt;/action&gt;
062:         * <!-- END SNIPPET: example -->
063:         * </pre>
064:         *
065:         * Date: Nov 5, 2003 2:33:11 AM
066:         *
067:         * @author Jason Carreira
068:         * @author Philip Luppens
069:         * @author tm_jee
070:         * @see com.opensymphony.xwork.Preparable
071:         */
072:        public class PrepareInterceptor extends AroundInterceptor {
073:
074:            private static final long serialVersionUID = -7182584510651751135L;
075:
076:            private static final Log _log = LogFactory
077:                    .getLog(PrepareInterceptor.class);
078:
079:            private final static String PREPARE_PREFIX = "prepare";
080:            private final static String ALT_PREPARE_PREFIX = "prepareDo";
081:
082:            private boolean alwaysInvokePrepare = true;
083:
084:            public void setAlwaysInvokePrepare(String alwaysInvokePrepare) {
085:                this .alwaysInvokePrepare = Boolean.valueOf(alwaysInvokePrepare)
086:                        .booleanValue();
087:            }
088:
089:            protected void after(ActionInvocation dispatcher, String result)
090:                    throws Exception {
091:
092:            }
093:
094:            protected void before(ActionInvocation invocation) throws Exception {
095:                Object action = invocation.getAction();
096:
097:                if (action instanceof  Preparable) {
098:                    try {
099:                        PrefixMethodInvocationUtil.invokePrefixMethod(
100:                                invocation, new String[] { PREPARE_PREFIX,
101:                                        ALT_PREPARE_PREFIX });
102:                    } catch (Exception e) {
103:                        // just in case there's an exception while doing reflection, 
104:                        // we still want prepare() to be able to get called.
105:                        _log
106:                                .warn(
107:                                        "an exception occured while trying to execute prefixed method",
108:                                        e);
109:                    }
110:                    if (alwaysInvokePrepare) {
111:                        ((Preparable) action).prepare();
112:                    }
113:                }
114:            }
115:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.