📄 portletstateinterceptor.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: PortletStateInterceptor.java
package org.apache.struts2.portlet.interceptor;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import com.opensymphony.xwork2.util.*;
import java.util.Map;
import javax.portlet.ActionResponse;
import javax.portlet.RenderRequest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.portlet.PortletActionConstants;
import org.apache.struts2.portlet.dispatcher.DirectRenderFromEventAction;
public class PortletStateInterceptor extends AbstractInterceptor
implements PortletActionConstants
{
private static final Log LOG = LogFactory.getLog(org/apache/struts2/portlet/interceptor/PortletStateInterceptor);
private static final long serialVersionUID = 0x553029a0f2f939e8L;
public PortletStateInterceptor()
{
}
public String intercept(ActionInvocation invocation)
throws Exception
{
Integer phase = (Integer)invocation.getInvocationContext().get("struts.portlet.phase");
if (RENDER_PHASE.equals(phase))
{
restoreStack(invocation);
return invocation.invoke();
}
if (!EVENT_PHASE.equals(phase))
break MISSING_BLOCK_LABEL_71;
String s = invocation.invoke();
saveStack(invocation);
return s;
Exception exception;
exception;
saveStack(invocation);
throw exception;
return invocation.invoke();
}
private void saveStack(ActionInvocation invocation)
{
Map session = invocation.getInvocationContext().getSession();
session.put("struts.portlet.valueStackFromEventPhase", invocation.getStack());
ActionResponse actionResponse = (ActionResponse)invocation.getInvocationContext().get("struts.portlet.response");
actionResponse.setRenderParameter("struts.portlet.eventAction", "true");
}
private void restoreStack(ActionInvocation invocation)
{
RenderRequest request = (RenderRequest)invocation.getInvocationContext().get("struts.portlet.request");
if (TextUtils.stringSet(request.getParameter("struts.portlet.eventAction")))
{
Map session = invocation.getInvocationContext().getSession();
if (!isProperPrg(invocation))
{
LOG.debug("Restoring value stack from event phase");
ValueStack oldStack = (ValueStack)invocation.getInvocationContext().getSession().get("struts.portlet.valueStackFromEventPhase");
if (oldStack != null)
{
CompoundRoot oldRoot = oldStack.getRoot();
ValueStack currentStack = invocation.getStack();
CompoundRoot root = currentStack.getRoot();
root.addAll(oldRoot);
LOG.debug("Restored stack");
}
} else
{
LOG.debug("Won't restore stack from event phase since it's a proper PRG request");
}
}
}
private boolean isProperPrg(ActionInvocation invocation)
{
return !(invocation.getAction() instanceof DirectRenderFromEventAction);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -