Source Code Cross Referenced for ExecuteCommand.java in  » Web-Framework » struts-1.3.8 » org » apache » struts » chain » commands » 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 » Web Framework » struts 1.3.8 » org.apache.struts.chain.commands 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: ExecuteCommand.java 471754 2006-11-06 14:55:09Z husted $
003:         *
004:         * Licensed to the Apache Software Foundation (ASF) under one
005:         * or more contributor license agreements.  See the NOTICE file
006:         * distributed with this work for additional information
007:         * regarding copyright ownership.  The ASF licenses this file
008:         * to you under the Apache License, Version 2.0 (the
009:         * "License"); you may not use this file except in compliance
010:         * with the License.  You may obtain a copy of the License at
011:         *
012:         *  http://www.apache.org/licenses/LICENSE-2.0
013:         *
014:         * Unless required by applicable law or agreed to in writing,
015:         * software distributed under the License is distributed on an
016:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017:         * KIND, either express or implied.  See the License for the
018:         * specific language governing permissions and limitations
019:         * under the License.
020:         */
021:        package org.apache.struts.chain.commands;
022:
023:        import org.apache.commons.chain.Catalog;
024:        import org.apache.commons.chain.CatalogFactory;
025:        import org.apache.commons.chain.Command;
026:        import org.apache.commons.logging.Log;
027:        import org.apache.commons.logging.LogFactory;
028:        import org.apache.struts.chain.contexts.ActionContext;
029:        import org.apache.struts.config.ActionConfig;
030:
031:        /**
032:         * <p>Invoke the appropriate <code>Command</code> for this request.  If the
033:         * context's <code>ActionConfig</code> has no <code>command</code> property
034:         * defined, no action will be taken.  If the specified command cannot be
035:         * found, a warning will be logged, but processing will continue.  Depending
036:         * on how the chain is configured, this can be used in place of an
037:         * <code>Action</code> or as a method of performing pre-processing. </p>
038:         *
039:         * <p>If used instead of an action, the command which is looked up should put
040:         * an ActionForward into the context, unless it has already dealt with the
041:         * response.</p>
042:         *
043:         * @version $Id: ExecuteCommand.java 471754 2006-11-06 14:55:09Z husted $
044:         */
045:        public class ExecuteCommand extends ActionCommandBase {
046:            // ------------------------------------------------------ Instance Variables
047:
048:            /**
049:             * Provide Commons Logging instance for this class.
050:             */
051:            private static final Log LOG = LogFactory
052:                    .getLog(ExecuteCommand.class);
053:
054:            // ---------------------------------------------------------- Public Methods
055:
056:            /**
057:             * <p>If the <code>context</code> is "valid", lookup a command and execute
058:             * it.</p>
059:             *
060:             * @param actionCtx The <code>Context</code> for the current request
061:             * @return the result of the lookup command's <code>execute</code> method,
062:             *         if executed, or <code>false</code> if it was not executed.
063:             * @throws Exception on any error
064:             */
065:            public boolean execute(ActionContext actionCtx) throws Exception {
066:                if (shouldProcess(actionCtx)) {
067:                    Command command = getCommand(actionCtx);
068:
069:                    if (command != null) {
070:                        return (command.execute(actionCtx));
071:                    }
072:                }
073:
074:                return (false);
075:            }
076:
077:            /**
078:             * <p>Evaluate the current context to see if a command should even be
079:             * executed.</p>
080:             *
081:             * @param context A valid ActionContext
082:             * @return TRUE if the pending Command should be executed
083:             */
084:            protected boolean shouldProcess(ActionContext context) {
085:                // Skip processing if the current request is not valid
086:                Boolean valid = context.getFormValid();
087:
088:                return ((valid != null) && valid.booleanValue());
089:            }
090:
091:            /**
092:             * <p>Find the <code>ActionConfig</code> in the current context and, if it
093:             * is properly configured, lookup the appropriate <code>commons-chain</code>
094:             * command.</p>
095:             *
096:             * @param context A valid ActionContext
097:             * @return a <code>Command</code> to execute, or null if none is specified
098:             *         or if the specified command cannot be found.
099:             */
100:            protected Command getCommand(ActionContext context) {
101:                ActionConfig actionConfig = context.getActionConfig();
102:
103:                String commandName = actionConfig.getCommand();
104:
105:                if (commandName == null) {
106:                    return null;
107:                }
108:
109:                String catalogName = actionConfig.getCatalog();
110:
111:                return getCommand(commandName, catalogName);
112:            }
113:
114:            /**
115:             * <p> Retrieve the specified Command from the specified Catalog. </p>
116:             *
117:             * @param commandName The Command to retrieve.
118:             * @param catalogName The Catalog to search.
119:             * @return Instantiated Command, or null
120:             */
121:            protected Command getCommand(String commandName, String catalogName) {
122:                if (commandName == null) {
123:                    return null;
124:                }
125:
126:                Catalog catalog;
127:
128:                if (catalogName != null) {
129:                    catalog = CatalogFactory.getInstance().getCatalog(
130:                            catalogName);
131:
132:                    if (catalog == null) {
133:                        LOG.warn("When looking up " + commandName + ","
134:                                + " no catalog found under " + catalogName);
135:
136:                        return null;
137:                    }
138:                } else {
139:                    catalogName = "the default catalog";
140:                    catalog = CatalogFactory.getInstance().getCatalog();
141:
142:                    if (catalog == null) {
143:                        LOG.warn("When looking up " + commandName + ","
144:                                + " no default catalog found.");
145:
146:                        return null;
147:                    }
148:                }
149:
150:                if (LOG.isDebugEnabled()) {
151:                    LOG.debug("looking up command " + commandName + " in "
152:                            + catalogName);
153:                }
154:
155:                return catalog.getCommand(commandName);
156:            }
157:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.