Search in sources :

Example 1 with ValidateOnExecution

use of javax.validation.executable.ValidateOnExecution in project tomee by apache.

the class BValInterceptor method computeIsConstructorValidated.

private <T> boolean computeIsConstructorValidated(Class<T> targetClass, Constructor<T> ctor) {
    final AnnotatedType<T> annotatedType = CDI.current().getBeanManager().createAnnotatedType(ctor.getDeclaringClass());
    final ValidateOnExecution annotation = annotatedType.getConstructors().stream().filter(ac -> ctor.equals(ac.getJavaMember())).findFirst().map(ac -> ac.getAnnotation(ValidateOnExecution.class)).orElseGet(() -> ctor.getAnnotation(ValidateOnExecution.class));
    final Set<ExecutableType> validatedExecutableTypes = annotation == null ? classConfiguration : ExecutableTypes.interpret(annotation.type());
    return validatedExecutableTypes.contains(ExecutableType.CONSTRUCTORS);
}
Also used : Reflection(org.apache.bval.util.reflection.Reflection) Arrays(java.util.Arrays) InvocationContext(javax.interceptor.InvocationContext) ObjectUtils(org.apache.bval.util.ObjectUtils) Proxies(org.apache.bval.jsr.util.Proxies) AnnotatedType(javax.enterprise.inject.spi.AnnotatedType) ExecutableValidator(javax.validation.executable.ExecutableValidator) Constructor(java.lang.reflect.Constructor) ConcurrentMap(java.util.concurrent.ConcurrentMap) Inject(javax.inject.Inject) Interceptor(javax.interceptor.Interceptor) MethodDescriptor(javax.validation.metadata.MethodDescriptor) BiPredicate(java.util.function.BiPredicate) Map(java.util.Map) Executable(java.lang.reflect.Executable) BValBinding(org.apache.bval.cdi.BValBinding) ConstraintViolation(javax.validation.ConstraintViolation) Method(java.lang.reflect.Method) ExecutableTypes(org.apache.bval.jsr.util.ExecutableTypes) EnumSet(java.util.EnumSet) BValExtension(org.apache.bval.cdi.BValExtension) Validate(org.apache.bval.util.Validate) Interfaces(org.apache.bval.util.reflection.Reflection.Interfaces) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) CDI(javax.enterprise.inject.spi.CDI) Validator(javax.validation.Validator) Set(java.util.Set) ConstructorDescriptor(javax.validation.metadata.ConstructorDescriptor) InterceptorBinding(javax.interceptor.InterceptorBinding) Serializable(java.io.Serializable) Methods(org.apache.bval.jsr.util.Methods) Priority(javax.annotation.Priority) AroundConstruct(javax.interceptor.AroundConstruct) List(java.util.List) ConstraintViolationException(javax.validation.ConstraintViolationException) ExecutableType(javax.validation.executable.ExecutableType) AroundInvoke(javax.interceptor.AroundInvoke) Optional(java.util.Optional) DescriptorManager(org.apache.bval.jsr.descriptor.DescriptorManager) Signature(org.apache.bval.jsr.metadata.Signature) Collections(java.util.Collections) AnnotatedMethod(javax.enterprise.inject.spi.AnnotatedMethod) ValidateOnExecution(javax.validation.executable.ValidateOnExecution) ExecutableType(javax.validation.executable.ExecutableType) ValidateOnExecution(javax.validation.executable.ValidateOnExecution)

Example 2 with ValidateOnExecution

use of javax.validation.executable.ValidateOnExecution in project cxf by apache.

the class AbstractValidationInterceptor method handleMessage.

@Override
public void handleMessage(Message message) {
    final Object theServiceObject = getServiceObject(message);
    if (theServiceObject == null) {
        return;
    }
    final Method method = getServiceMethod(message);
    if (method == null) {
        return;
    }
    ValidateOnExecution validateOnExec = method.getAnnotation(ValidateOnExecution.class);
    if (validateOnExec != null) {
        ExecutableType[] execTypes = validateOnExec.type();
        if (execTypes.length == 1 && execTypes[0] == ExecutableType.NONE) {
            return;
        }
    }
    final List<Object> arguments = MessageContentsList.getContentsList(message);
    handleValidation(message, theServiceObject, method, arguments);
}
Also used : ExecutableType(javax.validation.executable.ExecutableType) ValidateOnExecution(javax.validation.executable.ValidateOnExecution) Method(java.lang.reflect.Method)

Aggregations

Method (java.lang.reflect.Method)2 ExecutableType (javax.validation.executable.ExecutableType)2 ValidateOnExecution (javax.validation.executable.ValidateOnExecution)2 Serializable (java.io.Serializable)1 Constructor (java.lang.reflect.Constructor)1 Executable (java.lang.reflect.Executable)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 EnumSet (java.util.EnumSet)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 BiPredicate (java.util.function.BiPredicate)1 Priority (javax.annotation.Priority)1 AnnotatedMethod (javax.enterprise.inject.spi.AnnotatedMethod)1 AnnotatedType (javax.enterprise.inject.spi.AnnotatedType)1