mirror of
https://github.com/apache/struts.git
synced 2026-08-06 15:17:00 +00:00
WW-4873 Makes ActionInvocation not serializable
This commit is contained in:
@@ -21,8 +21,6 @@ package com.opensymphony.xwork2;
|
||||
import com.opensymphony.xwork2.interceptor.PreResultListener;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* An {@link ActionInvocation} represents the execution state of an {@link Action}. It holds the Interceptors and the Action instance.
|
||||
* By repeated re-entrant execution of the <code>invoke()</code> method, initially by the {@link ActionProxy}, then by the Interceptors, the
|
||||
@@ -31,7 +29,7 @@ import java.io.Serializable;
|
||||
* @author Jason Carreira
|
||||
* @see com.opensymphony.xwork2.ActionProxy
|
||||
*/
|
||||
public interface ActionInvocation extends Serializable {
|
||||
public interface ActionInvocation {
|
||||
|
||||
/**
|
||||
* Get the Action associated with this ActionInvocation.
|
||||
@@ -178,20 +176,4 @@ public interface ActionInvocation extends Serializable {
|
||||
|
||||
void init(ActionProxy proxy) ;
|
||||
|
||||
/**
|
||||
* Prepares instance of ActionInvocation to be serializable,
|
||||
* which simple means removing all unserializable fields, eg. Container
|
||||
*
|
||||
* @return ActionInvocation which can be serialize (eg. into HttpSession)
|
||||
*/
|
||||
ActionInvocation serialize();
|
||||
|
||||
/**
|
||||
* Performs opposite process to restore back ActionInvocation after deserialisation
|
||||
*
|
||||
* @param actionContext current {@link ActionContext}
|
||||
* @return fully operational ActionInvocation
|
||||
*/
|
||||
ActionInvocation deserialize(ActionContext actionContext);
|
||||
|
||||
}
|
||||
|
||||
@@ -500,27 +500,4 @@ public class DefaultActionInvocation implements ActionInvocation {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Version ready to be serialize
|
||||
*
|
||||
* @return instance without reference to {@link Container}
|
||||
*/
|
||||
public ActionInvocation serialize() {
|
||||
DefaultActionInvocation that = this;
|
||||
that.container = null;
|
||||
return that;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restoring Container
|
||||
*
|
||||
* @param actionContext current {@link ActionContext}
|
||||
* @return instance which can be used to invoke action
|
||||
*/
|
||||
public ActionInvocation deserialize(ActionContext actionContext) {
|
||||
DefaultActionInvocation that = this;
|
||||
that.container = actionContext.getContainer();
|
||||
return that;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -124,12 +124,4 @@ public class MockActionInvocation implements ActionInvocation {
|
||||
public void init(ActionProxy proxy) {
|
||||
}
|
||||
|
||||
public ActionInvocation serialize() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ActionInvocation deserialize(ActionContext actionContext) {
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class InvocationSessionStore {
|
||||
ValueStack stack = invocationContext.invocation.getStack();
|
||||
ActionContext.getContext().setValueStack(stack);
|
||||
|
||||
return invocationContext.invocation.deserialize(ActionContext.getContext());
|
||||
return invocationContext.invocation;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,7 +71,7 @@ public class InvocationSessionStore {
|
||||
* @param invocation the action invocation
|
||||
*/
|
||||
public static void storeInvocation(String key, String token, ActionInvocation invocation) {
|
||||
InvocationContext invocationContext = new InvocationContext(invocation.serialize(), token);
|
||||
InvocationContext invocationContext = new InvocationContext(invocation, token);
|
||||
Map invocationMap = getInvocationMap();
|
||||
invocationMap.put(key, invocationContext);
|
||||
setInvocationMap(invocationMap);
|
||||
|
||||
@@ -75,34 +75,6 @@ public class DefaultActionInvocationTest extends XWorkTestCase {
|
||||
assertTrue(mockInterceptor3.isExecuted());
|
||||
}
|
||||
|
||||
public void testSerialization() throws Exception {
|
||||
// given
|
||||
DefaultActionInvocation actionInvocation = new DefaultActionInvocation(new HashMap<String, Object>(), false);
|
||||
actionInvocation.setContainer(new MockContainer());
|
||||
|
||||
// when
|
||||
DefaultActionInvocation serializable = (DefaultActionInvocation) actionInvocation.serialize();
|
||||
|
||||
// then
|
||||
assertNull(actionInvocation.container);
|
||||
assertNull(serializable.container);
|
||||
}
|
||||
|
||||
public void testDeserialization() throws Exception {
|
||||
// given
|
||||
DefaultActionInvocation actionInvocation = new DefaultActionInvocation(new HashMap<String, Object>(), false);
|
||||
MockContainer mockContainer = new MockContainer();
|
||||
ActionContext.getContext().setContainer(mockContainer);
|
||||
|
||||
// when
|
||||
DefaultActionInvocation deserializable = (DefaultActionInvocation) actionInvocation.deserialize(ActionContext.getContext());
|
||||
|
||||
// then
|
||||
assertNotNull(actionInvocation.container);
|
||||
assertNotNull(deserializable.container);
|
||||
assertEquals(mockContainer, deserializable.container);
|
||||
}
|
||||
|
||||
public void testInvokingExistingExecuteMethod() throws Exception {
|
||||
// given
|
||||
DefaultActionInvocation dai = new DefaultActionInvocation(new HashMap<String, Object>(), false) {
|
||||
|
||||
-8
@@ -86,12 +86,4 @@ public class TestActionInvocation implements ActionInvocation {
|
||||
public void init(ActionProxy proxy) {
|
||||
}
|
||||
|
||||
public ActionInvocation serialize() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ActionInvocation deserialize(ActionContext actionContext) {
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -110,7 +110,6 @@ public class DWRValidator {
|
||||
}
|
||||
|
||||
public static class ValidatorActionInvocation extends DefaultActionInvocation {
|
||||
private static final long serialVersionUID = -7645433725470191275L;
|
||||
|
||||
protected ValidatorActionInvocation(Map<String, Object> extraContext, boolean pushAction) throws Exception {
|
||||
super(extraContext, pushAction);
|
||||
|
||||
@@ -556,8 +556,6 @@ public class JSONInterceptorTest extends StrutsTestCase {
|
||||
|
||||
class MockActionInvocationEx extends MockActionInvocation {
|
||||
|
||||
private static final long serialVersionUID = 3057703805130170757L;
|
||||
|
||||
private boolean invoked;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -46,8 +46,6 @@ import java.util.Map;
|
||||
*/
|
||||
public class RestActionInvocation extends DefaultActionInvocation {
|
||||
|
||||
private static final long serialVersionUID = 3485701178946428716L;
|
||||
|
||||
private static final Logger LOG = LogManager.getLogger(RestActionInvocation.class);
|
||||
|
||||
private ContentTypeHandlerManager handlerSelector;
|
||||
|
||||
-10
@@ -140,8 +140,6 @@ public abstract class OldDecorator2NewStrutsDecorator extends BaseWebAppDecorato
|
||||
|
||||
static class DummyActionInvocation implements ActionInvocation {
|
||||
|
||||
private static final long serialVersionUID = -4808072199157363028L;
|
||||
|
||||
ActionSupport action;
|
||||
|
||||
public DummyActionInvocation(ActionSupport action) {
|
||||
@@ -196,14 +194,6 @@ public abstract class OldDecorator2NewStrutsDecorator extends BaseWebAppDecorato
|
||||
public void init(ActionProxy proxy) {
|
||||
}
|
||||
|
||||
public ActionInvocation serialize() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public ActionInvocation deserialize(ActionContext actionContext) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user