Class AbstractMethodValidationInterceptor
- java.lang.Object
-
- io.quarkus.hibernate.validator.runtime.interceptor.AbstractMethodValidationInterceptor
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
JaxrsEndPointValidationInterceptor,MethodValidationInterceptor,ResteasyReactiveEndPointValidationInterceptor
public abstract class AbstractMethodValidationInterceptor extends Object implements Serializable
NOTE: this is a copy of the interceptor present in hibernate-validator-cdi. For now, I prefer not depending on this artifact but this might change in the future.An interceptor which performs a validation of the Bean Validation constraints specified at the parameters and/or return values of intercepted methods using the method validation functionality provided by Hibernate Validator.
- Author:
- Gunnar Morling, Hardy Ferentschik
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description (package private) javax.enterprise.inject.Instance<javax.validation.Validator>validatorInstanceThe validator to be used for method validation.
-
Constructor Summary
Constructors Constructor Description AbstractMethodValidationInterceptor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidvalidateConstructorInvocation(javax.interceptor.InvocationContext ctx)Validates the Bean Validation constraints specified at the parameters and/or return value of the intercepted constructor.protected ObjectvalidateMethodInvocation(javax.interceptor.InvocationContext ctx)Validates the Bean Validation constraints specified at the parameters and/or return value of the intercepted method.
-
-
-
Field Detail
-
validatorInstance
@Inject javax.enterprise.inject.Instance<javax.validation.Validator> validatorInstance
The validator to be used for method validation.Although the concrete validator is not necessarily serializable (and HV's implementation indeed isn't) it is still alright to have it as non-transient field here. Upon passivation not the validator itself will be serialized, but the proxy injected here, which in turn is serializable.
Instanceis used to make the resolution dynamic and working at runtime, this delaysValidatorinjection enough to enable it to work for beans that observe@Initialized(ApplicationScoped.class)event.
-
-
Method Detail
-
validateMethodInvocation
protected Object validateMethodInvocation(javax.interceptor.InvocationContext ctx) throws Exception
Validates the Bean Validation constraints specified at the parameters and/or return value of the intercepted method.- Parameters:
ctx- The context of the intercepted method invocation.- Returns:
- The result of the method invocation.
- Throws:
Exception- Any exception caused by the intercepted method invocation. AConstraintViolationExceptionin case at least one constraint violation occurred either during parameter or return value validation.
-
validateConstructorInvocation
protected void validateConstructorInvocation(javax.interceptor.InvocationContext ctx) throws ExceptionValidates the Bean Validation constraints specified at the parameters and/or return value of the intercepted constructor.- Parameters:
ctx- The context of the intercepted constructor invocation.- Throws:
Exception- Any exception caused by the intercepted constructor invocation. AConstraintViolationExceptionin case at least one constraint violation occurred either during parameter or return value validation.
-
-