You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by ra...@apache.org on 2018/10/12 15:00:51 UTC

svn commit: r1843674 [4/22] - in /tomee/deps/branches/bval-2: ./ bundle/ bundle/src/ bundle/src/main/ bundle/src/main/appended-resources/ bundle/src/main/appended-resources/META-INF/ bval-extras/ bval-extras/src/ bval-extras/src/main/ bval-extras/src/m...

Added: tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/BValExtension.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/BValExtension.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/BValExtension.java (added)
+++ tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/BValExtension.java Fri Oct 12 15:00:48 2018
@@ -0,0 +1,291 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.bval.cdi;
+
+import java.lang.reflect.Modifier;
+import java.lang.reflect.Type;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.enterprise.inject.spi.AnnotatedCallable;
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.BeforeBeanDiscovery;
+import javax.enterprise.inject.spi.CDI;
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.InjectionTarget;
+import javax.enterprise.inject.spi.ProcessAnnotatedType;
+import javax.enterprise.inject.spi.ProcessBean;
+import javax.validation.BootstrapConfiguration;
+import javax.validation.Configuration;
+import javax.validation.Validation;
+import javax.validation.ValidationException;
+import javax.validation.Validator;
+import javax.validation.ValidatorFactory;
+import javax.validation.executable.ExecutableType;
+import javax.validation.executable.ValidateOnExecution;
+import javax.validation.metadata.BeanDescriptor;
+import javax.validation.metadata.MethodType;
+
+import org.apache.bval.jsr.ConfigurationImpl;
+import org.apache.bval.jsr.util.ExecutableTypes;
+import org.apache.bval.util.Lazy;
+import org.apache.bval.util.Validate;
+
+/**
+ * CDI {@link Extension} for Apache BVal setup.
+ */
+public class BValExtension implements Extension {
+    private static final Logger LOGGER = Logger.getLogger(BValExtension.class.getName());
+
+    private static final AnnotatedTypeFilter DEFAULT_ANNOTATED_TYPE_FILTER =
+        annotatedType -> !annotatedType.getJavaClass().getName().startsWith("org.apache.bval.");
+
+    private static AnnotatedTypeFilter annotatedTypeFilter = DEFAULT_ANNOTATED_TYPE_FILTER;
+
+    public static void setAnnotatedTypeFilter(AnnotatedTypeFilter annotatedTypeFilter) {
+        BValExtension.annotatedTypeFilter = Validate.notNull(annotatedTypeFilter);
+    }
+
+    private boolean validatorFound = Boolean.getBoolean("bval.in-container");
+    private boolean validatorFactoryFound = Boolean.getBoolean("bval.in-container");
+
+    private final Configuration<?> config;
+    private Lazy<ValidatorFactory> factory;
+    private Lazy<Validator> validator;
+
+    private Set<ExecutableType> globalExecutableTypes;
+    private boolean isExecutableValidationEnabled;
+
+    public BValExtension() { // read the config, could be done in a quicker way but this let us get defaults without duplicating code
+        config = Validation.byDefaultProvider().configure();
+        try {
+            final BootstrapConfiguration bootstrap = config.getBootstrapConfiguration();
+            globalExecutableTypes =
+                ExecutableTypes.interpret(bootstrap.getDefaultValidatedExecutableTypes());
+
+            isExecutableValidationEnabled = bootstrap.isExecutableValidationEnabled();
+
+        } catch (final Exception e) { // custom providers can throw an exception
+            LOGGER.log(Level.SEVERE, e.getMessage(), e);
+
+            globalExecutableTypes = Collections.emptySet();
+            isExecutableValidationEnabled = false;
+        }
+    }
+
+    // lazily to get a small luck to have CDI in place
+    private void ensureFactoryValidator() {
+        if (validator != null) {
+            return;
+        }
+        if (config instanceof ConfigurationImpl) {
+            // ignore parts of the config relying on CDI since we didn't start yet
+            ((ConfigurationImpl) config).deferBootstrapOverrides();
+        }
+        if (factory == null) {
+            factory = new Lazy<>(config::buildValidatorFactory);
+        }
+        validator = new Lazy<>(() -> factory.get().getValidator());
+    }
+
+    public Set<ExecutableType> getGlobalExecutableTypes() {
+        return globalExecutableTypes;
+    }
+
+    public void addBvalBinding(final @Observes BeforeBeanDiscovery beforeBeanDiscovery, final BeanManager beanManager) {
+        beforeBeanDiscovery.addInterceptorBinding(BValBinding.class);
+        beforeBeanDiscovery.addAnnotatedType(beanManager.createAnnotatedType(BValInterceptor.class));
+    }
+
+    // @WithAnnotations(ValidateOnExecution.class) doesn't check interfaces so not enough
+    public <A> void processAnnotatedType(final @Observes ProcessAnnotatedType<A> pat) {
+        if (!isExecutableValidationEnabled) {
+            return;
+        }
+        final AnnotatedType<A> annotatedType = pat.getAnnotatedType();
+
+        if (!annotatedTypeFilter.accept(annotatedType)) {
+            return;
+        }
+        final Class<A> javaClass = annotatedType.getJavaClass();
+        final int modifiers = javaClass.getModifiers();
+        if (!javaClass.isInterface() && !Modifier.isFinal(modifiers) && !Modifier.isAbstract(modifiers)) {
+            try {
+                ensureFactoryValidator();
+                try {
+                    final BeanDescriptor classConstraints = validator.get().getConstraintsForClass(javaClass);
+
+                    final boolean validConstructors = globalExecutableTypes.contains(ExecutableType.CONSTRUCTORS)
+                        && !classConstraints.getConstrainedConstructors().isEmpty();
+                    final boolean validBusinessMethods =
+                        globalExecutableTypes.contains(ExecutableType.NON_GETTER_METHODS)
+                            && !classConstraints.getConstrainedMethods(MethodType.NON_GETTER).isEmpty();
+                    final boolean validGetterMethods = globalExecutableTypes.contains(ExecutableType.GETTER_METHODS)
+                        && !classConstraints.getConstrainedMethods(MethodType.GETTER).isEmpty();
+
+                    if (annotatedType.isAnnotationPresent(ValidateOnExecution.class)
+                        || hasValidationAnnotation(annotatedType.getMethods())
+                        || hasValidationAnnotation(annotatedType.getConstructors()) || validConstructors
+                        || validBusinessMethods || validGetterMethods) {
+                        pat.setAnnotatedType(new BValAnnotatedType<>(annotatedType));
+                    }
+                } catch (final NoClassDefFoundError ncdfe) {
+                    // skip
+                }
+            } catch (final Exception e) {
+                if (e instanceof ValidationException) {
+                    throw e;
+                }
+                LOGGER.log(Level.INFO, e.getMessage());
+            }
+        }
+    }
+
+    private static <A> boolean hasValidationAnnotation(
+        final Collection<? extends AnnotatedCallable<? super A>> methods) {
+        return methods.stream().anyMatch(m -> m.isAnnotationPresent(ValidateOnExecution.class));
+    }
+
+    public <A> void processBean(final @Observes ProcessBean<A> processBeanEvent) {
+        if (validatorFound && validatorFactoryFound) {
+            return;
+        }
+
+        final Bean<A> bean = processBeanEvent.getBean();
+        if (ValidatorBean.class.isInstance(bean) || ValidatorFactoryBean.class.isInstance(bean)) {
+            return;
+        }
+
+        final Set<Type> types = bean.getTypes();
+        if (!validatorFound) {
+            validatorFound = types.contains(Validator.class);
+        }
+        if (!validatorFactoryFound) {
+            validatorFactoryFound = types.contains(ValidatorFactory.class);
+        }
+    }
+
+    public void addBValBeans(final @Observes AfterBeanDiscovery afterBeanDiscovery, final BeanManager beanManager) {
+        if (factory != null && factory.optional().isPresent()) { // cleanup cache used to discover ValidateOnException before factory is recreated
+            factory.get().close();
+        }
+        if (config instanceof ConfigurationImpl) {
+            ((ConfigurationImpl) config).releaseDeferredBootstrapOverrides();
+        }
+        if (!validatorFactoryFound) {
+            try { // recreate the factory
+                factory = new Lazy<>(config::buildValidatorFactory);
+                afterBeanDiscovery.addBean(new ValidatorFactoryBean(factory));
+                validatorFactoryFound = true;
+            } catch (final ValidationException ve) {
+                //throw ve;
+            } catch (final Exception e) { // can throw an exception with custom providers
+                LOGGER.log(Level.SEVERE, e.getMessage(), e);
+            }
+        }
+        if (!validatorFound && validatorFactoryFound) {
+            try {
+                afterBeanDiscovery.addBean(new ValidatorBean(() -> CDI.current().select(ValidatorFactory.class).get().getValidator()));
+                validatorFound = true;
+            } catch (final ValidationException ve) {
+                throw ve;
+            } catch (final Exception e) {
+                LOGGER.log(Level.SEVERE, e.getMessage(), e);
+            }
+        }
+    }
+
+    /**
+     * Request that an instance of the specified type be provided by the container.
+     * @param clazz
+     * @return the requested instance wrapped in a {@link Releasable}.
+     */
+    public static <T> Releasable<T> inject(final Class<T> clazz) {
+        try {
+            final BeanManager beanManager = CDI.current().getBeanManager();
+            if (beanManager == null) {
+                return null;
+            }
+            final AnnotatedType<T> annotatedType = beanManager.createAnnotatedType(clazz);
+            final InjectionTarget<T> it = beanManager.createInjectionTarget(annotatedType);
+            final CreationalContext<T> context = beanManager.createCreationalContext(null);
+            final T instance = it.produce(context);
+            it.inject(instance, context);
+            it.postConstruct(instance);
+
+            return new Releasable<>(context, it, instance);
+        } catch (final Exception | NoClassDefFoundError error) {
+            // no-op
+        }
+        return null;
+    }
+
+    public static BeanManager getBeanManager() {
+        return CDI.current().getBeanManager();
+    }
+
+    /**
+     * Represents an item that can be released from a {@link CreationalContext} at some point in the future.
+     * @param <T>
+     */
+    public static class Releasable<T> {
+        private final CreationalContext<T> context;
+        private final InjectionTarget<T> injectionTarget;
+        private final T instance;
+
+        private Releasable(final CreationalContext<T> context, final InjectionTarget<T> injectionTarget,
+            final T instance) {
+            this.context = context;
+            this.injectionTarget = injectionTarget;
+            this.instance = instance;
+        }
+
+        public void release() {
+            try {
+                injectionTarget.preDestroy(instance);
+                injectionTarget.dispose(instance);
+                context.release();
+            } catch (final Exception | NoClassDefFoundError e) {
+                // no-op
+            }
+        }
+
+        public T getInstance() {
+            return instance;
+        }
+    }
+
+    /**
+     * Defines an item that can determine whether a given {@link AnnotatedType} will be processed
+     * by the {@link BValExtension} for executable validation. May be statically applied before
+     * container startup.
+     * @see BValExtension#setAnnotatedTypeFilter(AnnotatedTypeFilter)
+     */
+    public interface AnnotatedTypeFilter {
+        boolean accept(AnnotatedType<?> annotatedType);
+    }
+}

Added: tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/BValInterceptor.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/BValInterceptor.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/BValInterceptor.java (added)
+++ tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/BValInterceptor.java Fri Oct 12 15:00:48 2018
@@ -0,0 +1,288 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.bval.cdi;
+
+import java.io.Serializable;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Executable;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.function.BiPredicate;
+
+import javax.annotation.Priority;
+import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.CDI;
+import javax.inject.Inject;
+import javax.interceptor.AroundConstruct;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InterceptorBinding;
+import javax.interceptor.InvocationContext;
+import javax.validation.ConstraintViolation;
+import javax.validation.ConstraintViolationException;
+import javax.validation.Validator;
+import javax.validation.executable.ExecutableType;
+import javax.validation.executable.ExecutableValidator;
+import javax.validation.executable.ValidateOnExecution;
+import javax.validation.metadata.ConstructorDescriptor;
+import javax.validation.metadata.MethodDescriptor;
+
+import org.apache.bval.jsr.descriptor.DescriptorManager;
+import org.apache.bval.jsr.metadata.Signature;
+import org.apache.bval.jsr.util.ExecutableTypes;
+import org.apache.bval.jsr.util.Methods;
+import org.apache.bval.jsr.util.Proxies;
+import org.apache.bval.util.ObjectUtils;
+import org.apache.bval.util.Validate;
+import org.apache.bval.util.reflection.Reflection;
+import org.apache.bval.util.reflection.Reflection.Interfaces;
+
+/**
+ * Interceptor class for the {@link BValBinding} {@link InterceptorBinding}.
+ */
+@SuppressWarnings("serial")
+@Interceptor
+@BValBinding
+@Priority(4800)
+// TODO: maybe add it through ASM to be compliant with CDI 1.0 containers using simply this class as a template to
+// generate another one for CDI 1.1 impl
+public class BValInterceptor implements Serializable {
+    private static Collection<ExecutableType> removeFrom(Collection<ExecutableType> coll,
+        ExecutableType... executableTypes) {
+        Validate.notNull(coll, "collection was null");
+        if (!(coll.isEmpty() || ObjectUtils.isEmptyArray(executableTypes))) {
+            final List<ExecutableType> toRemove = Arrays.asList(executableTypes);
+            if (!Collections.disjoint(coll, toRemove)) {
+                final Set<ExecutableType> result = EnumSet.copyOf(coll);
+                result.removeAll(toRemove);
+                return result;
+            }
+        }
+        return coll;
+    }
+
+    private transient volatile Set<ExecutableType> classConfiguration;
+    private transient volatile Map<Signature, Boolean> executableValidation;
+
+    @Inject
+    private Validator validator;
+
+    @Inject
+    private BValExtension globalConfiguration;
+
+    private transient volatile ExecutableValidator executableValidator;
+
+    @SuppressWarnings({ "unchecked", "rawtypes" })
+    @AroundConstruct // TODO: see previous one
+    public Object construct(InvocationContext context) throws Exception {
+        final Constructor ctor = context.getConstructor();
+        if (!isConstructorValidated(ctor)) {
+            return context.proceed();
+        }
+        final ConstructorDescriptor constraints = validator.getConstraintsForClass(ctor.getDeclaringClass())
+            .getConstraintsForConstructor(ctor.getParameterTypes());
+
+        if (!DescriptorManager.isConstrained(constraints)) {
+            return context.proceed();
+        }
+        initExecutableValidator();
+
+        if (constraints.hasConstrainedParameters()) {
+            final Set<ConstraintViolation<?>> violations =
+                executableValidator.validateConstructorParameters(ctor, context.getParameters());
+            if (!violations.isEmpty()) {
+                throw new ConstraintViolationException(violations);
+            }
+        }
+        final Object result = context.proceed();
+
+        if (constraints.hasConstrainedReturnValue()) {
+            final Set<ConstraintViolation<?>> violations =
+                executableValidator.validateConstructorReturnValue(ctor, context.getTarget());
+            if (!violations.isEmpty()) {
+                throw new ConstraintViolationException(violations);
+            }
+        }
+        return result;
+    }
+
+    @AroundInvoke
+    public Object invoke(final InvocationContext context) throws Exception {
+        final Method method = context.getMethod();
+        final Class<?> targetClass = Proxies.classFor(context.getTarget().getClass());
+
+        if (!isExecutableValidated(targetClass, method, this::computeIsMethodValidated)) {
+            return context.proceed();
+        }
+
+        final MethodDescriptor constraintsForMethod = validator.getConstraintsForClass(targetClass)
+            .getConstraintsForMethod(method.getName(), method.getParameterTypes());
+
+        if (!DescriptorManager.isConstrained(constraintsForMethod)) {
+            return context.proceed();
+        }
+        initExecutableValidator();
+
+        if (constraintsForMethod.hasConstrainedParameters()) {
+            final Set<ConstraintViolation<Object>> violations =
+                executableValidator.validateParameters(context.getTarget(), method, context.getParameters());
+            if (!violations.isEmpty()) {
+                throw new ConstraintViolationException(violations);
+            }
+        }
+        final Object result = context.proceed();
+
+        if (constraintsForMethod.hasConstrainedReturnValue()) {
+            final Set<ConstraintViolation<Object>> violations =
+                executableValidator.validateReturnValue(context.getTarget(), method, result);
+            if (!violations.isEmpty()) {
+                throw new ConstraintViolationException(violations);
+            }
+        }
+        return result;
+    }
+
+    private <T> boolean isConstructorValidated(final Constructor<T> constructor)
+        {
+        return isExecutableValidated(constructor.getDeclaringClass(), constructor, this::computeIsConstructorValidated);
+    }
+
+    private <T, E extends Executable> boolean isExecutableValidated(final Class<T> targetClass, final E executable,
+        BiPredicate<? super Class<T>, ? super E> compute) {
+        initClassConfig(targetClass);
+
+        if (executableValidation == null) {
+            synchronized (this) {
+                if (executableValidation == null) {
+                    executableValidation = new ConcurrentHashMap<>();
+                }
+            }
+        }
+        return executableValidation.computeIfAbsent(Signature.of(executable),
+            s -> compute.test(targetClass, executable));
+    }
+
+    private void initClassConfig(Class<?> targetClass) {
+        if (classConfiguration == null) {
+            synchronized (this) {
+                if (classConfiguration == null) {
+                    final AnnotatedType<?> annotatedType = CDI.current().getBeanManager()
+                        .createAnnotatedType(targetClass);
+
+                    if (annotatedType.isAnnotationPresent(ValidateOnExecution.class)) {
+                        // implicit does not apply at the class level:
+                        classConfiguration = ExecutableTypes.interpret(
+                            removeFrom(Arrays.asList(annotatedType.getAnnotation(ValidateOnExecution.class).type()),
+                                ExecutableType.IMPLICIT));
+                    } else {
+                        classConfiguration = globalConfiguration.getGlobalExecutableTypes();
+                    }
+                }
+            }
+        }
+    }
+
+    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);
+    }
+
+    private <T> boolean computeIsMethodValidated(Class<T> targetClass, Method method) {
+        final Signature signature = Signature.of(method);
+
+        AnnotatedMethod<?> declaringMethod = null;
+
+        for (final Class<?> c : Reflection.hierarchy(targetClass, Interfaces.INCLUDE)) {
+            final AnnotatedType<?> annotatedType = CDI.current().getBeanManager().createAnnotatedType(c);
+
+            final AnnotatedMethod<?> annotatedMethod = annotatedType.getMethods().stream()
+                .filter(am -> Signature.of(am.getJavaMember()).equals(signature)).findFirst().orElse(null);
+
+            if (annotatedMethod != null) {
+                declaringMethod = annotatedMethod;
+            }
+        }
+        if (declaringMethod == null) {
+            return false;
+        }
+        final Collection<ExecutableType> declaredExecutableTypes;
+
+        if (declaringMethod.isAnnotationPresent(ValidateOnExecution.class)) {
+            final List<ExecutableType> validatedTypesOnMethod =
+                Arrays.asList(declaringMethod.getAnnotation(ValidateOnExecution.class).type());
+
+            // implicit directly on method -> early return:
+            if (validatedTypesOnMethod.contains(ExecutableType.IMPLICIT)) {
+                return true;
+            }
+            declaredExecutableTypes = validatedTypesOnMethod;
+        } else {
+            final AnnotatedType<?> declaringType = declaringMethod.getDeclaringType();
+            if (declaringType.isAnnotationPresent(ValidateOnExecution.class)) {
+                // IMPLICIT is meaningless at class level:
+                declaredExecutableTypes =
+                    removeFrom(Arrays.asList(declaringType.getAnnotation(ValidateOnExecution.class).type()),
+                        ExecutableType.IMPLICIT);
+            } else {
+                final Package pkg = declaringType.getJavaClass().getPackage();
+                if (pkg != null && pkg.isAnnotationPresent(ValidateOnExecution.class)) {
+                    // presumably IMPLICIT is likewise meaningless at package level:
+                    declaredExecutableTypes = removeFrom(
+                        Arrays.asList(pkg.getAnnotation(ValidateOnExecution.class).type()), ExecutableType.IMPLICIT);
+                } else {
+                    declaredExecutableTypes = null;
+                }
+            }
+        }
+        final ExecutableType methodType =
+            Methods.isGetter(method) ? ExecutableType.GETTER_METHODS : ExecutableType.NON_GETTER_METHODS;
+
+        return Optional.ofNullable(declaredExecutableTypes).map(ExecutableTypes::interpret)
+            .orElse(globalConfiguration.getGlobalExecutableTypes()).contains(methodType);
+    }
+
+    private void initExecutableValidator() {
+        if (executableValidator == null) {
+            synchronized (this) {
+                if (executableValidator == null) {
+                    executableValidator = validator.forExecutables();
+                }
+            }
+        }
+    }
+}

Added: tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/BValInterceptorBean.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/BValInterceptorBean.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/BValInterceptorBean.java (added)
+++ tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/BValInterceptorBean.java Fri Oct 12 15:00:48 2018
@@ -0,0 +1,170 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.bval.cdi;
+
+import javax.enterprise.context.Dependent;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Annotated;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.InjectionTarget;
+import javax.enterprise.inject.spi.PassivationCapable;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Member;
+import java.lang.reflect.Type;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * {@link BValInterceptor} CDI {@link Bean}.
+ */
+public class BValInterceptorBean implements Bean<BValInterceptor>, PassivationCapable {
+    private final Set<Type> types;
+    private final Set<Annotation> qualifiers;
+    private final Set<InjectionPoint> injectionPoints;
+    private final InjectionTarget<BValInterceptor> injectionTarget;
+
+    public BValInterceptorBean(final BeanManager bm) {
+        final Set<Type> t = new HashSet<>();
+        t.add(BValInterceptor.class);
+        t.add(Object.class);
+        types = Collections.unmodifiableSet(t);
+
+        final Set<Annotation> q = new HashSet<>();
+        q.add(DefaultLiteral.INSTANCE);
+        q.add(AnyLiteral.INSTANCE);
+        qualifiers = Collections.unmodifiableSet(q);
+
+        injectionTarget = bm.createInjectionTarget(bm.createAnnotatedType(BValInterceptor.class));
+        injectionPoints = Collections.singleton(InjectionPoint.class
+            .cast(new BValInterceptorInjectionPoint(this, injectionTarget.getInjectionPoints().iterator().next())));
+    }
+
+    @Override
+    public Set<Type> getTypes() {
+        return types;
+    }
+
+    @Override
+    public Set<Annotation> getQualifiers() {
+        return qualifiers;
+    }
+
+    @Override
+    public Class<? extends Annotation> getScope() {
+        return Dependent.class;
+    }
+
+    @Override
+    public String getName() {
+        return null;
+    }
+
+    @Override
+    public boolean isNullable() {
+        return false;
+    }
+
+    @Override
+    public Set<InjectionPoint> getInjectionPoints() {
+        return injectionPoints;
+    }
+
+    @Override
+    public Class<?> getBeanClass() {
+        return BValInterceptor.class;
+    }
+
+    @Override
+    public Set<Class<? extends Annotation>> getStereotypes() {
+        return Collections.emptySet();
+    }
+
+    @Override
+    public boolean isAlternative() {
+        return false;
+    }
+
+    @Override
+    public BValInterceptor create(final CreationalContext<BValInterceptor> context) {
+        final BValInterceptor produced = injectionTarget.produce(context);
+        injectionTarget.inject(produced, context);
+        injectionTarget.postConstruct(produced);
+        return produced;
+    }
+
+    @Override
+    public void destroy(final BValInterceptor instance, final CreationalContext<BValInterceptor> context) {
+        injectionTarget.preDestroy(instance);
+        injectionTarget.dispose(instance);
+        context.release();
+    }
+
+    @Override
+    public String getId() {
+        return String.format("%s-%d", BValInterceptor.class.getSimpleName(), hashCode());
+    }
+
+    private static class BValInterceptorInjectionPoint implements InjectionPoint {
+        private final InjectionPoint delegate;
+        private final Bean<?> bean;
+
+        public BValInterceptorInjectionPoint(final Bean<?> bean, final InjectionPoint next) {
+            this.bean = bean;
+            delegate = next;
+        }
+
+        @Override
+        public Type getType() {
+            return delegate.getType();
+        }
+
+        @Override
+        public Set<Annotation> getQualifiers() {
+            return delegate.getQualifiers();
+        }
+
+        @Override
+        public Bean<?> getBean() {
+            return bean;
+        }
+
+        @Override
+        public Member getMember() {
+            return delegate.getMember();
+        }
+
+        @Override
+        public Annotated getAnnotated() {
+            return delegate.getAnnotated();
+        }
+
+        @Override
+        public boolean isDelegate() {
+            return delegate.isDelegate();
+        }
+
+        @Override
+        public boolean isTransient() {
+            return delegate.isTransient();
+        }
+    }
+}

Added: tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/DefaultLiteral.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/DefaultLiteral.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/DefaultLiteral.java (added)
+++ tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/DefaultLiteral.java Fri Oct 12 15:00:48 2018
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.bval.cdi;
+
+import javax.enterprise.inject.Default;
+
+public class DefaultLiteral extends EmptyAnnotationLiteral<Default> implements Default {
+    private static final long serialVersionUID = 1L;
+
+    public static final DefaultLiteral INSTANCE = new DefaultLiteral();
+
+    @Override
+    public String toString() {
+        return String.format("@%s()", Default.class.getName());
+    }
+}

Added: tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/EmptyAnnotationLiteral.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/EmptyAnnotationLiteral.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/EmptyAnnotationLiteral.java (added)
+++ tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/EmptyAnnotationLiteral.java Fri Oct 12 15:00:48 2018
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.bval.cdi;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+
+import javax.enterprise.util.AnnotationLiteral;
+
+/**
+ * Base class for AnnotationLiterals which have no members.
+ * Taken from Apache OpenWebBeans.
+ * @param <T>
+ */
+@SuppressWarnings("serial")
+public abstract class EmptyAnnotationLiteral<T extends Annotation> extends AnnotationLiteral<T> {
+    private Class<T> annotationType;
+
+    protected EmptyAnnotationLiteral() {
+        // Leave this constructor protected, because an EmptyAnnotationLiteral may never directly be instantiated
+    }
+
+    /**
+     * Implemented for compatibility reasons with other cdi-api jar's.
+     * See OWB-802.
+     */
+    @Override
+    public Class<? extends Annotation> annotationType() {
+        if (annotationType == null) {
+            annotationType = getAnnotationType(getClass());
+        }
+        return annotationType;
+    }
+
+    /**
+     * Implemented for performance reasons.
+     * This is needed because an Annotation always returns 0 as hashCode
+     * if there is no method in it.
+     * Contrary to this the generic {@link AnnotationLiteral#hashCode()}
+     * always does search for methods via reflection and only then returns 0.
+     * Not very well performing ...
+     * @return always 0
+     */
+    @Override
+    public int hashCode() {
+        return 0;
+    }
+
+    /**
+     * Just checks whether the 2 classes have the same annotationType.
+     * We do not need to dynamically evaluate the member values via reflection
+     * as there are no members in this annotation at all.
+     */
+    @Override
+    public boolean equals(final Object other) {
+        // implemented for performance reasons
+        return Annotation.class.isInstance(other)
+            && Annotation.class.cast(other).annotationType().equals(annotationType());
+    }
+
+    private Class<T> getAnnotationType(Class<?> definedClazz) {
+        Type superClazz = definedClazz.getGenericSuperclass();
+
+        if (Object.class.equals(superClazz)) {
+            throw new RuntimeException("Super class must be parameterized type!");
+        }
+        if (superClazz instanceof ParameterizedType) {
+            ParameterizedType paramType = (ParameterizedType) superClazz;
+            Type[] actualArgs = paramType.getActualTypeArguments();
+
+            if (actualArgs.length == 1) {
+                //Actual annotation type
+                Type type = actualArgs[0];
+
+                if (type instanceof Class<?>) {
+                    @SuppressWarnings("unchecked")
+                    Class<T> clazz = (Class<T>) type;
+                    return clazz;
+                }
+                throw new RuntimeException("Not class type!");
+            }
+            throw new RuntimeException("More than one parametric type!");
+        }
+        return getAnnotationType((Class<?>) superClazz);
+    }
+}

Added: tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/ValidatorBean.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/ValidatorBean.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/ValidatorBean.java (added)
+++ tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/ValidatorBean.java Fri Oct 12 15:00:48 2018
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.bval.cdi;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.PassivationCapable;
+import javax.validation.Validator;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.function.Supplier;
+
+/**
+ * {@link Validator} CDI {@link Bean}.
+ */
+public class ValidatorBean implements Bean<Validator>, PassivationCapable {
+    private final Set<Type> types;
+    private final Set<Annotation> qualifiers;
+    private final Supplier<Validator> instance;
+
+    public ValidatorBean(final Supplier<Validator> validator) {
+        this.instance = validator;
+
+        final Set<Type> t = new HashSet<>();
+        t.add(Validator.class);
+        t.add(Object.class);
+        types = Collections.unmodifiableSet(t);
+
+        final Set<Annotation> q = new HashSet<>();
+        q.add(DefaultLiteral.INSTANCE);
+        q.add(AnyLiteral.INSTANCE);
+        qualifiers = Collections.unmodifiableSet(q);
+    }
+
+    @Override
+    public Set<Type> getTypes() {
+        return types;
+    }
+
+    @Override
+    public Set<Annotation> getQualifiers() {
+        return qualifiers;
+    }
+
+    @Override
+    public Class<? extends Annotation> getScope() {
+        return ApplicationScoped.class;
+    }
+
+    @Override
+    public String getName() {
+        return null;
+    }
+
+    @Override
+    public boolean isNullable() {
+        return false;
+    }
+
+    @Override
+    public Set<InjectionPoint> getInjectionPoints() {
+        return Collections.emptySet();
+    }
+
+    @Override
+    public Class<?> getBeanClass() {
+        return Validator.class;
+    }
+
+    @Override
+    public Set<Class<? extends Annotation>> getStereotypes() {
+        return Collections.emptySet();
+    }
+
+    @Override
+    public boolean isAlternative() {
+        return false;
+    }
+
+    @Override
+    public Validator create(final CreationalContext<Validator> context) {
+        return instance == null ? null : instance.get();
+    }
+
+    @Override
+    public void destroy(final Validator instance, final CreationalContext<Validator> context) {
+        // no-op
+    }
+
+    @Override
+    public String getId() {
+        return String.format("BVal%s-%d", Validator.class.getSimpleName(), hashCode());
+    }
+}

Added: tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/ValidatorFactoryBean.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/ValidatorFactoryBean.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/ValidatorFactoryBean.java (added)
+++ tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/cdi/ValidatorFactoryBean.java Fri Oct 12 15:00:48 2018
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.bval.cdi;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.PassivationCapable;
+import javax.validation.ValidatorFactory;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.function.Supplier;
+
+/**
+ * {@link ValidatorFactory} CDI {@link Bean}.
+ */
+public class ValidatorFactoryBean implements Bean<ValidatorFactory>, PassivationCapable {
+    private final Set<Type> types;
+    private final Set<Annotation> qualifiers;
+    private final Supplier<ValidatorFactory> instance;
+
+    public ValidatorFactoryBean(final Supplier<ValidatorFactory> validatorFactory) {
+        this.instance = validatorFactory;
+
+        final Set<Type> t = new HashSet<>();
+        t.add(ValidatorFactory.class);
+        t.add(Object.class);
+        types = Collections.unmodifiableSet(t);
+
+        final Set<Annotation> q = new HashSet<>();
+        q.add(DefaultLiteral.INSTANCE);
+        q.add(AnyLiteral.INSTANCE);
+        qualifiers = Collections.unmodifiableSet(q);
+    }
+
+    @Override
+    public Set<Type> getTypes() {
+        return types;
+    }
+
+    @Override
+    public Set<Annotation> getQualifiers() {
+        return qualifiers;
+    }
+
+    @Override
+    public Class<? extends Annotation> getScope() {
+        return ApplicationScoped.class;
+    }
+
+    @Override
+    public String getName() {
+        return null;
+    }
+
+    @Override
+    public boolean isNullable() {
+        return false;
+    }
+
+    @Override
+    public Set<InjectionPoint> getInjectionPoints() {
+        return Collections.emptySet();
+    }
+
+    @Override
+    public Class<?> getBeanClass() {
+        return ValidatorFactory.class;
+    }
+
+    @Override
+    public Set<Class<? extends Annotation>> getStereotypes() {
+        return Collections.emptySet();
+    }
+
+    @Override
+    public boolean isAlternative() {
+        return false;
+    }
+
+    @Override
+    public ValidatorFactory create(final CreationalContext<ValidatorFactory> context) {
+        return instance.get();
+    }
+
+    @Override
+    public void destroy(final ValidatorFactory instance, final CreationalContext<ValidatorFactory> context) {
+        instance.close();
+    }
+
+    @Override
+    public String getId() {
+        return String.format("BVal%s-%d", ValidatorFactory.class.getSimpleName(), hashCode());
+    }
+}

Added: tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/AbstractPatternValidator.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/AbstractPatternValidator.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/AbstractPatternValidator.java (added)
+++ tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/AbstractPatternValidator.java Fri Oct 12 15:00:48 2018
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.bval.constraints;
+
+import java.lang.annotation.Annotation;
+import java.util.function.Function;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.Pattern.Flag;
+
+import org.apache.bval.util.Validate;
+
+public abstract class AbstractPatternValidator<A extends Annotation, T extends CharSequence>
+    implements ConstraintValidator<A, T> {
+
+    public interface PatternDescriptor {
+        String regexp();
+
+        Flag[] flags();
+    }
+
+    private final Function<A, PatternDescriptor> toDescriptor;
+
+    protected Pattern pattern;
+
+    protected AbstractPatternValidator(Function<A, PatternDescriptor> toDescriptor) {
+        super();
+        this.toDescriptor = Validate.notNull(toDescriptor);
+    }
+
+    @Override
+    public void initialize(A constraintAnnotation) {
+        ConstraintValidator.super.initialize(constraintAnnotation);
+
+        final PatternDescriptor pd = toDescriptor.apply(constraintAnnotation);
+
+        final Flag flags[] = pd.flags();
+        int intFlag = 0;
+        for (Flag flag : flags) {
+            intFlag = intFlag | flag.getValue();
+        }
+        try {
+            pattern = Pattern.compile(pd.regexp(), intFlag);
+        } catch (PatternSyntaxException e) {
+            throw new IllegalArgumentException("Invalid regular expression.", e);
+        }
+    }
+
+    @Override
+    public boolean isValid(T value, ConstraintValidatorContext context) {
+        return value == null || pattern.matcher(value).matches();
+    }
+}

Added: tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/AssertFalseValidator.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/AssertFalseValidator.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/AssertFalseValidator.java (added)
+++ tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/AssertFalseValidator.java Fri Oct 12 15:00:48 2018
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.bval.constraints;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.AssertFalse;
+
+/**
+ * Description: assert that value is false<br/>
+ */
+public class AssertFalseValidator implements ConstraintValidator<AssertFalse, Boolean> {
+
+    @Override
+    public boolean isValid(Boolean value, ConstraintValidatorContext context) {
+        return !Boolean.TRUE.equals(value);
+    }
+
+}
\ No newline at end of file

Added: tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/AssertTrueValidator.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/AssertTrueValidator.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/AssertTrueValidator.java (added)
+++ tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/AssertTrueValidator.java Fri Oct 12 15:00:48 2018
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.bval.constraints;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.AssertTrue;
+
+/**
+ * Description: assert that value is true<br/>
+ */
+public class AssertTrueValidator implements ConstraintValidator<AssertTrue, Boolean> {
+
+    @Override
+    public boolean isValid(Boolean value, ConstraintValidatorContext context) {
+        return !Boolean.FALSE.equals(value);
+    }
+
+}
\ No newline at end of file

Added: tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/DecimalMaxValidator.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/DecimalMaxValidator.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/DecimalMaxValidator.java (added)
+++ tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/DecimalMaxValidator.java Fri Oct 12 15:00:48 2018
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.bval.constraints;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.DecimalMax;
+
+public abstract class DecimalMaxValidator<T> implements ConstraintValidator<DecimalMax, T> {
+    public static class ForString extends DecimalMaxValidator<String> {
+        @Override
+        public boolean isValid(String value, ConstraintValidatorContext context) {
+            return value == null || isValid(new BigDecimal(value));
+        }
+    }
+
+    public static class ForNumber extends DecimalMaxValidator<Number> {
+        @Override
+        public boolean isValid(Number value, ConstraintValidatorContext context) {
+            if (value == null) {
+                return true;
+            }
+            final BigDecimal bigValue;
+            if (value instanceof BigDecimal) {
+                bigValue = (BigDecimal) value;
+            } else if (value instanceof BigInteger) {
+                bigValue = new BigDecimal((BigInteger) value);
+            } else {
+                bigValue = new BigDecimal(value.doubleValue());
+            }
+            return isValid(bigValue);
+        }
+    }
+
+    private BigDecimal maxValue;
+    private boolean inclusive;
+
+    @Override
+    public void initialize(DecimalMax annotation) {
+        try {
+            this.maxValue = new BigDecimal(annotation.value());
+        } catch (NumberFormatException nfe) {
+            throw new IllegalArgumentException(annotation.value() + " does not represent a valid BigDecimal format");
+        }
+        this.inclusive = annotation.inclusive();
+    }
+
+    protected boolean isValid(BigDecimal value) {
+        // null values are valid
+        if (value == null) {
+            return true;
+        }
+        final int comparison = value.compareTo(maxValue);
+        return comparison < 0 || inclusive && comparison == 0;
+    }
+}

Added: tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/DecimalMinValidator.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/DecimalMinValidator.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/DecimalMinValidator.java (added)
+++ tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/DecimalMinValidator.java Fri Oct 12 15:00:48 2018
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.bval.constraints;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.DecimalMin;
+
+public abstract class DecimalMinValidator<T> implements ConstraintValidator<DecimalMin, T> {
+    public static class ForString extends DecimalMinValidator<String> {
+        @Override
+        public boolean isValid(String value, ConstraintValidatorContext context) {
+            return value == null || isValid(new BigDecimal(value));
+        }
+    }
+
+    public static class ForNumber extends DecimalMinValidator<Number> {
+        @Override
+        public boolean isValid(Number value, ConstraintValidatorContext context) {
+            if (value == null) {
+                return true;
+            }
+            final BigDecimal bigValue;
+            if (value instanceof BigDecimal) {
+                bigValue = (BigDecimal) value;
+            } else if (value instanceof BigInteger) {
+                bigValue = new BigDecimal((BigInteger) value);
+            } else {
+                bigValue = new BigDecimal(value.doubleValue());
+            }
+            return isValid(bigValue);
+        }
+    }
+
+    private BigDecimal minValue;
+    private boolean inclusive;
+
+    @Override
+    public void initialize(DecimalMin annotation) {
+        try {
+            this.minValue = new BigDecimal(annotation.value());
+        } catch (NumberFormatException nfe) {
+            throw new IllegalArgumentException(annotation.value() + " does not represent a valid BigDecimal format");
+        }
+        this.inclusive = annotation.inclusive();
+    }
+
+    protected boolean isValid(BigDecimal value) {
+        // null values are valid
+        if (value == null) {
+            return true;
+        }
+        final int comparison = value.compareTo(minValue);
+        return comparison > 0 || inclusive && comparison == 0;
+    }
+}

Added: tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/DigitsValidatorForNumber.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/DigitsValidatorForNumber.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/DigitsValidatorForNumber.java (added)
+++ tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/DigitsValidatorForNumber.java Fri Oct 12 15:00:48 2018
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.bval.constraints;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.Digits;
+import java.math.BigDecimal;
+
+/**
+ * Validates that the <code>Number</code> being validates matches the pattern
+ * defined in the constraint.
+ */
+public class DigitsValidatorForNumber implements ConstraintValidator<Digits, Number> {
+
+    private int integral;
+    private int fractional;
+
+    public int getIntegral() {
+        return integral;
+    }
+
+    public void setIntegral(int integral) {
+        this.integral = integral;
+    }
+
+    public int getFractional() {
+        return fractional;
+    }
+
+    public void setFractional(int fractional) {
+        this.fractional = fractional;
+    }
+
+    @Override
+    public void initialize(Digits annotation) {
+        this.integral = annotation.integer();
+        this.fractional = annotation.fraction();
+        if (integral < 0) {
+            throw new IllegalArgumentException("The length of the integer part cannot be negative.");
+        }
+        if (fractional < 0) {
+            throw new IllegalArgumentException("The length of the fraction part cannot be negative.");
+        }
+    }
+
+    @Override
+    public boolean isValid(Number num, ConstraintValidatorContext context) {
+        if (num == null) {
+            return true;
+        }
+
+        BigDecimal bigDecimal;
+        if (num instanceof BigDecimal) {
+            bigDecimal = (BigDecimal) num;
+        } else {
+            bigDecimal = new BigDecimal(num.toString());
+        }
+        bigDecimal = bigDecimal.stripTrailingZeros();
+
+        final int intLength = bigDecimal.precision() - bigDecimal.scale();
+        if (integral >= intLength) {
+            int factionLength = bigDecimal.scale() < 0 ? 0 : bigDecimal.scale();
+            return fractional >= factionLength;
+        }
+        return false;
+    }
+}

Added: tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/DigitsValidatorForString.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/DigitsValidatorForString.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/DigitsValidatorForString.java (added)
+++ tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/DigitsValidatorForString.java Fri Oct 12 15:00:48 2018
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.bval.constraints;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.Digits;
+import java.math.BigDecimal;
+
+/**
+ * Validates that the <code>String</code> being validated consists of digits,
+ * and matches the pattern defined in the constraint.
+ */
+public class DigitsValidatorForString implements ConstraintValidator<Digits, String> {
+
+    private int integral;
+    private int fractional;
+
+    public int getIntegral() {
+        return integral;
+    }
+
+    public void setIntegral(int integral) {
+        this.integral = integral;
+    }
+
+    public int getFractional() {
+        return fractional;
+    }
+
+    public void setFractional(int fractional) {
+        this.fractional = fractional;
+    }
+
+    @Override
+    public void initialize(Digits annotation) {
+        this.integral = annotation.integer();
+        this.fractional = annotation.fraction();
+        if (integral < 0) {
+            throw new IllegalArgumentException("The length of the integer part cannot be negative.");
+        }
+        if (fractional < 0) {
+            throw new IllegalArgumentException("The length of the fraction part cannot be negative.");
+        }
+    }
+
+    @Override
+    public boolean isValid(String str, ConstraintValidatorContext context) {
+        //null values are valid
+        if (str == null) {
+            return true;
+        }
+
+        final BigDecimal bigDecimal = getBigDecimalValue(str);
+        if (bigDecimal == null) {
+            return false;
+        }
+
+        int intLength = bigDecimal.precision() - bigDecimal.scale();
+        if (integral >= intLength) {
+            int factionLength = bigDecimal.scale() < 0 ? 0 : bigDecimal.scale();
+            return fractional >= factionLength;
+        }
+        return false;
+    }
+
+    private BigDecimal getBigDecimalValue(String str) {
+        try {
+            return new BigDecimal(str);
+        } catch (NumberFormatException nfe) {
+            return null;
+        }
+    }
+}

Added: tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/Email.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/Email.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/Email.java (added)
+++ tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/Email.java Fri Oct 12 15:00:48 2018
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.bval.constraints;
+
+import javax.validation.Constraint;
+import javax.validation.OverridesAttribute;
+import javax.validation.Payload;
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.CONSTRUCTOR;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE_USE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * <p>
+ * --
+ * NOTE - This constraint predates the equivalent version from the bean_validation spec.
+ * --
+ * </p>
+ * Description: annotation to validate an email address (by pattern)<br/>
+ */
+@Deprecated
+@Documented
+@Constraint(validatedBy = {})
+@javax.validation.constraints.Email
+@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE })
+@Retention(RUNTIME)
+public @interface Email {
+    @OverridesAttribute(constraint = javax.validation.constraints.Email.class, name = "groups")
+    Class<?>[] groups() default {};
+
+    @OverridesAttribute(constraint = javax.validation.constraints.Email.class, name = "message")
+    String message() default "{org.apache.bval.constraints.Email.message}";
+
+    @OverridesAttribute(constraint = javax.validation.constraints.Email.class, name = "payload")
+    Class<? extends Payload>[] payload() default {};
+}

Added: tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/EmailValidator.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/EmailValidator.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/EmailValidator.java (added)
+++ tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/EmailValidator.java Fri Oct 12 15:00:48 2018
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.bval.constraints;
+
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.Pattern.Flag;
+
+import org.apache.bval.routines.EMailValidationUtils;
+
+/**
+ * Description: <br/>
+ */
+public class EmailValidator extends AbstractPatternValidator<javax.validation.constraints.Email, CharSequence> {
+
+    public EmailValidator() {
+        super(email -> new PatternDescriptor() {
+
+            @Override
+            public String regexp() {
+                return email.regexp();
+            }
+
+            @Override
+            public Flag[] flags() {
+                return email.flags();
+            }
+        });
+    }
+
+    @Override
+    public boolean isValid(CharSequence value, ConstraintValidatorContext context) {
+        return EMailValidationUtils.isValid(value) && super.isValid(value, context);
+    }
+}

Added: tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/FutureOrPresentValidator.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/FutureOrPresentValidator.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/FutureOrPresentValidator.java (added)
+++ tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/FutureOrPresentValidator.java Fri Oct 12 15:00:48 2018
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.bval.constraints;
+
+import java.time.Clock;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.MonthDay;
+import java.time.OffsetDateTime;
+import java.time.OffsetTime;
+import java.time.Year;
+import java.time.YearMonth;
+import java.time.ZonedDateTime;
+import java.time.chrono.ChronoLocalDate;
+import java.time.chrono.ChronoLocalDateTime;
+import java.time.chrono.ChronoZonedDateTime;
+import java.util.Calendar;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.function.Function;
+import java.util.function.IntPredicate;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.constraints.FutureOrPresent;
+
+/**
+ * Defines built-in {@link ConstraintValidator} implementations for {@link FutureOrPresent}.
+ *
+ * @param <T>
+ *            validated type
+ */
+public abstract class FutureOrPresentValidator<T extends Comparable<T>> extends TimeValidator<FutureOrPresent, T> {
+
+    public static class ForDate extends FutureOrPresentValidator<Date> {
+
+        public ForDate() {
+            super(clock -> Date.from(clock.instant()));
+        }
+    }
+
+    public static class ForCalendar extends FutureOrPresentValidator<Calendar> {
+
+        public ForCalendar() {
+            super(clock -> GregorianCalendar.from(clock.instant().atZone(clock.getZone())));
+        }
+    }
+
+    public static class ForInstant extends FutureOrPresentValidator<Instant> {
+
+        public ForInstant() {
+            super(Instant::now);
+        }
+    }
+
+    public static class ForChronoLocalDate extends FutureOrPresentValidator<ChronoLocalDate> {
+
+        public ForChronoLocalDate() {
+            super(LocalDate::now, CHRONO_LOCAL_DATE_COMPARATOR);
+        }
+    }
+
+    public static class ForChronoLocalDateTime extends FutureOrPresentValidator<ChronoLocalDateTime<?>> {
+
+        public ForChronoLocalDateTime() {
+            super(LocalDateTime::now, CHRONO_LOCAL_DATE_TIME_COMPARATOR);
+        }
+    }
+
+    public static class ForLocalTime extends FutureOrPresentValidator<LocalTime> {
+
+        public ForLocalTime() {
+            super(LocalTime::now);
+        }
+    }
+
+    public static class ForOffsetDateTime extends FutureOrPresentValidator<OffsetDateTime> {
+
+        public ForOffsetDateTime() {
+            super(OffsetDateTime::now);
+        }
+    }
+
+    public static class ForOffsetTime extends FutureOrPresentValidator<OffsetTime> {
+
+        public ForOffsetTime() {
+            super(OffsetTime::now);
+        }
+    }
+
+    public static class ForChronoZonedDateTime extends FutureOrPresentValidator<ChronoZonedDateTime<?>> {
+
+        public ForChronoZonedDateTime() {
+            super(ZonedDateTime::now, CHRONO_ZONED_DATE_TIME_COMPARATOR);
+        }
+    }
+
+    public static class ForMonthDay extends FutureOrPresentValidator<MonthDay> {
+
+        public ForMonthDay() {
+            super(MonthDay::now);
+        }
+    }
+
+    public static class ForYear extends FutureOrPresentValidator<Year> {
+
+        public ForYear() {
+            super(Year::now);
+        }
+    }
+
+    public static class ForYearMonth extends FutureOrPresentValidator<YearMonth> {
+
+        public ForYearMonth() {
+            super(YearMonth::now);
+        }
+    }
+
+    private static final IntPredicate TEST = n -> n >= 0;
+
+    protected FutureOrPresentValidator(Function<Clock, T> now) {
+        super(now, TEST);
+    }
+
+    protected FutureOrPresentValidator(Function<Clock, T> now, Comparator<? super T> cmp) {
+        super(now, cmp, TEST);
+    }
+
+}

Added: tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/FutureValidator.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/FutureValidator.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/FutureValidator.java (added)
+++ tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/FutureValidator.java Fri Oct 12 15:00:48 2018
@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.bval.constraints;
+
+import java.time.Clock;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.MonthDay;
+import java.time.OffsetDateTime;
+import java.time.OffsetTime;
+import java.time.Year;
+import java.time.YearMonth;
+import java.time.ZonedDateTime;
+import java.time.chrono.ChronoLocalDate;
+import java.time.chrono.ChronoLocalDateTime;
+import java.time.chrono.ChronoZonedDateTime;
+import java.util.Calendar;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.function.Function;
+import java.util.function.IntPredicate;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.constraints.Future;
+
+/**
+ * Defines built-in {@link ConstraintValidator} implementations for {@link Future}.
+ *
+ * @param <T>
+ *            validated type
+ */
+public abstract class FutureValidator<T extends Comparable<T>> extends TimeValidator<Future, T> {
+
+    public static class ForDate extends FutureValidator<Date> {
+
+        public ForDate() {
+            super(clock -> Date.from(clock.instant()));
+        }
+    }
+
+    public static class ForCalendar extends FutureValidator<Calendar> {
+
+        public ForCalendar() {
+            super(clock -> GregorianCalendar.from(clock.instant().atZone(clock.getZone())));
+        }
+    }
+
+    public static class ForInstant extends FutureValidator<Instant> {
+
+        public ForInstant() {
+            super(Instant::now);
+        }
+    }
+
+    public static class ForChronoLocalDate extends FutureValidator<ChronoLocalDate> {
+
+        public ForChronoLocalDate() {
+            super(LocalDate::now, CHRONO_LOCAL_DATE_COMPARATOR);
+        }
+    }
+
+    public static class ForChronoLocalDateTime extends FutureValidator<ChronoLocalDateTime<?>> {
+
+        public ForChronoLocalDateTime() {
+            super(LocalDateTime::now, CHRONO_LOCAL_DATE_TIME_COMPARATOR);
+        }
+    }
+
+    public static class ForLocalTime extends FutureValidator<LocalTime> {
+
+        public ForLocalTime() {
+            super(LocalTime::now);
+        }
+    }
+
+    public static class ForOffsetDateTime extends FutureValidator<OffsetDateTime> {
+
+        public ForOffsetDateTime() {
+            super(OffsetDateTime::now);
+        }
+    }
+
+    public static class ForOffsetTime extends FutureValidator<OffsetTime> {
+
+        public ForOffsetTime() {
+            super(OffsetTime::now);
+        }
+    }
+
+    public static class ForChronoZonedDateTime extends FutureValidator<ChronoZonedDateTime<?>> {
+
+        public ForChronoZonedDateTime() {
+            super(ZonedDateTime::now, CHRONO_ZONED_DATE_TIME_COMPARATOR);
+        }
+    }
+
+    public static class ForMonthDay extends FutureValidator<MonthDay> {
+
+        public ForMonthDay() {
+            super(MonthDay::now);
+        }
+    }
+
+    public static class ForYear extends FutureValidator<Year> {
+
+        public ForYear() {
+            super(Year::now);
+        }
+    }
+
+    public static class ForYearMonth extends FutureValidator<YearMonth> {
+
+        public ForYearMonth() {
+            super(YearMonth::now);
+        }
+    }
+
+    private static final IntPredicate TEST = n -> n > 0;
+
+    protected FutureValidator(Function<Clock, T> now) {
+        super(now, TEST);
+    }
+
+    protected FutureValidator(Function<Clock, T> now, Comparator<T> cmp) {
+        super(now, cmp, TEST);
+    }
+}

Added: tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/MaxValidatorForNumber.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/MaxValidatorForNumber.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/MaxValidatorForNumber.java (added)
+++ tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/MaxValidatorForNumber.java Fri Oct 12 15:00:48 2018
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.bval.constraints;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.Max;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+/**
+ * Check that the number being validated is less than or equal to the maximum
+ * value specified.
+ */
+public class MaxValidatorForNumber implements ConstraintValidator<Max, Number> {
+
+    private long max;
+
+    @Override
+    public void initialize(Max annotation) {
+        this.max = annotation.value();
+    }
+
+    @Override
+    public boolean isValid(Number value, ConstraintValidatorContext context) {
+        if (value == null) {
+            return true;
+        }
+        if (value instanceof BigDecimal) {
+            return ((BigDecimal) value).compareTo(BigDecimal.valueOf(max)) < 1;
+        }
+        if (value instanceof BigInteger) {
+            return ((BigInteger) value).compareTo(BigInteger.valueOf(max)) < 1;
+        }
+        return value.longValue() <= max;
+    }
+}

Added: tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/MaxValidatorForString.java
URL: http://svn.apache.org/viewvc/tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/MaxValidatorForString.java?rev=1843674&view=auto
==============================================================================
--- tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/MaxValidatorForString.java (added)
+++ tomee/deps/branches/bval-2/bval-jsr/src/main/java/org/apache/bval/constraints/MaxValidatorForString.java Fri Oct 12 15:00:48 2018
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.bval.constraints;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.constraints.Max;
+import java.math.BigDecimal;
+
+/**
+ * Check that the String being validated represents a number, and has a value
+ * less than or equal to the maximum value specified.
+ */
+public class MaxValidatorForString implements ConstraintValidator<Max, String> {
+
+    private long max;
+
+    @Override
+    public void initialize(Max annotation) {
+        this.max = annotation.value();
+    }
+
+    @Override
+    public boolean isValid(String value, ConstraintValidatorContext context) {
+        if (value == null) {
+            return true;
+        }
+        try {
+            return new BigDecimal(value).compareTo(BigDecimal.valueOf(max)) < 1;
+        } catch (NumberFormatException nfe) {
+            return false;
+        }
+    }
+}