📄 actioncomponent.java
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space
// Source File Name: ActionComponent.java
package org.apache.struts2.components;
import com.opensymphony.xwork2.*;
import com.opensymphony.xwork2.util.ValueStack;
import com.opensymphony.xwork2.util.ValueStackFactory;
import java.io.IOException;
import java.io.Writer;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.PageContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.StrutsException;
import org.apache.struts2.dispatcher.Dispatcher;
import org.apache.struts2.dispatcher.RequestMap;
import org.apache.struts2.views.jsp.TagUtils;
// Referenced classes of package org.apache.struts2.components:
// Component
public class ActionComponent extends Component
{
private static final Log LOG = LogFactory.getLog(org/apache/struts2/components/ActionComponent);
protected HttpServletResponse res;
protected HttpServletRequest req;
protected ActionProxyFactory actionProxyFactory;
protected ActionProxy proxy;
protected String name;
protected String namespace;
protected boolean executeResult;
protected boolean ignoreContextParams;
protected boolean flush;
public ActionComponent(ValueStack stack, HttpServletRequest req, HttpServletResponse res)
{
super(stack);
flush = true;
this.req = req;
this.res = res;
}
public void setActionProxyFactory(ActionProxyFactory actionProxyFactory)
{
this.actionProxyFactory = actionProxyFactory;
}
public boolean end(Writer writer, String body)
{
boolean end = super.end(writer, "", false);
if (flush)
try
{
writer.flush();
}
catch (IOException e)
{
LOG.warn("error while trying to flush writer ", e);
}
executeAction();
if (getId() != null && proxy != null)
getStack().setValue((new StringBuilder()).append("#attr['").append(getId()).append("']").toString(), proxy.getAction());
popComponentStack();
break MISSING_BLOCK_LABEL_116;
Exception exception;
exception;
popComponentStack();
throw exception;
return end;
}
private Map createExtraContext()
{
Map parentParams = null;
if (!ignoreContextParams)
parentParams = (new ActionContext(getStack().getContext())).getParameters();
Map newParams = parentParams == null ? ((Map) (new HashMap())) : ((Map) (new HashMap(parentParams)));
if (parameters != null)
newParams.putAll(parameters);
ActionContext ctx = new ActionContext(stack.getContext());
ServletContext servletContext = (ServletContext)ctx.get("com.opensymphony.xwork2.dispatcher.ServletContext");
PageContext pageContext = (PageContext)ctx.get("com.opensymphony.xwork2.dispatcher.PageContext");
Map session = ctx.getSession();
Map application = ctx.getApplication();
Dispatcher du = Dispatcher.getInstance();
Map extraContext = du.createContextMap(new RequestMap(req), newParams, session, application, req, res, servletContext);
ValueStack newStack = ValueStackFactory.getFactory().createValueStack(stack);
extraContext.put("com.opensymphony.xwork2.util.ValueStack.ValueStack", newStack);
extraContext.put("com.opensymphony.xwork2.dispatcher.PageContext", pageContext);
return extraContext;
}
public ActionProxy getProxy()
{
return proxy;
}
private void executeAction()
{
String actualName;
String actionName;
String methodName;
String namespace;
ValueStack stack;
actualName = findString(name, "name", "Action name is required. Example: updatePerson");
if (actualName == null)
throw new StrutsException((new StringBuilder()).append("Unable to find value for name ").append(name).toString());
int exclamation = actualName.lastIndexOf("!");
if (exclamation != -1)
{
actionName = actualName.substring(0, exclamation);
methodName = actualName.substring(exclamation + 1);
} else
{
actionName = actualName;
methodName = null;
}
if (this.namespace == null)
namespace = TagUtils.buildNamespace(actionMapper, getStack(), req);
else
namespace = findString(this.namespace);
stack = getStack();
proxy = actionProxyFactory.createActionProxy(namespace, actionName, createExtraContext(), executeResult, true);
if (null != methodName)
proxy.setMethod(methodName);
req.setAttribute("struts.valueStack", proxy.getInvocation().getStack());
proxy.execute();
req.setAttribute("struts.valueStack", stack);
break MISSING_BLOCK_LABEL_298;
Exception e;
e;
String message = (new StringBuilder()).append("Could not execute action: ").append(namespace).append("/").append(actualName).toString();
LOG.error(message, e);
req.setAttribute("struts.valueStack", stack);
break MISSING_BLOCK_LABEL_298;
Exception exception;
exception;
req.setAttribute("struts.valueStack", stack);
throw exception;
if (getId() != null && proxy != null)
{
Map context = stack.getContext();
context.put(getId(), proxy.getAction());
}
return;
}
public void setName(String name)
{
this.name = name;
}
public void setNamespace(String namespace)
{
this.namespace = namespace;
}
public void setExecuteResult(boolean executeResult)
{
this.executeResult = executeResult;
}
public void setIgnoreContextParams(boolean ignoreContextParams)
{
this.ignoreContextParams = ignoreContextParams;
}
public void setFlush(boolean flush)
{
this.flush = flush;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -