mirror of
https://github.com/apache/struts.git
synced 2026-08-11 01:27:14 +00:00
Better handling of action context creation
WW-2203 git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@579021 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -162,7 +162,11 @@ public class StrutsXmlConfigurationProvider extends XmlConfigurationProvider {
|
||||
@Override
|
||||
public boolean needsReload() {
|
||||
ActionContext ctx = ActionContext.getContext();
|
||||
return ctx.get(reloadKey) == null && super.needsReload();
|
||||
if (ctx != null) {
|
||||
return ctx.get(reloadKey) == null && super.needsReload();
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,8 @@ import org.apache.struts2.dispatcher.mapper.ActionMapping;
|
||||
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.util.ClassLoaderUtil;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.util.ValueStackFactory;
|
||||
import com.opensymphony.xwork2.util.profiling.UtilTimerStack;
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
|
||||
@@ -386,6 +388,12 @@ public class FilterDispatcher implements StrutsStatics, Filter {
|
||||
|
||||
String timerKey = "FilterDispatcher_doFilter: ";
|
||||
try {
|
||||
|
||||
// FIXME: this should be refactored better to not duplicate work with the action invocation
|
||||
ValueStack stack = dispatcher.getContainer().getInstance(ValueStackFactory.class).createValueStack();
|
||||
ActionContext ctx = new ActionContext(stack.getContext());
|
||||
ActionContext.setContext(ctx);
|
||||
|
||||
UtilTimerStack.push(timerKey);
|
||||
request = prepareDispatcherAndWrapRequest(request, response);
|
||||
ActionMapping mapping;
|
||||
|
||||
@@ -62,26 +62,27 @@ public class StrutsRequestWrapper extends HttpServletRequestWrapper {
|
||||
|
||||
ActionContext ctx = ActionContext.getContext();
|
||||
Object attribute = super.getAttribute(s);
|
||||
|
||||
if (attribute == null) {
|
||||
boolean alreadyIn = false;
|
||||
Boolean b = (Boolean) ctx.get("__requestWrapper.getAttribute");
|
||||
if (b != null) {
|
||||
alreadyIn = b.booleanValue();
|
||||
}
|
||||
|
||||
// note: we don't let # come through or else a request for
|
||||
// #attr.foo or #request.foo could cause an endless loop
|
||||
if (!alreadyIn && s.indexOf("#") == -1) {
|
||||
try {
|
||||
// If not found, then try the ValueStack
|
||||
ctx.put("__requestWrapper.getAttribute", Boolean.TRUE);
|
||||
ValueStack stack = ctx.getValueStack();
|
||||
if (stack != null) {
|
||||
attribute = stack.findValue(s);
|
||||
if (ctx != null) {
|
||||
if (attribute == null) {
|
||||
boolean alreadyIn = false;
|
||||
Boolean b = (Boolean) ctx.get("__requestWrapper.getAttribute");
|
||||
if (b != null) {
|
||||
alreadyIn = b.booleanValue();
|
||||
}
|
||||
|
||||
// note: we don't let # come through or else a request for
|
||||
// #attr.foo or #request.foo could cause an endless loop
|
||||
if (!alreadyIn && s.indexOf("#") == -1) {
|
||||
try {
|
||||
// If not found, then try the ValueStack
|
||||
ctx.put("__requestWrapper.getAttribute", Boolean.TRUE);
|
||||
ValueStack stack = ctx.getValueStack();
|
||||
if (stack != null) {
|
||||
attribute = stack.findValue(s);
|
||||
}
|
||||
} finally {
|
||||
ctx.put("__requestWrapper.getAttribute", Boolean.FALSE);
|
||||
}
|
||||
} finally {
|
||||
ctx.put("__requestWrapper.getAttribute", Boolean.FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user