incubator-bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r1165923 [2/3] - in /incubator/bval/sandbox/lang3-work: ./ bval-core/src/main/java/org/apache/bval/ bval-core/src/main/java/org/apache/bval/model/ bval-core/src/main/java/org/apache/bval/util/ bval-jsr303-dynamic/provider/src/main/java/org/...
Date Tue, 06 Sep 2011 23:07:55 GMT
Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/DefaultValidationProviderResolver.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/DefaultValidationProviderResolver.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/DefaultValidationProviderResolver.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/DefaultValidationProviderResolver.java Tue Sep  6 23:07:53 2011
@@ -20,13 +20,12 @@ package org.apache.bval.jsr303;
 import javax.validation.ValidationException;
 import javax.validation.ValidationProviderResolver;
 import javax.validation.spi.ValidationProvider;
-
-import org.apache.bval.jsr303.util.SecureActions;
-
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.List;
@@ -35,7 +34,7 @@ public class DefaultValidationProviderRe
 
     //TODO - Spec recommends caching per classloader
     private static final String SPI_CFG =
-        "META-INF/services/javax.validation.spi.ValidationProvider";
+            "META-INF/services/javax.validation.spi.ValidationProvider";
 
     /**
      * {@inheritDoc}
@@ -63,10 +62,21 @@ public class DefaultValidationProviderRe
                                 // try loading the specified class
                                 final Class<?> provider = cl.loadClass(line);
                                 // create an instance to return
-                                providers.add((ValidationProvider<?>) SecureActions.newInstance(provider));
+                                ValidationProvider<?> vp =
+                                        AccessController.doPrivileged(new PrivilegedAction<ValidationProvider<?>>() {
+                                            public ValidationProvider<?> run() {
+                                                try {
+                                                    return (ValidationProvider<?>) provider.newInstance();
+                                                } catch (final Exception ex) {
+                                                    throw new ValidationException("Cannot instantiate : " + provider, ex);
+                                                }
+                                            }
+                                        });
+                                 providers.add(vp);
+
                             } catch (ClassNotFoundException e) {
                                 throw new ValidationException("Failed to load provider " +
-                                    line + " configured in file " + url, e);
+                                        line + " configured in file " + url, e);
                             }
                         }
                         line = br.readLine();

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ElementDescriptorImpl.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ElementDescriptorImpl.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ElementDescriptorImpl.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ElementDescriptorImpl.java Tue Sep  6 23:07:53 2011
@@ -16,12 +16,11 @@
  */
 package org.apache.bval.jsr303;
 
-import javax.validation.metadata.ConstraintDescriptor;
-import javax.validation.metadata.ElementDescriptor;
-
 import org.apache.bval.model.MetaBean;
 import org.apache.bval.model.Validation;
 
+import javax.validation.metadata.ConstraintDescriptor;
+import javax.validation.metadata.ElementDescriptor;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/Jsr303MetaBeanFactory.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/Jsr303MetaBeanFactory.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/Jsr303MetaBeanFactory.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/Jsr303MetaBeanFactory.java Tue Sep  6 23:07:53 2011
@@ -22,6 +22,8 @@ import java.lang.annotation.Annotation;
 import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -118,7 +120,7 @@ public class Jsr303MetaBeanFactory imple
                 metabean));
         }
 
-        final Field[] fields = SecureActions.getDeclaredFields(beanClass);
+        final Field[] fields = doPrivileged(SecureActions.getDeclaredFields(beanClass));
         for (Field field : fields) {
             MetaProperty metaProperty = metabean.getProperty(field.getName());
             // create a property for those fields for which there is not yet a
@@ -135,7 +137,7 @@ public class Jsr303MetaBeanFactory imple
                 }
             }
         }
-        final Method[] methods = SecureActions.getDeclaredMethods(beanClass);
+        final Method[] methods = doPrivileged(SecureActions.getDeclaredMethods(beanClass));
         for (Method method : methods) {
             String propName = null;
             if (method.getParameterTypes().length == 0) {
@@ -294,4 +296,22 @@ public class Jsr303MetaBeanFactory imple
         return result;
     }
 
+
+
+
+    /**
+     * Perform action with AccessController.doPrivileged() if a security manager is installed.
+     *
+     * @param action
+     *  the action to run
+     * @return
+     *  result of the action
+     */
+    private static <T> T doPrivileged(final PrivilegedAction<T> action) {
+        if (System.getSecurityManager() != null) {
+            return AccessController.doPrivileged(action);
+        } else {
+            return action.run();
+        }
+    }
 }

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/PropertyDescriptorImpl.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/PropertyDescriptorImpl.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/PropertyDescriptorImpl.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/PropertyDescriptorImpl.java Tue Sep  6 23:07:53 2011
@@ -18,11 +18,11 @@
  */
 package org.apache.bval.jsr303;
 
-import javax.validation.metadata.PropertyDescriptor;
-
 import org.apache.bval.model.Features;
 import org.apache.bval.model.MetaProperty;
 
+import javax.validation.metadata.PropertyDescriptor;
+
 /**
  * Description: {@link PropertyDescriptor} implementation.<br/>
  */

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/ConstructorDescriptorImpl.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/ConstructorDescriptorImpl.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/ConstructorDescriptorImpl.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/ConstructorDescriptorImpl.java Tue Sep  6 23:07:53 2011
@@ -17,13 +17,13 @@
 package org.apache.bval.jsr303.extensions;
 
 
-import java.util.ArrayList;
-import java.util.List;
-
 import org.apache.bval.jsr303.ElementDescriptorImpl;
 import org.apache.bval.model.MetaBean;
 import org.apache.bval.model.Validation;
 
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * Description: {@link ConstructorDescriptor} implementation.<br/>
  */

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/MethodBeanDescriptorImpl.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/MethodBeanDescriptorImpl.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/MethodBeanDescriptorImpl.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/MethodBeanDescriptorImpl.java Tue Sep  6 23:07:53 2011
@@ -16,16 +16,16 @@
  */
 package org.apache.bval.jsr303.extensions;
 
+import org.apache.bval.jsr303.ApacheFactoryContext;
+import org.apache.bval.jsr303.BeanDescriptorImpl;
+import org.apache.bval.model.MetaBean;
+
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.bval.jsr303.ApacheFactoryContext;
-import org.apache.bval.jsr303.BeanDescriptorImpl;
-import org.apache.bval.model.MetaBean;
-
 /**
  * Description: {@link MethodBeanDescriptor} implementation.<br/>
  */

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/MethodDescriptorImpl.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/MethodDescriptorImpl.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/MethodDescriptorImpl.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/MethodDescriptorImpl.java Tue Sep  6 23:07:53 2011
@@ -16,15 +16,15 @@
  */
 package org.apache.bval.jsr303.extensions;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
 import org.apache.bval.jsr303.ConstraintValidation;
 import org.apache.bval.jsr303.ElementDescriptorImpl;
 import org.apache.bval.model.MetaBean;
 import org.apache.bval.model.Validation;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
 /**
  * Description: {@link MethodDescriptor} implementation.<br/>
  */

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/ProcedureDescriptor.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/ProcedureDescriptor.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/ProcedureDescriptor.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/ProcedureDescriptor.java Tue Sep  6 23:07:53 2011
@@ -17,10 +17,10 @@
 package org.apache.bval.jsr303.extensions;
 
 
-import java.util.List;
-
 import org.apache.bval.model.MetaBean;
 
+import java.util.List;
+
 /**
  * Description: superinterface of {@link ConstructorDescriptor} and {@link MethodDescriptor}.<br/>
  */

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/resolver/DefaultTraversableResolver.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/resolver/DefaultTraversableResolver.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/resolver/DefaultTraversableResolver.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/resolver/DefaultTraversableResolver.java Tue Sep  6 23:07:53 2011
@@ -16,15 +16,17 @@
  */
 package org.apache.bval.jsr303.resolver;
 
-import org.apache.bval.jsr303.util.SecureActions;
-import org.apache.commons.lang3.ClassUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import java.lang.annotation.ElementType;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 
 import javax.validation.Path;
 import javax.validation.TraversableResolver;
-import java.lang.annotation.ElementType;
 
+import org.apache.bval.jsr303.util.ClassHelper;
+import org.apache.commons.lang3.ClassUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /** @see javax.validation.TraversableResolver */
 public class DefaultTraversableResolver implements TraversableResolver, CachingRelevant {
@@ -71,8 +73,9 @@ public class DefaultTraversableResolver 
     /** Tries to load detect and load JPA. */
     @SuppressWarnings("unchecked")
     private void initJpa() {
+        final ClassLoader classLoader = getClassLoader();
         try {
-            ClassUtils.getClass(PERSISTENCE_UTIL_CLASSNAME);
+            ClassUtils.getClass(classLoader, PERSISTENCE_UTIL_CLASSNAME, true);
             log.debug("Found {} on classpath.", PERSISTENCE_UTIL_CLASSNAME);
         } catch (Exception e) {
             log.debug("Cannot find {} on classpath. All properties will per default be traversable.", PERSISTENCE_UTIL_CLASSNAME);
@@ -81,9 +84,9 @@ public class DefaultTraversableResolver 
 
         try {
             Class<? extends TraversableResolver> jpaAwareResolverClass =
-                  (Class<? extends TraversableResolver>) ClassUtils
-                        .getClass(JPA_AWARE_TRAVERSABLE_RESOLVER_CLASSNAME);
-            jpaTR = SecureActions.newInstance(jpaAwareResolverClass);
+              (Class<? extends TraversableResolver>)
+                ClassUtils.getClass(classLoader, JPA_AWARE_TRAVERSABLE_RESOLVER_CLASSNAME, true);
+            jpaTR = jpaAwareResolverClass.newInstance();
             log.debug("Instantiated an instance of {}.", JPA_AWARE_TRAVERSABLE_RESOLVER_CLASSNAME);
         } catch (Exception e) {
             log.warn("Unable to load or instanciate JPA aware resolver " +
@@ -98,4 +101,25 @@ public class DefaultTraversableResolver 
     public boolean needsCaching() {
         return jpaTR != null && CachingTraversableResolver.needsCaching(jpaTR);
     }
+
+
+    
+    private static ClassLoader getClassLoader()
+    {
+      return (System.getSecurityManager() == null)
+        ? getClassLoader0()
+        : AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+              public ClassLoader run() {
+                return getClassLoader0();
+              }
+          });
+    }
+
+    private static ClassLoader getClassLoader0()
+    {
+      final ClassLoader loader = Thread.currentThread().getContextClassLoader();
+      return (loader != null) ? loader : ClassHelper.class.getClassLoader();
+    }
+
+
 }

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/ClassHelper.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/ClassHelper.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/ClassHelper.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/ClassHelper.java Tue Sep  6 23:07:53 2011
@@ -19,8 +19,6 @@
 package org.apache.bval.jsr303.util;
 
 import java.security.AccessController;
-import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
 
 /**
@@ -51,9 +49,8 @@ public class ClassHelper {
             return;
         }
         allClasses.add(clazz);
-        List<Class<?>> subClasses = new ArrayList<Class<?>>(Arrays.asList(clazz.getInterfaces()));
-        subClasses.add(0, clazz.getSuperclass());
-        for (Class<?> subClass : subClasses) {
+        fillFullClassHierarchyAsList(allClasses, clazz.getSuperclass());
+        for (Class<?> subClass : clazz.getInterfaces()) {
             fillFullClassHierarchyAsList(allClasses, subClass);
         }
     }

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/ConstraintDefinitionValidator.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/ConstraintDefinitionValidator.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/ConstraintDefinitionValidator.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/ConstraintDefinitionValidator.java Tue Sep  6 23:07:53 2011
@@ -56,9 +56,11 @@ public class ConstraintDefinitionValidat
      * @param annotation
      *            The annotation to check.
      */
-    private static void validAttributes(Annotation annotation) {
-        Method[] methods = SecureActions.getDeclaredMethods(annotation.annotationType());
-        for (Method method : methods) {
+    private static void validAttributes(final Annotation annotation) {
+        final Method[] methods = SecureActions.doPrivileged(
+            SecureActions.getDeclaredMethods(annotation.annotationType())
+        );
+        for (Method method : methods ){
             // Currently case insensitive, the spec is unclear about this
             if (method.getName().toLowerCase(Locale.ENGLISH).startsWith("valid")) {
                 throw new ConstraintDefinitionException(

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/NodeBuilderCustomizableContextImpl.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/NodeBuilderCustomizableContextImpl.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/NodeBuilderCustomizableContextImpl.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/NodeBuilderCustomizableContextImpl.java Tue Sep  6 23:07:53 2011
@@ -19,10 +19,10 @@
 package org.apache.bval.jsr303.util;
 
 
-import javax.validation.ConstraintValidatorContext;
-
 import org.apache.bval.jsr303.ConstraintValidatorContextImpl;
 
+import javax.validation.ConstraintValidatorContext;
+
 /**
  * Description: implementation of {@link NodeBuilderCustomizableContext}.<br/>
  */

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/NodeBuilderDefinedContextImpl.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/NodeBuilderDefinedContextImpl.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/NodeBuilderDefinedContextImpl.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/NodeBuilderDefinedContextImpl.java Tue Sep  6 23:07:53 2011
@@ -19,10 +19,10 @@
 package org.apache.bval.jsr303.util;
 
 
-import javax.validation.ConstraintValidatorContext;
-
 import org.apache.bval.jsr303.ConstraintValidatorContextImpl;
 
+import javax.validation.ConstraintValidatorContext;
+
 /**
  * Description: Implementation of {@link NodeBuilderDefinedContext}.<br/>
  */

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/NodeContextBuilderImpl.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/NodeContextBuilderImpl.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/NodeContextBuilderImpl.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/NodeContextBuilderImpl.java Tue Sep  6 23:07:53 2011
@@ -19,11 +19,11 @@
 package org.apache.bval.jsr303.util;
 
 
+import org.apache.bval.jsr303.ConstraintValidatorContextImpl;
+
 import javax.validation.ConstraintValidatorContext;
 import javax.validation.ConstraintValidatorContext.ConstraintViolationBuilder.NodeContextBuilder;
 
-import org.apache.bval.jsr303.ConstraintValidatorContextImpl;
-
 /**
  * Description: Implementation of {@link NodeContextBuilder}.<br/>
  */

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/SecureActions.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/SecureActions.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/SecureActions.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/util/SecureActions.java Tue Sep  6 23:07:53 2011
@@ -18,218 +18,129 @@
  */
 package org.apache.bval.jsr303.util;
 
-import org.apache.bval.util.PrivilegedActions;
-import org.apache.commons.lang3.StringUtils;
-
-import javax.validation.ValidationException;
-import java.lang.reflect.Constructor;
+import java.lang.reflect.AccessibleObject;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
+import java.security.AccessController;
 import java.security.PrivilegedAction;
 
+import org.apache.bval.util.PrivilegedActions;
+
 /**
  * Description: utility methods to perform actions with AccessController or without.<br/>
  */
 public class SecureActions extends PrivilegedActions {
 
     /**
-     * Create a new instance of the class using the default no-arg constructor.
-     * perform newInstance() call with AccessController.doPrivileged() if possible.
-     *
-     * @param cls - the class (no interface, non-abstract, has accessible default no-arg-constructor)
-     * @return a new instance
-     */
-    public static <T> T newInstance(final Class<T> cls) {
-        return newInstance(cls, ValidationException.class);
-    }
-
-    /**
-     * Create a new instance of a specified class, rethrowing {@link ValidationException}.
+     * Create a privileged action to get the context classloader of the current thread.
      *
-     * @param <T>
-     * @param cls - the class (no interface, non-abstract, has accessible matching constructor)
-     * @param paramTypes
-     * @param values
-     * @return a new instance
+     * @see Thread#getContextClassLoader()
      */
-    public static <T> T newInstance(final Class<T> cls, final Class<?>[] paramTypes,
-                                    final Object[] values) {
-        return newInstance(cls, ValidationException.class, paramTypes, values);
+    public static PrivilegedAction<ClassLoader> getContextClassLoader()
+    {
+        return SecureActions.GetContextClassLoader.instance;
     }
 
-    /**
-     * Load a class.
-     * @param className
-     * @param caller
-     * @return loaded Class instance
-     */
-    public static Class<?> loadClass(final String className, final Class<?> caller) {
-        return run(new PrivilegedAction<Class<?>>() {
-            public Class<?> run() {
-                try {
-                    ClassLoader contextClassLoader =
-                          Thread.currentThread().getContextClassLoader();
-                    if (contextClassLoader != null) {
-                        return contextClassLoader.loadClass(className);
-                    }
-                } catch (Throwable e) {
-                    // ignore
-                }
-                try {
-                    return Class.forName(className, true, caller.getClassLoader());
-                } catch (ClassNotFoundException e) {
-                    throw new ValidationException("Unable to load class: " + className, e);
-                }
-            }
-        });
-    }
 
     /**
-     * Get a field declared on a given class.
-     * @param clazz
-     * @param fieldName
-     * @return Field found
+     * Create a privileged action to get the named field declared by the specified class.
+     * The result of the action will be {@code null} if there is no such field.
      */
-    public static Field getDeclaredField(final Class<?> clazz, final String fieldName) {
-        return run(new PrivilegedAction<Field>() {
+    public static PrivilegedAction<Field> getDeclaredField(final Class<?> clazz, final String fieldName) {
+        return new PrivilegedAction<Field>() {
             public Field run() {
                 try {
-                    Field f = clazz.getDeclaredField(fieldName);
+                    final Field f = clazz.getDeclaredField(fieldName);
                     setAccessibility(f);
                     return f;
-                } catch (NoSuchFieldException e) {
+                } catch (final NoSuchFieldException ex) {
                     return null;
                 }
             }
-        });
+        };
     }
 
+
+
     /**
-     * Get all fields declared on a given class.
-     * @param clazz
-     * @return Field found
+     * Create a privileged action to get all fields declared by the specified class.
      */
-    public static Field[] getDeclaredFields(final Class<?> clazz) {
-        return run(new PrivilegedAction<Field[]>() {
+    public static PrivilegedAction<Field[]> getDeclaredFields(final Class<?> clazz) {
+        return new PrivilegedAction<Field[]>() {
             public Field[] run() {
-                Field[] fs = clazz.getDeclaredFields();
-                for( Field f : fs ) {
-                    setAccessibility(f);
-                }
-                return fs;
+                final Field[] fields = clazz.getDeclaredFields();
+                if (fields.length > 0)
+                    AccessibleObject.setAccessible(fields, true);
+                return fields;
             }
-        });
-    }
-
-    private static void setAccessibility(Field field) {
-        if (!Modifier.isPublic(field.getModifiers()) || (
-              Modifier.isPublic(field.getModifiers()) &&
-                    Modifier.isAbstract(field.getModifiers()))) {
-            field.setAccessible(true);
-        }
+        };
     }
 
-    /**
-     * Returns the <b>public method</b> with the specified name or null if it does not exist.
-     *
-     * @param clazz
-     * @param methodName
-     * @return Returns the method or null if not found.
-     */
-    public static Method getGetter(final Class<?> clazz, final String methodName) {
-        return run(new PrivilegedAction<Method>() {
-            public Method run() {
-                try {
-                    String methodName0 = StringUtils.capitalize(methodName);
-                    try {
-                        return clazz.getMethod("get" + methodName0);
-                    } catch (NoSuchMethodException e) {
-                        return clazz.getMethod("is" + methodName0);
-                    }
-                } catch (NoSuchMethodException e) {
-                    return null;
-                }
-            }
-        });
 
-    }
 
     /**
-     * Get the method of <code>methodName</code> available on <code>clazz</code>.
-     * @param clazz
-     * @param methodName
-     * @return {@link Method} found
+     * Create a privileged action to get all methods declared by the specified class.
      */
-    public static Method getMethod(final Class<?> clazz, final String methodName) {
-        return run(new PrivilegedAction<Method>() {
-            public Method run() {
-                try {
-                    return clazz.getMethod(methodName);
-                } catch (NoSuchMethodException e) {
-                    return null;
-                }
-            }
-        });
+    public static PrivilegedAction<Method[]> getDeclaredMethods(final Class<?> clazz) {
+      // XXX 2011-03-27 jw: Inconsistent behaviour.
+      // doGetDeclaredFields() is setting fields accessible, but here we don't.
+      return new PrivilegedAction<Method[]>() {
+          public Method[] run() {
+            return clazz.getDeclaredMethods();
+        }
+      };
     }
 
     /**
-     * Get methods declared on <code>clazz</code>.
-     * @param clazz
-     * @return {@link Method} array
-     */
-    public static Method[] getDeclaredMethods(final Class<?> clazz) {
-        return run(new PrivilegedAction<Method[]>() {
-            public Method[] run() {
-                return clazz.getDeclaredMethods();
-            }
-        });
+     * Create a privileged action to get the named method declared by the specified class
+     * or by one of its ancestors.
+     * The result of the action will be {@code null} if there is no such method.
+     */
+    public static PrivilegedAction<Method> getPublicMethod(final Class<?> clazz, final String methodName) {
+      return new PrivilegedAction<Method>() {
+          public Method run() {
+              try {
+                  return clazz.getMethod(methodName, (Class[]) null);
+              } catch (final NoSuchMethodException ex) {
+                  return null;
+              }
+          }
+      };
     }
 
-    /**
-     * Get class loader of <code>clazz</code>.
-     * @param clazz
-     * @return {@link ClassLoader}
-     */
-    public static ClassLoader getClassLoader(final Class<?> clazz) {
-        return run(new PrivilegedAction<ClassLoader>() {
-            public ClassLoader run() {
-                return clazz.getClassLoader();
-            }
-        });
+    private static void setAccessibility(Field field) {
+      // FIXME 2011-03-27 jw:
+      // - Why not simply call field.setAccessible(true)?
+      // - Fields can not be abstract.
+        if (!Modifier.isPublic(field.getModifiers()) || (
+              Modifier.isPublic(field.getModifiers()) &&
+                    Modifier.isAbstract(field.getModifiers()))) {
+            field.setAccessible(true);
+        }
     }
 
-    /**
-     * Get context class loader of <code>thread</code>.
-     * @param thread
-     * @return {@link ClassLoader}
-     */
-    public static ClassLoader getContextClassLoader(final Thread thread) {
-        return run(new PrivilegedAction<ClassLoader>() {
-            public ClassLoader run() {
-                return thread.getContextClassLoader();
-            }
-        });
+    static <T> T doPrivileged(final PrivilegedAction<T> action) {
+        if (System.getSecurityManager() != null) {
+            return AccessController.doPrivileged(action);
+        } else {
+            return action.run();
+        }
     }
 
-    /**
-     * Get the constructor of <code>clazz</code> matching <code>params</code>.
-     * @param <T>
-     * @param clazz
-     * @param params
-     * @return {@link Constructor} found
-     */
-    public static <T> Constructor<T> getConstructor(final Class<T> clazz,
-                                                    final Class<?>... params) {
-        return run(new PrivilegedAction<Constructor<T>>() {
-            public Constructor<T> run() {
-                try {
-                    return clazz.getConstructor(params);
-                } catch (NoSuchMethodException e) {
-                    return null;
-                }
-            }
-        });
+    private static final class GetContextClassLoader extends Object implements PrivilegedAction<ClassLoader> {
+
+      static final GetContextClassLoader instance = new GetContextClassLoader();
+
+      private GetContextClassLoader()
+      {
+        super();
+      }
+
+      public final ClassLoader run() {
+          return Thread.currentThread().getContextClassLoader();
+      }
+
     }
 
 }

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/AnnotationProxy.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/AnnotationProxy.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/AnnotationProxy.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/AnnotationProxy.java Tue Sep  6 23:07:53 2011
@@ -20,6 +20,8 @@ import java.io.Serializable;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.SortedSet;
@@ -57,7 +59,9 @@ class AnnotationProxy implements Annotat
     private <A extends Annotation> Map<String, Object> getAnnotationValues(AnnotationProxyBuilder<A> descriptor) {
         Map<String, Object> result = new HashMap<String, Object>();
         int processedValuesFromDescriptor = 0;
-        final Method[] declaredMethods = SecureActions.getDeclaredMethods(annotationType);
+        final Method[] declaredMethods = doPrivileged(
+          SecureActions.getDeclaredMethods(annotationType)
+        );
         for (Method m : declaredMethods) {
             if (descriptor.contains(m.getName())) {
                 result.put(m.getName(), descriptor.getValue(m.getName()));
@@ -113,4 +117,14 @@ class AnnotationProxy implements Annotat
         result.addAll(values.keySet());
         return result;
     }
+
+
+
+    private static <T> T doPrivileged(final PrivilegedAction<T> action) {
+        if (System.getSecurityManager() != null) {
+            return AccessController.doPrivileged(action);
+        } else {
+            return action.run();
+        }
+    }
 }

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/AnnotationProxyBuilder.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/AnnotationProxyBuilder.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/AnnotationProxyBuilder.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/AnnotationProxyBuilder.java Tue Sep  6 23:07:53 2011
@@ -17,10 +17,13 @@
 package org.apache.bval.jsr303.xml;
 
 import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -42,7 +45,7 @@ final public class AnnotationProxyBuilde
 
     /**
      * Create a new AnnotationProxyBuilder instance.
-     * 
+     *
      * @param annotationType
      */
     public AnnotationProxyBuilder(Class<A> annotationType) {
@@ -51,7 +54,7 @@ final public class AnnotationProxyBuilde
 
     /**
      * Create a new AnnotationProxyBuilder instance.
-     * 
+     *
      * @param annotationType
      * @param elements
      */
@@ -66,14 +69,13 @@ final public class AnnotationProxyBuilde
      * Create a builder initially configured to create an annotation equivalent
      * to <code>annot</code>.
      * 
-     * @param annot
-     *            Annotation to be replicated.
+     * @param annot Annotation to be replicated.
      */
     @SuppressWarnings("unchecked")
     public AnnotationProxyBuilder(A annot) {
         this((Class<A>) annot.annotationType());
         // Obtain the "elements" of the annotation
-        Method[] methods = SecureActions.getDeclaredMethods(annot.annotationType());
+        final Method[] methods = doPrivileged(SecureActions.getDeclaredMethods(annot.annotationType()));
         for (Method m : methods) {
             if (!m.isAccessible()) {
                 m.setAccessible(true);
@@ -94,7 +96,7 @@ final public class AnnotationProxyBuilde
 
     /**
      * Add an element to the configuration.
-     * 
+     *
      * @param elementName
      * @param value
      */
@@ -104,7 +106,7 @@ final public class AnnotationProxyBuilde
 
     /**
      * Get the specified element value from the current configuration.
-     * 
+     *
      * @param elementName
      * @return Object value
      */
@@ -114,7 +116,7 @@ final public class AnnotationProxyBuilde
 
     /**
      * Learn whether a given element has been configured.
-     * 
+     *
      * @param elementName
      * @return <code>true</code> if an <code>elementName</code> element is found
      *         on this annotation
@@ -125,7 +127,7 @@ final public class AnnotationProxyBuilde
 
     /**
      * Get the number of configured elements.
-     * 
+     *
      * @return int
      */
     public int size() {
@@ -134,7 +136,7 @@ final public class AnnotationProxyBuilde
 
     /**
      * Get the configured Annotation type.
-     * 
+     *
      * @return Class<A>
      */
     public Class<A> getType() {
@@ -143,7 +145,7 @@ final public class AnnotationProxyBuilde
 
     /**
      * Configure the well-known JSR303 "message" element.
-     * 
+     *
      * @param message
      */
     public void setMessage(String message) {
@@ -152,7 +154,7 @@ final public class AnnotationProxyBuilde
 
     /**
      * Configure the well-known JSR303 "groups" element.
-     * 
+     *
      * @param groups
      */
     public void setGroups(Class<?>[] groups) {
@@ -170,20 +172,31 @@ final public class AnnotationProxyBuilde
 
     /**
      * Create the annotation represented by this builder.
-     * 
+     *
      * @return {@link Annotation}
      */
-    @SuppressWarnings("unchecked")
     public A createAnnotation() {
         ClassLoader classLoader = SecureActions.getClassLoader(getClass());
-        Class<A> proxyClass = (Class<A>) Proxy.getProxyClass(classLoader, getType());
-        InvocationHandler handler = new AnnotationProxy(this);
-        try {
-            return SecureActions.getConstructor(proxyClass, InvocationHandler.class).newInstance(handler);
-        } catch (ValidationException e) {
-            throw e;
-        } catch (Exception e) {
-            throw new ValidationException("Unable to create annotation for configured constraint", e);
+        @SuppressWarnings("unchecked")
+        final Class<A> proxyClass = (Class<A>) Proxy.getProxyClass(classLoader, getType());
+        final InvocationHandler handler = new AnnotationProxy(this);
+        return doPrivileged(new PrivilegedAction<A>() {
+            public A run() {
+                try {
+                    Constructor<A> constructor = proxyClass.getConstructor(InvocationHandler.class);
+                    return constructor.newInstance(handler);
+                } catch (Exception e) {
+                    throw new ValidationException("Unable to create annotation for configured constraint", e);
+                }
+            }
+        });
+    }
+
+    private static <T> T doPrivileged(final PrivilegedAction<T> action) {
+        if (System.getSecurityManager() != null) {
+            return AccessController.doPrivileged(action);
+        } else {
+            return action.run();
         }
     }
 }

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/MetaConstraint.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/MetaConstraint.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/MetaConstraint.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/MetaConstraint.java Tue Sep  6 23:07:53 2011
@@ -17,12 +17,11 @@
 package org.apache.bval.jsr303.xml;
 
 
-import javax.validation.ValidationException;
-
 import org.apache.bval.util.AccessStrategy;
 import org.apache.bval.util.FieldAccess;
 import org.apache.bval.util.MethodAccess;
 
+import javax.validation.ValidationException;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Field;
 import java.lang.reflect.Member;

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/ValidationMappingParser.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/ValidationMappingParser.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/ValidationMappingParser.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/ValidationMappingParser.java Tue Sep  6 23:07:53 2011
@@ -17,15 +17,22 @@
 package org.apache.bval.jsr303.xml;
 
 
-import org.apache.bval.jsr303.ApacheValidatorFactory;
-import org.apache.bval.jsr303.ConstraintAnnotationAttributes;
-import org.apache.bval.jsr303.util.EnumerationConverter;
-import org.apache.bval.jsr303.util.IOUtils;
-import org.apache.bval.jsr303.util.SecureActions;
-import org.apache.bval.util.FieldAccess;
-import org.apache.bval.util.MethodAccess;
-import org.apache.commons.beanutils.ConvertUtils;
-import org.apache.commons.beanutils.Converter;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Array;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
 
 import javax.validation.Constraint;
 import javax.validation.ConstraintValidator;
@@ -37,14 +44,17 @@ import javax.xml.bind.JAXBException;
 import javax.xml.bind.Unmarshaller;
 import javax.xml.transform.stream.StreamSource;
 import javax.xml.validation.Schema;
-import java.io.InputStream;
-import java.io.Serializable;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Array;
-import java.lang.reflect.Field;
-import java.lang.reflect.Member;
-import java.lang.reflect.Method;
-import java.util.*;
+
+import org.apache.bval.jsr303.ApacheValidatorFactory;
+import org.apache.bval.jsr303.ConstraintAnnotationAttributes;
+import org.apache.bval.jsr303.util.EnumerationConverter;
+import org.apache.bval.jsr303.util.IOUtils;
+import org.apache.bval.jsr303.util.SecureActions;
+import org.apache.bval.util.FieldAccess;
+import org.apache.bval.util.MethodAccess;
+import org.apache.commons.beanutils.ConvertUtils;
+import org.apache.commons.beanutils.Converter;
+import org.apache.commons.lang3.StringUtils;
 
 
 /**
@@ -185,8 +195,8 @@ public class ValidationMappingParser {
     }
 
     private <A extends Annotation> Class<?> getAnnotationParameterType(
-          Class<A> annotationClass, String name) {
-        Method m = SecureActions.getMethod(annotationClass, name);
+          final Class<A> annotationClass, final String name) {
+        final Method m = doPrivileged(SecureActions.getPublicMethod(annotationClass, name));
         if (m == null) {
             throw new ValidationException("Annotation of type " + annotationClass.getName() +
                   " does not contain a parameter " + name + ".");
@@ -355,7 +365,7 @@ public class ValidationMappingParser {
             } else {
                 fieldNames.add(fieldName);
             }
-            final Field field = SecureActions.getDeclaredField(beanClass, fieldName);
+            final Field field = doPrivileged(SecureActions.getDeclaredField(beanClass, fieldName));
             if (field == null) {
                 throw new ValidationException(
                       beanClass.getName() + " does not contain the fieldType  " + fieldName);
@@ -394,7 +404,7 @@ public class ValidationMappingParser {
             } else {
                 getterNames.add(getterName);
             }
-            final Method method = SecureActions.getGetter(beanClass, getterName);
+            final Method method = getGetter(beanClass, getterName);
             if (method == null) {
                 throw new ValidationException(
                       beanClass.getName() + " does not contain the property  " + getterName);
@@ -451,8 +461,8 @@ public class ValidationMappingParser {
             }
             for (JAXBElement<String> validatorClassName : validatedByType.getValue()) {
                 Class<? extends ConstraintValidator<?, ?>> validatorClass;
-                validatorClass = (Class<? extends ConstraintValidator<?, ?>>) SecureActions
-                      .loadClass(validatorClassName.getValue(), this.getClass());
+                validatorClass = (Class<? extends ConstraintValidator<?, ?>>)
+                      loadClass(validatorClassName.getValue());
 
 
                 if (!ConstraintValidator.class.isAssignableFrom(validatorClass)) {
@@ -497,8 +507,7 @@ public class ValidationMappingParser {
     }
 
     private Class<?> loadClass(String className, String defaultPackage) {
-        return SecureActions
-              .loadClass(toQualifiedClassName(className, defaultPackage), this.getClass());
+        return loadClass(toQualifiedClassName(className, defaultPackage));
     }
 
     private String toQualifiedClassName(String className, String defaultPackage) {
@@ -512,4 +521,48 @@ public class ValidationMappingParser {
         return clazz.contains(".");
     }
 
+
+
+    private static <T> T doPrivileged(final PrivilegedAction<T> action) {
+        if (System.getSecurityManager() != null) {
+            return AccessController.doPrivileged(action);
+        } else {
+            return action.run();
+        }
+    }
+
+
+
+    private static Method getGetter(final Class<?> clazz, final String propertyName) {
+        return doPrivileged(new PrivilegedAction<Method>() {
+            public Method run() {
+                try {
+                    final String p = StringUtils.capitalize(propertyName);
+                    try {
+                        return clazz.getMethod("get" + p);
+                    } catch (NoSuchMethodException e) {
+                        return clazz.getMethod("is" + p);
+                    }
+                } catch (NoSuchMethodException e) {
+                    return null;
+                }
+            }
+        });
+
+    }
+
+
+
+    private Class<?> loadClass(final String className) {
+        ClassLoader loader = doPrivileged(SecureActions.getContextClassLoader());
+        if (loader == null)
+            loader = getClass().getClassLoader();
+
+        try {
+            return Class.forName(className, true, loader);
+        } catch (ClassNotFoundException ex) {
+            throw new ValidationException("Unable to load class: " + className, ex);
+        }
+    }
+
 }

Propchange: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/ValidationMappingParser.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Sep  6 23:07:53 2011
@@ -1 +1 @@
-/incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/ValidationMappingParser.java:992330-992353,992401,992406,992412,992510,992648,993404-993438,996236,996240,997154,1002445,1002497,1031642,1035416-1036603,1069985,1073929,1073944,1073946,1073949,1089957
+/incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/ValidationMappingParser.java:992330-992353,992401,992406,992412,992510,992648,993404-993438,996236,996240,997154,1002445,1002497,1031642,1035416-1036603,1069985,1073929,1073944,1073946,1073949,1089957,1145260-1165833

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/ValidationParser.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/ValidationParser.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/ValidationParser.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/xml/ValidationParser.java Tue Sep  6 23:07:53 2011
@@ -19,10 +19,13 @@
 package org.apache.bval.jsr303.xml;
 
 
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Enumeration;
+import org.apache.bval.jsr303.ConfigurationImpl;
+import org.apache.bval.jsr303.util.IOUtils;
+import org.apache.bval.jsr303.util.SecureActions;
+import org.apache.bval.util.PrivilegedActions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.xml.sax.SAXException;
 
 import javax.validation.ConstraintValidatorFactory;
 import javax.validation.MessageInterpolator;
@@ -37,14 +40,12 @@ import javax.xml.bind.Unmarshaller;
 import javax.xml.transform.stream.StreamSource;
 import javax.xml.validation.Schema;
 import javax.xml.validation.SchemaFactory;
-
-import org.apache.bval.jsr303.ConfigurationImpl;
-import org.apache.bval.jsr303.util.IOUtils;
-import org.apache.bval.jsr303.util.SecureActions;
-import org.apache.bval.util.PrivilegedActions;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.xml.sax.SAXException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Enumeration;
 
 /**
  * Description: uses jaxb to parse validation.xml<br/>
@@ -53,16 +54,17 @@ import org.xml.sax.SAXException;
 public class ValidationParser {
     private static final String DEFAULT_VALIDATION_XML_FILE = "META-INF/validation.xml";
     private static final String VALIDATION_CONFIGURATION_XSD =
-          "META-INF/validation-configuration-1.0.xsd";
+            "META-INF/validation-configuration-1.0.xsd";
     private static final Logger log = LoggerFactory.getLogger(ValidationParser.class);
-    private final String validationXmlFile;
+    protected final String validationXmlFile;
 
     /**
      * Create a new ValidationParser instance.
+     *
      * @param file
      */
     public ValidationParser(String file) {
-        if(file == null) {
+        if (file == null) {
             validationXmlFile = DEFAULT_VALIDATION_XML_FILE;
         } else {
             validationXmlFile = file;
@@ -71,6 +73,7 @@ public class ValidationParser {
 
     /**
      * Process the validation configuration into <code>targetConfig</code>.
+     *
      * @param targetConfig
      */
     public void processValidationConfig(ConfigurationImpl targetConfig) {
@@ -97,7 +100,7 @@ public class ValidationParser {
             unmarshaller.setSchema(schema);
             StreamSource stream = new StreamSource(inputStream);
             JAXBElement<ValidationConfigType> root =
-                  unmarshaller.unmarshal(stream, ValidationConfigType.class);
+                    unmarshaller.unmarshal(stream, ValidationConfigType.class);
             return root.getValue();
         } catch (JAXBException e) {
             throw new ValidationException("Unable to parse " + validationXmlFile, e);
@@ -108,21 +111,24 @@ public class ValidationParser {
         }
     }
 
-    private InputStream getInputStream(String path) throws IOException {
+    protected InputStream getInputStream(String path) throws IOException {
         ClassLoader loader = PrivilegedActions.getClassLoader(getClass());
-        InputStream inputStream = loader.getResourceAsStream( path );
-        
-        if ( inputStream != null ) {
+        InputStream inputStream = loader.getResourceAsStream(path);
+
+        if (inputStream != null) {
             // spec says: If more than one META-INF/validation.xml file
             // is found in the classpath, a ValidationException is raised.
-            if ( path.equals("META-INF/validation.xml") ) {
-                Enumeration<URL> urls = loader.getResources(path);
-                if ( urls.hasMoreElements() && (urls.nextElement() != null) && urls.hasMoreElements() ) {
-                    throw new ValidationException("More than one " + path + " is found in the classpath");
+            Enumeration<URL> urls = loader.getResources(path);
+            if (urls.hasMoreElements()) {
+                String url = urls.nextElement().toString();
+                while (urls.hasMoreElements()) {
+                    if (!url.equals(urls.nextElement().toString())) { // complain when first duplicate found
+                        throw new ValidationException("More than one " + path + " is found in the classpath");
+                    }
                 }
             }
         }
-        
+
         return inputStream;
     }
 
@@ -132,6 +138,7 @@ public class ValidationParser {
 
     /**
      * Get a Schema object from the specified resource name.
+     *
      * @param xsd
      * @return {@link Schema}
      */
@@ -160,7 +167,7 @@ public class ValidationParser {
         for (PropertyType property : xmlConfig.getProperty()) {
             if (log.isDebugEnabled()) {
                 log.debug("Found property '" + property.getName() + "' with value '" +
-                      property.getValue() + "' in " + validationXmlFile);
+                        property.getValue() + "' in " + validationXmlFile);
             }
             target.addProperty(property.getName(), property.getValue());
         }
@@ -171,8 +178,7 @@ public class ValidationParser {
         String providerClassName = xmlConfig.getDefaultProvider();
         if (providerClassName != null) {
             Class<? extends ValidationProvider<?>> clazz =
-                  (Class<? extends ValidationProvider<?>>) SecureActions
-                        .loadClass(providerClassName, this.getClass());
+                    (Class<? extends ValidationProvider<?>>) loadClass(providerClassName);
             target.setProviderClass(clazz);
             log.info("Using {} as validation provider.", providerClassName);
         }
@@ -182,11 +188,11 @@ public class ValidationParser {
     private void applyMessageInterpolator(ValidationConfigType xmlConfig,
                                           ConfigurationImpl target) {
         String messageInterpolatorClass = xmlConfig.getMessageInterpolator();
-        if ( target.getMessageInterpolator() == null ) {
+        if (target.getMessageInterpolator() == null) {
             if (messageInterpolatorClass != null) {
-                Class<MessageInterpolator> clazz = (Class<MessageInterpolator>) SecureActions
-                      .loadClass(messageInterpolatorClass, this.getClass());
-                target.messageInterpolator(SecureActions.newInstance(clazz));
+                Class<MessageInterpolator> clazz = (Class<MessageInterpolator>)
+                        loadClass(messageInterpolatorClass);
+                target.messageInterpolator(newInstance(clazz));
                 log.info("Using {} as message interpolator.", messageInterpolatorClass);
             }
         }
@@ -196,26 +202,37 @@ public class ValidationParser {
     private void applyTraversableResolver(ValidationConfigType xmlConfig,
                                           ConfigurationImpl target) {
         String traversableResolverClass = xmlConfig.getTraversableResolver();
-        if ( target.getTraversableResolver() == null ) {
+        if (target.getTraversableResolver() == null) {
             if (traversableResolverClass != null) {
-                Class<TraversableResolver> clazz = (Class<TraversableResolver>) SecureActions
-                      .loadClass(traversableResolverClass, this.getClass());
-                target.traversableResolver(SecureActions.newInstance(clazz));
+                Class<TraversableResolver> clazz = (Class<TraversableResolver>)
+                        loadClass(traversableResolverClass);
+                target.traversableResolver(newInstance(clazz));
                 log.info("Using {} as traversable resolver.", traversableResolverClass);
             }
         }
     }
 
+    private <T> T newInstance(final Class<T> cls) {
+        return AccessController.doPrivileged(new PrivilegedAction<T>() {
+            public T run() {
+                try {
+                    return cls.newInstance();
+                } catch (final Exception ex) {
+                    throw new ValidationException("Cannot instantiate : " + cls, ex);
+                }
+            }
+        });
+    }
+
     @SuppressWarnings("unchecked")
     private void applyConstraintFactory(ValidationConfigType xmlConfig,
                                         ConfigurationImpl target) {
         String constraintFactoryClass = xmlConfig.getConstraintValidatorFactory();
-        if ( target.getConstraintValidatorFactory() == null ) {
+        if (target.getConstraintValidatorFactory() == null) {
             if (constraintFactoryClass != null) {
-                Class<ConstraintValidatorFactory> clazz =
-                      (Class<ConstraintValidatorFactory>) SecureActions
-                            .loadClass(constraintFactoryClass, this.getClass());
-                target.constraintValidatorFactory(SecureActions.newInstance(clazz));
+                Class<ConstraintValidatorFactory> clazz = (Class<ConstraintValidatorFactory>)
+                        loadClass(constraintFactoryClass);
+                target.constraintValidatorFactory(newInstance(clazz));
                 log.info("Using {} as constraint factory.", constraintFactoryClass);
             }
         }
@@ -225,7 +242,7 @@ public class ValidationParser {
                                      ConfigurationImpl target) {
         for (JAXBElement<String> mappingFileNameElement : xmlConfig.getConstraintMapping()) {
             String mappingFileName = mappingFileNameElement.getValue();
-            if ( mappingFileName.startsWith("/") ) {
+            if (mappingFileName.startsWith("/")) {
                 // Classloader needs a path without a starting /
                 mappingFileName = mappingFileName.substring(1);
             }
@@ -235,14 +252,36 @@ public class ValidationParser {
                 in = getInputStream(mappingFileName);
                 if (in == null) {
                     throw new ValidationException(
-                          "Unable to open input stream for mapping file " +
-                                mappingFileName);
+                            "Unable to open input stream for mapping file " +
+                                    mappingFileName);
                 }
             } catch (IOException e) {
                 throw new ValidationException("Unable to open input stream for mapping file " +
-                      mappingFileName, e);
+                        mappingFileName, e);
             }
             target.addMapping(in);
         }
     }
+
+
+    private static <T> T doPrivileged(final PrivilegedAction<T> action) {
+        if (System.getSecurityManager() != null) {
+            return AccessController.doPrivileged(action);
+        } else {
+            return action.run();
+        }
+    }
+
+    private Class<?> loadClass(final String className) {
+        ClassLoader loader = doPrivileged(SecureActions.getContextClassLoader());
+        if (loader == null)
+            loader = getClass().getClassLoader();
+
+        try {
+            return Class.forName(className, true, loader);
+        } catch (ClassNotFoundException ex) {
+            throw new ValidationException("Unable to load class: " + className, ex);
+        }
+    }
+
 }

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/constraints/DigitsValidatorTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/constraints/DigitsValidatorTest.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/constraints/DigitsValidatorTest.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/constraints/DigitsValidatorTest.java Tue Sep  6 23:07:53 2011
@@ -25,9 +25,6 @@ import junit.framework.TestSuite;
 
 import java.math.BigDecimal;
 
-import org.apache.bval.constraints.DigitsValidatorForNumber;
-import org.apache.bval.constraints.DigitsValidatorForString;
-
 /**
  * DigitsConstraintValidator Tester.
  *

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/constraints/EmailValidatorTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/constraints/EmailValidatorTest.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/constraints/EmailValidatorTest.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/constraints/EmailValidatorTest.java Tue Sep  6 23:07:53 2011
@@ -22,12 +22,11 @@ import junit.framework.Assert;
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
-
-import javax.validation.Validator;
-
 import org.apache.bval.jsr303.ApacheValidatorFactory;
 import org.apache.bval.jsr303.example.Customer;
 
+import javax.validation.Validator;
+
 /**
  * EmailValidator Tester.
  *

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/constraints/FrenchZipCode.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/constraints/FrenchZipCode.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/constraints/FrenchZipCode.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/constraints/FrenchZipCode.java Tue Sep  6 23:07:53 2011
@@ -24,15 +24,13 @@ import javax.validation.Payload;
 import javax.validation.ReportAsSingleViolation;
 import javax.validation.constraints.NotNull;
 import javax.validation.constraints.Size;
-
-import org.apache.bval.constraints.NotEmpty;
-
 import java.lang.annotation.Documented;
-import static java.lang.annotation.ElementType.*;
 import java.lang.annotation.Retention;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
 import java.lang.annotation.Target;
 
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
 /**
  * Description: example for composed constraint.
  * not implemented! simple dummy implemenation for tests only! <br/>

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/constraints/HasValue.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/constraints/HasValue.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/constraints/HasValue.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/constraints/HasValue.java Tue Sep  6 23:07:53 2011
@@ -20,11 +20,12 @@ package org.apache.bval.constraints;
 
 import javax.validation.Constraint;
 import javax.validation.Payload;
-import static java.lang.annotation.ElementType.*;
 import java.lang.annotation.Retention;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
 import java.lang.annotation.Target;
 
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
 /**
  * Description: allow distinct string values for element (like enums) <br/>
  */

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/constraints/ZipCodeCityCoherence.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/constraints/ZipCodeCityCoherence.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/constraints/ZipCodeCityCoherence.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/constraints/ZipCodeCityCoherence.java Tue Sep  6 23:07:53 2011
@@ -21,11 +21,12 @@ package org.apache.bval.constraints;
 import javax.validation.Constraint;
 import javax.validation.Payload;
 import java.lang.annotation.Documented;
-import static java.lang.annotation.ElementType.TYPE;
 import java.lang.annotation.Retention;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
 import java.lang.annotation.Target;
 
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
 /**
  * not implemented! simple dummy implemenation for tests only!
  */

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/constraints/ZipCodeCityCoherenceValidator.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/constraints/ZipCodeCityCoherenceValidator.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/constraints/ZipCodeCityCoherenceValidator.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/constraints/ZipCodeCityCoherenceValidator.java Tue Sep  6 23:07:53 2011
@@ -19,11 +19,11 @@
 package org.apache.bval.constraints;
 
 
+import org.apache.bval.jsr303.example.ZipCodeCityCarrier;
+
 import javax.validation.ConstraintValidator;
 import javax.validation.ConstraintValidatorContext;
 
-import org.apache.bval.jsr303.example.ZipCodeCityCarrier;
-
 /**
  * Description: Class not implemented! simple dummy implemenation for tests only! <br/>
  * User: roman.stumm <br/>

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/BeanDescriptorTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/BeanDescriptorTest.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/BeanDescriptorTest.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/BeanDescriptorTest.java Tue Sep  6 23:07:53 2011
@@ -22,6 +22,7 @@ import static java.lang.annotation.Eleme
 import static java.lang.annotation.ElementType.METHOD;
 import static java.lang.annotation.ElementType.TYPE;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import org.apache.bval.jsr303.util.TestUtils;
 
 import java.lang.annotation.Documented;
 import java.lang.annotation.Retention;
@@ -36,15 +37,9 @@ import javax.validation.Validator;
 import javax.validation.ValidatorFactory;
 import javax.validation.constraints.NotNull;
 import javax.validation.groups.Default;
-import javax.validation.metadata.BeanDescriptor;
-import javax.validation.metadata.ConstraintDescriptor;
-import javax.validation.metadata.ElementDescriptor;
-import javax.validation.metadata.PropertyDescriptor;
-import javax.validation.metadata.Scope;
+import javax.validation.metadata.*;
 import javax.validation.metadata.ElementDescriptor.ConstraintFinder;
 
-import org.apache.bval.jsr303.util.TestUtils;
-
 import junit.framework.Assert;
 import junit.framework.TestCase;
 

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/CustomValidatorFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/CustomValidatorFactoryTest.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/CustomValidatorFactoryTest.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/CustomValidatorFactoryTest.java Tue Sep  6 23:07:53 2011
@@ -18,18 +18,11 @@
  */
 package org.apache.bval.jsr303;
 
-import javax.validation.ConstraintValidatorFactory;
-import javax.validation.MessageInterpolator;
-import javax.validation.TraversableResolver;
-import javax.validation.Validation;
-import javax.validation.ValidationException;
-import javax.validation.Validator;
-import javax.validation.ValidatorContext;
-import javax.validation.ValidatorFactory;
-import javax.validation.spi.ConfigurationState;
-
 import junit.framework.TestCase;
 
+import javax.validation.*;
+import javax.validation.spi.ConfigurationState;
+
 /**
  * Test the ability to force a particular {@link ValidatorFactory}
  * implementation class.

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/FooTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/FooTest.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/FooTest.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/FooTest.java Tue Sep  6 23:07:53 2011
@@ -18,16 +18,15 @@
  */
 package org.apache.bval.jsr303;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Set;
+import junit.framework.TestCase;
 
 import javax.validation.ConstraintViolation;
 import javax.validation.Valid;
 import javax.validation.Validator;
 import javax.validation.constraints.NotNull;
-
-import junit.framework.TestCase;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Set;
 
 /**
  * Description: <br/>

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/ValidatorResolutionTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/ValidatorResolutionTest.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/ValidatorResolutionTest.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/ValidatorResolutionTest.java Tue Sep  6 23:07:53 2011
@@ -18,27 +18,18 @@
  */
 package org.apache.bval.jsr303;
 
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import junit.framework.TestCase;
 
+import javax.validation.*;
+import javax.validation.constraints.NotNull;
 import java.lang.annotation.Documented;
 import java.lang.annotation.Retention;
 import java.lang.annotation.Target;
 import java.util.Locale;
 
-import javax.validation.Constraint;
-import javax.validation.ConstraintDefinitionException;
-import javax.validation.ConstraintValidator;
-import javax.validation.ConstraintValidatorContext;
-import javax.validation.Payload;
-import javax.validation.Validation;
-import javax.validation.Validator;
-import javax.validation.ValidatorFactory;
-import javax.validation.constraints.NotNull;
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
 
-import junit.framework.TestCase;
 
 /**
  * Checks the correct behavior of the validator resolution algorithm.

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/example/AccessTestBusinessObject.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/example/AccessTestBusinessObject.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/example/AccessTestBusinessObject.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/example/AccessTestBusinessObject.java Tue Sep  6 23:07:53 2011
@@ -19,10 +19,10 @@
 package org.apache.bval.jsr303.example;
 
 
-import javax.validation.Valid;
-
 import org.apache.bval.constraints.HasValue;
 
+import javax.validation.Valid;
+
 /**
  * Description: <br/>
  */

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/example/Address.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/example/Address.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/example/Address.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/example/Address.java Tue Sep  6 23:07:53 2011
@@ -19,14 +19,14 @@
 package org.apache.bval.jsr303.example;
 
 
+import org.apache.bval.constraints.ZipCodeCityCoherence;
+
 import javax.validation.GroupSequence;
 import javax.validation.Valid;
 import javax.validation.constraints.NotNull;
 import javax.validation.constraints.Size;
 import javax.validation.groups.Default;
 
-import org.apache.bval.constraints.ZipCodeCityCoherence;
-
 @ZipCodeCityCoherence
 public class Address implements ZipCodeCityCarrier {
     @NotNull

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/example/Author.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/example/Author.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/example/Author.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/example/Author.java Tue Sep  6 23:07:53 2011
@@ -19,12 +19,11 @@
 package org.apache.bval.jsr303.example;
 
 
+import org.apache.bval.constraints.NotEmpty;
+
 import javax.validation.GroupSequence;
 import javax.validation.Valid;
 import javax.validation.constraints.Size;
-
-import org.apache.bval.constraints.NotEmpty;
-
 import java.util.List;
 
 @GroupSequence({First.class, Author.class, Last.class})

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/example/Book.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/example/Book.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/example/Book.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/example/Book.java Tue Sep  6 23:07:53 2011
@@ -19,13 +19,13 @@
 package org.apache.bval.jsr303.example;
 
 
+import org.apache.bval.constraints.NotEmpty;
+
 import javax.validation.GroupSequence;
 import javax.validation.Valid;
 import javax.validation.constraints.NotNull;
 import javax.validation.constraints.Size;
 
-import org.apache.bval.constraints.NotEmpty;
-
 @GroupSequence({First.class, Second.class, Book.class, Last.class})
 public class Book {
     @NotNull(groups = First.class)

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/example/Customer.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/example/Customer.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/example/Customer.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/example/Customer.java Tue Sep  6 23:07:53 2011
@@ -19,11 +19,11 @@
 package org.apache.bval.jsr303.example;
 
 
-import javax.validation.constraints.NotNull;
-
 import org.apache.bval.constraints.Email;
 import org.apache.bval.constraints.Password;
 
+import javax.validation.constraints.NotNull;
+
 public class Customer implements Person {
     private String firstName;
     private String middleName;

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/example/RecursiveFoo.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/example/RecursiveFoo.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/example/RecursiveFoo.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/example/RecursiveFoo.java Tue Sep  6 23:07:53 2011
@@ -19,10 +19,9 @@
 package org.apache.bval.jsr303.example;
 
 
-import javax.validation.Valid;
-
 import org.apache.bval.constraints.NotEmpty;
 
+import javax.validation.Valid;
 import java.util.ArrayList;
 import java.util.Collection;
 

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/DefaultGroupSequenceTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/DefaultGroupSequenceTest.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/DefaultGroupSequenceTest.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/DefaultGroupSequenceTest.java Tue Sep  6 23:07:53 2011
@@ -22,10 +22,6 @@ import junit.framework.TestCase;
 
 import javax.validation.GroupDefinitionException;
 import javax.validation.groups.Default;
-
-import org.apache.bval.jsr303.groups.Group;
-import org.apache.bval.jsr303.groups.Groups;
-
 import java.util.ArrayList;
 import java.util.List;
 

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupSequenceTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupSequenceTest.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupSequenceTest.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupSequenceTest.java Tue Sep  6 23:07:53 2011
@@ -27,11 +27,7 @@ import org.apache.bval.jsr303.example.*;
 import org.apache.bval.jsr303.util.TestUtils;
 import org.apache.bval.model.MetaBean;
 
-import javax.validation.ConstraintViolation;
-import javax.validation.GroupSequence;
-import javax.validation.Validation;
-import javax.validation.Validator;
-import javax.validation.ValidatorFactory;
+import javax.validation.*;
 import javax.validation.constraints.NotNull;
 import java.util.List;
 import java.util.Locale;

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupValidationTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupValidationTest.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupValidationTest.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupValidationTest.java Tue Sep  6 23:07:53 2011
@@ -19,13 +19,11 @@
 package org.apache.bval.jsr303.groups;
 
 import junit.framework.TestCase;
-
-import javax.validation.ConstraintViolation;
-import javax.validation.Validator;
-
 import org.apache.bval.jsr303.ApacheValidatorFactory;
 import org.apache.bval.jsr303.util.TestUtils;
 
+import javax.validation.ConstraintViolation;
+import javax.validation.Validator;
 import java.util.Set;
 
 /**

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupsComputerTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupsComputerTest.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupsComputerTest.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupsComputerTest.java Tue Sep  6 23:07:53 2011
@@ -21,19 +21,14 @@ package org.apache.bval.jsr303.groups;
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
-
-import javax.validation.GroupDefinitionException;
-import javax.validation.ValidationException;
-import javax.validation.groups.Default;
-
 import org.apache.bval.jsr303.example.Address;
 import org.apache.bval.jsr303.example.First;
 import org.apache.bval.jsr303.example.Last;
 import org.apache.bval.jsr303.example.Second;
-import org.apache.bval.jsr303.groups.Group;
-import org.apache.bval.jsr303.groups.Groups;
-import org.apache.bval.jsr303.groups.GroupsComputer;
 
+import javax.validation.GroupDefinitionException;
+import javax.validation.ValidationException;
+import javax.validation.groups.Default;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/implicit/ImplicitGroupingTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/implicit/ImplicitGroupingTest.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/implicit/ImplicitGroupingTest.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/implicit/ImplicitGroupingTest.java Tue Sep  6 23:07:53 2011
@@ -19,13 +19,11 @@
 package org.apache.bval.jsr303.groups.implicit;
 
 import junit.framework.TestCase;
-
-import javax.validation.ConstraintViolation;
-import javax.validation.Validator;
-
 import org.apache.bval.jsr303.ApacheValidatorFactory;
 import org.apache.bval.jsr303.util.TestUtils;
 
+import javax.validation.ConstraintViolation;
+import javax.validation.Validator;
 import java.util.Set;
 
 /**

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/inheritance/BillableUser.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/inheritance/BillableUser.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/inheritance/BillableUser.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/inheritance/BillableUser.java Tue Sep  6 23:07:53 2011
@@ -19,12 +19,12 @@
 package org.apache.bval.jsr303.groups.inheritance;
 
 
-import javax.validation.constraints.NotNull;
-import javax.validation.groups.Default;
-
 import org.apache.bval.jsr303.groups.Billable;
 import org.apache.bval.jsr303.groups.BillableCreditCard;
 
+import javax.validation.constraints.NotNull;
+import javax.validation.groups.Default;
+
 /**
  * Description: <br/>
  */

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/inheritance/BuyInOneClick.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/inheritance/BuyInOneClick.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/inheritance/BuyInOneClick.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/inheritance/BuyInOneClick.java Tue Sep  6 23:07:53 2011
@@ -19,10 +19,10 @@
 package org.apache.bval.jsr303.groups.inheritance;
 
 
-import javax.validation.groups.Default;
-
 import org.apache.bval.jsr303.groups.Billable;
 
+import javax.validation.groups.Default;
+
 /**
  * Customer can buy without harrassing checking process.
  * spec: Example 3.3. Groups can inherit other groups

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/inheritance/GroupInheritanceTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/inheritance/GroupInheritanceTest.java?rev=1165923&r1=1165922&r2=1165923&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/inheritance/GroupInheritanceTest.java (original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/inheritance/GroupInheritanceTest.java Tue Sep  6 23:07:53 2011
@@ -19,13 +19,11 @@
 package org.apache.bval.jsr303.groups.inheritance;
 
 import junit.framework.TestCase;
-
-import javax.validation.ConstraintViolation;
-import javax.validation.Validator;
-
 import org.apache.bval.jsr303.ApacheValidatorFactory;
 import org.apache.bval.jsr303.util.TestUtils;
 
+import javax.validation.ConstraintViolation;
+import javax.validation.Validator;
 import java.util.Set;
 
 /**



Mime
View raw message