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

📄 executeandwaitinterceptor.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:   ExecuteAndWaitInterceptor.java

package org.apache.struts2.interceptor;

import com.opensymphony.xwork2.*;
import com.opensymphony.xwork2.config.entities.ActionConfig;
import com.opensymphony.xwork2.config.entities.ResultConfig;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;
import com.opensymphony.xwork2.util.ValueStack;
import java.util.Collections;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

// Referenced classes of package org.apache.struts2.interceptor:
//			BackgroundProcess

public class ExecuteAndWaitInterceptor extends MethodFilterInterceptor
{

	private static final long serialVersionUID = 0xd9c58e3ec95e9de0L;
	private static final Log LOG = LogFactory.getLog(org/apache/struts2/interceptor/ExecuteAndWaitInterceptor);
	public static final String KEY = "__execWait";
	public static final String WAIT = "wait";
	protected int delay;
	protected int delaySleepInterval;
	protected boolean executeAfterValidationPass;
	private int threadPriority;

	public ExecuteAndWaitInterceptor()
	{
		delaySleepInterval = 100;
		executeAfterValidationPass = false;
		threadPriority = 5;
	}

	public void init()
	{
	}

	protected BackgroundProcess getNewBackgroundProcess(String name, ActionInvocation actionInvocation, int threadPriority)
	{
		return new BackgroundProcess((new StringBuilder()).append(name).append("BackgroundThread").toString(), actionInvocation, threadPriority);
	}

	protected String getBackgroundProcessName(ActionProxy proxy)
	{
		return proxy.getActionName();
	}

	protected String doIntercept(ActionInvocation actionInvocation)
		throws Exception
	{
		ActionProxy proxy;
		String name;
		Map session;
		Boolean secondTime;
label0:
		{
			proxy = actionInvocation.getProxy();
			name = getBackgroundProcessName(proxy);
			ActionContext context = actionInvocation.getInvocationContext();
			session = context.getSession();
			secondTime = Boolean.valueOf(true);
			if (!executeAfterValidationPass)
				break label0;
			secondTime = (Boolean)context.get("__execWait");
			if (secondTime == null)
			{
				context.put("__execWait", Boolean.valueOf(true));
				secondTime = Boolean.valueOf(false);
				break label0;
			}
			secondTime = Boolean.valueOf(true);
			context.put("__execWait", null);
		}
		Map map = session;
		JVM INSTR monitorenter ;
		BackgroundProcess bp;
		bp = (BackgroundProcess)session.get((new StringBuilder()).append("__execWait").append(name).toString());
		if ((!executeAfterValidationPass || secondTime.booleanValue()) && bp == null)
		{
			bp = getNewBackgroundProcess(name, actionInvocation, threadPriority);
			session.put((new StringBuilder()).append("__execWait").append(name).toString(), bp);
			performInitialDelay(bp);
			secondTime = Boolean.valueOf(false);
		}
		if (executeAfterValidationPass && secondTime.booleanValue() || bp == null || bp.isDone())
			break MISSING_BLOCK_LABEL_317;
		actionInvocation.getStack().push(bp.getAction());
		Map results = proxy.getConfig().getResults();
		if (!results.containsKey("wait"))
		{
			LOG.warn("ExecuteAndWait interceptor has detected that no result named 'wait' is available. Defaulting to a plain built-in wait page. It is highly recommend you provide an action-specific or global result named 'wait'! This requires FreeMarker support and won't work if you don't have it installed");
			ResultConfig rc = new ResultConfig("wait", "org.apache.struts2.views.freemarker.FreemarkerResult", Collections.singletonMap("location", "/org/apache/struts2/interceptor/wait.ftl"));
			results.put("wait", rc);
		}
		return "wait";
		if (executeAfterValidationPass && secondTime.booleanValue() || bp == null || !bp.isDone()) goto _L2; else goto _L1
_L1:
		session.remove((new StringBuilder()).append("__execWait").append(name).toString());
		actionInvocation.getStack().push(bp.getAction());
		if (bp.getException() != null)
			throw bp.getException();
		bp.getResult();
		map;
		JVM INSTR monitorexit ;
		return;
_L2:
		actionInvocation.invoke();
		map;
		JVM INSTR monitorexit ;
		return;
		Exception exception;
		exception;
		throw exception;
	}

	public void destroy()
	{
	}

	protected void performInitialDelay(BackgroundProcess bp)
		throws InterruptedException
	{
		if (delay <= 0 || delaySleepInterval <= 0)
			return;
		int steps = delay / delaySleepInterval;
		if (LOG.isDebugEnabled())
			LOG.debug((new StringBuilder()).append("Delaying for ").append(delay).append(" millis. (using ").append(steps).append(" steps)").toString());
		int step;
		for (step = 0; step < steps && !bp.isDone(); step++)
			Thread.sleep(delaySleepInterval);

		if (LOG.isDebugEnabled())
			LOG.debug((new StringBuilder()).append("Sleeping ended after ").append(step).append(" steps and the background process is ").append(bp.isDone() ? " done" : " not done").toString());
	}

	public void setThreadPriority(int threadPriority)
	{
		this.threadPriority = threadPriority;
	}

	public void setDelay(int delay)
	{
		this.delay = delay;
	}

	public void setDelaySleepInterval(int delaySleepInterval)
	{
		this.delaySleepInterval = delaySleepInterval;
	}

	public void setExecuteAfterValidationPass(boolean executeAfterValidationPass)
	{
		this.executeAfterValidationPass = executeAfterValidationPass;
	}

}

⌨️ 快捷键说明

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