com.baidu.unbiz.fluentvalidator.interceptor
类 FluentValidateInterceptor

java.lang.Object
  继承者 com.baidu.unbiz.fluentvalidator.interceptor.FluentValidateInterceptor
所有已实现的接口:
org.aopalliance.aop.Advice, org.aopalliance.intercept.Interceptor, org.aopalliance.intercept.MethodInterceptor, org.springframework.beans.factory.Aware, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware

public class FluentValidateInterceptor
extends Object
implements org.aopalliance.intercept.MethodInterceptor, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware

与Spring集成的拦截器,结合FluentValid注解装饰在参数前面,可以利用AOP来拦截请求,对参数进行校验

作者:
zhangxu

构造方法摘要
FluentValidateInterceptor()
           
 
方法摘要
 void afterPropertiesSet()
           
 Object invoke(org.aopalliance.intercept.MethodInvocation invocation)
          拦截方法进行验证,如果参数前面存在FluentValid注解,则进行校验,分一下三中情况: 1.
 void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
           
 void setCallback(ValidateCallback callback)
           
 void setFluentValidatorPostProcessor(FluentValidatorPostProcessor fluentValidatorPostProcessor)
           
 void setHibernateDefaultErrorCode(int hibernateDefaultErrorCode)
           
 void setLocale(String locale)
           
 void setValidator(javax.validation.Validator validator)
           
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

FluentValidateInterceptor

public FluentValidateInterceptor()
方法详细信息

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
指定者:
接口 org.springframework.beans.factory.InitializingBean 中的 afterPropertiesSet
抛出:
Exception

invoke

public Object invoke(org.aopalliance.intercept.MethodInvocation invocation)
              throws Throwable
拦截方法进行验证,如果参数前面存在FluentValid注解,则进行校验,分一下三中情况:

注:
1) 如果参数上的注解FluentValid设置了value,则value上的验证器先验证。 2) hibernate validator次先校验,然后才是级联验证

指定者:
接口 org.aopalliance.intercept.MethodInterceptor 中的 invoke
参数:
invocation - 调用
返回:
返回对象
抛出:
Throwable

setCallback

public void setCallback(ValidateCallback callback)

setApplicationContext

public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
                           throws org.springframework.beans.BeansException
指定者:
接口 org.springframework.context.ApplicationContextAware 中的 setApplicationContext
抛出:
org.springframework.beans.BeansException

setValidator

public void setValidator(javax.validation.Validator validator)

setLocale

public void setLocale(String locale)

setHibernateDefaultErrorCode

public void setHibernateDefaultErrorCode(int hibernateDefaultErrorCode)

setFluentValidatorPostProcessor

public void setFluentValidatorPostProcessor(FluentValidatorPostProcessor fluentValidatorPostProcessor)


Copyright © 2015–2017 neoremind. All rights reserved.