I would like if it we, the struts team, refrain from using the term "legacy" in packages or to talk about the Struts 1.x code base.

From a personal perspective, my focus is on 1.x and I do not think that 2.x "supersedes" what we have in the 1.x line. It's a totally different architecture and 2.x has better way of solving some problems, but we're still solving the same problems.

But with regards to what the 1.x will become in the future, I have a slew of enhancements I want to apply; this means 1.x may have some good features 2.x does not, and vice-versa. I don't want these new features to be viewed as "legacy"; I think that label carries a lot of negative weight and biases developers against the work that goes into it.

Paul
--- Begin Message ---
Author: mrdon
Date: Sat Sep 23 21:09:38 2006
New Revision: 449350

URL: http://svn.apache.org/viewvc?view=rev&rev=449350
Log:
Adding the legacy module classes (silly local svn problem), minor improvements 
to support 
intelligent defaults, added documentation

Added:
    struts/struts2/trunk/legacy/src/main/java/org/apache/
    struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/
    struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/
    
struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/ActionFormResetInterceptor.java
      - copied, changed from r449318, 
struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/ActionFormResetInterceptor.java
    
struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/ActionFormValidationInterceptor.java
      - copied, changed from r449318, 
struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/ActionFormValidationInterceptor.java
    
struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/DynaBeanPropertyAccessor.java
      - copied, changed from r449318, 
struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/DynaBeanPropertyAccessor.java
    
struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/LegacyAction.java
    
struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/ScopedModelDriven.java
      - copied, changed from r449318, 
struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/ScopedModelDriven.java
    
struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/ScopedModelDrivenInterceptor.java
      - copied, changed from r449318, 
struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/ScopedModelDrivenInterceptor.java
    
struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/StrutsFactory.java
      - copied, changed from r449318, 
struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/StrutsFactory.java
    
struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/WrapperActionForward.java
      - copied, changed from r449318, 
struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/WrapperActionForward.java
    
struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/WrapperActionMapping.java
      - copied, changed from r449318, 
struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/WrapperActionMapping.java
    
struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/WrapperExceptionConfig.java
      - copied, changed from r449318, 
struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/WrapperExceptionConfig.java
    
struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/WrapperModuleConfig.java
      - copied, changed from r449318, 
struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/WrapperModuleConfig.java
Modified:
    
struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/legacy/EditGangsterAction.java
    struts/struts2/trunk/apps/showcase/src/main/resources/struts-legacy.xml

Modified: 
struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/legacy/EditGangsterAction.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/legacy/EditGangsterAction.java?view=diff&rev=449350&r1=449349&r2=449350
==============================================================================
--- 
struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/legacy/EditGangsterAction.java
 (original)
+++ 
struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/legacy/EditGangsterAction.java
 Sat Sep 23 21:09:38 2006
@@ -33,6 +33,7 @@
     @Override
     public ActionForward execute(ActionMapping mapping, ActionForm form, 
HttpServletRequest request, HttpServletResponse response) throws Exception {
         // Some code to load the gangster from the db as necessary
+        
         return mapping.findForward("success");
     }
 

Modified: 
struts/struts2/trunk/apps/showcase/src/main/resources/struts-legacy.xml
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/resources/struts-legacy.xml?view=diff&rev=449350&r1=449349&r2=449350
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/resources/struts-legacy.xml 
(original)
+++ struts/struts2/trunk/apps/showcase/src/main/resources/struts-legacy.xml Sat 
Sep 23 21:09:38 2006
@@ -9,8 +9,6 @@
            
            <interceptors>
                <interceptor name="gangsterForm" 
class="org.apache.struts2.legacy.ScopedModelDrivenInterceptor">
-                       <param name="scope">request</param>
-                       <param name="name">gangsterForm</param>
                        <param 
name="className">org.apache.struts2.showcase.legacy.GangsterForm</param>
                </interceptor>
            

Copied: 
struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/ActionFormResetInterceptor.java
 (from r449318, 
struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/ActionFormResetInterceptor.java)
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/ActionFormResetInterceptor.java?view=diff&rev=449350&p1=struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/ActionFormResetInterceptor.java&r1=449318&p2=struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/ActionFormResetInterceptor.java&r2=449350
==============================================================================
--- 
struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/ActionFormResetInterceptor.java
 (original)
+++ 
struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/ActionFormResetInterceptor.java
 Sat Sep 23 21:09:38 2006
@@ -16,36 +16,37 @@
  * limitations under the License.
  */
 
-package org.apache.ti.legacy;
+package org.apache.struts2.legacy;
 
-import com.opensymphony.xwork.interceptor.ModelDrivenInterceptor;
-import com.opensymphony.xwork.ActionInvocation;
-import com.opensymphony.xwork.interceptor.AroundInterceptor;
-import com.opensymphony.xwork.ObjectFactory;
-import com.opensymphony.webwork.ServletActionContext;
 import javax.servlet.http.HttpServletRequest;
+
 import org.apache.struts.action.ActionForm;
 import org.apache.struts.action.ActionMapping;
+import org.apache.struts2.ServletActionContext;
+import org.apache.struts2.dispatcher.Dispatcher;
+
+import com.opensymphony.xwork2.ActionInvocation;
+import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
 
 /**
  *  Calls the reset() method on the ActionForm, if it exists.
  */
-public class ActionFormResetInterceptor extends AroundInterceptor {
-
-    protected void after(ActionInvocation dispatcher, String result) throws 
Exception {
-    }
+public class ActionFormResetInterceptor extends AbstractInterceptor {
 
-    protected void before(ActionInvocation invocation) throws Exception {
+    @Override
+    public String intercept(ActionInvocation invocation) throws Exception {
         Object action = invocation.getAction();
 
         if (action instanceof ScopedModelDriven) {
             ScopedModelDriven modelDriven = (ScopedModelDriven) action;
             Object model = modelDriven.getModel();
-            if (model != null) {
-                ActionMapping mapping = 
StrutsFactory.getStrutsFactory().createActionMapping(invocation.getProxy().getConfig());
+            if (model != null && model instanceof ActionForm) {
+                StrutsFactory factory = new 
StrutsFactory(Dispatcher.getInstance().getConfigurationManager().getConfiguration());
+                ActionMapping mapping = 
factory.createActionMapping(invocation.getProxy().getConfig());
                 HttpServletRequest req = ServletActionContext.getRequest();
                 ((ActionForm)model).reset(mapping, req);
             }
         }
+        return invocation.invoke();
     }
 }

Copied: 
struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/ActionFormValidationInterceptor.java
 (from r449318, 
struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/ActionFormValidationInterceptor.java)
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/ActionFormValidationInterceptor.java?view=diff&rev=449350&p1=struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/ActionFormValidationInterceptor.java&r1=449318&p2=struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/ActionFormValidationInterceptor.java&r2=449350
==============================================================================
--- 
struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/ActionFormValidationInterceptor.java
 (original)
+++ 
struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/ActionFormValidationInterceptor.java
 Sat Sep 23 21:09:38 2006
@@ -16,40 +16,43 @@
  * limitations under the License.
  */
 
-package org.apache.ti.legacy;
+package org.apache.struts2.legacy;
 
-import com.opensymphony.xwork.interceptor.ModelDrivenInterceptor;
-import com.opensymphony.xwork.ActionInvocation;
-import com.opensymphony.xwork.interceptor.AroundInterceptor;
-import com.opensymphony.xwork.ObjectFactory;
-import com.opensymphony.webwork.ServletActionContext;
 import javax.servlet.http.HttpServletRequest;
+
+import org.apache.struts.action.ActionErrors;
 import org.apache.struts.action.ActionForm;
 import org.apache.struts.action.ActionMapping;
-import org.apache.struts.action.ActionErrors;
-import org.apache.struts.action.ActionError;
+import org.apache.struts2.ServletActionContext;
+import org.apache.struts2.dispatcher.Dispatcher;
+
+import com.opensymphony.xwork2.ActionInvocation;
+import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
 
 /**
  *  Calls the validate() method on the ActionForm, if it exists.  The errors 
are handled
- *  like regular XWork validation errors.
+ *  like regular XWork validation errors.  Action-level validation flag 
supported if the
+ *  action is a subclass of LegacyAction.
  */
-public class ActionFormValidationInterceptor extends AroundInterceptor {
-
-    protected void after(ActionInvocation dispatcher, String result) throws 
Exception {
-    }
+public class ActionFormValidationInterceptor extends AbstractInterceptor {
 
-    protected void before(ActionInvocation invocation) throws Exception {
+    @Override
+    public String intercept(ActionInvocation invocation) throws Exception {
         Object action = invocation.getAction();
 
-        if (action instanceof ScopedModelDriven) {
+        
+        if ((action instanceof ScopedModelDriven) &&
+            (!(action instanceof LegacyAction) || 
((LegacyAction)action).isValidate())) {
             ScopedModelDriven modelDriven = (ScopedModelDriven) action;
             Object model = modelDriven.getModel();
             if (model != null) {
-                ActionMapping mapping = 
StrutsFactory.getStrutsFactory().createActionMapping(invocation.getProxy().getConfig());
+                StrutsFactory strutsFactory = new 
StrutsFactory(Dispatcher.getInstance().getConfigurationManager().getConfiguration());
+                ActionMapping mapping = 
strutsFactory.createActionMapping(invocation.getProxy().getConfig());
                 HttpServletRequest req = ServletActionContext.getRequest();
                 ActionErrors errors = ((ActionForm)model).validate(mapping, 
req);
-                StrutsFactory.getStrutsFactory().convertErrors(errors, 
action);                
+                strutsFactory.convertErrors(errors, action);                
             }
         }
+        return invocation.invoke();
     }
 }

Copied: 
struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/DynaBeanPropertyAccessor.java
 (from r449318, 
struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/DynaBeanPropertyAccessor.java)
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/DynaBeanPropertyAccessor.java?view=diff&rev=449350&p1=struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/DynaBeanPropertyAccessor.java&r1=449318&p2=struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/DynaBeanPropertyAccessor.java&r2=449350
==============================================================================
--- 
struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/DynaBeanPropertyAccessor.java
 (original)
+++ 
struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/DynaBeanPropertyAccessor.java
 Sat Sep 23 21:09:38 2006
@@ -16,7 +16,7 @@
  *
  */
 
-package org.apache.ti.legacy;
+package org.apache.struts2.legacy;
 
 import java.io.Serializable;
 import org.apache.commons.beanutils.DynaBean;

Added: 
struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/LegacyAction.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/LegacyAction.java?view=auto&rev=449350
==============================================================================
--- 
struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/LegacyAction.java
 (added)
+++ 
struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/LegacyAction.java
 Sat Sep 23 21:09:38 2006
@@ -0,0 +1,128 @@
+/*
+ * Copyright 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.
+ *
+ * $Header:$
+ */
+package org.apache.struts2.legacy;
+
+import java.util.Arrays;
+import java.util.Iterator;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.struts.Globals;
+import org.apache.struts.action.Action;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.ActionMessage;
+import org.apache.struts.action.ActionMessages;
+import org.apache.struts2.ServletActionContext;
+import org.apache.struts2.StrutsException;
+import org.apache.struts2.dispatcher.DefaultActionSupport;
+import org.apache.struts2.dispatcher.Dispatcher;
+
+import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.ObjectFactory;
+import com.opensymphony.xwork2.config.entities.ActionConfig;
+
+/**
+ * Wraps legacy Struts 1.3 Actions.  Supports the following features:
+ * <ul>
+ *  <li>ActionForms</li>
+ *  <li>ActionForwards that have the same name as a result</li>
+ *  <li>ActionMessages stored in the request, converted to Struts 2 
messages</li>
+ *  <li>Action-level validation flag</li>
+ * </ul>
+ * Still to do:
+ * <ul>
+ *  <li>Custom ActionForward instances that don't have an associated result 
config</li>
+ *  <li>setServlet() calls for the Action</li>
+ *  <li>Most everything else...</li>
+ * </ul>
+ */
+public class LegacyAction extends DefaultActionSupport implements 
ScopedModelDriven<ActionForm> {
+
+    private ActionForm actionForm;
+    private String className;
+    private boolean validate;
+    
+    public String execute() throws Exception {
+        ActionContext ctx = ActionContext.getContext();
+        ActionConfig actionConfig = 
ctx.getActionInvocation().getProxy().getConfig();
+        Action action = null;
+        try {
+            action = (Action) 
ObjectFactory.getObjectFactory().buildBean(className, null);
+        } catch (Exception e) {
+            throw new StrutsException("Unable to create the legacy Struts 
Action", e, actionConfig);
+        }
+        
+        // We should call setServlet() here, but let's stub that out later
+        
+        StrutsFactory strutsFactory = new 
StrutsFactory(Dispatcher.getInstance().getConfigurationManager().getConfiguration());
+        ActionMapping mapping = 
strutsFactory.createActionMapping(actionConfig);
+        HttpServletRequest request = ServletActionContext.getRequest();
+        HttpServletResponse response = ServletActionContext.getResponse();
+        ActionForward forward = action.execute(mapping, actionForm, request, 
response);
+        
+        ActionMessages messages = (ActionMessages) 
request.getAttribute(Globals.MESSAGE_KEY);
+        if (messages != null) {
+            for (Iterator i = messages.get(); i.hasNext(); ) {
+                ActionMessage msg = (ActionMessage) i.next();
+                if (msg.getValues() != null && msg.getValues().length > 0) {
+                    addActionMessage(getText(msg.getKey(), 
Arrays.asList(msg.getValues())));
+                } else {
+                    addActionMessage(getText(msg.getKey()));
+                }
+            }
+        }
+        
+        if (forward instanceof WrapperActionForward || 
actionConfig.getResults().containsKey(forward.getName())) {
+            return forward.getName();
+        } else {
+            throw new StrutsException("Unable to handle action forwards that 
don't have an associated result", actionConfig);
+        }
+    }
+    
+    public void setModel(ActionForm model) {
+        actionForm = model;
+    }
+
+    public ActionForm getModel() {
+        return actionForm;
+    }
+    
+    /**
+     * @return the validate
+     */
+    public boolean isValidate() {
+        return validate;
+    }
+
+    /**
+     * @param validate the validate to set
+     */
+    public void setValidate(boolean validate) {
+        this.validate = validate;
+    }
+
+    /**
+     * @param className the className to set
+     */
+    public void setClassName(String className) {
+        this.className = className;
+    }
+}

Copied: 
struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/ScopedModelDriven.java
 (from r449318, 
struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/ScopedModelDriven.java)
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/ScopedModelDriven.java?view=diff&rev=449350&p1=struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/ScopedModelDriven.java&r1=449318&p2=struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/ScopedModelDriven.java&r2=449350
==============================================================================
--- 
struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/ScopedModelDriven.java
 (original)
+++ 
struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/ScopedModelDriven.java
 Sat Sep 23 21:09:38 2006
@@ -16,17 +16,17 @@
  *
  */
 
-package org.apache.ti.legacy;
+package org.apache.struts2.legacy;
 
-import com.opensymphony.xwork.ModelDriven;
+import com.opensymphony.xwork2.ModelDriven;
 
 /**
  * Adds the ability to set a model, probably retrieved from a given state.
  */
-public interface ScopedModelDriven extends ModelDriven {
+public interface ScopedModelDriven<T> extends ModelDriven {
 
     /**
      * Sets the model
      */
-    void setModel(Object model);
+    void setModel(T model);
 }

Copied: 
struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/ScopedModelDrivenInterceptor.java
 (from r449318, 
struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/ScopedModelDrivenInterceptor.java)
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/ScopedModelDrivenInterceptor.java?view=diff&rev=449350&p1=struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/ScopedModelDrivenInterceptor.java&r1=449318&p2=struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/ScopedModelDrivenInterceptor.java&r2=449350
==============================================================================
--- 
struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/ScopedModelDrivenInterceptor.java
 (original)
+++ 
struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/ScopedModelDrivenInterceptor.java
 Sat Sep 23 21:09:38 2006
@@ -16,55 +16,144 @@
  *
  */
 
-package org.apache.ti.legacy;
-
-import com.opensymphony.xwork.interceptor.ModelDrivenInterceptor;
-import com.opensymphony.xwork.ActionInvocation;
-import com.opensymphony.xwork.ActionContext;
-import com.opensymphony.xwork.ActionProxy;
-import com.opensymphony.xwork.config.entities.ActionConfig;
-import com.opensymphony.xwork.ObjectFactory;
+package org.apache.struts2.legacy;
 
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
 import java.util.Map;
 
+import com.opensymphony.xwork2.Action;
+import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.ActionInvocation;
+import com.opensymphony.xwork2.ObjectFactory;
+import com.opensymphony.xwork2.Validateable;
+import com.opensymphony.xwork2.ValidationAware;
+import com.opensymphony.xwork2.config.entities.ActionConfig;
+import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
+
 /**
- *  Retrieves the model class from the configured scope, then provides it 
- *  to the Action.
+ * <!-- START SNIPPET: description -->
+ *
+ * An interceptor that enables scoped model-driven actions.
+ *
+ * <p/>This interceptor only activates on actions that implement the [EMAIL 
PROTECTED] ScopedModelDriven} interface.  If
+ * detected, it will retrieve the model class from the configured scope, then 
provide it to the Action.
+ *  
+ * <!-- END SNIPPET: description -->
+ *
+ * <p/> <u>Interceptor parameters:</u>
+ *
+ * <!-- START SNIPPET: parameters -->
+ *
+ * <ul>
+ *
+ * <li>className - The model class name.  Defaults to the class name of the 
object returned by the getModel() method.</li>
+ *            
+ * <li>name - The key to use when storing or retrieving the instance in a 
scope.  Defaults to the model
+ *            class name.</li>
+ *
+ * <li>scope - The scope to store and retrieve the model.  Defaults to 
'request' but can also be 'session'.</li>
+ * </ul>
+ *
+ * <!-- END SNIPPET: parameters -->
+ *
+ * <p/> <u>Extending the interceptor:</u>
+ *
+ * <p/>
+ *
+ * <!-- START SNIPPET: extending -->
+ *
+ * There are no known extension points for this interceptor.
+ *
+ * <!-- END SNIPPET: extending -->
+ *
+ * <p/> <u>Example code:</u>
+ *
+ * <pre>
+ * <!-- START SNIPPET: example -->
+ * 
+ * &lt;-- Basic ussage --&gt;
+ * lt;interceptor name="scopedModelDriven" 
class="org.apache.struts2.legacy.ScopedModelDrivenInterceptor" /gt;
+ * 
+ * &lt;-- Using all available parameters --&gt;
+ * lt;interceptor name="gangsterForm" 
class="org.apache.struts2.legacy.ScopedModelDrivenInterceptor"gt;
+ *      lt;param name="scope"gt;sessionlt;/paramgt;
+ *      lt;param name="name"gt;gangsterFormlt;/paramgt;
+ *      lt;param 
name="className"gt;org.apache.struts2.showcase.legacy.GangsterFormlt;/paramgt;
+ *  lt;/interceptorgt;
+ * 
+ * <!-- END SNIPPET: example -->
+ * </pre>
  */
-public class ScopedModelDrivenInterceptor extends ModelDrivenInterceptor {
+public class ScopedModelDrivenInterceptor extends AbstractInterceptor {
 
-    protected void after(ActionInvocation dispatcher, String result) throws 
Exception {
+    private static final String GET_MODEL = "getModel";
+    private String scope;
+    private String name;
+    private String className;
+    
+    protected Object resolveModel(ObjectFactory factory, Map session, String 
modelClassName, String modelScope, String modelName) throws Exception {
+        Object model = null;
+        if (modelName == null) {
+            modelName = modelClassName;
+        }
+        if ("session".equals(modelScope)) {
+            model = session.get(modelName);
+            if (model == null) {
+                model = factory.buildBean(modelClassName, null);
+                session.put(modelName, model);
+            }
+        } else {
+            model = factory.buildBean(modelClassName, null);
+        }
+        return model;
     }
 
-    protected void before(ActionInvocation invocation) throws Exception {
+    public String intercept(ActionInvocation invocation) throws Exception {
         Object action = invocation.getAction();
 
         if (action instanceof ScopedModelDriven) {
             ScopedModelDriven modelDriven = (ScopedModelDriven) action;
-            ActionContext ctx = ActionContext.getContext();
-            ActionConfig config = invocation.getProxy().getConfig();
-            String scope = (String)config.getParams().get("modelScope");
-            String attr = (String)config.getParams().get("modelName");
-            String clsName = (String)config.getParams().get("modelClass");
-           
-            Object model = resolveModel(ObjectFactory.getObjectFactory(), 
ctx.getSession(), clsName, scope, attr);
-            modelDriven.setModel(model);
+            if (modelDriven.getModel() == null) {
+                ActionContext ctx = ActionContext.getContext();
+                ActionConfig config = invocation.getProxy().getConfig();
+                
+                String cName = className;
+                if (cName == null) {
+                    try {
+                        Method method = action.getClass().getMethod(GET_MODEL, 
new Class[0]);
+                        Class cls = method.getReturnType();
+                        cName = cls.getName();
+                    } catch (NoSuchMethodException e) {
+                        throw new IllegalArgumentException("The " + GET_MODEL 
+ "() is not defined in action " + action.getClass() + "");
+                    }
+                }
+                Object model = resolveModel(ObjectFactory.getObjectFactory(), 
ctx.getSession(), cName, scope, name);
+                modelDriven.setModel(model);
+            }
         }
-        super.before(invocation);
+        return invocation.invoke();
     }
 
-    protected Object resolveModel(ObjectFactory factory, Map session, String 
className, String scope, String name) throws Exception {
-        Object model = null;
-        if ("session".equals(scope)) {
-            model = session.get(name);
-            if (model == null) {
-                model = factory.buildBean(className, null);
-                session.put(name, model);
-            }
-        } else {
-            model = factory.buildBean(className, null);
-        }
-        return model;
+    /**
+     * @param className the className to set
+     */
+    public void setClassName(String className) {
+        this.className = className;
+    }
+
+    /**
+     * @param name the name to set
+     */
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    /**
+     * @param scope the scope to set
+     */
+    public void setScope(String scope) {
+        this.scope = scope;
     }    
-                    
 }

Copied: 
struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/StrutsFactory.java
 (from r449318, 
struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/StrutsFactory.java)
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/StrutsFactory.java?view=diff&rev=449350&p1=struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/StrutsFactory.java&r1=449318&p2=struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/StrutsFactory.java&r2=449350
==============================================================================
--- 
struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/StrutsFactory.java
 (original)
+++ 
struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/StrutsFactory.java
 Sat Sep 23 21:09:38 2006
@@ -16,12 +16,13 @@
  *
  */
 
-package org.apache.ti.legacy;
+package org.apache.struts2.legacy;
 
-import com.opensymphony.xwork.*;
-import com.opensymphony.xwork.config.entities.ActionConfig;
-import com.opensymphony.xwork.config.entities.ResultConfig;
-import com.opensymphony.xwork.config.entities.ExceptionMappingConfig;
+import com.opensymphony.xwork2.*;
+import com.opensymphony.xwork2.config.Configuration;
+import com.opensymphony.xwork2.config.entities.ActionConfig;
+import com.opensymphony.xwork2.config.entities.ResultConfig;
+import com.opensymphony.xwork2.config.entities.ExceptionMappingConfig;
 import org.apache.struts.action.*;
 import org.apache.struts.config.*;
 
@@ -34,19 +35,13 @@
  *  classes.
  */
 public class StrutsFactory {
-    private static StrutsFactory FACTORY = new StrutsFactory();
+    
+    private Configuration configuration;
 
-    protected StrutsFactory() {
+    public StrutsFactory(Configuration config) {
+        this.configuration = config;
     }
-
-    public static void setStrutsFactory(StrutsFactory factory) {
-        FACTORY = factory;
-    }
-
-    public static StrutsFactory getStrutsFactory() {
-        return FACTORY;
-    }
-
+    
     /**
      * Create a Struts 1.x ModuleConfig based on an XWork package 
configuration.
      * 
@@ -56,7 +51,7 @@
      */
     public ModuleConfig createModuleConfig(String packageName) {
         assert packageName != null;
-        return new WrapperModuleConfig(packageName);
+        return new WrapperModuleConfig(this, 
configuration.getPackageConfig(packageName));
     }
 
     /**
@@ -67,7 +62,7 @@
      */
     public ActionMapping createActionMapping(ActionConfig cfg) {
         assert cfg != null;
-        return new WrapperActionMapping(cfg);
+        return new WrapperActionMapping(this, cfg);
     }
 
     /**
@@ -82,7 +77,7 @@
     ActionMapping createActionMapping(ActionConfig cfg, String actionPath, 
ModuleConfig moduleConfig) {
         assert cfg != null;
         assert moduleConfig != null;
-        return new WrapperActionMapping(cfg, actionPath, moduleConfig);
+        return new WrapperActionMapping(this, cfg, actionPath, moduleConfig);
     }
 
     /**

Copied: 
struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/WrapperActionForward.java
 (from r449318, 
struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/WrapperActionForward.java)
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/WrapperActionForward.java?view=diff&rev=449350&p1=struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/WrapperActionForward.java&r1=449318&p2=struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/WrapperActionForward.java&r2=449350
==============================================================================
--- 
struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/WrapperActionForward.java
 (original)
+++ 
struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/WrapperActionForward.java
 Sat Sep 23 21:09:38 2006
@@ -15,10 +15,10 @@
  *
  * $Header:$
  */
-package org.apache.ti.legacy;
+package org.apache.struts2.legacy;
 
 import org.apache.struts.action.ActionForward;
-import com.opensymphony.xwork.config.entities.ResultConfig;
+import com.opensymphony.xwork2.config.entities.ResultConfig;
 
 /**
  * Wrapper for a Struts 1.x ActionForward based on an XWork ResultConfig.  
Using a wrapper object

Copied: 
struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/WrapperActionMapping.java
 (from r449318, 
struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/WrapperActionMapping.java)
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/WrapperActionMapping.java?view=diff&rev=449350&p1=struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/WrapperActionMapping.java&r1=449318&p2=struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/WrapperActionMapping.java&r2=449350
==============================================================================
--- 
struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/WrapperActionMapping.java
 (original)
+++ 
struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/WrapperActionMapping.java
 Sat Sep 23 21:09:38 2006
@@ -15,16 +15,16 @@
  *
  * $Header:$
  */
-package org.apache.ti.legacy;
+package org.apache.struts2.legacy;
 
 import org.apache.struts.action.ActionMapping;
 import org.apache.struts.action.ActionForward;
 import org.apache.struts.config.ModuleConfig;
 import org.apache.struts.config.ExceptionConfig;
 import org.apache.struts.config.ForwardConfig;
-import com.opensymphony.xwork.config.entities.ActionConfig;
-import com.opensymphony.xwork.config.entities.ResultConfig;
-import com.opensymphony.xwork.config.entities.ExceptionMappingConfig;
+import com.opensymphony.xwork2.config.entities.ActionConfig;
+import com.opensymphony.xwork2.config.entities.ResultConfig;
+import com.opensymphony.xwork2.config.entities.ExceptionMappingConfig;
 
 import java.util.Iterator;
 import java.util.Map;
@@ -39,15 +39,17 @@
 
     private ActionConfig delegate;
     private String actionPath;
+    private StrutsFactory strutsFactory;
 
-    public WrapperActionMapping(ActionConfig delegate) {
+    public WrapperActionMapping(StrutsFactory factory, ActionConfig delegate) {
         this.delegate = delegate;
+        this.strutsFactory = factory;
         forwards = null;
         exceptions = null;
     }
 
-    public WrapperActionMapping(ActionConfig delegate, String actionPath, 
ModuleConfig moduleConfig) {
-        this(delegate);
+    public WrapperActionMapping(StrutsFactory factory, ActionConfig delegate, 
String actionPath, ModuleConfig moduleConfig) {
+        this(factory, delegate);
         this.moduleConfig = moduleConfig;
         this.actionPath = actionPath;
     }
@@ -58,7 +60,6 @@
     private void initActionForwards() {
         if (forwards == null) {
             forwards = new HashMap();
-            StrutsFactory strutsFactory = StrutsFactory.getStrutsFactory();
             Map results = delegate.getResults();
             for (Iterator i = results.entrySet().iterator(); i.hasNext();) {
                 Map.Entry entry = (Map.Entry) i.next();
@@ -74,7 +75,6 @@
     private void initExceptionConfigs() {
         if (exceptions == null) {
             exceptions = new HashMap();
-            StrutsFactory strutsFactory = StrutsFactory.getStrutsFactory();
             List exceptionMappings = delegate.getExceptionMappings();
             for (Iterator i = exceptionMappings.iterator(); i.hasNext();) {
                 ExceptionConfig wrapper = 
strutsFactory.createExceptionConfig((ExceptionMappingConfig) i.next());
@@ -124,7 +124,6 @@
 
     public ModuleConfig getModuleConfig() {
         if (moduleConfig == null) {
-            StrutsFactory strutsFactory = StrutsFactory.getStrutsFactory();
             moduleConfig = 
strutsFactory.createModuleConfig(delegate.getPackageName());
         }
 

Copied: 
struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/WrapperExceptionConfig.java
 (from r449318, 
struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/WrapperExceptionConfig.java)
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/WrapperExceptionConfig.java?view=diff&rev=449350&p1=struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/WrapperExceptionConfig.java&r1=449318&p2=struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/WrapperExceptionConfig.java&r2=449350
==============================================================================
--- 
struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/WrapperExceptionConfig.java
 (original)
+++ 
struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/WrapperExceptionConfig.java
 Sat Sep 23 21:09:38 2006
@@ -15,9 +15,9 @@
  *
  * $Header:$
  */
-package org.apache.ti.legacy;
+package org.apache.struts2.legacy;
 
-import com.opensymphony.xwork.config.entities.ExceptionMappingConfig;
+import com.opensymphony.xwork2.config.entities.ExceptionMappingConfig;
 import org.apache.struts.config.ExceptionConfig;
 
 /**

Copied: 
struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/WrapperModuleConfig.java
 (from r449318, 
struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/WrapperModuleConfig.java)
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/WrapperModuleConfig.java?view=diff&rev=449350&p1=struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/WrapperModuleConfig.java&r1=449318&p2=struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/WrapperModuleConfig.java&r2=449350
==============================================================================
--- 
struts/sandbox/trunk/ti/phase1/jars/legacy/src/java/org/apache/ti/legacy/WrapperModuleConfig.java
 (original)
+++ 
struts/struts2/trunk/legacy/src/main/java/org/apache/struts2/legacy/WrapperModuleConfig.java
 Sat Sep 23 21:09:38 2006
@@ -15,25 +15,24 @@
  *
  * $Header:$
  */
-package org.apache.ti.legacy;
+package org.apache.struts2.legacy;
 
-import org.apache.struts.config.ModuleConfig;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.struts.config.ActionConfig;
 import org.apache.struts.config.ControllerConfig;
-import org.apache.struts.config.DataSourceConfig;
 import org.apache.struts.config.ExceptionConfig;
 import org.apache.struts.config.FormBeanConfig;
 import org.apache.struts.config.ForwardConfig;
 import org.apache.struts.config.MessageResourcesConfig;
+import org.apache.struts.config.ModuleConfig;
 import org.apache.struts.config.PlugInConfig;
-import org.apache.struts.config.ActionConfig;
-import com.opensymphony.xwork.config.ConfigurationManager;
-import com.opensymphony.xwork.config.entities.PackageConfig;
-import com.opensymphony.xwork.config.entities.ExceptionMappingConfig;
-import com.opensymphony.xwork.config.entities.ResultConfig;
 
-import java.util.Map;
-import java.util.Iterator;
-import java.util.HashMap;
+import com.opensymphony.xwork2.config.entities.ExceptionMappingConfig;
+import com.opensymphony.xwork2.config.entities.PackageConfig;
+import com.opensymphony.xwork2.config.entities.ResultConfig;
 
 /**
  * Wrapper for a Struts 1.x ModuleConfig based on an XWork PackageConfig.  
Using a wrapper object
@@ -41,13 +40,15 @@
  */
 class WrapperModuleConfig implements ModuleConfig {
 
+    private StrutsFactory strutsFactory;
     private PackageConfig delegate;
     private Map _actionMappings;
     private Map _exceptionConfigs;
     private Map _actionForwards;
 
-    public WrapperModuleConfig(String packageName) {
-        delegate = 
ConfigurationManager.getConfiguration().getPackageConfig(packageName);
+    public WrapperModuleConfig(StrutsFactory factory, PackageConfig config) {
+        delegate = config;
+        this.strutsFactory = factory;
     }
 
     /**
@@ -57,12 +58,11 @@
 
         if (_actionMappings == null) {
             _actionMappings = new HashMap();
-            StrutsFactory strutsFactory = StrutsFactory.getStrutsFactory();
             for (Iterator i = 
delegate.getActionConfigs().entrySet().iterator(); i.hasNext();) {
                 Map.Entry entry = (Map.Entry) i.next();
                 String actionPath = '/' + (String) entry.getKey();
-                com.opensymphony.xwork.config.entities.ActionConfig 
actionConfig =
-                        (com.opensymphony.xwork.config.entities.ActionConfig) 
entry.getValue();
+                com.opensymphony.xwork2.config.entities.ActionConfig 
actionConfig =
+                        (com.opensymphony.xwork2.config.entities.ActionConfig) 
entry.getValue();
                 _actionMappings.put(actionPath, 
strutsFactory.createActionMapping(actionConfig, actionPath, this));
             }
         }
@@ -74,7 +74,6 @@
     private void initExceptionConfigs() {
         if (_exceptionConfigs == null) {
             _exceptionConfigs = new HashMap();
-            StrutsFactory strutsFactory = StrutsFactory.getStrutsFactory();
             for (Iterator i = 
delegate.getGlobalExceptionMappingConfigs().iterator(); i.hasNext();) {
                 ExceptionMappingConfig config = (ExceptionMappingConfig) 
i.next();
                 _exceptionConfigs.put(config.getExceptionClassName(), 
strutsFactory.createExceptionConfig(config));
@@ -88,7 +87,6 @@
     private void initActionForwards() {
         if (_actionForwards == null) {
             _actionForwards = new HashMap();
-            StrutsFactory strutsFactory = StrutsFactory.getStrutsFactory();
             for (Iterator i = 
delegate.getGlobalResultConfigs().entrySet().iterator(); i.hasNext();) {
                 Map.Entry entry = (Map.Entry) i.next();
                 String name = (String) entry.getKey();
@@ -138,10 +136,6 @@
         throw new UnsupportedOperationException("Not implemented - immutable");
     }
 
-    public void addDataSourceConfig(DataSourceConfig config) {
-        throw new UnsupportedOperationException("Not implemented - immutable");
-    }
-
     public void addExceptionConfig(ExceptionConfig config) {
         throw new UnsupportedOperationException("Not implemented - immutable");
     }
@@ -180,14 +174,6 @@
         return (ActionConfig[]) _actionMappings.values().toArray(new 
ActionConfig[_actionMappings.size()]);
     }
 
-    public DataSourceConfig findDataSourceConfig(String key) {
-        throw new UnsupportedOperationException("NYI");
-    }
-
-    public DataSourceConfig[] findDataSourceConfigs() {
-        throw new UnsupportedOperationException("NYI");
-    }
-
     public ExceptionConfig findExceptionConfig(String type) {
         initExceptionConfigs();
         return (ExceptionConfig) _exceptionConfigs.get(type);
@@ -240,10 +226,6 @@
         throw new UnsupportedOperationException("Not implemented - immutable");
     }
 
-    public void removeDataSourceConfig(DataSourceConfig config) {
-        throw new UnsupportedOperationException("Not implemented - immutable");
-    }
-
     public void removeFormBeanConfig(FormBeanConfig config) {
         throw new UnsupportedOperationException("Not implemented - immutable");
     }
@@ -254,5 +236,9 @@
 
     public void removeMessageResourcesConfig(MessageResourcesConfig config) {
         throw new UnsupportedOperationException("Not implemented - immutable");
+    }
+
+    public ExceptionConfig findException(Class arg0) {
+        throw new UnsupportedOperationException("NYI");
     }
 }





--- End Message ---
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to