You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by ma...@apache.org on 2005/08/05 06:03:51 UTC
svn commit: r230390 - in /struts/sandbox/trunk/ti/src/java/org/apache/ti:
config/ config/mapper/ processor/ processor/chain/ servlet/
Author: martinc
Date: Thu Aug 4 21:03:46 2005
New Revision: 230390
URL: http://svn.apache.org/viewcvs?rev=230390&view=rev
Log:
Fix line ends.
Modified:
struts/sandbox/trunk/ti/src/java/org/apache/ti/config/ProcessTags.java
struts/sandbox/trunk/ti/src/java/org/apache/ti/config/ProcessTagsTask.java
struts/sandbox/trunk/ti/src/java/org/apache/ti/config/XDocletParser.java
struts/sandbox/trunk/ti/src/java/org/apache/ti/config/mapper/ActionMapper.java
struts/sandbox/trunk/ti/src/java/org/apache/ti/config/mapper/ActionMapping.java
struts/sandbox/trunk/ti/src/java/org/apache/ti/config/mapper/ServletActionMapper.java
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/BaseResult.java
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/ControllerAction.java
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/ControllerActionInvocation.java
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/SpringActionProxyFactory.java
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/SpringObjectFactory.java
struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/SpringConfigRuleSet.java
struts/sandbox/trunk/ti/src/java/org/apache/ti/servlet/ServletDispatcherResult.java
Modified: struts/sandbox/trunk/ti/src/java/org/apache/ti/config/ProcessTags.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/java/org/apache/ti/config/ProcessTags.java?rev=230390&r1=230389&r2=230390&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/src/java/org/apache/ti/config/ProcessTags.java (original)
+++ struts/sandbox/trunk/ti/src/java/org/apache/ti/config/ProcessTags.java Thu Aug 4 21:03:46 2005
@@ -15,66 +15,66 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.ti.config;
-
-import java.io.File;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Crawls a directory, processing all found Java source files.
- */
-public class ProcessTags {
-
- private XDocletParser xdocletParser;
-
- private static final Log log = LogFactory.getLog(ProcessTags.class);
- private static final String SEP = File.separator;
-
- public void setXDocletParser(XDocletParser parser) {
- this.xdocletParser = parser;
- }
-
- public void process(File src, String srcName, File dest, String destName) throws IOException {
- crawl(src, srcName, dest, destName, new ArrayList());
- }
-
- protected void crawl(File src, String srcName, File dest, String destName, List stack) throws IOException {
- File[] kids = src.listFiles();
- boolean controllerFound = false;
- for (int x=0; x<kids.length; x++) {
- if (kids[x].isDirectory()) {
- stack.add(kids[x].getName());
- crawl(kids[x], srcName, dest, destName, stack);
- stack.remove(stack.size() - 1);
- } else if (!controllerFound && srcName.equals(kids[x].getName())) {
- StringBuffer path = new StringBuffer();
- for (Iterator i = stack.iterator(); i.hasNext(); ) {
- path.append(i.next()).append(SEP);
- }
- File destDir = new File(dest, path.toString());
- destDir.mkdirs();
- File destFile = new File(destDir, destName);
- String filePath = path.toString() + kids[x].getName();
-
- log.info("Generating "+destFile);
- FileWriter writer = new FileWriter(destFile);
- try {
- xdocletParser.generate(filePath, new FileReader(kids[x]), writer);
- } finally {
- try {
- writer.close();
- } catch (IOException ex) {}
- }
- controllerFound = true;
- }
- }
- }
-}
+package org.apache.ti.config;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Crawls a directory, processing all found Java source files.
+ */
+public class ProcessTags {
+
+ private XDocletParser xdocletParser;
+
+ private static final Log log = LogFactory.getLog(ProcessTags.class);
+ private static final String SEP = File.separator;
+
+ public void setXDocletParser(XDocletParser parser) {
+ this.xdocletParser = parser;
+ }
+
+ public void process(File src, String srcName, File dest, String destName) throws IOException {
+ crawl(src, srcName, dest, destName, new ArrayList());
+ }
+
+ protected void crawl(File src, String srcName, File dest, String destName, List stack) throws IOException {
+ File[] kids = src.listFiles();
+ boolean controllerFound = false;
+ for (int x=0; x<kids.length; x++) {
+ if (kids[x].isDirectory()) {
+ stack.add(kids[x].getName());
+ crawl(kids[x], srcName, dest, destName, stack);
+ stack.remove(stack.size() - 1);
+ } else if (!controllerFound && srcName.equals(kids[x].getName())) {
+ StringBuffer path = new StringBuffer();
+ for (Iterator i = stack.iterator(); i.hasNext(); ) {
+ path.append(i.next()).append(SEP);
+ }
+ File destDir = new File(dest, path.toString());
+ destDir.mkdirs();
+ File destFile = new File(destDir, destName);
+ String filePath = path.toString() + kids[x].getName();
+
+ log.info("Generating "+destFile);
+ FileWriter writer = new FileWriter(destFile);
+ try {
+ xdocletParser.generate(filePath, new FileReader(kids[x]), writer);
+ } finally {
+ try {
+ writer.close();
+ } catch (IOException ex) {}
+ }
+ controllerFound = true;
+ }
+ }
+ }
+}
Modified: struts/sandbox/trunk/ti/src/java/org/apache/ti/config/ProcessTagsTask.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/java/org/apache/ti/config/ProcessTagsTask.java?rev=230390&r1=230389&r2=230390&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/src/java/org/apache/ti/config/ProcessTagsTask.java (original)
+++ struts/sandbox/trunk/ti/src/java/org/apache/ti/config/ProcessTagsTask.java Thu Aug 4 21:03:46 2005
@@ -15,43 +15,43 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.ti.config;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Ant task that wraps ProcessTags
- */
-public class ProcessTagsTask {
-
- private ProcessTags processTags;
- private File srcdir;
- private File destdir;
-
- private static final Log log = LogFactory.getLog(ProcessTagsTask.class);
-
- public void setSrcdir(File file) {
- this.srcdir = file;
- }
-
- public void setDestdir(File file) {
- this.destdir = file;
- }
-
- public void execute() {
- XDocletParser parser = new XDocletParser();
- parser.init();
- ProcessTags pt = new ProcessTags();
- pt.setXDocletParser(parser);
-
- try {
- pt.process(srcdir, "Controller.java", destdir, "xwork.xml");
- } catch (IOException ex) {
- ex.printStackTrace();
- }
- }
-}
+package org.apache.ti.config;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Ant task that wraps ProcessTags
+ */
+public class ProcessTagsTask {
+
+ private ProcessTags processTags;
+ private File srcdir;
+ private File destdir;
+
+ private static final Log log = LogFactory.getLog(ProcessTagsTask.class);
+
+ public void setSrcdir(File file) {
+ this.srcdir = file;
+ }
+
+ public void setDestdir(File file) {
+ this.destdir = file;
+ }
+
+ public void execute() {
+ XDocletParser parser = new XDocletParser();
+ parser.init();
+ ProcessTags pt = new ProcessTags();
+ pt.setXDocletParser(parser);
+
+ try {
+ pt.process(srcdir, "Controller.java", destdir, "xwork.xml");
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ }
+}
Modified: struts/sandbox/trunk/ti/src/java/org/apache/ti/config/XDocletParser.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/java/org/apache/ti/config/XDocletParser.java?rev=230390&r1=230389&r2=230390&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/src/java/org/apache/ti/config/XDocletParser.java (original)
+++ struts/sandbox/trunk/ti/src/java/org/apache/ti/config/XDocletParser.java Thu Aug 4 21:03:46 2005
@@ -15,88 +15,88 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.ti.config;
-
-import java.io.Reader;
-import java.io.Writer;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.velocity.Template;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.VelocityEngine;
-import org.apache.velocity.exception.ResourceNotFoundException;
-
-import xjavadoc.XClass;
-import xjavadoc.XJavaDoc;
-import xjavadoc.filesystem.ReaderFile;
-
-/**
- * Processes xdoclet-style tags and uses a velocity template to generate
- * content.
- */
-public class XDocletParser {
-
- private String templateName = "org/apache/ti/config/xdocletToXWork.vm";
- private Template template;
- private Map parameters;
- private static final Log log = LogFactory.getLog(XDocletParser.class);
-
- public void init() {
- VelocityEngine velocity = new VelocityEngine();
-
- Properties props = new Properties();
- try {
- props.load(getClass().getResourceAsStream("velocity.properties"));
- velocity.init(props);
- template = velocity.getTemplate(templateName);
- } catch (ResourceNotFoundException ex) {
- log.error("Unable to locate template to process javadoc tags", ex);
- }catch (Exception ex) {
- log.error("Unable to intialize velocity", ex);
- }
-
- }
-
- public void setParameters(Map map) {
- this.parameters = map;
- }
-
- public Map getParameters() {
- return parameters;
- }
-
- public void setTemplateName(String name) {
- this.templateName = name;
- }
-
- public void generate(String name, Reader reader, Writer writer) {
- XJavaDoc jdoc = new XJavaDoc();
- ReaderFile file = new ReaderFile(reader);
-
-
- String className = name.replace('/', '.');
- className = className.replace('\\', '.');
- className = className.substring(0, className.indexOf(".java"));
-
- jdoc.addAbstractFile(className, file);
- XClass xclass = jdoc.getXClass(className);
-
- Map contextMap = new HashMap();
- if (parameters != null) {
- contextMap.putAll(parameters);
- }
- VelocityContext context = new VelocityContext(contextMap);
- context.put("xclass", xclass);
- context.put("javaFile", name);
-
- try {
- template.merge(context, writer);
- } catch (Exception ex) {
- log.error("Unable to generate javadoc output", ex);
- }
- }
-}
+package org.apache.ti.config;
+
+import java.io.Reader;
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.exception.ResourceNotFoundException;
+
+import xjavadoc.XClass;
+import xjavadoc.XJavaDoc;
+import xjavadoc.filesystem.ReaderFile;
+
+/**
+ * Processes xdoclet-style tags and uses a velocity template to generate
+ * content.
+ */
+public class XDocletParser {
+
+ private String templateName = "org/apache/ti/config/xdocletToXWork.vm";
+ private Template template;
+ private Map parameters;
+ private static final Log log = LogFactory.getLog(XDocletParser.class);
+
+ public void init() {
+ VelocityEngine velocity = new VelocityEngine();
+
+ Properties props = new Properties();
+ try {
+ props.load(getClass().getResourceAsStream("velocity.properties"));
+ velocity.init(props);
+ template = velocity.getTemplate(templateName);
+ } catch (ResourceNotFoundException ex) {
+ log.error("Unable to locate template to process javadoc tags", ex);
+ }catch (Exception ex) {
+ log.error("Unable to intialize velocity", ex);
+ }
+
+ }
+
+ public void setParameters(Map map) {
+ this.parameters = map;
+ }
+
+ public Map getParameters() {
+ return parameters;
+ }
+
+ public void setTemplateName(String name) {
+ this.templateName = name;
+ }
+
+ public void generate(String name, Reader reader, Writer writer) {
+ XJavaDoc jdoc = new XJavaDoc();
+ ReaderFile file = new ReaderFile(reader);
+
+
+ String className = name.replace('/', '.');
+ className = className.replace('\\', '.');
+ className = className.substring(0, className.indexOf(".java"));
+
+ jdoc.addAbstractFile(className, file);
+ XClass xclass = jdoc.getXClass(className);
+
+ Map contextMap = new HashMap();
+ if (parameters != null) {
+ contextMap.putAll(parameters);
+ }
+ VelocityContext context = new VelocityContext(contextMap);
+ context.put("xclass", xclass);
+ context.put("javaFile", name);
+
+ try {
+ template.merge(context, writer);
+ } catch (Exception ex) {
+ log.error("Unable to generate javadoc output", ex);
+ }
+ }
+}
Modified: struts/sandbox/trunk/ti/src/java/org/apache/ti/config/mapper/ActionMapper.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/java/org/apache/ti/config/mapper/ActionMapper.java?rev=230390&r1=230389&r2=230390&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/src/java/org/apache/ti/config/mapper/ActionMapper.java (original)
+++ struts/sandbox/trunk/ti/src/java/org/apache/ti/config/mapper/ActionMapper.java Thu Aug 4 21:03:46 2005
@@ -15,15 +15,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.ti.config.mapper;
-
-import org.apache.commons.chain.web.WebContext;
-
-/**
- * Handles creation of ActionMapping and reconstruction of URI's from one
- */
-public interface ActionMapper {
- ActionMapping getMapping(WebContext ctx);
-
- String getUriFromActionMapping(ActionMapping mapping);
-}
+package org.apache.ti.config.mapper;
+
+import org.apache.commons.chain.web.WebContext;
+
+/**
+ * Handles creation of ActionMapping and reconstruction of URI's from one
+ */
+public interface ActionMapper {
+ ActionMapping getMapping(WebContext ctx);
+
+ String getUriFromActionMapping(ActionMapping mapping);
+}
Modified: struts/sandbox/trunk/ti/src/java/org/apache/ti/config/mapper/ActionMapping.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/java/org/apache/ti/config/mapper/ActionMapping.java?rev=230390&r1=230389&r2=230390&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/src/java/org/apache/ti/config/mapper/ActionMapping.java (original)
+++ struts/sandbox/trunk/ti/src/java/org/apache/ti/config/mapper/ActionMapping.java Thu Aug 4 21:03:46 2005
@@ -15,44 +15,44 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.ti.config.mapper;
-
-import java.util.Map;
-
-/**
- * Simple class that holds the action mapping information used to invoke an
- * action. The name and namespace are required, but the params map
- * is optional, and as such may be null. If a params map is supplied,
- * it <b>must</b> be a mutable map, such as a HashMap.
- *
- * @author Patrick Lightbody
- */
-public class ActionMapping {
- private String name;
- private String externalMapping;
- private String namespace;
- private Map params;
-
- public ActionMapping(String name, String namespace, String extMapping, Map params) {
- this.name = name;
- this.namespace = namespace;
- this.params = params;
- this.externalMapping = extMapping;
- }
-
- public String getName() {
- return name;
- }
-
- public String getNamespace() {
- return namespace;
- }
-
- public Map getParams() {
- return params;
- }
-
- public String getExternalMapping() {
- return externalMapping;
- }
-}
+package org.apache.ti.config.mapper;
+
+import java.util.Map;
+
+/**
+ * Simple class that holds the action mapping information used to invoke an
+ * action. The name and namespace are required, but the params map
+ * is optional, and as such may be null. If a params map is supplied,
+ * it <b>must</b> be a mutable map, such as a HashMap.
+ *
+ * @author Patrick Lightbody
+ */
+public class ActionMapping {
+ private String name;
+ private String externalMapping;
+ private String namespace;
+ private Map params;
+
+ public ActionMapping(String name, String namespace, String extMapping, Map params) {
+ this.name = name;
+ this.namespace = namespace;
+ this.params = params;
+ this.externalMapping = extMapping;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getNamespace() {
+ return namespace;
+ }
+
+ public Map getParams() {
+ return params;
+ }
+
+ public String getExternalMapping() {
+ return externalMapping;
+ }
+}
Modified: struts/sandbox/trunk/ti/src/java/org/apache/ti/config/mapper/ServletActionMapper.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/java/org/apache/ti/config/mapper/ServletActionMapper.java?rev=230390&r1=230389&r2=230390&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/src/java/org/apache/ti/config/mapper/ServletActionMapper.java (original)
+++ struts/sandbox/trunk/ti/src/java/org/apache/ti/config/mapper/ServletActionMapper.java Thu Aug 4 21:03:46 2005
@@ -15,94 +15,94 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.ti.config.mapper;
-
-import java.util.Iterator;
-import java.util.List;
-
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.commons.chain.web.WebContext;
-import org.apache.commons.chain.web.servlet.ServletWebContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.ti.servlet.StrutsTiServlet;
-
-/**
- * Handles creation of ActionMapping and reconstruction of URI's from one. Uses
- * original servlet mapping to determine action mapping and reconstructed uri.
- */
-public class ServletActionMapper implements ActionMapper {
-
- protected static final Log log = LogFactory.getLog(ServletActionMapper.class);
-
- public ActionMapping getMapping(WebContext ctx) {
-
- HttpServletRequest request = ((ServletWebContext)ctx).getRequest();
- List mappings = (List) ctx.get(StrutsTiServlet.SERVLET_MAPPINGS_KEY);
- String servletPath = request.getServletPath();
- return getMapping(servletPath, mappings);
- }
-
- protected ActionMapping getMapping(String servletPath, List mappings) {
- String uri = null;
- String mapping = null;
- for (Iterator i = mappings.iterator(); i.hasNext(); ) {
- mapping = (String)i.next();
-
- // Try to match prefix-based mapping
- if (mapping.charAt(mapping.length() - 1) == '*') {
- String prefix = mapping.substring(0, mapping.length() - 1);
- if (servletPath.startsWith(prefix)) {
- uri = servletPath.substring(prefix.length());
- log.debug("matched prefix:"+prefix);
- break;
- }
-
- // Try to match extension mapping
- } else if (mapping.charAt(0) == '*') {
- String ext = mapping.substring(1);
- if (servletPath.endsWith(ext)) {
- uri = servletPath.substring(1, (servletPath.length() - ext.length()));
- log.debug("matched ext:"+ext);
- break;
- }
- }
- }
-
- if (uri != null) {
- log.debug("uri:"+uri);
- int div = uri.lastIndexOf('/');
- String action = uri.substring(div + 1);
- String namespace = "";
- if (div > 0) {
- namespace = uri.substring(0, div);
- }
-
- return new ActionMapping(action, namespace, mapping, null);
- } else {
- // Couldn't find any action mapping
- return null;
- }
- }
-
- public String getUriFromActionMapping(ActionMapping mapping) {
-
- String ext = mapping.getExternalMapping();
- int star = ext.indexOf('*');
-
- StringBuffer sb = new StringBuffer();
- if (star > 0) {
- sb.append(ext.substring(0, star));
- } else {
- sb.append('/');
- }
- sb.append(mapping.getNamespace());
- sb.append('/');
- sb.append(mapping.getName());
- if (star < ext.length() - 1) {
- sb.append(ext.substring(star + 1));
- }
- return sb.toString();
- }
-}
+package org.apache.ti.config.mapper;
+
+import java.util.Iterator;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.chain.web.WebContext;
+import org.apache.commons.chain.web.servlet.ServletWebContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ti.servlet.StrutsTiServlet;
+
+/**
+ * Handles creation of ActionMapping and reconstruction of URI's from one. Uses
+ * original servlet mapping to determine action mapping and reconstructed uri.
+ */
+public class ServletActionMapper implements ActionMapper {
+
+ protected static final Log log = LogFactory.getLog(ServletActionMapper.class);
+
+ public ActionMapping getMapping(WebContext ctx) {
+
+ HttpServletRequest request = ((ServletWebContext)ctx).getRequest();
+ List mappings = (List) ctx.get(StrutsTiServlet.SERVLET_MAPPINGS_KEY);
+ String servletPath = request.getServletPath();
+ return getMapping(servletPath, mappings);
+ }
+
+ protected ActionMapping getMapping(String servletPath, List mappings) {
+ String uri = null;
+ String mapping = null;
+ for (Iterator i = mappings.iterator(); i.hasNext(); ) {
+ mapping = (String)i.next();
+
+ // Try to match prefix-based mapping
+ if (mapping.charAt(mapping.length() - 1) == '*') {
+ String prefix = mapping.substring(0, mapping.length() - 1);
+ if (servletPath.startsWith(prefix)) {
+ uri = servletPath.substring(prefix.length());
+ log.debug("matched prefix:"+prefix);
+ break;
+ }
+
+ // Try to match extension mapping
+ } else if (mapping.charAt(0) == '*') {
+ String ext = mapping.substring(1);
+ if (servletPath.endsWith(ext)) {
+ uri = servletPath.substring(1, (servletPath.length() - ext.length()));
+ log.debug("matched ext:"+ext);
+ break;
+ }
+ }
+ }
+
+ if (uri != null) {
+ log.debug("uri:"+uri);
+ int div = uri.lastIndexOf('/');
+ String action = uri.substring(div + 1);
+ String namespace = "";
+ if (div > 0) {
+ namespace = uri.substring(0, div);
+ }
+
+ return new ActionMapping(action, namespace, mapping, null);
+ } else {
+ // Couldn't find any action mapping
+ return null;
+ }
+ }
+
+ public String getUriFromActionMapping(ActionMapping mapping) {
+
+ String ext = mapping.getExternalMapping();
+ int star = ext.indexOf('*');
+
+ StringBuffer sb = new StringBuffer();
+ if (star > 0) {
+ sb.append(ext.substring(0, star));
+ } else {
+ sb.append('/');
+ }
+ sb.append(mapping.getNamespace());
+ sb.append('/');
+ sb.append(mapping.getName());
+ if (star < ext.length() - 1) {
+ sb.append(ext.substring(star + 1));
+ }
+ return sb.toString();
+ }
+}
Modified: struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/BaseResult.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/BaseResult.java?rev=230390&r1=230389&r2=230390&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/BaseResult.java (original)
+++ struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/BaseResult.java Thu Aug 4 21:03:46 2005
@@ -1,28 +1,28 @@
-/*
- * Copyright (c) 2002-2003 by OpenSymphony
- * All rights reserved.
- */
-package org.apache.ti.processor;
-
-import com.opensymphony.xwork.ActionInvocation;
-import com.opensymphony.xwork.Result;
-
-/**
- * Wraps a controller
- */
-public abstract class BaseResult implements Result {
-
- protected String location;
-
- public void setLocation(String loc) {
- this.location = loc;
- }
-
- public void execute(ActionInvocation invocation) throws Exception {
- // perform processing like evaluating location argument as expression
- doExecute(location, invocation);
- }
-
- protected abstract void doExecute(String path, ActionInvocation invocation) throws Exception;
-
-}
+/*
+ * Copyright (c) 2002-2003 by OpenSymphony
+ * All rights reserved.
+ */
+package org.apache.ti.processor;
+
+import com.opensymphony.xwork.ActionInvocation;
+import com.opensymphony.xwork.Result;
+
+/**
+ * Wraps a controller
+ */
+public abstract class BaseResult implements Result {
+
+ protected String location;
+
+ public void setLocation(String loc) {
+ this.location = loc;
+ }
+
+ public void execute(ActionInvocation invocation) throws Exception {
+ // perform processing like evaluating location argument as expression
+ doExecute(location, invocation);
+ }
+
+ protected abstract void doExecute(String path, ActionInvocation invocation) throws Exception;
+
+}
Modified: struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/ControllerAction.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/ControllerAction.java?rev=230390&r1=230389&r2=230390&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/ControllerAction.java (original)
+++ struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/ControllerAction.java Thu Aug 4 21:03:46 2005
@@ -1,40 +1,40 @@
-/*
- * Copyright (c) 2002-2003 by OpenSymphony
- * All rights reserved.
- */
-package org.apache.ti.processor;
-
-import com.opensymphony.xwork.Action;
-
-/**
- * Wraps a controller
- */
-public class ControllerAction implements Action {
-
- protected Object controller;
- protected Object form;
-
- public void setController(Object w) {
- this.controller = w;
- }
-
- public Object getController() {
- return controller;
- }
-
- public Object getForm() {
- return form;
- }
-
- public void setForm(Object obj) {
- this.form = obj;
- }
-
-
- public String execute() {
-
- // TODO
- return Action.SUCCESS;
- }
-
-}
+/*
+ * Copyright (c) 2002-2003 by OpenSymphony
+ * All rights reserved.
+ */
+package org.apache.ti.processor;
+
+import com.opensymphony.xwork.Action;
+
+/**
+ * Wraps a controller
+ */
+public class ControllerAction implements Action {
+
+ protected Object controller;
+ protected Object form;
+
+ public void setController(Object w) {
+ this.controller = w;
+ }
+
+ public Object getController() {
+ return controller;
+ }
+
+ public Object getForm() {
+ return form;
+ }
+
+ public void setForm(Object obj) {
+ this.form = obj;
+ }
+
+
+ public String execute() {
+
+ // TODO
+ return Action.SUCCESS;
+ }
+
+}
Modified: struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/ControllerActionInvocation.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/ControllerActionInvocation.java?rev=230390&r1=230389&r2=230390&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/ControllerActionInvocation.java (original)
+++ struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/ControllerActionInvocation.java Thu Aug 4 21:03:46 2005
@@ -1,129 +1,129 @@
-/*
- * Copyright (c) 2002-2003 by OpenSymphony
- * All rights reserved.
- */
-package org.apache.ti.processor;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.beans.factory.BeanFactory;
-
-import com.opensymphony.xwork.Action;
-import com.opensymphony.xwork.ActionProxy;
-import com.opensymphony.xwork.DefaultActionInvocation;
-import com.opensymphony.xwork.config.entities.ActionConfig;
-
-
-/**
- * Adds code to handle ControllerActions if detected
- *
- * @see com.opensymphony.xwork.DefaultActionInvocation
- */
-public class ControllerActionInvocation extends DefaultActionInvocation {
-
- private static final Log log = LogFactory.getLog(ControllerActionInvocation.class);
-
- protected static final Map methodsCache = Collections.synchronizedMap(new HashMap());
-
- protected BeanFactory beanFactory;
- protected ControllerAction ctrAction;
- protected Method actionMethod;
-
- protected ControllerActionInvocation(BeanFactory factory, ActionProxy proxy) throws Exception {
- this(factory, proxy, null);
- }
-
- protected ControllerActionInvocation(BeanFactory factory, ActionProxy proxy, Map extraContext) throws Exception {
- this(factory, proxy, extraContext, true);
- }
-
- protected ControllerActionInvocation(BeanFactory factory, ActionProxy proxy, Map extraContext, boolean pushAction) throws Exception {
- super(proxy, extraContext, pushAction);
- }
-
- protected Object getController() {
- return ((ControllerAction)action).getController();
- }
-
- public Method getActionMethod() {
- return actionMethod;
- }
-
- protected void createAction() {
- super.createAction();
-
- if (action instanceof ControllerAction) {
- ctrAction = (ControllerAction)action;
- createActionMethod();
- }
- }
-
- protected String invokeAction(Action action, ActionConfig actionConfig) throws Exception {
-
- if (action instanceof ControllerAction) {
- try {
- if (actionMethod.getParameterTypes().length == 1) {
- return (String) actionMethod.invoke(getController(), new Object[]{ctrAction.getForm()});
- } else {
- return (String) actionMethod.invoke(getController(), new Object[0]);
- }
- } catch (InvocationTargetException e) {
- // We try to return the source exception.
- Throwable t = e.getTargetException();
-
- if (t instanceof Exception) {
- throw (Exception) t;
- } else {
- throw e;
- }
- }
- // DO STUFF
- } else {
- return super.invokeAction(action, actionConfig);
- }
- }
-
-
- protected void createActionMethod() {
- //String methodName = proxy.getMethod();
-
- //if (methodName == null && actionConfig.getMethodName() == null) {
- // return null;
- //}
- //if (methodName == null) {
- // methodName = actionConfig.getMethodName();
- //}
- String methodName = getProxy().getConfig().getMethodName();
- Method method = null;
- Class ctrClass = getController().getClass();
-
-
-
- Method[] methods = (Method[])methodsCache.get(ctrClass);
- if (methods == null) {
- methods = ctrClass.getMethods();
- methodsCache.put(ctrClass, methods);
- }
-
- Method m;
- for (int x=0; x < methods.length; x++) {
- m = methods[x];
- if (m.getName().equals(methodName) && m.getParameterTypes().length < 2) {
- method = m;
- break;
- }
- }
-
- if (method == null) {
- throw new IllegalArgumentException("Method '" + methodName + "()' is not defined in controller '" + ctrClass + "'");
- }
-
- actionMethod = method;
- }
-}
+/*
+ * Copyright (c) 2002-2003 by OpenSymphony
+ * All rights reserved.
+ */
+package org.apache.ti.processor;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.BeanFactory;
+
+import com.opensymphony.xwork.Action;
+import com.opensymphony.xwork.ActionProxy;
+import com.opensymphony.xwork.DefaultActionInvocation;
+import com.opensymphony.xwork.config.entities.ActionConfig;
+
+
+/**
+ * Adds code to handle ControllerActions if detected
+ *
+ * @see com.opensymphony.xwork.DefaultActionInvocation
+ */
+public class ControllerActionInvocation extends DefaultActionInvocation {
+
+ private static final Log log = LogFactory.getLog(ControllerActionInvocation.class);
+
+ protected static final Map methodsCache = Collections.synchronizedMap(new HashMap());
+
+ protected BeanFactory beanFactory;
+ protected ControllerAction ctrAction;
+ protected Method actionMethod;
+
+ protected ControllerActionInvocation(BeanFactory factory, ActionProxy proxy) throws Exception {
+ this(factory, proxy, null);
+ }
+
+ protected ControllerActionInvocation(BeanFactory factory, ActionProxy proxy, Map extraContext) throws Exception {
+ this(factory, proxy, extraContext, true);
+ }
+
+ protected ControllerActionInvocation(BeanFactory factory, ActionProxy proxy, Map extraContext, boolean pushAction) throws Exception {
+ super(proxy, extraContext, pushAction);
+ }
+
+ protected Object getController() {
+ return ((ControllerAction)action).getController();
+ }
+
+ public Method getActionMethod() {
+ return actionMethod;
+ }
+
+ protected void createAction() {
+ super.createAction();
+
+ if (action instanceof ControllerAction) {
+ ctrAction = (ControllerAction)action;
+ createActionMethod();
+ }
+ }
+
+ protected String invokeAction(Action action, ActionConfig actionConfig) throws Exception {
+
+ if (action instanceof ControllerAction) {
+ try {
+ if (actionMethod.getParameterTypes().length == 1) {
+ return (String) actionMethod.invoke(getController(), new Object[]{ctrAction.getForm()});
+ } else {
+ return (String) actionMethod.invoke(getController(), new Object[0]);
+ }
+ } catch (InvocationTargetException e) {
+ // We try to return the source exception.
+ Throwable t = e.getTargetException();
+
+ if (t instanceof Exception) {
+ throw (Exception) t;
+ } else {
+ throw e;
+ }
+ }
+ // DO STUFF
+ } else {
+ return super.invokeAction(action, actionConfig);
+ }
+ }
+
+
+ protected void createActionMethod() {
+ //String methodName = proxy.getMethod();
+
+ //if (methodName == null && actionConfig.getMethodName() == null) {
+ // return null;
+ //}
+ //if (methodName == null) {
+ // methodName = actionConfig.getMethodName();
+ //}
+ String methodName = getProxy().getConfig().getMethodName();
+ Method method = null;
+ Class ctrClass = getController().getClass();
+
+
+
+ Method[] methods = (Method[])methodsCache.get(ctrClass);
+ if (methods == null) {
+ methods = ctrClass.getMethods();
+ methodsCache.put(ctrClass, methods);
+ }
+
+ Method m;
+ for (int x=0; x < methods.length; x++) {
+ m = methods[x];
+ if (m.getName().equals(methodName) && m.getParameterTypes().length < 2) {
+ method = m;
+ break;
+ }
+ }
+
+ if (method == null) {
+ throw new IllegalArgumentException("Method '" + methodName + "()' is not defined in controller '" + ctrClass + "'");
+ }
+
+ actionMethod = method;
+ }
+}
Modified: struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/SpringActionProxyFactory.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/SpringActionProxyFactory.java?rev=230390&r1=230389&r2=230390&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/SpringActionProxyFactory.java (original)
+++ struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/SpringActionProxyFactory.java Thu Aug 4 21:03:46 2005
@@ -1,42 +1,42 @@
-/*
- * Copyright (c) 2002-2003 by OpenSymphony
- * All rights reserved.
- */
-package org.apache.ti.processor;
-
-import java.util.Map;
-
-import org.springframework.beans.factory.BeanFactory;
-import org.springframework.beans.factory.BeanFactoryAware;
-
-import com.opensymphony.xwork.ActionInvocation;
-import com.opensymphony.xwork.ActionProxy;
-import com.opensymphony.xwork.DefaultActionProxyFactory;
-
-
-/**
- * Creates special action invocation instances that handle ControllerActions
- */
-public class SpringActionProxyFactory extends DefaultActionProxyFactory implements BeanFactoryAware {
-
- public static final String ACTION_INVOCATION = "actionInvocation";
-
- protected BeanFactory beanFactory;
-
- public void setBeanFactory(BeanFactory factory) {
- this.beanFactory = factory;
- }
-
- public ActionInvocation createActionInvocation(ActionProxy actionProxy) throws Exception {
- return new ControllerActionInvocation(beanFactory, actionProxy);
- }
-
- public ActionInvocation createActionInvocation(ActionProxy actionProxy, Map extraContext) throws Exception {
- return new ControllerActionInvocation(beanFactory, actionProxy, extraContext);
- }
-
- public ActionInvocation createActionInvocation(ActionProxy actionProxy, Map extraContext, boolean pushAction) throws Exception {
- return new ControllerActionInvocation(beanFactory, actionProxy, extraContext, pushAction);
- }
-
-}
+/*
+ * Copyright (c) 2002-2003 by OpenSymphony
+ * All rights reserved.
+ */
+package org.apache.ti.processor;
+
+import java.util.Map;
+
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.BeanFactoryAware;
+
+import com.opensymphony.xwork.ActionInvocation;
+import com.opensymphony.xwork.ActionProxy;
+import com.opensymphony.xwork.DefaultActionProxyFactory;
+
+
+/**
+ * Creates special action invocation instances that handle ControllerActions
+ */
+public class SpringActionProxyFactory extends DefaultActionProxyFactory implements BeanFactoryAware {
+
+ public static final String ACTION_INVOCATION = "actionInvocation";
+
+ protected BeanFactory beanFactory;
+
+ public void setBeanFactory(BeanFactory factory) {
+ this.beanFactory = factory;
+ }
+
+ public ActionInvocation createActionInvocation(ActionProxy actionProxy) throws Exception {
+ return new ControllerActionInvocation(beanFactory, actionProxy);
+ }
+
+ public ActionInvocation createActionInvocation(ActionProxy actionProxy, Map extraContext) throws Exception {
+ return new ControllerActionInvocation(beanFactory, actionProxy, extraContext);
+ }
+
+ public ActionInvocation createActionInvocation(ActionProxy actionProxy, Map extraContext, boolean pushAction) throws Exception {
+ return new ControllerActionInvocation(beanFactory, actionProxy, extraContext, pushAction);
+ }
+
+}
Modified: struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/SpringObjectFactory.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/SpringObjectFactory.java?rev=230390&r1=230389&r2=230390&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/SpringObjectFactory.java (original)
+++ struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/SpringObjectFactory.java Thu Aug 4 21:03:46 2005
@@ -1,43 +1,43 @@
-/*
- * Copyright (c) 2002-2003 by OpenSymphony
- * All rights reserved.
- */
-package org.apache.ti.processor;
-
-import org.springframework.beans.factory.BeanFactory;
-import org.springframework.beans.factory.BeanFactoryAware;
-
-import com.opensymphony.xwork.Action;
-import com.opensymphony.xwork.ObjectFactory;
-import com.opensymphony.xwork.config.entities.ActionConfig;
-
-
-/**
- * Builds actions from the config. If an Action is not created, it is assumed to be a Controller.
- */
-public class SpringObjectFactory extends ObjectFactory implements BeanFactoryAware {
-
- public static final String CONTROLLER_ACTION = "controllerAction";
-
- protected BeanFactory beanFactory;
-
- public void setBeanFactory(BeanFactory factory) {
- this.beanFactory = factory;
- }
-
- /**
- * Build an Action of the given type
- */
- public Action buildAction(ActionConfig config) throws Exception {
- Object obj = buildBean(config.getClassName());
- if (obj instanceof Action) {
- return (Action) obj;
- } else {
- ControllerAction action = (ControllerAction) beanFactory.getBean(CONTROLLER_ACTION);
- Object controller = buildBean(config.getClassName());
- action.setController(controller);
- return action;
- }
- }
-
-}
+/*
+ * Copyright (c) 2002-2003 by OpenSymphony
+ * All rights reserved.
+ */
+package org.apache.ti.processor;
+
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.BeanFactoryAware;
+
+import com.opensymphony.xwork.Action;
+import com.opensymphony.xwork.ObjectFactory;
+import com.opensymphony.xwork.config.entities.ActionConfig;
+
+
+/**
+ * Builds actions from the config. If an Action is not created, it is assumed to be a Controller.
+ */
+public class SpringObjectFactory extends ObjectFactory implements BeanFactoryAware {
+
+ public static final String CONTROLLER_ACTION = "controllerAction";
+
+ protected BeanFactory beanFactory;
+
+ public void setBeanFactory(BeanFactory factory) {
+ this.beanFactory = factory;
+ }
+
+ /**
+ * Build an Action of the given type
+ */
+ public Action buildAction(ActionConfig config) throws Exception {
+ Object obj = buildBean(config.getClassName());
+ if (obj instanceof Action) {
+ return (Action) obj;
+ } else {
+ ControllerAction action = (ControllerAction) beanFactory.getBean(CONTROLLER_ACTION);
+ Object controller = buildBean(config.getClassName());
+ action.setController(controller);
+ return action;
+ }
+ }
+
+}
Modified: struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/SpringConfigRuleSet.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/SpringConfigRuleSet.java?rev=230390&r1=230389&r2=230390&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/SpringConfigRuleSet.java (original)
+++ struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/SpringConfigRuleSet.java Thu Aug 4 21:03:46 2005
@@ -15,67 +15,67 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.ti.processor.chain;
-
-
-import java.util.List;
-
-import org.apache.commons.chain.config.ConfigRuleSet;
-import org.apache.commons.digester.Digester;
-import org.apache.commons.digester.ObjectCreateRule;
-import org.apache.commons.digester.Rule;
-import org.springframework.beans.factory.BeanFactory;
-import org.springframework.beans.factory.BeanFactoryAware;
-import org.xml.sax.Attributes;
-
-
-/**
- * Builds on commons-chain rule set to first try to locate the command name in
- * a bean factory before processing the command class name.
- */
-public class SpringConfigRuleSet extends ConfigRuleSet implements BeanFactoryAware {
-
- protected BeanFactory factory;
-
- public void setBeanFactory(BeanFactory factory) {
- this.factory = factory;
- }
-
- /**
- * <p>Add the set of Rule instances defined in this RuleSet to the
- * specified <code>Digester</code> instance, associating them with
- * our namespace URI (if any). This method should only be called
- * by a Digester instance.</p>
- *
- * @param digester Digester instance to which the new Rule instances
- * should be added.
- */
- public void addRuleInstances(Digester digester) {
-
- super.addRuleInstances(digester);
- String pattern = "*/" + getCommandElement();
-
- // Add rules for a command element
- Rule rule = new ObjectCreateRule(digester, null, getClassAttribute()) {
- public void begin(Attributes attrs) throws Exception {
- String name = attrs.getValue(getNameAttribute());
- System.out.println("looking up "+name);
- if (name != null) {
- if (factory.containsBean(name)) {
- getDigester().push(factory.getBean(name));
- } else {
- super.begin(attrs);
- }
- } else {
- throw new IllegalArgumentException("Unable to locate class name");
- }
- }
- };
- rule.setDigester(digester);
-
- List list = digester.getRules().match(null, pattern);
- list.set(0, rule);
- }
-
-
-}
+package org.apache.ti.processor.chain;
+
+
+import java.util.List;
+
+import org.apache.commons.chain.config.ConfigRuleSet;
+import org.apache.commons.digester.Digester;
+import org.apache.commons.digester.ObjectCreateRule;
+import org.apache.commons.digester.Rule;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.BeanFactoryAware;
+import org.xml.sax.Attributes;
+
+
+/**
+ * Builds on commons-chain rule set to first try to locate the command name in
+ * a bean factory before processing the command class name.
+ */
+public class SpringConfigRuleSet extends ConfigRuleSet implements BeanFactoryAware {
+
+ protected BeanFactory factory;
+
+ public void setBeanFactory(BeanFactory factory) {
+ this.factory = factory;
+ }
+
+ /**
+ * <p>Add the set of Rule instances defined in this RuleSet to the
+ * specified <code>Digester</code> instance, associating them with
+ * our namespace URI (if any). This method should only be called
+ * by a Digester instance.</p>
+ *
+ * @param digester Digester instance to which the new Rule instances
+ * should be added.
+ */
+ public void addRuleInstances(Digester digester) {
+
+ super.addRuleInstances(digester);
+ String pattern = "*/" + getCommandElement();
+
+ // Add rules for a command element
+ Rule rule = new ObjectCreateRule(digester, null, getClassAttribute()) {
+ public void begin(Attributes attrs) throws Exception {
+ String name = attrs.getValue(getNameAttribute());
+ System.out.println("looking up "+name);
+ if (name != null) {
+ if (factory.containsBean(name)) {
+ getDigester().push(factory.getBean(name));
+ } else {
+ super.begin(attrs);
+ }
+ } else {
+ throw new IllegalArgumentException("Unable to locate class name");
+ }
+ }
+ };
+ rule.setDigester(digester);
+
+ List list = digester.getRules().match(null, pattern);
+ list.set(0, rule);
+ }
+
+
+}
Modified: struts/sandbox/trunk/ti/src/java/org/apache/ti/servlet/ServletDispatcherResult.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/java/org/apache/ti/servlet/ServletDispatcherResult.java?rev=230390&r1=230389&r2=230390&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/src/java/org/apache/ti/servlet/ServletDispatcherResult.java (original)
+++ struts/sandbox/trunk/ti/src/java/org/apache/ti/servlet/ServletDispatcherResult.java Thu Aug 4 21:03:46 2005
@@ -1,90 +1,90 @@
-/*
- * Copyright (c) 2002-2003 by OpenSymphony
- * All rights reserved.
- */
-package org.apache.ti.servlet;
-
-import javax.servlet.RequestDispatcher;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.chain.web.servlet.ServletWebContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.ti.processor.BaseResult;
-import org.apache.ti.processor.ControllerContext;
-
-import com.opensymphony.xwork.ActionInvocation;
-
-/**
- * Includes or forwards a view. There are three possible ways the result can be executed: <ul>
- * <p/>
- * <li>If we are in the scope of a JSP (a PageContext is available), PageContext's
- * {@link PageContext#include(String) include} method is called.</li>
- * <p/>
- * <li>If there is no PageContext and we're not in any sort of include (there is no
- * "javax.servlet.include.servlet_path" in the request attributes), then a call to
- * {@link RequestDispatcher#forward(javax.servlet.ServletRequest, javax.servlet.ServletResponse) forward}
- * is made.</li>
- * <p/>
- * <li>Otherwise, {@link RequestDispatcher#include(javax.servlet.ServletRequest, javax.servlet.ServletResponse) include}
- * is called.</li></ul>
- * <p/>
- * This result follows the same rules from {@link WebWorkResultSupport}.
- *
- * @author Patrick Lightbody
- * @see javax.servlet.RequestDispatcher
- */
-public class ServletDispatcherResult extends BaseResult {
- //~ Static fields/initializers /////////////////////////////////////////////
-
- private static final Log log = LogFactory.getLog(ServletDispatcherResult.class);
-
- //~ Methods ////////////////////////////////////////////////////////////////
-
- /**
- * Dispatches to the given location. Does its forward via a RequestDispatcher. If the
- * dispatch fails a 404 error will be sent back in the http response.
- *
- * @param finalLocation the location to dispatch to.
- * @param invocation the execution state of the action
- * @throws Exception if an error occurs. If the dispatch fails the error will go back via the
- * HTTP request.
- */
- public void doExecute(String finalLocation, ActionInvocation invocation) throws Exception {
- if (log.isDebugEnabled()) {
- log.debug("Forwarding to location " + finalLocation);
- }
-
- ServletWebContext ctx = (ServletWebContext) ControllerContext.getContext().getWebContext();
-
- //PageContext pageContext = ServletActionContext.getPageContext();
-
- //if (pageContext != null) {
- // pageContext.include(finalLocation);
- //} else {
- HttpServletRequest request = ctx.getRequest();
- HttpServletResponse response = ctx.getResponse();
- RequestDispatcher dispatcher = request.getRequestDispatcher(finalLocation);
-
- // if the view doesn't exist, let's do a 404
- if (dispatcher == null) {
- response.sendError(404, "result '" + finalLocation + "' not found");
-
- return;
- }
-
- // If we're included, then include the view
- // Otherwise do forward
- // This allow the page to, for example, set content type
- if (!response.isCommitted() && (request.getAttribute("javax.servlet.include.servlet_path") == null)) {
- request.setAttribute("ti.view_uri", finalLocation);
- request.setAttribute("ti.request_uri", request.getRequestURI());
-
- dispatcher.forward(request, response);
- } else {
- dispatcher.include(request, response);
- }
- //}
- }
-}
+/*
+ * Copyright (c) 2002-2003 by OpenSymphony
+ * All rights reserved.
+ */
+package org.apache.ti.servlet;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.chain.web.servlet.ServletWebContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ti.processor.BaseResult;
+import org.apache.ti.processor.ControllerContext;
+
+import com.opensymphony.xwork.ActionInvocation;
+
+/**
+ * Includes or forwards a view. There are three possible ways the result can be executed: <ul>
+ * <p/>
+ * <li>If we are in the scope of a JSP (a PageContext is available), PageContext's
+ * {@link PageContext#include(String) include} method is called.</li>
+ * <p/>
+ * <li>If there is no PageContext and we're not in any sort of include (there is no
+ * "javax.servlet.include.servlet_path" in the request attributes), then a call to
+ * {@link RequestDispatcher#forward(javax.servlet.ServletRequest, javax.servlet.ServletResponse) forward}
+ * is made.</li>
+ * <p/>
+ * <li>Otherwise, {@link RequestDispatcher#include(javax.servlet.ServletRequest, javax.servlet.ServletResponse) include}
+ * is called.</li></ul>
+ * <p/>
+ * This result follows the same rules from {@link WebWorkResultSupport}.
+ *
+ * @author Patrick Lightbody
+ * @see javax.servlet.RequestDispatcher
+ */
+public class ServletDispatcherResult extends BaseResult {
+ //~ Static fields/initializers /////////////////////////////////////////////
+
+ private static final Log log = LogFactory.getLog(ServletDispatcherResult.class);
+
+ //~ Methods ////////////////////////////////////////////////////////////////
+
+ /**
+ * Dispatches to the given location. Does its forward via a RequestDispatcher. If the
+ * dispatch fails a 404 error will be sent back in the http response.
+ *
+ * @param finalLocation the location to dispatch to.
+ * @param invocation the execution state of the action
+ * @throws Exception if an error occurs. If the dispatch fails the error will go back via the
+ * HTTP request.
+ */
+ public void doExecute(String finalLocation, ActionInvocation invocation) throws Exception {
+ if (log.isDebugEnabled()) {
+ log.debug("Forwarding to location " + finalLocation);
+ }
+
+ ServletWebContext ctx = (ServletWebContext) ControllerContext.getContext().getWebContext();
+
+ //PageContext pageContext = ServletActionContext.getPageContext();
+
+ //if (pageContext != null) {
+ // pageContext.include(finalLocation);
+ //} else {
+ HttpServletRequest request = ctx.getRequest();
+ HttpServletResponse response = ctx.getResponse();
+ RequestDispatcher dispatcher = request.getRequestDispatcher(finalLocation);
+
+ // if the view doesn't exist, let's do a 404
+ if (dispatcher == null) {
+ response.sendError(404, "result '" + finalLocation + "' not found");
+
+ return;
+ }
+
+ // If we're included, then include the view
+ // Otherwise do forward
+ // This allow the page to, for example, set content type
+ if (!response.isCommitted() && (request.getAttribute("javax.servlet.include.servlet_path") == null)) {
+ request.setAttribute("ti.view_uri", finalLocation);
+ request.setAttribute("ti.request_uri", request.getRequestURI());
+
+ dispatcher.forward(request, response);
+ } else {
+ dispatcher.include(request, response);
+ }
+ //}
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org