bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r1628598 [2/2] - in /bval/branches/bval-11: ./ bval-core/ 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-core/src/main/java/org/apache/bval/util/ref...
Date Wed, 01 Oct 2014 04:37:37 GMT
Modified: bval/branches/bval-11/bval-jsr/src/main/java/org/apache/bval/jsr/xml/AnnotationProxyBuilder.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr/src/main/java/org/apache/bval/jsr/xml/AnnotationProxyBuilder.java?rev=1628598&r1=1628597&r2=1628598&view=diff
==============================================================================
--- bval/branches/bval-11/bval-jsr/src/main/java/org/apache/bval/jsr/xml/AnnotationProxyBuilder.java
(original)
+++ bval/branches/bval-11/bval-jsr/src/main/java/org/apache/bval/jsr/xml/AnnotationProxyBuilder.java
Wed Oct  1 04:37:36 2014
@@ -18,19 +18,21 @@ package org.apache.bval.jsr.xml;
 
 import org.apache.bval.jsr.ConstraintAnnotationAttributes;
 import org.apache.bval.util.reflection.Reflection;
+import org.apache.commons.weaver.privilizer.Privileged;
+import org.apache.commons.weaver.privilizer.Privilizing;
+import org.apache.commons.weaver.privilizer.Privilizing.CallTo;
 
 import javax.validation.Payload;
 import javax.validation.Valid;
 import javax.validation.ValidationException;
 import javax.validation.groups.ConvertGroup;
+
 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;
 import java.util.concurrent.ConcurrentHashMap;
@@ -42,6 +44,7 @@ import java.util.concurrent.ConcurrentMa
  */
 // TODO move this guy up to org.apache.bval.jsr or
 // org.apache.bval.jsr.model
+@Privilizing(@CallTo(Reflection.class))
 final public class AnnotationProxyBuilder<A extends Annotation> {
     private static final ConcurrentMap<Class<?>, Method[]> METHODS_CACHE = new
ConcurrentHashMap<Class<?>, Method[]>();
 
@@ -63,7 +66,7 @@ final public class AnnotationProxyBuilde
         if (annotationType.getName().startsWith("javax.validation.constraints.")) { // cache
built-in constraints only to avoid mem leaks
             Method[] mtd = METHODS_CACHE.get(annotationType);
             if (mtd == null) {
-                final Method[] value = Reflection.INSTANCE.getDeclaredMethods(annotationType);
+                final Method[] value = Reflection.getDeclaredMethods(annotationType);
                 mtd = METHODS_CACHE.putIfAbsent(annotationType, value);
                 if (mtd == null) {
                     mtd = value;
@@ -71,7 +74,7 @@ final public class AnnotationProxyBuilde
             }
             return mtd;
         }
-        return Reflection.INSTANCE.getDeclaredMethods(annotationType);
+        return Reflection.getDeclaredMethods(annotationType);
     }
 
     /**
@@ -201,20 +204,14 @@ final public class AnnotationProxyBuilde
      * @return {@link Annotation}
      */
     public A createAnnotation() {
-        ClassLoader classLoader = Reflection.INSTANCE.getClassLoader(getType());
+        final ClassLoader classLoader = Reflection.getClassLoader(getType());
         @SuppressWarnings("unchecked")
         final Class<A> proxyClass = (Class<A>) Proxy.getProxyClass(classLoader,
getType());
         final InvocationHandler handler = new AnnotationProxy(this);
-        if (System.getSecurityManager() == null) {
-            return doCreateAnnotation(proxyClass, handler);
-        }
-        return AccessController.doPrivileged(new PrivilegedAction<A>() {
-            public A run() {
-                return doCreateAnnotation(proxyClass, handler);
-            }
-        });
+        return doCreateAnnotation(proxyClass, handler);
     }
 
+    @Privileged
     private A doCreateAnnotation(final Class<A> proxyClass, final InvocationHandler
handler) {
         try {
             Constructor<A> constructor = proxyClass.getConstructor(InvocationHandler.class);
@@ -232,11 +229,11 @@ final public class AnnotationProxyBuilde
         }
     }
 
-    public static final class ConverGroupAnnotation implements ConvertGroup {
+    public static final class ConvertGroupAnnotation implements ConvertGroup {
         private final Class<?> from;
         private final Class<?> to;
 
-        public ConverGroupAnnotation(final Class<?> from, final Class<?> to)
{
+        public ConvertGroupAnnotation(final Class<?> from, final Class<?> to)
{
             this.from = from;
             this.to = to;
         }

Modified: bval/branches/bval-11/bval-jsr/src/main/java/org/apache/bval/jsr/xml/ValidationMappingParser.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr/src/main/java/org/apache/bval/jsr/xml/ValidationMappingParser.java?rev=1628598&r1=1628597&r2=1628598&view=diff
==============================================================================
--- bval/branches/bval-11/bval-jsr/src/main/java/org/apache/bval/jsr/xml/ValidationMappingParser.java
(original)
+++ bval/branches/bval-11/bval-jsr/src/main/java/org/apache/bval/jsr/xml/ValidationMappingParser.java
Wed Oct  1 04:37:36 2014
@@ -16,28 +16,6 @@
  */
 package org.apache.bval.jsr.xml;
 
-
-import org.apache.bval.jsr.ApacheValidatorFactory;
-import org.apache.bval.jsr.ConstraintAnnotationAttributes;
-import org.apache.bval.jsr.util.EnumerationConverter;
-import org.apache.bval.jsr.util.IOs;
-import org.apache.bval.util.FieldAccess;
-import org.apache.bval.util.MethodAccess;
-import org.apache.bval.util.reflection.Reflection;
-import org.apache.commons.beanutils.ConvertUtils;
-import org.apache.commons.beanutils.Converter;
-import org.apache.commons.lang3.StringUtils;
-
-import javax.validation.Constraint;
-import javax.validation.ConstraintValidator;
-import javax.validation.Payload;
-import javax.validation.ValidationException;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.validation.Schema;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.Serializable;
@@ -47,8 +25,6 @@ import java.lang.reflect.Constructor;
 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.Collection;
@@ -58,10 +34,35 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
+import javax.validation.Constraint;
+import javax.validation.ConstraintValidator;
+import javax.validation.Payload;
+import javax.validation.ValidationException;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+
+import org.apache.bval.jsr.ApacheValidatorFactory;
+import org.apache.bval.jsr.ConstraintAnnotationAttributes;
+import org.apache.bval.jsr.util.EnumerationConverter;
+import org.apache.bval.jsr.util.IOs;
+import org.apache.bval.util.FieldAccess;
+import org.apache.bval.util.MethodAccess;
+import org.apache.bval.util.reflection.Reflection;
+import org.apache.commons.beanutils.ConvertUtils;
+import org.apache.commons.beanutils.Converter;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.weaver.privilizer.Privileged;
+import org.apache.commons.weaver.privilizer.Privilizing;
+import org.apache.commons.weaver.privilizer.Privilizing.CallTo;
+
 /**
  * Uses JAXB to parse constraints.xml based on validation-mapping-1.0.xsd.<br>
  */
-@SuppressWarnings("restriction")
+@Privilizing(@CallTo(Reflection.class))
 public class ValidationMappingParser {
     //    private static final Log log = LogFactory.getLog(ValidationMappingParser.class);
     private static final String VALIDATION_MAPPING_XSD = "META-INF/validation-mapping-1.1.xsd";
@@ -199,7 +200,7 @@ public class ValidationMappingParser {
 
     private <A extends Annotation> Class<?> getAnnotationParameterType(
           final Class<A> annotationClass, final String name) {
-        final Method m = Reflection.INSTANCE.getPublicMethod(annotationClass, name);
+        final Method m = Reflection.getPublicMethod(annotationClass, name);
         if (m == null) {
             throw new ValidationException("Annotation of type " + annotationClass.getName()
+
                   " does not contain a parameter " + name + ".");
@@ -384,7 +385,7 @@ public class ValidationMappingParser {
             } else {
                 methodNames.add(methodName);
             }
-            final Method method = Reflection.INSTANCE.getDeclaredMethod(beanClass, methodName,
toTypes(methodType.getParameter(), defaultPackage));
+            final Method method = Reflection.getDeclaredMethod(beanClass, methodName, toTypes(methodType.getParameter(),
defaultPackage));
             if (method == null) {
                 throw new ValidationException(beanClass.getName() + " does not contain the
method  " + methodName);
             }
@@ -418,7 +419,7 @@ public class ValidationMappingParser {
                     for (final GroupConversionType groupConversion : p.getConvertGroup())
{
                         final Class<?> from = loadClass(groupConversion.getFrom(),
defaultPackage);
                         final Class<?> to = loadClass(groupConversion.getTo(), defaultPackage);
-                        final MetaConstraint<?, ?> constraint = new MetaConstraint<A,
Annotation>(beanClass, method, new AnnotationProxyBuilder.ConverGroupAnnotation(from, to));
+                        final MetaConstraint<?, ?> constraint = new MetaConstraint<A,
Annotation>(beanClass, method, new AnnotationProxyBuilder.ConvertGroupAnnotation(from,
to));
                         constraint.setIndex(i);
                         factory.addMetaConstraint(beanClass, constraint);
                     }
@@ -445,7 +446,7 @@ public class ValidationMappingParser {
                     for (final GroupConversionType groupConversion : returnValue.getConvertGroup())
{
                         final Class<?> from = loadClass(groupConversion.getFrom(),
defaultPackage);
                         final Class<?> to = loadClass(groupConversion.getTo(), defaultPackage);
-                        final MetaConstraint<?, ?> constraint = new MetaConstraint<A,
Annotation>(beanClass, method, new AnnotationProxyBuilder.ConverGroupAnnotation(from, to));
+                        final MetaConstraint<?, ?> constraint = new MetaConstraint<A,
Annotation>(beanClass, method, new AnnotationProxyBuilder.ConvertGroupAnnotation(from,
to));
                         factory.addMetaConstraint(beanClass, constraint);
                     }
                 }
@@ -465,7 +466,7 @@ public class ValidationMappingParser {
 
     private <A> void processConstructorLevel(final List<ConstructorType> constructors,
final Class<A> beanClass, final String defaultPackage, final boolean parentIgnore) {
         for (final ConstructorType constructorType : constructors) {
-            final Constructor<?> constructor = Reflection.INSTANCE.getDeclaredConstructor(beanClass,
toTypes(constructorType.getParameter(), defaultPackage));
+            final Constructor<?> constructor = Reflection.getDeclaredConstructor(beanClass,
toTypes(constructorType.getParameter(), defaultPackage));
             if (constructor == null) {
                 throw new ValidationException(beanClass.getName() + " does not contain the
constructor  " + constructorType);
             }
@@ -499,7 +500,7 @@ public class ValidationMappingParser {
                     for (final GroupConversionType groupConversion : p.getConvertGroup())
{
                         final Class<?> from = loadClass(groupConversion.getFrom(),
defaultPackage);
                         final Class<?> to = loadClass(groupConversion.getTo(), defaultPackage);
-                        final MetaConstraint<?, ?> constraint = new MetaConstraint<A,
Annotation>(beanClass, constructor, new AnnotationProxyBuilder.ConverGroupAnnotation(from,
to));
+                        final MetaConstraint<?, ?> constraint = new MetaConstraint<A,
Annotation>(beanClass, constructor, new AnnotationProxyBuilder.ConvertGroupAnnotation(from,
to));
                         constraint.setIndex(i);
                         factory.addMetaConstraint(beanClass, constraint);
                     }
@@ -531,7 +532,7 @@ public class ValidationMappingParser {
                     for (final GroupConversionType groupConversion : returnValue.getConvertGroup())
{
                         final Class<?> from = loadClass(groupConversion.getFrom(),
defaultPackage);
                         final Class<?> to = loadClass(groupConversion.getTo(), defaultPackage);
-                        final MetaConstraint<?, ?> constraint = new MetaConstraint<A,
Annotation>(beanClass, constructor, new AnnotationProxyBuilder.ConverGroupAnnotation(from,
to));
+                        final MetaConstraint<?, ?> constraint = new MetaConstraint<A,
Annotation>(beanClass, constructor, new AnnotationProxyBuilder.ConvertGroupAnnotation(from,
to));
                         constraint.setIndex(-1);
                         factory.addMetaConstraint(beanClass, constraint);
                     }
@@ -574,7 +575,7 @@ public class ValidationMappingParser {
             } else {
                 fieldNames.add(fieldName);
             }
-            final Field field = Reflection.INSTANCE.getDeclaredField(beanClass, fieldName);
+            final Field field = Reflection.getDeclaredField(beanClass, fieldName);
             if (field == null) {
                 throw new ValidationException(
                       beanClass.getName() + " does not contain the fieldType  " + fieldName);
@@ -592,7 +593,7 @@ public class ValidationMappingParser {
             for (final GroupConversionType conversion : fieldType.getConvertGroup()) {
                 final Class<?> from = loadClass(conversion.getFrom(), defaultPackage);
                 final Class<?> to = loadClass(conversion.getTo(), defaultPackage);
-                final MetaConstraint<?, ?> constraint = new MetaConstraint<A, Annotation>(beanClass,
field, new AnnotationProxyBuilder.ConverGroupAnnotation(from, to));
+                final MetaConstraint<?, ?> constraint = new MetaConstraint<A, Annotation>(beanClass,
field, new AnnotationProxyBuilder.ConvertGroupAnnotation(from, to));
                 factory.addMetaConstraint(beanClass, constraint);
             }
 
@@ -637,7 +638,7 @@ public class ValidationMappingParser {
             for (final GroupConversionType conversion : getterType.getConvertGroup()) {
                 final Class<?> from = loadClass(conversion.getFrom(), defaultPackage);
                 final Class<?> to = loadClass(conversion.getTo(), defaultPackage);
-                final MetaConstraint<?, ?> constraint = new MetaConstraint<A, Annotation>(beanClass,
method, new AnnotationProxyBuilder.ConverGroupAnnotation(from, to));
+                final MetaConstraint<?, ?> constraint = new MetaConstraint<A, Annotation>(beanClass,
method, new AnnotationProxyBuilder.ConvertGroupAnnotation(from, to));
                 factory.addMetaConstraint(beanClass, constraint);
             }
 
@@ -746,19 +747,8 @@ public class ValidationMappingParser {
         return clazz.contains(".");
     }
 
-    private static Method getGetter(final Class<?> clazz, final String propertyName)
{
-        if (System.getSecurityManager() == null) {
-            return doGetGetter(propertyName, clazz);
-        }
-        return AccessController.doPrivileged(new PrivilegedAction<Method>() {
-            public Method run() {
-                return doGetGetter(propertyName, clazz);
-            }
-        });
-
-    }
-
-    private static Method doGetGetter(String propertyName, Class<?> clazz) {
+    @Privileged
+    private static Method getGetter(Class<?> clazz,String propertyName) {
         try {
             final String p = StringUtils.capitalize(propertyName);
             try {
@@ -771,9 +761,8 @@ public class ValidationMappingParser {
         }
     }
 
-
     private Class<?> loadClass(final String className) {
-        ClassLoader loader = Reflection.INSTANCE.getClassLoader(ValidationMappingParser.class);
+        ClassLoader loader = Reflection.getClassLoader(ValidationMappingParser.class);
         if (loader == null)
             loader = getClass().getClassLoader();
 

Modified: bval/branches/bval-11/bval-jsr/src/main/java/org/apache/bval/jsr/xml/ValidationParser.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr/src/main/java/org/apache/bval/jsr/xml/ValidationParser.java?rev=1628598&r1=1628597&r2=1628598&view=diff
==============================================================================
--- bval/branches/bval-11/bval-jsr/src/main/java/org/apache/bval/jsr/xml/ValidationParser.java
(original)
+++ bval/branches/bval-11/bval-jsr/src/main/java/org/apache/bval/jsr/xml/ValidationParser.java
Wed Oct  1 04:37:36 2014
@@ -18,11 +18,20 @@
  */
 package org.apache.bval.jsr.xml;
 
-import org.apache.bval.jsr.BootstrapConfigurationImpl;
-import org.apache.bval.jsr.ConfigurationImpl;
-import org.apache.bval.jsr.util.IOs;
-import org.apache.bval.util.reflection.Reflection;
-import org.xml.sax.SAXException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.CopyOnWriteArraySet;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 import javax.validation.ConstraintValidatorFactory;
 import javax.validation.MessageInterpolator;
@@ -39,27 +48,20 @@ import javax.xml.bind.Unmarshaller;
 import javax.xml.transform.stream.StreamSource;
 import javax.xml.validation.Schema;
 import javax.xml.validation.SchemaFactory;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.CopyOnWriteArraySet;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+
+import org.apache.bval.jsr.BootstrapConfigurationImpl;
+import org.apache.bval.jsr.ConfigurationImpl;
+import org.apache.bval.jsr.util.IOs;
+import org.apache.bval.util.reflection.Reflection;
+import org.apache.commons.weaver.privilizer.Privileged;
+import org.apache.commons.weaver.privilizer.Privilizing;
+import org.apache.commons.weaver.privilizer.Privilizing.CallTo;
+import org.xml.sax.SAXException;
 
 /**
  * Description: uses jaxb to parse validation.xml<br/>
  */
-@SuppressWarnings("restriction")
+@Privilizing(@CallTo(Reflection.class))
 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.1.xsd";
@@ -160,6 +162,7 @@ public class ValidationParser {
         return map;
     }
 
+    @Privileged
     private static ValidationConfigType parseXmlConfig(final String validationXmlFile) {
         InputStream inputStream = null;
         try {
@@ -189,7 +192,7 @@ public class ValidationParser {
     }
 
     protected static InputStream getInputStream(final String path) throws IOException {
-        final ClassLoader loader = Reflection.INSTANCE.getClassLoader(ValidationParser.class);
+        final ClassLoader loader = Reflection.getClassLoader(ValidationParser.class);
         final InputStream inputStream = loader.getResourceAsStream(path);
 
         if (inputStream != null) {
@@ -219,7 +222,7 @@ public class ValidationParser {
             return schema;
         }
 
-        final ClassLoader loader = Reflection.INSTANCE.getClassLoader(ValidationParser.class);
+        final ClassLoader loader = Reflection.getClassLoader(ValidationParser.class);
         final SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
         final URL schemaUrl = loader.getResource(xsd);
         try {
@@ -268,7 +271,8 @@ public class ValidationParser {
         final String parameterNameProvider = xmlConfig.getParameterNameProvider();
         if (targetConfig.getParameterNameProvider() == targetConfig.getDefaultParameterNameProvider())
{ // ref ==
             if (parameterNameProvider != null) {
-                final Class<? extends ParameterNameProvider> clazz = Class.class.cast(loadClass(parameterNameProvider));
+                final Class<? extends ParameterNameProvider> clazz =
+                    loadClass(parameterNameProvider).asSubclass(ParameterNameProvider.class);
                 targetConfig.parameterNameProviderClass(clazz);
                 log.log(Level.INFO, String.format("Using %s as validation provider.", parameterNameProvider));
             }
@@ -354,7 +358,7 @@ public class ValidationParser {
     }
 
     private Class<?> loadClass(final String className) {
-        final ClassLoader loader = Reflection.INSTANCE.getClassLoader(ValidationParser.class);
+        final ClassLoader loader = Reflection.getClassLoader(ValidationParser.class);
         try {
             return Class.forName(className, true, loader);
         } catch (final ClassNotFoundException ex) {

Modified: bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/jsr/xml/ValidationParserTest.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/jsr/xml/ValidationParserTest.java?rev=1628598&r1=1628597&r2=1628598&view=diff
==============================================================================
--- bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/jsr/xml/ValidationParserTest.java
(original)
+++ bval/branches/bval-11/bval-jsr/src/test/java/org/apache/bval/jsr/xml/ValidationParserTest.java
Wed Oct  1 04:37:36 2014
@@ -21,18 +21,24 @@ package org.apache.bval.jsr.xml;
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
+
 import org.apache.bval.jsr.ApacheValidationProvider;
 import org.apache.bval.jsr.ApacheValidatorConfiguration;
 import org.apache.bval.jsr.ConfigurationImpl;
 import org.apache.bval.jsr.example.XmlEntitySampleBean;
 import org.apache.bval.jsr.resolver.SimpleTraversableResolver;
+import org.apache.bval.util.reflection.Reflection;
+import org.junit.Assume;
 
 import javax.validation.ConstraintViolation;
 import javax.validation.Validation;
 import javax.validation.ValidationException;
 import javax.validation.Validator;
 import javax.validation.ValidatorFactory;
+
 import java.io.IOException;
+import java.net.URL;
+import java.util.Enumeration;
 import java.util.Set;
 
 /**
@@ -51,6 +57,13 @@ public class ValidationParserTest extend
     public void testGetInputStream() throws IOException {
         assertNotNull(ValidationParser.getInputStream("sample-validation.xml"));
 
+        // make sure there are duplicate resources on the classpath before the next checks:
+        final Enumeration<URL> resources = Reflection.getClassLoader(ValidationParser.class).getResources("META-INF/MANIFEST.MF");
+        
+        Assume.assumeTrue(resources.hasMoreElements());
+        resources.nextElement();
+        Assume.assumeTrue(resources.hasMoreElements());
+
         try {
             ValidationParser.getInputStream("META-INF/MANIFEST.MF"); // this is available
in multiple jars hopefully
             fail("exception not thrown");

Modified: bval/branches/bval-11/bval-jsr/src/test/resources/java.policy
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-jsr/src/test/resources/java.policy?rev=1628598&r1=1628597&r2=1628598&view=diff
==============================================================================
--- bval/branches/bval-11/bval-jsr/src/test/resources/java.policy (original)
+++ bval/branches/bval-11/bval-jsr/src/test/resources/java.policy Wed Oct  1 04:37:36 2014
@@ -1,34 +1,27 @@
-//
-// 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.
-//
-
-//
-// $Id$
+// 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.
 //
 // Allows unit tests to run with a Java Security Manager
 //
-// Cloned from https://svn.apache.org/repos/asf/commons/proper/lang/trunk/src/test/resources/java.policy
-//
-// <argLine>-Djava.security.manager -Djava.security.policy=${basedir}/src/test/resources/java.policy</argLine>
-//
 
 grant
 {
   // let everyone read target dir
-  permission java.io.FilePermission "${user.dir}/target/-", "read";
+  permission java.io.FilePermission "${preserve.project.build.directory}${/}-", "read";
 };
 
 // we don't care about the permissions of the testing infrastructure,
@@ -56,21 +49,52 @@ grant codeBase "file://${user.home}/.m2/
   permission java.security.AllPermission;
 };
 
-// and our own testcases
-grant codeBase "file://${user.dir}/target/test-classes/-"
+// surefire booter;
+grant codeBase "file://${project.build.directory}/surefire/-"
 {
   permission java.security.AllPermission;
 };
 
+// jaxb impl
+grant codeBase "file://${user.home}/.m2/repository/com/sun/xml/bind/jaxb-impl/-"
+{
+  permission java.security.AllPermission;
+};
+
+// Geronimo specs
+grant codeBase "file://${user.home}/.m2/repository/org/apache/geronimo/specs/-"
+{
+  permission java.lang.RuntimePermission "accessDeclaredMembers";
+  permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
+  permission java.io.FilePermission "${user.home}/.m2/repository/-", "read";
+};
+
+// RI specs
+grant codeBase "file://${user.home}/.m2/repository/javax/validation/-"
+{
+  permission java.lang.RuntimePermission "accessDeclaredMembers";
+  permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
+  permission java.io.FilePermission "${user.home}/.m2/repository/-", "read";
+};
+
 grant codeBase "file://${user.home}/.m2/repository/org/apache/bval/-"
 {
   permission java.lang.RuntimePermission "accessDeclaredMembers";
   permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
 };
 
-grant codeBase "file://${user.dir}/target/classes/-"
+// test classes
+grant codeBase "file://${project.build.testOutputDirectory}/-"
+{
+  permission java.security.AllPermission;
+};
+
+// classes under test
+grant codeBase "file://${project.build.outputDirectory}/-"
 {
+  permission java.lang.RuntimePermission "accessClassInPackage.com.sun.xml.internal.bind.*";
   permission java.lang.RuntimePermission "accessDeclaredMembers";
   permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
   permission java.io.FilePermission "${user.home}/.m2/repository/-", "read";
+  permission java.util.PropertyPermission "*", "read";
 };

Propchange: bval/branches/bval-11/bval-tck11/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Oct  1 04:37:36 2014
@@ -0,0 +1,4 @@
+.classpath
+.project
+.settings
+target

Modified: bval/branches/bval-11/bval-xstream/pom.xml
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-xstream/pom.xml?rev=1628598&r1=1628597&r2=1628598&view=diff
==============================================================================
--- bval/branches/bval-11/bval-xstream/pom.xml (original)
+++ bval/branches/bval-11/bval-xstream/pom.xml Wed Oct  1 04:37:36 2014
@@ -46,6 +46,10 @@
       <groupId>com.thoughtworks.xstream</groupId>
       <artifactId>xstream</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-weaver-privilizer-api</artifactId>
+    </dependency>
     <!-- Test dependencies -->
     <dependency>
       <groupId>junit</groupId>
@@ -89,6 +93,10 @@
             <excludeFilterFile>findbugs-exclude-filter.xml</excludeFilterFile>
         </configuration>
       </plugin>
+      <plugin>
+        <groupId>org.apache.commons</groupId>
+        <artifactId>commons-weaver-maven-plugin</artifactId>
+      </plugin>
     </plugins>
   </build>
 </project>

Modified: bval/branches/bval-11/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanManager.java
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanManager.java?rev=1628598&r1=1628597&r2=1628598&view=diff
==============================================================================
--- bval/branches/bval-11/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanManager.java
(original)
+++ bval/branches/bval-11/bval-xstream/src/main/java/org/apache/bval/xml/XMLMetaBeanManager.java
Wed Oct  1 04:37:36 2014
@@ -20,6 +20,8 @@ import org.apache.bval.MetaBeanManager;
 import org.apache.bval.model.MetaBean;
 import org.apache.bval.model.MetaProperty;
 import org.apache.bval.util.reflection.Reflection;
+import org.apache.commons.weaver.privilizer.Privilizing;
+import org.apache.commons.weaver.privilizer.Privilizing.CallTo;
 
 import java.util.Map;
 
@@ -35,6 +37,7 @@ import static org.apache.bval.model.Feat
  * Date: 17.06.2010<br>
  * Time: 09:47:14<br>
  */
+@Privilizing(@CallTo(Reflection.class))
 public class XMLMetaBeanManager extends MetaBeanManager implements XMLMetaBeanRegistry, MetaBeanEnricher
{
     public XMLMetaBeanManager() {
         this(new XMLMetaBeanBuilder());
@@ -45,7 +48,7 @@ public class XMLMetaBeanManager extends 
     }
 
     public void addResourceLoader(String resource) {
-        addLoader(new XMLMetaBeanURLLoader(Reflection.INSTANCE.getClassLoader(getClass()).getResource(resource)));
+        addLoader(new XMLMetaBeanURLLoader(Reflection.getClassLoader(getClass()).getResource(resource)));
     }
 
     public synchronized void addLoader(XMLMetaBeanLoader loader) {

Modified: bval/branches/bval-11/pom.xml
URL: http://svn.apache.org/viewvc/bval/branches/bval-11/pom.xml?rev=1628598&r1=1628597&r2=1628598&view=diff
==============================================================================
--- bval/branches/bval-11/pom.xml (original)
+++ bval/branches/bval-11/pom.xml Wed Oct  1 04:37:36 2014
@@ -39,6 +39,7 @@
 
     <properties>
         <site.deploy.url>scp://people.apache.org/home/${user.name}/public_html/bval/${project.version}/staging-site</site.deploy.url>
+        <commons.weaver.version>1.1</commons.weaver.version>
     </properties>
 
     <inceptionYear>2010</inceptionYear>
@@ -250,10 +251,10 @@
                 <configuration>
                     <show>package</show>
                     <quiet>true</quiet>
-                    <source>1.5</source>
+                    <source>1.6</source>
                     <links>
-                        <link>http://java.sun.com/j2se/1.5.0/docs/api</link>
-                        <link>http://java.sun.com/javaee/6/docs/api</link>
+                        <link>http://docs.oracle.com/javase/6/docs/api</link>
+                        <link>http://docs.oracle.com/javaee/7/api</link>
                     </links>
                 </configuration>
                 <reportSets>
@@ -313,7 +314,7 @@
             <dependency>
                 <groupId>org.apache.commons</groupId>
                 <artifactId>commons-lang3</artifactId>
-                <version>3.1</version>
+                <version>3.3.2</version>
             </dependency>
             <dependency>
                 <groupId>commons-beanutils</groupId>
@@ -321,6 +322,12 @@
                 <version>1.8.3</version>
             </dependency>
             <dependency>
+                <groupId>org.apache.commons</groupId>
+                <artifactId>commons-weaver-privilizer-api</artifactId>
+                <version>${commons.weaver.version}</version>
+                <scope>provided</scope>
+            </dependency>
+            <dependency>
                 <groupId>com.thoughtworks.xstream</groupId>
                 <artifactId>xstream</artifactId>
                 <version>1.3.1</version>
@@ -377,8 +384,8 @@
                     <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-compiler-plugin</artifactId>
                     <configuration>
-                        <source>1.5</source>
-                        <target>1.5</target>
+                        <source>1.6</source>
+                        <target>1.6</target>
                         <encoding>${project.build.sourceEncoding}</encoding>
                     </configuration>
                 </plugin>
@@ -410,8 +417,8 @@
                         <verbose>false</verbose>
                         <maxmemory>512m</maxmemory>
                         <links>
-                            <link>http://java.sun.com/j2se/1.5.0/docs/api</link>
-                            <link>http://java.sun.com/javaee/6/docs/api</link>
+                            <link>http://docs.oracle.com/javase/6/docs/api</link>
+                            <link>http://docs.oracle.com/javaee/7/api</link>
                         </links>
                     </configuration>
                 </plugin>
@@ -536,12 +543,12 @@
                 <plugin>
                     <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-surefire-plugin</artifactId>
-                    <version>2.12</version>
+                    <version>2.17</version>
                 </plugin>
                 <plugin>
                     <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-surefire-report-plugin</artifactId>
-                    <version>2.12</version>
+                    <version>2.17</version>
                 </plugin>
                 <plugin>
                     <groupId>org.codehaus.mojo</groupId>
@@ -554,9 +561,34 @@
                     <version>1.2</version>
                 </plugin>
                 <plugin>
-                  <groupId>org.apache.maven.plugins</groupId>
-                  <artifactId>maven-source-plugin</artifactId>
-                  <version>2.1.1</version>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-source-plugin</artifactId>
+                    <version>2.1.1</version>
+                </plugin>
+                <plugin>
+                    <groupId>org.apache.commons</groupId>
+                    <artifactId>commons-weaver-maven-plugin</artifactId>
+                    <version>${commons.weaver.version}</version>
+                    <configuration>
+                        <weaverConfig>
+                            <privilizer.policy>DYNAMIC</privilizer.policy>
+                        </weaverConfig>
+                    </configuration>
+                    <executions>
+                        <execution>
+                            <goals>
+                                <goal>prepare</goal>
+                                <goal>weave</goal>
+                            </goals>
+                        </execution>
+                    </executions>
+                    <dependencies>
+                        <dependency>
+                            <groupId>org.apache.commons</groupId>
+                            <artifactId>commons-weaver-privilizer</artifactId>
+                            <version>${commons.weaver.version}</version>
+                        </dependency>
+                    </dependencies>
                 </plugin>
             </plugins>
         </pluginManagement>
@@ -577,7 +609,7 @@
                                     <version>[2.2.1,)</version>
                                 </requireMavenVersion>
                                 <requireJavaVersion>
-                                    <version>[1.5,)</version>
+                                    <version>[1.6,)</version>
                                 </requireJavaVersion>
                             </rules>
                         </configuration>



Mime
View raw message