mirror of
https://github.com/apache/struts.git
synced 2026-08-11 01:27:14 +00:00
Updates classes to use the new version of Dispatcher's methods without ServletContext
This commit is contained in:
@@ -32,22 +32,16 @@ import org.apache.struts2.dispatcher.ApplicationMap;
|
||||
import org.apache.struts2.dispatcher.Dispatcher;
|
||||
import org.apache.struts2.dispatcher.RequestMap;
|
||||
import org.apache.struts2.dispatcher.SessionMap;
|
||||
import org.apache.struts2.dispatcher.mapper.ActionMapper;
|
||||
import org.apache.struts2.dispatcher.mapper.ActionMapping;
|
||||
|
||||
import uk.ltd.getahead.dwr.WebContextFactory;
|
||||
|
||||
import com.opensymphony.xwork2.Action;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.ActionProxy;
|
||||
import com.opensymphony.xwork2.ActionProxyFactory;
|
||||
import com.opensymphony.xwork2.DefaultActionInvocation;
|
||||
import com.opensymphony.xwork2.ValidationAware;
|
||||
import com.opensymphony.xwork2.ValidationAwareSupport;
|
||||
import com.opensymphony.xwork2.config.Configuration;
|
||||
import com.opensymphony.xwork2.config.entities.ActionConfig;
|
||||
import com.opensymphony.xwork2.config.entities.PackageConfig;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
@@ -69,8 +63,9 @@ import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
* </pre>
|
||||
*/
|
||||
public class DWRValidator {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(DWRValidator.class);
|
||||
|
||||
|
||||
public ValidationAwareSupport doPost(String namespace, String actionName, Map params) throws Exception {
|
||||
HttpServletRequest req = WebContextFactory.get().getHttpServletRequest();
|
||||
ServletContext servletContext = WebContextFactory.get().getServletContext();
|
||||
@@ -91,8 +86,7 @@ public class DWRValidator {
|
||||
session,
|
||||
application,
|
||||
req,
|
||||
res,
|
||||
servletContext);
|
||||
res);
|
||||
|
||||
try {
|
||||
ActionProxyFactory actionProxyFactory = du.getContainer().getInstance(ActionProxyFactory.class);
|
||||
|
||||
+4
-3
@@ -184,6 +184,7 @@ public class Jsr168Dispatcher extends GenericPortlet implements StrutsStatics {
|
||||
private Dispatcher dispatcherUtils;
|
||||
private ActionMapper actionMapper;
|
||||
private Container container;
|
||||
private ServletContext servletContext;
|
||||
|
||||
/**
|
||||
* Initialize the portlet with the init parameters from <tt>portlet.xml</tt>
|
||||
@@ -201,7 +202,8 @@ public class Jsr168Dispatcher extends GenericPortlet implements StrutsStatics {
|
||||
params.put(name, value);
|
||||
}
|
||||
|
||||
dispatcherUtils = new Dispatcher(new PortletServletContext(cfg.getPortletContext()), params);
|
||||
servletContext = new PortletServletContext(cfg.getPortletContext());
|
||||
dispatcherUtils = new Dispatcher(servletContext, params);
|
||||
dispatcherUtils.init();
|
||||
|
||||
// For testability
|
||||
@@ -428,11 +430,10 @@ public class Jsr168Dispatcher extends GenericPortlet implements StrutsStatics {
|
||||
String actionName = null;
|
||||
String namespace;
|
||||
try {
|
||||
ServletContext servletContext = new PortletServletContext(getPortletContext());
|
||||
HttpServletRequest servletRequest = new PortletServletRequest(request, getPortletContext());
|
||||
HttpServletResponse servletResponse = createPortletServletResponse(response);
|
||||
if (phase.isAction()) {
|
||||
servletRequest = dispatcherUtils.wrapRequest(servletRequest, servletContext);
|
||||
servletRequest = dispatcherUtils.wrapRequest(servletRequest);
|
||||
if (servletRequest instanceof MultiPartRequestWrapper) {
|
||||
// Multipart request. Request parameters are encoded in the multipart data,
|
||||
// so we need to manually add them to the parameter map.
|
||||
|
||||
+1
-1
@@ -97,7 +97,7 @@ public abstract class OldDecorator2NewStrutsDecorator extends BaseWebAppDecorato
|
||||
if (ctx == null) {
|
||||
// ok, one isn't associated with the request, so let's create one using the current Dispatcher
|
||||
ValueStack vs = Dispatcher.getInstance().getContainer().getInstance(ValueStackFactory.class).createValueStack();
|
||||
vs.getContext().putAll(Dispatcher.getInstance().createContextMap(request, response, null, servletContext));
|
||||
vs.getContext().putAll(Dispatcher.getInstance().createContextMap(request, response, null));
|
||||
ctx = new ActionContext(vs.getContext());
|
||||
if (ctx.getActionInvocation() == null) {
|
||||
// put in a dummy ActionSupport so basic functionality still works
|
||||
|
||||
Reference in New Issue
Block a user