⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 portletawareinterceptor.java

📁 struts 2 核心包 的源码 有错误是难免的
💻 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:   PortletAwareInterceptor.java

package org.apache.struts2.portlet.interceptor;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import javax.portlet.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.StrutsStatics;
import org.apache.struts2.interceptor.PrincipalAware;
import org.apache.struts2.portlet.PortletActionConstants;

// Referenced classes of package org.apache.struts2.portlet.interceptor:
//			PortletRequestAware, PortletResponseAware, PortletPrincipalProxy, PortletContextAware, 
//			PortletPreferencesAware, ServletPortletPreferences

public class PortletAwareInterceptor extends AbstractInterceptor
	implements PortletActionConstants, StrutsStatics
{

	private static final long serialVersionUID = 0x225e54785e8ef674L;
	private static final Log LOG = LogFactory.getLog(org/apache/struts2/portlet/interceptor/PortletAwareInterceptor);

	public PortletAwareInterceptor()
	{
	}

	public String intercept(ActionInvocation invocation)
		throws Exception
	{
		Object action = invocation.getAction();
		ActionContext context = invocation.getInvocationContext();
		if (action instanceof PortletRequestAware)
		{
			PortletRequest request = (PortletRequest)context.get("struts.portlet.request");
			((PortletRequestAware)action).setPortletRequest(request);
		}
		if (action instanceof PortletResponseAware)
		{
			PortletResponse response = (PortletResponse)context.get("struts.portlet.response");
			((PortletResponseAware)action).setPortletResponse(response);
		}
		if (action instanceof PrincipalAware)
		{
			PortletRequest request = (PortletRequest)context.get("struts.portlet.request");
			((PrincipalAware)action).setPrincipalProxy(new PortletPrincipalProxy(request));
		}
		if (action instanceof PortletContextAware)
		{
			PortletContext portletContext = (PortletContext)context.get("struts.portlet.context");
			((PortletContextAware)action).setPortletContext(portletContext);
		}
		if (action instanceof PortletPreferencesAware)
		{
			PortletRequest request = (PortletRequest)context.get("struts.portlet.request");
			if (request == null)
			{
				LOG.warn("This portlet preferences implementation should only be used during development");
				((PortletPreferencesAware)action).setPortletPreferences(new ServletPortletPreferences(ActionContext.getContext().getSession()));
			} else
			{
				((PortletPreferencesAware)action).setPortletPreferences(request.getPreferences());
			}
		}
		return invocation.invoke();
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -