mirror of
https://github.com/apache/struts.git
synced 2026-08-07 15:46:57 +00:00
Matched action proxy handling to xwork changes
XW-440 git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@476642 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -41,7 +41,6 @@ import org.apache.struts2.views.jsp.TagUtils;
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionProxy;
|
||||
import com.opensymphony.xwork2.ActionProxyFactory;
|
||||
import com.opensymphony.xwork2.config.Configuration;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.util.ValueStackFactory;
|
||||
@@ -121,7 +120,6 @@ public class ActionComponent extends Component {
|
||||
protected HttpServletRequest req;
|
||||
|
||||
protected ActionProxyFactory actionProxyFactory;
|
||||
protected Configuration configuration;
|
||||
protected ActionProxy proxy;
|
||||
protected String name;
|
||||
protected String namespace;
|
||||
@@ -143,18 +141,6 @@ public class ActionComponent extends Component {
|
||||
this.actionProxyFactory = actionProxyFactory;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param configuration the configuration to set
|
||||
*/
|
||||
@Inject
|
||||
public void setConfiguration(Configuration configuration) {
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean end(Writer writer, String body) {
|
||||
boolean end = super.end(writer, "", false);
|
||||
try {
|
||||
@@ -259,7 +245,7 @@ public class ActionComponent extends Component {
|
||||
// execute at this point, after params have been set
|
||||
try {
|
||||
|
||||
proxy = actionProxyFactory.createActionProxy(configuration, namespace, actionName, createExtraContext(), executeResult, true);
|
||||
proxy = actionProxyFactory.createActionProxy(namespace, actionName, createExtraContext(), executeResult, true);
|
||||
if (null != methodName) {
|
||||
proxy.setMethod(methodName);
|
||||
}
|
||||
|
||||
@@ -431,7 +431,7 @@ public class Dispatcher {
|
||||
|
||||
Configuration config = configurationManager.getConfiguration();
|
||||
ActionProxy proxy = config.getContainer().getInstance(ActionProxyFactory.class).createActionProxy(
|
||||
config, namespace, name, extraContext, true, false);
|
||||
namespace, name, extraContext, true, false);
|
||||
proxy.setMethod(method);
|
||||
request.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, proxy.getInvocation().getStack());
|
||||
|
||||
|
||||
@@ -27,16 +27,14 @@ import java.util.concurrent.Callable;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.DefaultActionProxy;
|
||||
import com.opensymphony.xwork2.ObjectFactory;
|
||||
import com.opensymphony.xwork2.config.Configuration;
|
||||
|
||||
public class StrutsActionProxy extends DefaultActionProxy {
|
||||
|
||||
private static final long serialVersionUID = -2434901249671934080L;
|
||||
|
||||
public StrutsActionProxy(ObjectFactory objectFactory, Configuration cfg, String namespace, String actionName, Map extraContext,
|
||||
public StrutsActionProxy(String namespace, String actionName, Map extraContext,
|
||||
boolean executeResult, boolean cleanupContext) throws Exception {
|
||||
super(objectFactory, cfg, namespace, actionName, extraContext, executeResult, cleanupContext);
|
||||
super(namespace, actionName, extraContext, executeResult, cleanupContext);
|
||||
}
|
||||
|
||||
public String execute() throws Exception {
|
||||
|
||||
@@ -26,17 +26,19 @@ import java.util.Map;
|
||||
|
||||
import com.opensymphony.xwork2.ActionProxy;
|
||||
import com.opensymphony.xwork2.DefaultActionProxyFactory;
|
||||
import com.opensymphony.xwork2.config.Configuration;
|
||||
|
||||
public class StrutsActionProxyFactory extends DefaultActionProxyFactory {
|
||||
|
||||
public ActionProxy createActionProxy(Configuration config, String namespace, String actionName, Map extraContext)
|
||||
public ActionProxy createActionProxy(String namespace, String actionName, Map extraContext)
|
||||
throws Exception {
|
||||
return new StrutsActionProxy(objectFactory, config, namespace, actionName, extraContext, true, true);
|
||||
return createActionProxy(namespace, actionName, extraContext, true, true);
|
||||
}
|
||||
|
||||
public ActionProxy createActionProxy(Configuration config, String namespace, String actionName, Map extraContext,
|
||||
public ActionProxy createActionProxy(String namespace, String actionName, Map extraContext,
|
||||
boolean executeResult, boolean cleanupContext) throws Exception {
|
||||
return new StrutsActionProxy(objectFactory, config, namespace, actionName, extraContext, executeResult, cleanupContext);
|
||||
ActionProxy proxy = new StrutsActionProxy(namespace, actionName, extraContext, executeResult, cleanupContext);
|
||||
container.inject(proxy);
|
||||
proxy.prepare();
|
||||
return proxy;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -398,8 +398,7 @@ public class Jsr168Dispatcher extends GenericPortlet implements StrutsStatics,
|
||||
try {
|
||||
LOG.debug("Creating action proxy for name = " + actionName
|
||||
+ ", namespace = " + namespace);
|
||||
ActionProxy proxy = factory.createActionProxy(
|
||||
dispatcherUtils.getConfigurationManager().getConfiguration(), namespace,
|
||||
ActionProxy proxy = factory.createActionProxy(namespace,
|
||||
actionName, extraContext);
|
||||
request.setAttribute("struts.valueStack", proxy.getInvocation()
|
||||
.getStack());
|
||||
|
||||
@@ -41,6 +41,7 @@ import com.opensymphony.xwork2.ActionProxy;
|
||||
import com.opensymphony.xwork2.DefaultActionInvocation;
|
||||
import com.opensymphony.xwork2.DefaultActionProxy;
|
||||
import com.opensymphony.xwork2.ObjectFactory;
|
||||
import com.opensymphony.xwork2.UnknownHandler;
|
||||
import com.opensymphony.xwork2.ValidationAware;
|
||||
import com.opensymphony.xwork2.ValidationAwareSupport;
|
||||
import com.opensymphony.xwork2.config.Configuration;
|
||||
@@ -91,8 +92,9 @@ public class DWRValidator {
|
||||
|
||||
try {
|
||||
Configuration cfg = du.getConfigurationManager().getConfiguration();
|
||||
ObjectFactory of = cfg.getContainer().getInstance(ObjectFactory.class);
|
||||
ValidatorActionProxy proxy = new ValidatorActionProxy(of, cfg, namespace, action, ctx);
|
||||
ValidatorActionProxy proxy = new ValidatorActionProxy(namespace, action, ctx);
|
||||
cfg.getContainer().inject(proxy);
|
||||
proxy.prepare();
|
||||
proxy.execute();
|
||||
Object a = proxy.getAction();
|
||||
|
||||
@@ -116,8 +118,8 @@ public class DWRValidator {
|
||||
public static class ValidatorActionInvocation extends DefaultActionInvocation {
|
||||
private static final long serialVersionUID = -7645433725470191275L;
|
||||
|
||||
protected ValidatorActionInvocation(ObjectFactory objectFactory, ActionProxy proxy, Map extraContext) throws Exception {
|
||||
super(objectFactory, proxy, extraContext, true);
|
||||
protected ValidatorActionInvocation(ObjectFactory objectFactory, UnknownHandler handler, ActionProxy proxy, Map extraContext) throws Exception {
|
||||
super(objectFactory, handler, proxy, extraContext, true);
|
||||
}
|
||||
|
||||
protected String invokeAction(Object action, ActionConfig actionConfig) throws Exception {
|
||||
@@ -128,12 +130,13 @@ public class DWRValidator {
|
||||
public static class ValidatorActionProxy extends DefaultActionProxy {
|
||||
private static final long serialVersionUID = 5754781916414047963L;
|
||||
|
||||
protected ValidatorActionProxy(ObjectFactory objectFactory, Configuration config, String namespace, String actionName, Map extraContext) throws Exception {
|
||||
super(objectFactory, config, namespace, actionName, extraContext, false, true);
|
||||
protected ValidatorActionProxy(String namespace, String actionName, Map extraContext) throws Exception {
|
||||
super(namespace, actionName, extraContext, false, true);
|
||||
}
|
||||
|
||||
protected void prepare() throws Exception {
|
||||
invocation = new ValidatorActionInvocation(objectFactory, this, extraContext);
|
||||
public void prepare() throws Exception {
|
||||
super.prepare();
|
||||
invocation = new ValidatorActionInvocation(objectFactory, unknownHandler, this, extraContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-6
@@ -170,15 +170,11 @@ public class ExecuteAndWaitInterceptorTest extends StrutsTestCase {
|
||||
}
|
||||
|
||||
protected ActionProxy buildProxy(String actionName) throws Exception {
|
||||
return container.getInstance(ActionProxyFactory.class).createActionProxy(
|
||||
configurationManager.getConfiguration(), "", actionName, context);
|
||||
return actionProxyFactory.createActionProxy("", actionName, context);
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
configurationManager = new ConfigurationManager();
|
||||
configurationManager.addConfigurationProvider(new WaitConfigurationProvider());
|
||||
configurationManager.reload();
|
||||
container = configurationManager.getConfiguration().getContainer();
|
||||
loadConfigurationProviders(new WaitConfigurationProvider());
|
||||
|
||||
session = new HashMap();
|
||||
params = new HashMap();
|
||||
|
||||
@@ -107,10 +107,7 @@ public class TokenInterceptorTest extends StrutsTestCase {
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
configurationManager = new ConfigurationManager();
|
||||
configurationManager.addConfigurationProvider(new TestConfigurationProvider());
|
||||
configurationManager.reload();
|
||||
container = configurationManager.getConfiguration().getContainer();
|
||||
loadConfigurationProviders(new TestConfigurationProvider());
|
||||
|
||||
session = new HashMap();
|
||||
params = new HashMap();
|
||||
@@ -131,8 +128,7 @@ public class TokenInterceptorTest extends StrutsTestCase {
|
||||
}
|
||||
|
||||
protected ActionProxy buildProxy(String actionName) throws Exception {
|
||||
return container.getInstance(ActionProxyFactory.class).createActionProxy(
|
||||
configurationManager.getConfiguration(), "", actionName, extraContext, true, true);
|
||||
return actionProxyFactory.createActionProxy("", actionName, extraContext, true, true);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
|
||||
@@ -103,7 +103,7 @@ public class Jsr168DispatcherTest extends MockObjectTestCase implements PortletA
|
||||
mockActionProxy = mock(ActionProxy.class);
|
||||
mockInvocation = mock(ActionInvocation.class);
|
||||
|
||||
mockActionFactory.expects(once()).method("createActionProxy").with(new Constraint[]{isA(Configuration.class), eq(namespace), eq(actionName), isA(Map.class)}).will(returnValue(mockActionProxy.proxy()));
|
||||
mockActionFactory.expects(once()).method("createActionProxy").with(new Constraint[]{eq(namespace), eq(actionName), isA(Map.class)}).will(returnValue(mockActionProxy.proxy()));
|
||||
mockActionProxy.stubs().method("getAction").will(returnValue(mockAction.proxy()));
|
||||
mockActionProxy.expects(once()).method("execute").will(returnValue(result));
|
||||
mockActionProxy.expects(once()).method("getInvocation").will(returnValue(mockInvocation.proxy()));
|
||||
|
||||
Reference in New Issue
Block a user