You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by mr...@apache.org on 2005/08/02 20:57:11 UTC

svn commit: r227065 [2/2] - in /struts/sandbox/trunk/ti: ./ src/ src/example/ src/example/WEB-INF/ src/example/WEB-INF/src/ src/example/WEB-INF/src/java/ src/example/WEB-INF/src/java/ttt/ src/java/ src/java/org/ src/java/org/apache/ src/java/org/apache...

Added: struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/ExecuteAction.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/ExecuteAction.java?rev=227065&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/ExecuteAction.java (added)
+++ struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/ExecuteAction.java Tue Aug  2 11:57:06 2005
@@ -0,0 +1,43 @@
+/*
+ * $Id: ServletRequestHandler.java 170184 2005-05-14 23:54:24Z martinc $
+ *
+ * Copyright 2000-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ti.processor.chain;
+
+import org.apache.commons.chain.web.*;
+import org.apache.commons.chain.*;
+import org.apache.ti.config.mapper.*;
+import com.opensymphony.xwork.*;
+
+
+/**
+ *  Initializes XWork by replacing default factories
+ */
+public class ExecuteAction implements Command {
+    
+    public boolean execute(Context origctx) throws Exception {
+        ActionContext ctx = ActionContext.getContext();
+        ActionProxy proxy = ctx.getActionInvocation().getProxy();
+        
+        String ret = proxy.execute();
+    
+        origctx.put("result", ret);
+        return false;
+    }
+    
+    
+}

Propchange: struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/ExecuteAction.java
------------------------------------------------------------------------------
    svn:executable = *

Added: struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/InitControllerContext.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/InitControllerContext.java?rev=227065&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/InitControllerContext.java (added)
+++ struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/InitControllerContext.java Tue Aug  2 11:57:06 2005
@@ -0,0 +1,45 @@
+/*
+ * $Id: ServletRequestHandler.java 170184 2005-05-14 23:54:24Z martinc $
+ *
+ * Copyright 2000-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ti.processor.chain;
+
+import org.apache.commons.chain.web.*;
+import org.apache.commons.chain.*;
+import org.apache.commons.logging.*;
+import org.apache.ti.config.mapper.*;
+import org.apache.ti.processor.*;
+import com.opensymphony.xwork.*;
+
+
+/**
+ *  Intializes the ControllerContext for this request
+ */
+public class InitControllerContext implements Command {
+    
+    protected ControllerContext context;
+    protected static final Log log = LogFactory.getLog(InitControllerContext.class);
+   
+    public void setControllerContext(ControllerContext ctx) {
+        this.context = ctx;
+    }
+    
+    public boolean execute(Context origctx) {
+        ControllerContext.setControllerContext(context);
+        return false;
+    }
+}

Propchange: struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/InitControllerContext.java
------------------------------------------------------------------------------
    svn:executable = *

Added: struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/InitXWork.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/InitXWork.java?rev=227065&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/InitXWork.java (added)
+++ struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/InitXWork.java Tue Aug  2 11:57:06 2005
@@ -0,0 +1,53 @@
+/*
+ * $Id: ServletRequestHandler.java 170184 2005-05-14 23:54:24Z martinc $
+ *
+ * Copyright 2000-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ti.processor.chain;
+
+import org.apache.commons.chain.web.*;
+import org.apache.commons.chain.*;
+import org.apache.ti.config.mapper.*;
+import com.opensymphony.xwork.*;
+
+
+/**
+ *  Initializes XWork by replacing default factories
+ */
+public class InitXWork implements Command {
+    
+    protected ObjectFactory objectFactory;
+    protected ActionProxyFactory actionProxyFactory;
+    
+    public void setObjectFactory(ObjectFactory factory) {
+        this.objectFactory = factory;
+    }
+    
+    public void setActionProxyFactory(ActionProxyFactory factory) {
+        this.actionProxyFactory = factory;
+    }
+    
+    public boolean execute(Context origctx) {
+        WebContext ctx = (WebContext)origctx;
+    
+        ObjectFactory.setObjectFactory(objectFactory);
+        ActionProxyFactory.setFactory(actionProxyFactory);
+    
+        return false;
+    }
+    
+    
+}

Propchange: struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/InitXWork.java
------------------------------------------------------------------------------
    svn:executable = *

Added: struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/ProcessActionChain.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/ProcessActionChain.java?rev=227065&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/ProcessActionChain.java (added)
+++ struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/ProcessActionChain.java Tue Aug  2 11:57:06 2005
@@ -0,0 +1,53 @@
+/*
+ * $Id: ServletRequestHandler.java 170184 2005-05-14 23:54:24Z martinc $
+ *
+ * Copyright 2000-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ti.processor.chain;
+
+import org.apache.commons.chain.web.*;
+import org.apache.commons.chain.*;
+import org.apache.commons.chain.impl.*;
+import org.apache.ti.config.mapper.*;
+import com.opensymphony.xwork.*;
+
+
+
+/**
+ *  Initializes XWork by replacing default factories
+ */
+public class ProcessActionChain extends ChainBase {
+    
+    public boolean execute(Context context) throws Exception {
+        
+        ActionContext nestedContext = ActionContext.getContext();
+        
+        ActionProxy proxy = (ActionProxy) context.get("actionProxy");
+        ActionContext.setContext(proxy.getInvocation().getInvocationContext());
+
+        boolean retCode = false;
+
+        try {
+            retCode = super.execute(context);
+        } finally {
+            ActionContext.setContext(nestedContext);
+        }
+
+        return retCode;
+    }
+    
+    
+}

Propchange: struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/ProcessActionChain.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 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=227065&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/SpringConfigRuleSet.java (added)
+++ struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/SpringConfigRuleSet.java Tue Aug  2 11:57:06 2005
@@ -0,0 +1,75 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ti.processor.chain;
+
+
+import org.apache.commons.digester.*;
+import org.apache.commons.chain.config.*;
+import org.springframework.beans.factory.*;
+import org.xml.sax.Attributes;
+import java.util.*;
+
+
+/**
+ *  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);
+    }
+
+
+}

Propchange: struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/SpringConfigRuleSet.java
------------------------------------------------------------------------------
    svn:executable = *

Added: struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/chain-config-servlet.xml
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/chain-config-servlet.xml?rev=227065&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/chain-config-servlet.xml (added)
+++ struts/sandbox/trunk/ti/src/java/org/apache/ti/processor/chain/chain-config-servlet.xml Tue Aug  2 11:57:06 2005
@@ -0,0 +1,60 @@
+<?xml version="1.0" ?>
+
+
+<!--
+
+ Copyright 2002,2004 The Apache Software Foundation.
+ 
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+ 
+      http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+
+
+<!--
+    This file contains definitions of the standard Chain Of Responsibility
+    chains.
+
+    $Id: chain-config.xml 191314 2005-06-19 00:27:26Z mrdon $
+-->
+
+
+<catalog name="struts-ti">
+
+    <define name= "lookup"
+            className= "org.apache.commons.chain.generic.LookupCommand" />
+            
+            
+    <!-- ========== Start of chain ========================= -->
+
+    <chain     name="start" >
+      <command name="createActionMapping"  />
+      <command name="initXWork" />
+      <command name="createActionProxy" className="org.apache.ti.processor.chain.CreateActionProxy" />
+      <lookup
+        catalogName="struts-ti"
+               name="process-action"
+           optional="false"/>
+    </chain>
+    
+    <!-- ========== Initialization chain ========================= -->
+
+    <chain     name="init" >
+    </chain>
+    
+    <chain     name="process-action" className="org.apache.ti.processor.chain.ProcessActionChain">
+      <command name="initControllerContext"  />
+      <command name="executeAction" className="org.apache.ti.processor.chain.ExecuteAction" />
+    </chain>
+    
+
+</catalog>

Added: 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=227065&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/src/java/org/apache/ti/servlet/ServletDispatcherResult.java (added)
+++ struts/sandbox/trunk/ti/src/java/org/apache/ti/servlet/ServletDispatcherResult.java Tue Aug  2 11:57:06 2005
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2002-2003 by OpenSymphony
+ * All rights reserved.
+ */
+package org.apache.ti.servlet;
+
+import com.opensymphony.xwork.*;
+import org.apache.ti.processor.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.chain.*;
+import org.apache.commons.chain.web.*;
+import org.apache.commons.chain.web.servlet.*;
+
+/**
+ * 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);
+            }
+        //}
+    }
+}

Propchange: struts/sandbox/trunk/ti/src/java/org/apache/ti/servlet/ServletDispatcherResult.java
------------------------------------------------------------------------------
    svn:executable = *

Added: struts/sandbox/trunk/ti/src/java/org/apache/ti/servlet/StrutsTiServlet.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/java/org/apache/ti/servlet/StrutsTiServlet.java?rev=227065&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/src/java/org/apache/ti/servlet/StrutsTiServlet.java (added)
+++ struts/sandbox/trunk/ti/src/java/org/apache/ti/servlet/StrutsTiServlet.java Tue Aug  2 11:57:06 2005
@@ -0,0 +1,258 @@
+/*
+ * $Id: StrutsTiServlet.java 170184 2005-05-14 23:54:24Z martinc $
+ *
+ * Copyright 2000-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ti.servlet;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.*;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.MissingResourceException;
+
+import org.apache.commons.chain.*;
+import org.apache.commons.chain.web.*;
+import org.apache.commons.chain.web.servlet.*;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.UnavailableException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.chain.CatalogFactory;
+import org.apache.commons.chain.config.ConfigParser;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+import org.springframework.beans.factory.xml.*;
+import org.springframework.beans.factory.*;
+import org.springframework.core.io.*;
+
+import org.apache.commons.digester.*;
+
+import org.apache.ti.processor.RequestProcessor;
+
+/**
+ * <p><strong>StrutsTiServlet</strong> is the entry point into Struts Ti.</p>
+ * @version $Rev: 170184 $ $Date: 2005-05-14 16:54:24 -0700 (Sat, 14 May 2005) $
+ */
+public class StrutsTiServlet extends HttpServlet {
+    
+    public static final String SERVLET_MAPPINGS_KEY = "servletMappings";
+    
+    protected String springConfig = "org/apache/ti/config/spring-config-servlet.xml";
+    
+    protected static Log log = LogFactory.getLog(StrutsTiServlet.class);
+    
+    protected BeanFactory beanFactory = null;
+    protected List servletMappings = new ArrayList();
+    protected RequestProcessor processor = null;
+    
+    public void destroy() {
+        
+        processor.destroy();
+        beanFactory = null;
+        processor = null;
+    }
+
+
+
+    /**
+     * <p>Initialize this servlet.  Most of the processing has been factored
+     * into support methods so that you can override particular functionality
+     * at a fairly granular level.</p>
+     *
+     * @exception ServletException if we cannot configure ourselves correctly
+     */
+    public void init() throws ServletException {
+        super.init();
+        
+        initSpring();
+        initServlet();
+        
+        Map initParameters = new HashMap();
+        String key;
+        for (Enumeration e = getInitParameterNames(); e.hasMoreElements(); ) {
+            key = (String) e.nextElement();
+            initParameters.put(key, getInitParameter(key));
+        }
+        initParameters.put(SERVLET_MAPPINGS_KEY, servletMappings);
+        
+        processor = (RequestProcessor) beanFactory.getBean("requestProcessor");
+        processor.init(initParameters, new ServletWebContext(getServletContext(), null, null));
+    }
+    
+    protected void initSpring() throws ServletException {
+        // Parse the configuration file specified by path or resource
+        try {
+            String paths = getInitParameter("springConfig");
+            if (paths != null) {
+                springConfig = paths;
+            }
+
+            URL resource = resolve(springConfig);
+            log.info("Loading spring configuration from " + resource);
+            beanFactory = new XmlBeanFactory(new UrlResource(resource));
+        } catch (Exception e) {
+            String msg = "Exception loading spring configuration";
+            log.error(msg, e);
+            throw new UnavailableException(msg);
+        }   
+    }
+    
+
+    /**
+     * <p>Perform the standard request processing for this request, and create
+     * the corresponding response.</p>
+     *
+     * @param request The servlet request we are processing
+     * @param response The servlet response we are creating
+     *
+     * @exception IOException if an input/output error occurs
+     * @exception ServletException if a servlet exception is thrown
+     */
+    public void service(HttpServletRequest request,
+            HttpServletResponse response) throws ServletException {
+
+        processor.process(new ServletWebContext(getServletContext(), request, response));
+    }
+    
+    
+    protected URL resolve(String path) throws ServletException {
+        URL resource = null;
+        ClassLoader loader = Thread.currentThread().getContextClassLoader();
+        if (loader == null) {
+            loader = this.getClass().getClassLoader();
+        }
+        
+        try {
+            if (path.charAt(0) == '/') {
+                resource = getServletContext().getResource(path);
+            }
+    
+            if (resource == null) {
+                if (log.isDebugEnabled()) {
+                    log.debug("Unable to locate " + path
+                            + " in the servlet context, "
+                            + "trying classloader.");
+                }
+                Enumeration e = loader.getResources(path);
+                if (!e.hasMoreElements()) {
+                    String msg = "Resource not found: "+path;
+                    log.error(msg);
+                    throw new UnavailableException(msg);
+                } else {
+                    resource = (URL) e.nextElement();
+                    if (e.hasMoreElements()) {
+                        log.warn("Found more than one resource at "+path
+                            +", only using the first");
+                    }
+                }
+            }
+        } catch (Exception e) {
+            log.error(e);
+            throw new UnavailableException("Unable to load resource at "+path);
+        }
+        
+        return resource;
+    }
+    
+    /**
+     * <p>Remember a servlet mapping from our web application deployment
+     * descriptor, if it is for this servlet.</p>
+     *
+     * @param servletName The name of the servlet being mapped
+     * @param urlPattern The URL pattern to which this servlet is mapped
+     */
+    public void addServletMapping(String servletName, String urlPattern) {
+
+        if (log.isDebugEnabled()) {
+            log.debug("Process servletName=" + servletName
+                    + ", urlPattern=" + urlPattern);
+        }
+        String myServletName = getServletConfig().getServletName();
+        
+        if (servletName != null && servletName.equals(myServletName)) {
+            servletMappings.add(urlPattern);
+        }
+
+    }
+    
+    /**
+     * <p>Initialize the servlet mapping under which our controller servlet
+     * is being accessed.  This will be used in the <code>&html:form&gt;</code>
+     * tag to generate correct destination URLs for form submissions.</p>
+     *
+     * @throws ServletException if error happens while scanning web.xml
+     */
+    protected void initServlet() throws ServletException {
+
+        // Prepare a Digester to scan the web application deployment descriptor
+        Digester digester = new Digester();
+        digester.push(this);
+        digester.setNamespaceAware(true);
+        digester.setValidating(false);
+
+        // Configure the processing rules that we need
+        digester.addCallMethod("web-app/servlet-mapping",
+                               "addServletMapping", 2);
+        digester.addCallParam("web-app/servlet-mapping/servlet-name", 0);
+        digester.addCallParam("web-app/servlet-mapping/url-pattern", 1);
+
+        // Process the web application deployment descriptor
+        if (log.isDebugEnabled()) {
+            log.debug("Scanning web.xml for controller servlet mapping");
+        }
+
+        InputStream input =
+            getServletContext().getResourceAsStream("/WEB-INF/web.xml");
+
+        String err = "Unable to process web.xml";    
+        if (input == null) {
+            throw new ServletException(err);
+        }
+
+        try {
+            digester.parse(input);
+
+        } catch (IOException e) {
+            log.error(err, e);
+            throw new ServletException(e);
+
+        } catch (SAXException e) {
+            log.error(err, e);
+            throw new ServletException(e);
+
+        } finally {
+            try {
+                input.close();
+            } catch (IOException e) {
+                log.error(err, e);
+                throw new ServletException(e);
+            }
+        }
+    }
+
+}

Added: struts/sandbox/trunk/ti/src/java/org/apache/ti/util/ServletSourceResolver.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/java/org/apache/ti/util/ServletSourceResolver.java?rev=227065&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/src/java/org/apache/ti/util/ServletSourceResolver.java (added)
+++ struts/sandbox/trunk/ti/src/java/org/apache/ti/util/ServletSourceResolver.java Tue Aug  2 11:57:06 2005
@@ -0,0 +1,165 @@
+/*
+ * $Id: ServletRequestHandler.java 170184 2005-05-14 23:54:24Z martinc $
+ *
+ * Copyright 2000-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ti.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.MissingResourceException;
+
+import org.apache.commons.chain.*;
+import org.apache.commons.chain.web.*;
+import org.apache.commons.chain.web.servlet.*;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.UnavailableException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.chain.CatalogFactory;
+import org.apache.commons.chain.config.ConfigParser;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+
+/**
+ *  Source resolver that uses the servlet resource locator
+ */
+public class ServletSourceResolver implements SourceResolver {
+
+    /**
+     * <p>Commons Logging instance.</p>
+     */
+    protected static Log log = LogFactory.getLog(ServletSourceResolver.class);
+    
+    public URL resolve(String path, WebContext context) 
+            throws IOException, MalformedURLException {
+                
+        List list = resolveList(path, context);
+        if (list.size() > 0) {
+            return (URL) list.get(0);
+        } else {
+            return null;
+        }
+    }
+    
+    public List resolveList(String path, WebContext context) 
+            throws IOException, MalformedURLException {
+        
+        ServletContext servletContext = ((ServletWebContext)context).getContext();
+        ClassLoader loader = Thread.currentThread().getContextClassLoader();
+        if (loader == null) {
+            loader = this.getClass().getClassLoader();
+        }
+        ArrayList resolvedUrls = new ArrayList();
+
+        URL resource = null;
+        if (path != null && path.length() > 0) {
+
+            if (path.charAt(0) == '/') {
+                resource = servletContext.getResource(path);
+            }
+
+            if (resource == null) {
+                if (log.isDebugEnabled()) {
+                    log.debug("Unable to locate " + path
+                            + " in the servlet context, "
+                            + "trying classloader.");
+                }
+                Enumeration e = loader.getResources(path);
+                if (!e.hasMoreElements()) {
+                    String msg = "Resource not found: "+path;
+                    log.error(msg);
+                    throw new IOException(msg);
+                } else {
+                    while (e.hasMoreElements()) {
+                        resolvedUrls.add(e.nextElement());
+                    }
+                }
+            } else {
+                resolvedUrls.add(resource);
+            }
+        }
+        return resolvedUrls;  
+    }
+    
+    public List resolveFromList(String paths, WebContext context) 
+            throws IOException, MalformedURLException {
+        
+        ServletContext servletContext = ((ServletWebContext)context).getContext();
+        ClassLoader loader = Thread.currentThread().getContextClassLoader();
+        if (loader == null) {
+            loader = this.getClass().getClassLoader();
+        }
+        ArrayList resolvedUrls = new ArrayList();
+
+        URL resource = null;
+        String path = null;
+        // Process each specified resource path
+        while (paths.length() > 0) {
+            int comma = paths.indexOf(',');
+            if (comma >= 0) {
+                path = paths.substring(0, comma).trim();
+                paths = paths.substring(comma + 1);
+            } else {
+                path = paths.trim();
+                paths = "";
+            }
+
+            if (path.length() < 1) {
+                break;
+            }
+
+            if (path.charAt(0) == '/') {
+                resource = servletContext.getResource(path);
+            }
+
+            if (resource == null) {
+                if (log.isDebugEnabled()) {
+                    log.debug("Unable to locate " + path
+                            + " in the servlet context, "
+                            + "trying classloader.");
+                }
+                Enumeration e = loader.getResources(path);
+                if (!e.hasMoreElements()) {
+                    String msg = "Resource not found: "+path;
+                    log.error(msg);
+                    throw new IOException(msg);
+                } else {
+                    while (e.hasMoreElements()) {
+                        resolvedUrls.add(e.nextElement());
+                    }
+                }
+            } else {
+                resolvedUrls.add(resource);
+            }
+        }
+        return resolvedUrls;   
+    }
+
+}

Added: struts/sandbox/trunk/ti/src/java/org/apache/ti/util/SourceResolver.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/java/org/apache/ti/util/SourceResolver.java?rev=227065&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/src/java/org/apache/ti/util/SourceResolver.java (added)
+++ struts/sandbox/trunk/ti/src/java/org/apache/ti/util/SourceResolver.java Tue Aug  2 11:57:06 2005
@@ -0,0 +1,38 @@
+/*
+ * $Id: ServletRequestHandler.java 170184 2005-05-14 23:54:24Z martinc $
+ *
+ * Copyright 2000-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ti.util;
+
+import java.net.*;
+import java.io.*;
+import java.util.List;
+import org.apache.commons.chain.web.WebContext;
+
+
+/**
+ *  Resovles resources
+ */
+public interface SourceResolver {
+
+    public URL resolve(String path, WebContext context) throws IOException, MalformedURLException;
+    
+    public List resolveList(String path, WebContext context) throws IOException, MalformedURLException;
+    
+    public List resolveFromList(String paths, WebContext context) throws IOException, MalformedURLException;
+
+}

Added: struts/sandbox/trunk/ti/src/java/xwork-default.xml
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/java/xwork-default.xml?rev=227065&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/src/java/xwork-default.xml (added)
+++ struts/sandbox/trunk/ti/src/java/xwork-default.xml Tue Aug  2 11:57:06 2005
@@ -0,0 +1,35 @@
+<!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.0//EN" "http://www.opensymphony.com/xwork/xwork-1.0.dtd">
+
+<xwork>
+    <package name="xwork-default">
+        <result-types>
+            <result-type name="chain" class="com.opensymphony.xwork.ActionChainResult"/>
+            <result-type name="dispatcher" class="org.apache.ti.servlet.ServletDispatcherResult" default="true"/>
+        </result-types>
+
+        <interceptors>
+            <interceptor name="timer" class="com.opensymphony.xwork.interceptor.TimerInterceptor"/>
+            <interceptor name="logger" class="com.opensymphony.xwork.interceptor.LoggingInterceptor"/>
+            <interceptor name="chain" class="com.opensymphony.xwork.interceptor.ChainingInterceptor"/>
+            <interceptor name="static-params" class="com.opensymphony.xwork.interceptor.StaticParametersInterceptor"/>
+            <interceptor name="params" class="com.opensymphony.xwork.interceptor.ParametersInterceptor"/>
+            <interceptor name="model-driven" class="com.opensymphony.xwork.interceptor.ModelDrivenInterceptor"/>
+            <interceptor name="component" class="com.opensymphony.xwork.interceptor.component.ComponentInterceptor"/>
+            <interceptor name="validation" class="com.opensymphony.xwork.validator.ValidationInterceptor"/>
+            <interceptor name="workflow" class="com.opensymphony.xwork.interceptor.DefaultWorkflowInterceptor"/>
+            <interceptor name="prepare" class="com.opensymphony.xwork.interceptor.PrepareInterceptor"/>
+            <interceptor name="conversionError" class="com.opensymphony.xwork.interceptor.ConversionErrorInterceptor"/>
+
+            <interceptor-stack name="defaultStack">
+                <interceptor-ref name="static-params"/>
+                <interceptor-ref name="params"/>
+                <interceptor-ref name="conversionError"/>
+            </interceptor-stack>
+            <interceptor-stack name="validationWorkflowStack">
+                <interceptor-ref name="defaultStack"/>
+                <interceptor-ref name="validation"/>
+                <interceptor-ref name="workflow"/>
+            </interceptor-stack>
+        </interceptors>
+    </package>
+</xwork>
\ No newline at end of file

Propchange: struts/sandbox/trunk/ti/src/java/xwork-default.xml
------------------------------------------------------------------------------
    svn:executable = *

Added: struts/sandbox/trunk/ti/src/test/org/apache/ti/config/Controller.jsrc
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/test/org/apache/ti/config/Controller.jsrc?rev=227065&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/src/test/org/apache/ti/config/Controller.jsrc (added)
+++ struts/sandbox/trunk/ti/src/test/org/apache/ti/config/Controller.jsrc Tue Aug  2 11:57:06 2005
@@ -0,0 +1,21 @@
+
+import com.opensymphony.xwork.Action;
+
+public class Controller {
+
+    /** @ti.action */
+    public String index() {
+        return Action.SUCCESS;
+    }
+    
+    /**
+     * @ti.action
+     * @ti.forward name="success" type="redirect" location="index"
+     * @ti.forward name="lost" type="dispatch" location="lostPassword.jsp"
+     * @ti.forward name="error" type="action" location="login"
+     */
+    public String doLogin() {
+        return Action.SUCCESS;
+    }    
+
+}

Added: struts/sandbox/trunk/ti/src/test/org/apache/ti/config/TestProcessTags.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/test/org/apache/ti/config/TestProcessTags.java?rev=227065&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/src/test/org/apache/ti/config/TestProcessTags.java (added)
+++ struts/sandbox/trunk/ti/src/test/org/apache/ti/config/TestProcessTags.java Tue Aug  2 11:57:06 2005
@@ -0,0 +1,136 @@
+/*
+ * $Id: TestProcessTags.java 171041 2005-05-20 03:50:06Z jmitchell $ 
+ *
+ * Copyright 2002-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ti.config;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import java.io.*;
+import java.util.*;
+
+/**
+ * Unit tests for the <code>org.apache.ti.config.ProcessTags</code> class.
+ *
+ * @version $Rev: 171041 $ $Date: 2005-05-19 20:50:06 -0700 (Thu, 19 May 2005) $
+ */
+public class TestProcessTags extends TestCase {
+    
+    File src, dest;
+    
+    /**
+     * Defines the testcase name for JUnit.
+     *
+     * @param theName the testcase's name.
+     */
+    public TestProcessTags(String theName) {
+        super(theName);
+    }
+
+    /**
+     * Start the tests.
+     *
+     * @param theArgs the arguments. Not used
+     */
+    public static void main(String[] theArgs) {
+        junit.awtui.TestRunner.main(
+            new String[] { TestProcessTags.class.getName()});
+    }
+
+    /**
+     * @return a test suite (<code>TestSuite</code>) that includes all methods
+     *         starting with "test"
+     */
+    public static Test suite() {
+        // All methods starting with "test" will be executed in the test suite.
+        return new TestSuite(TestProcessTags.class);
+    }
+    
+    public void setUp() throws Exception {
+        File root = File.createTempFile("strutsti", "").getParentFile();
+        src = new File(root, "strutsti-src");
+        src.mkdirs();
+        dest = new File(root, "strutsti-dest");
+        dest.mkdirs();
+    }
+    
+    public void tearDown() {
+        deleteDir(src);
+        deleteDir(dest);
+    }
+        
+
+    public void testCrawl() throws Exception {
+        final HashSet shouldFind = new HashSet();
+        shouldFind.add("Controller.java");
+        shouldFind.add("foo/Controller.java");
+        shouldFind.add("foo\\Controller.java");
+        
+        XDocletParser mock = new XDocletParser() {
+            public void generate(String name, Reader reader, Writer writer) {
+                if (!shouldFind.contains(name)) {
+                    fail("Invalid controller file "+name);
+                }
+                try {
+                    writer.write("foo");
+                    writer.close();
+                } catch (IOException ex) {
+                    ex.printStackTrace(); 
+                }
+            }
+        };
+        
+        File rootCtr = new File(src, "Controller.java");
+        rootCtr.createNewFile();
+        File sub = new File(src, "foo");
+        sub.mkdirs();
+        File subCtr = new File(sub, "Controller.java");
+        subCtr.createNewFile();
+        
+        ProcessTags processer = new ProcessTags();
+        processer.setXDocletParser(mock);
+        
+        processer.process(src, "Controller.java", dest, "xwork.xml");
+        assertTrue(new File(dest, "xwork.xml").exists());
+        assertTrue(new File(dest, "foo/xwork.xml").exists());
+        
+    }
+    
+    
+    
+    
+    // Deletes all files and subdirectories under dir.
+    // Returns true if all deletions were successful.
+    // If a deletion fails, the method stops attempting to delete and returns false.
+    private static boolean deleteDir(File dir) {
+        if (dir.isDirectory()) {
+            String[] children = dir.list();
+            for (int i=0; i<children.length; i++) {
+                boolean success = deleteDir(new File(dir, children[i]));
+                if (!success) {
+                    return false;
+                }
+            }
+        }
+    
+        // The directory is now empty so delete it
+        return dir.delete();
+    }
+
+}

Added: struts/sandbox/trunk/ti/src/test/org/apache/ti/config/TestXDocletParser.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/test/org/apache/ti/config/TestXDocletParser.java?rev=227065&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/src/test/org/apache/ti/config/TestXDocletParser.java (added)
+++ struts/sandbox/trunk/ti/src/test/org/apache/ti/config/TestXDocletParser.java Tue Aug  2 11:57:06 2005
@@ -0,0 +1,137 @@
+/*
+ * $Id: TestXDocletParser.java 171041 2005-05-20 03:50:06Z jmitchell $ 
+ *
+ * Copyright 2002-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ti.config;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import java.io.*;
+
+import org.jdom.*;
+import org.jdom.xpath.XPath;
+import org.jdom.input.*;
+
+/**
+ * Unit tests for the <code>org.apache.ti.config.XDocletParser</code> class.
+ *
+ * @version $Rev: 171041 $ $Date: 2005-05-19 20:50:06 -0700 (Thu, 19 May 2005) $
+ */
+public class TestXDocletParser extends TestCase {
+    
+    /**
+     * Defines the testcase name for JUnit.
+     *
+     * @param theName the testcase's name.
+     */
+    public TestXDocletParser(String theName) {
+        super(theName);
+    }
+
+    /**
+     * Start the tests.
+     *
+     * @param theArgs the arguments. Not used
+     */
+    public static void main(String[] theArgs) {
+        junit.awtui.TestRunner.main(
+            new String[] { TestXDocletParser.class.getName()});
+    }
+
+    /**
+     * @return a test suite (<code>TestSuite</code>) that includes all methods
+     *         starting with "test"
+     */
+    public static Test suite() {
+        // All methods starting with "test" will be executed in the test suite.
+        return new TestSuite(TestXDocletParser.class);
+    }
+
+    public void testGenerateSimple() {
+        XDocletParser p = new XDocletParser();
+        p.setTemplateName("org/apache/ti/config/test.vm");
+        p.init();
+        
+        String src = "public class Test {}";
+        StringReader reader = new StringReader(src);
+        StringWriter writer = new StringWriter();
+        p.generate("Test.java", reader, writer);
+        
+        String out = writer.toString();
+        assertNotNull(out);
+        assertTrue("incorrect output: '"+out+"'", "File is 'Test.java'".equals(out));
+    }
+    
+    public void testGenerateTag() {
+        XDocletParser p = new XDocletParser();
+        p.setTemplateName("org/apache/ti/config/testTag.vm");
+        p.init();
+        
+        String src = "package foo;\n/** \n * things\n *  @foo bar\n */\npublic class Test{}";
+        StringReader reader = new StringReader(src);
+        StringWriter writer = new StringWriter();
+        p.generate("Test.java", reader, writer);
+        
+        String out = writer.toString();
+        assertNotNull(out);
+        assertTrue("incorrect output: '"+out+"'", "Tag is 'bar'".equals(out));
+    }
+    
+    public void testForwards() throws Exception {
+        Document doc = runTemplate("Controller.jsrc");
+        assertXPath(doc, "/xwork/package[@name='default']");
+        
+        // Test simple forward
+        assertXPath(doc, "/xwork/package/action[@name='index']");
+        assertXPath(doc, "/xwork/package/action[@name='index']/result[param = 'index.jsp']");
+        
+        // Test declared forwards
+        assertXPath(doc, "/xwork/package/action[@name='doLogin']");
+        assertXPath(doc, "/xwork/package/action[@name='doLogin']/result[@name='success' and param='index']");
+        assertXPath(doc, "/xwork/package/action[@name='doLogin']/result[@name='lost' and param='lostPassword.jsp']");
+        assertXPath(doc, "/xwork/package/action[@name='doLogin']/result[@name='error' and param='login']");
+        
+    }
+    
+    public void testInPackage() throws Exception {
+        Document doc = runTemplate("foo/Controller.jsrc");
+        assertXPath(doc, "/xwork/package[@name='foo' and @namespace='/foo']");
+    }
+        
+    
+    protected void assertXPath(Document doc, String xpath) throws Exception {
+        XPath xp = XPath.newInstance(xpath);
+        assertNotNull(xp.selectSingleNode(doc));
+    }
+    
+    protected Document runTemplate(String path) throws Exception {
+        XDocletParser p = new XDocletParser();
+        p.setTemplateName("org/apache/ti/config/xdocletToXWork.vm");
+        p.init();
+        
+        StringWriter writer = new StringWriter();
+        Reader reader = new InputStreamReader(getClass().getResourceAsStream(path));
+        path = path.replaceAll("jsrc", "java");
+        p.generate(path, reader, writer);
+        System.out.println("xwork: \n"+writer.toString());
+        Document doc = new SAXBuilder().build(new StringReader(writer.toString()));
+        return doc;
+    }
+
+}

Added: struts/sandbox/trunk/ti/src/test/org/apache/ti/config/foo/Controller.jsrc
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/test/org/apache/ti/config/foo/Controller.jsrc?rev=227065&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/src/test/org/apache/ti/config/foo/Controller.jsrc (added)
+++ struts/sandbox/trunk/ti/src/test/org/apache/ti/config/foo/Controller.jsrc Tue Aug  2 11:57:06 2005
@@ -0,0 +1,22 @@
+package foo;
+
+import com.opensymphony.xwork.Action;
+
+public class Controller {
+
+    /** @ti.action */
+    public String index() {
+        return Action.SUCCESS;
+    }
+    
+    /**
+     * @ti.action
+     * @ti.forward name="success" type="redirect" location="index"
+     * @ti.forward name="lost" type="dispatch" location="lostPassword.jsp"
+     * @ti.forward name="error" type="action" location="login"
+     */
+    public String doLogin() {
+        return Action.SUCCESS;
+    }    
+
+}

Added: struts/sandbox/trunk/ti/src/test/org/apache/ti/config/mapper/TestServletActionMapper.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/test/org/apache/ti/config/mapper/TestServletActionMapper.java?rev=227065&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/src/test/org/apache/ti/config/mapper/TestServletActionMapper.java (added)
+++ struts/sandbox/trunk/ti/src/test/org/apache/ti/config/mapper/TestServletActionMapper.java Tue Aug  2 11:57:06 2005
@@ -0,0 +1,115 @@
+/*
+ * $Id: TestServletActionMapper.java 171041 2005-05-20 03:50:06Z jmitchell $ 
+ *
+ * Copyright 2002-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ti.config.mapper;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import java.io.*;
+import java.util.*;
+
+/**
+ * Unit tests for the <code>org.apache.ti.config.ServletActionMapper</code> class.
+ *
+ * @version $Rev: 171041 $ $Date: 2005-05-19 20:50:06 -0700 (Thu, 19 May 2005) $
+ */
+public class TestServletActionMapper extends TestCase {
+    
+    List mappings;
+    ServletActionMapper mapper;
+    
+    /**
+     * Defines the testcase name for JUnit.
+     *
+     * @param theName the testcase's name.
+     */
+    public TestServletActionMapper(String theName) {
+        super(theName);
+    }
+
+    /**
+     * Start the tests.
+     *
+     * @param theArgs the arguments. Not used
+     */
+    public static void main(String[] theArgs) {
+        junit.awtui.TestRunner.main(
+            new String[] { TestServletActionMapper.class.getName()});
+    }
+
+    /**
+     * @return a test suite (<code>TestSuite</code>) that includes all methods
+     *         starting with "test"
+     */
+    public static Test suite() {
+        // All methods starting with "test" will be executed in the test suite.
+        return new TestSuite(TestServletActionMapper.class);
+    }
+    
+    public void setUp() {
+        mappings = new ArrayList();
+        mappings.add("*.do");
+        mappings.add("/foo/*");
+        
+        mapper = new ServletActionMapper();
+    }
+    
+    public void testGetPrefixMapping() throws Exception {
+        ActionMapping am = mapper.getMapping("/foo/ns/bar", mappings);
+        assertNotNull(am);
+        assertTrue("action:"+am.getName(), "bar".equals(am.getName()));
+        assertTrue("ns".equals(am.getNamespace()));
+        assertTrue("/foo/*".equals(am.getExternalMapping()));
+    }
+    
+    public void testGetExtMapping() throws Exception {
+        ActionMapping am = mapper.getMapping("/ns/bar.do", mappings);
+        assertNotNull(am);
+        assertTrue("bar".equals(am.getName()));
+        assertTrue("ns".equals(am.getNamespace()));
+        assertTrue("*.do".equals(am.getExternalMapping()));
+    }
+    
+    public void testGetNoNSMapping() throws Exception {
+        ActionMapping am = mapper.getMapping("/bar.do", mappings);
+        assertNotNull(am);
+        assertTrue("bar".equals(am.getName()));
+        assertTrue("".equals(am.getNamespace()));
+        assertTrue("*.do".equals(am.getExternalMapping()));
+    }
+    
+    public void testGetNoMapping() throws Exception {
+        ActionMapping am = mapper.getMapping("/ns/bar.doasd", mappings);
+        assertNull(am);
+    }
+    
+    public void testGetPrefixUri() throws Exception {
+        ActionMapping am = new ActionMapping("bar", "ns", "/foo/*", null);
+        String uri = mapper.getUriFromActionMapping(am);
+        assertTrue("Invalid uri is "+uri, "/foo/ns/bar".equals(uri));
+    }
+    
+    public void testGetExtUri() throws Exception {
+        ActionMapping am = new ActionMapping("bar", "ns", "*.do", null);
+        String uri = mapper.getUriFromActionMapping(am);
+        assertTrue("Invalid uri is "+uri, "/ns/bar.do".equals(uri));
+    }
+    
+}

Propchange: struts/sandbox/trunk/ti/src/test/org/apache/ti/config/mapper/TestServletActionMapper.java
------------------------------------------------------------------------------
    svn:executable = *

Added: struts/sandbox/trunk/ti/src/test/org/apache/ti/config/test.vm
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/test/org/apache/ti/config/test.vm?rev=227065&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/src/test/org/apache/ti/config/test.vm (added)
+++ struts/sandbox/trunk/ti/src/test/org/apache/ti/config/test.vm Tue Aug  2 11:57:06 2005
@@ -0,0 +1 @@
+File is '$javaFile'##

Added: struts/sandbox/trunk/ti/src/test/org/apache/ti/config/testTag.vm
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/test/org/apache/ti/config/testTag.vm?rev=227065&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/src/test/org/apache/ti/config/testTag.vm (added)
+++ struts/sandbox/trunk/ti/src/test/org/apache/ti/config/testTag.vm Tue Aug  2 11:57:06 2005
@@ -0,0 +1 @@
+Tag is '${xclass.doc.getTag("foo").value}'##

Added: struts/sandbox/trunk/ti/src/test/org/apache/ti/processor/chain/Bean.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/test/org/apache/ti/processor/chain/Bean.java?rev=227065&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/src/test/org/apache/ti/processor/chain/Bean.java (added)
+++ struts/sandbox/trunk/ti/src/test/org/apache/ti/processor/chain/Bean.java Tue Aug  2 11:57:06 2005
@@ -0,0 +1,25 @@
+/*
+ * $Id: TestSpringConfigRuleSet.java 171041 2005-05-20 03:50:06Z jmitchell $ 
+ *
+ * Copyright 2002-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ti.processor.chain;
+
+import org.apache.commons.chain.*;
+
+public class Bean implements Command {
+    public boolean execute(Context ctx) {return true;}
+}

Propchange: struts/sandbox/trunk/ti/src/test/org/apache/ti/processor/chain/Bean.java
------------------------------------------------------------------------------
    svn:executable = *

Added: struts/sandbox/trunk/ti/src/test/org/apache/ti/processor/chain/TestSpringConfigRuleSet.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/test/org/apache/ti/processor/chain/TestSpringConfigRuleSet.java?rev=227065&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/src/test/org/apache/ti/processor/chain/TestSpringConfigRuleSet.java (added)
+++ struts/sandbox/trunk/ti/src/test/org/apache/ti/processor/chain/TestSpringConfigRuleSet.java Tue Aug  2 11:57:06 2005
@@ -0,0 +1,89 @@
+/*
+ * $Id: TestSpringConfigRuleSet.java 171041 2005-05-20 03:50:06Z jmitchell $ 
+ *
+ * Copyright 2002-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ti.processor.chain;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import java.io.*;
+import java.util.*;
+
+import org.apache.commons.chain.config.*;
+import org.apache.commons.chain.*;
+import org.apache.commons.chain.impl.*;
+import org.springframework.beans.factory.*;
+import org.springframework.beans.factory.support.*;
+
+/**
+ * Unit tests for the <code>org.apache.ti.config.SpringConfigRuleSet</code> class.
+ *
+ * @version $Rev: 171041 $ $Date: 2005-05-19 20:50:06 -0700 (Thu, 19 May 2005) $
+ */
+public class TestSpringConfigRuleSet extends TestCase {
+    
+    /**
+     * Defines the testcase name for JUnit.
+     *
+     * @param theName the testcase's name.
+     */
+    public TestSpringConfigRuleSet(String theName) {
+        super(theName);
+    }
+
+    /**
+     * Start the tests.
+     *
+     * @param theArgs the arguments. Not used
+     */
+    public static void main(String[] theArgs) {
+        junit.awtui.TestRunner.main(
+            new String[] { TestSpringConfigRuleSet.class.getName()});
+    }
+
+    /**
+     * @return a test suite (<code>TestSuite</code>) that includes all methods
+     *         starting with "test"
+     */
+    public static Test suite() {
+        // All methods starting with "test" will be executed in the test suite.
+        return new TestSuite(TestSpringConfigRuleSet.class);
+    }
+    
+
+    public void testLoadConfig() throws Exception {
+        DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
+        factory.registerBeanDefinition("springBean", new RootBeanDefinition(Bean.class));
+        assertNotNull(factory.getBean("springBean"));
+        
+        ConfigParser parser = new ConfigParser();
+        SpringConfigRuleSet ruleset = new SpringConfigRuleSet();
+        ruleset.setBeanFactory(factory);
+        parser.setRuleSet(ruleset);
+        
+        parser.parse(getClass().getResource("/org/apache/ti/processor/chain/chain-config.xml"));
+        Catalog cat = CatalogFactory.getInstance().getCatalog("test");
+        assertNotNull(cat);
+        assertNotNull(cat.getCommand("normalBean"));
+        assertNotNull(cat.getCommand("springBean"));
+        
+        assertNull(cat.getCommand("beandoesntexist"));
+    }
+
+}

Propchange: struts/sandbox/trunk/ti/src/test/org/apache/ti/processor/chain/TestSpringConfigRuleSet.java
------------------------------------------------------------------------------
    svn:executable = *

Added: struts/sandbox/trunk/ti/src/test/org/apache/ti/processor/chain/chain-config.xml
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/src/test/org/apache/ti/processor/chain/chain-config.xml?rev=227065&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/src/test/org/apache/ti/processor/chain/chain-config.xml (added)
+++ struts/sandbox/trunk/ti/src/test/org/apache/ti/processor/chain/chain-config.xml Tue Aug  2 11:57:06 2005
@@ -0,0 +1,43 @@
+<?xml version="1.0" ?>
+
+
+<!--
+
+ Copyright 2002,2004 The Apache Software Foundation.
+ 
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+ 
+      http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+
+
+<!--
+    This file contains definitions of the standard Chain Of Responsibility
+    chains.
+
+    $Id: chain-config.xml 191314 2005-06-19 00:27:26Z mrdon $
+-->
+
+
+<catalog name="test">
+
+    <define name= "lookup"
+            className= "org.apache.commons.chain.generic.LookupCommand" />
+            
+            
+    <!-- ========== Start of chain ========================= -->
+    <chain name="foo" />
+
+    <command name="springBean" />
+    <command name="normalBean" className="org.apache.ti.processor.chain.Bean" />
+
+</catalog>

Propchange: struts/sandbox/trunk/ti/src/test/org/apache/ti/processor/chain/chain-config.xml
------------------------------------------------------------------------------
    svn:executable = *



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org