bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r1762808 - /bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/ApacheFactoryContext.java
Date Thu, 29 Sep 2016 16:17:30 GMT
Author: mbenson
Date: Thu Sep 29 16:17:30 2016
New Revision: 1762808

URL: http://svn.apache.org/viewvc?rev=1762808&view=rev
Log:
cleanup

Modified:
    bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/ApacheFactoryContext.java

Modified: bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/ApacheFactoryContext.java
URL: http://svn.apache.org/viewvc/bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/ApacheFactoryContext.java?rev=1762808&r1=1762807&r2=1762808&view=diff
==============================================================================
--- bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/ApacheFactoryContext.java (original)
+++ bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/ApacheFactoryContext.java Thu Sep
29 16:17:30 2016
@@ -32,7 +32,7 @@ import javax.validation.ValidatorContext
 
 /**
  * Description: Represents the context that is used to create
- * <code>ClassValidator</code> instances.<br/>
+ * {@link ClassValidator} instances.
  */
 @Privilizing(@CallTo(Reflection.class))
 public class ApacheFactoryContext implements ValidatorContext {
@@ -74,7 +74,17 @@ public class ApacheFactoryContext implem
         return metaBeanFinder;
     }
 
-    private synchronized void resetMeta() { // ensure to ingnore the cache and rebuild constraint
with new model
+    /**
+     * Discard cached metadata. Calling this method unnecessarily has the effect of severly
+     * limiting performance, therefore only do so when changes have been made that affect
+     * validation metadata, i.e. particularly NOT in response to:
+     * <ul>
+     *   <li>{@link #messageInterpolator(MessageInterpolator)}</li>
+     *   <li>{@link #traversableResolver(TraversableResolver)}</li>
+     *   <li>{@link #constraintValidatorFactory(ConstraintValidatorFactory)</li>
+     * </ul>
+     */
+    private synchronized void resetMeta() {
         metaBeanFinder = factory.buildMetaBeanFinder();
     }
 
@@ -83,7 +93,6 @@ public class ApacheFactoryContext implem
      */
     public ValidatorContext messageInterpolator(MessageInterpolator messageInterpolator)
{
         this.messageInterpolator = messageInterpolator;
-        // resetMeta();, see traversableResolver() comment
         return this;
     }
 
@@ -92,8 +101,6 @@ public class ApacheFactoryContext implem
      */
     public ValidatorContext traversableResolver(TraversableResolver traversableResolver)
{
         this.traversableResolver = traversableResolver;
-         // meta are not affected by this so don't call resetMeta();
-        // implementor note: this is what does hibernate and loosing our cache cause of resetMeta()
call makes it super slow!
         return this;
     }
 
@@ -102,13 +109,12 @@ public class ApacheFactoryContext implem
      */
     public ValidatorContext constraintValidatorFactory(ConstraintValidatorFactory constraintValidatorFactory)
{
         this.constraintValidatorFactory = constraintValidatorFactory;
-        // same note as traversableResolver resetMeta();
         return this;
     }
 
     public ValidatorContext parameterNameProvider(ParameterNameProvider parameterNameProvider)
{
         this.parameterNameProvider = parameterNameProvider;
-        resetMeta(); // needed since param names are capture during processing
+        resetMeta(); // needed since parameter names are a component of validation metadata
         return this;
     }
 



Mime
View raw message