FileDocCategorySizeDatePackage
AnnotationValidationInterceptor.javaAPI DocExample2819Mon Jul 23 13:26:52 BST 2007org.apache.struts2.interceptor.validation

AnnotationValidationInterceptor

public class AnnotationValidationInterceptor extends com.opensymphony.xwork2.validator.ValidationInterceptor
Extends the xwork validation interceptor to also check for a @SkipValidation annotation, and if found, don't validate this action method

Fields Summary
private static final long
serialVersionUID
Auto-generated serialization id
Constructors Summary
Methods Summary
protected java.lang.StringdoIntercept(com.opensymphony.xwork2.ActionInvocation invocation)


          
        
        Object action = invocation.getAction();
        if (action != null) {
            Method method = getActionMethod(action.getClass(), invocation.getProxy().getMethod());
            SkipValidation skip = (SkipValidation) method.getAnnotation(SkipValidation.class);
            if (skip != null) {
                return invocation.invoke();
            }
        }
        
        return super.doIntercept(invocation);
    
protected java.lang.reflect.MethodgetActionMethod(java.lang.Class actionClass, java.lang.String methodName)

        Method method;
        try {
            method = actionClass.getMethod(methodName, new Class[0]);
        } catch (NoSuchMethodException e) {
            // hmm -- OK, try doXxx instead
            try {
                String altMethodName = "do" + methodName.substring(0, 1).toUpperCase() + methodName.substring(1);
                method = actionClass.getMethod(altMethodName, new Class[0]);
            } catch (NoSuchMethodException e1) {
                // throw the original one
                throw e;
            }
        }
        return method;