annotationvalidationinterceptor.java

来自「struts 2 核心包 的源码 有错误是难免的」· Java 代码 · 共 62 行

JAVA
62
字号
// 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:   AnnotationValidationInterceptor.java

package org.apache.struts2.interceptor.validation;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.ActionProxy;
import com.opensymphony.xwork2.validator.ValidationInterceptor;
import java.lang.reflect.Method;

// Referenced classes of package org.apache.struts2.interceptor.validation:
//			SkipValidation

public class AnnotationValidationInterceptor extends ValidationInterceptor
{

	private static final long serialVersionUID = 0x192a0a0087f6f010L;

	public AnnotationValidationInterceptor()
	{
	}

	protected String doIntercept(ActionInvocation invocation)
		throws Exception
	{
		Object action = invocation.getAction();
		if (action != null)
		{
			Method method = getActionMethod(action.getClass(), invocation.getProxy().getMethod());
			SkipValidation skip = (SkipValidation)method.getAnnotation(org/apache/struts2/interceptor/validation/SkipValidation);
			if (skip != null)
				return invocation.invoke();
		}
		return super.doIntercept(invocation);
	}

	protected Method getActionMethod(Class actionClass, String methodName)
		throws NoSuchMethodException
	{
		Method method;
		try
		{
			method = actionClass.getMethod(methodName, new Class[0]);
		}
		catch (NoSuchMethodException e)
		{
			try
			{
				String altMethodName = (new StringBuilder()).append("do").append(methodName.substring(0, 1).toUpperCase()).append(methodName.substring(1)).toString();
				method = actionClass.getMethod(altMethodName, new Class[0]);
			}
			catch (NoSuchMethodException e1)
			{
				throw e;
			}
		}
		return method;
	}
}

⌨️ 快捷键说明

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