incubator-bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r1073958 - in /incubator/bval/sandbox/lang3-work/bval-jsr303d/src/main/java/org/apache/bval/jsr303/dynamic: DynamicMetaGraphManagerImpl.java DynamicModelManager.java DynamicValidatorContext.java
Date Wed, 23 Feb 2011 21:45:01 GMT
Author: mbenson
Date: Wed Feb 23 21:45:01 2011
New Revision: 1073958

URL: http://svn.apache.org/viewvc?rev=1073958&view=rev
Log:
compute relationships only once for cached dynamic MetaBean results

Modified:
    incubator/bval/sandbox/lang3-work/bval-jsr303d/src/main/java/org/apache/bval/jsr303/dynamic/DynamicMetaGraphManagerImpl.java
    incubator/bval/sandbox/lang3-work/bval-jsr303d/src/main/java/org/apache/bval/jsr303/dynamic/DynamicModelManager.java
    incubator/bval/sandbox/lang3-work/bval-jsr303d/src/main/java/org/apache/bval/jsr303/dynamic/DynamicValidatorContext.java

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303d/src/main/java/org/apache/bval/jsr303/dynamic/DynamicMetaGraphManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303d/src/main/java/org/apache/bval/jsr303/dynamic/DynamicMetaGraphManagerImpl.java?rev=1073958&r1=1073957&r2=1073958&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303d/src/main/java/org/apache/bval/jsr303/dynamic/DynamicMetaGraphManagerImpl.java
(original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303d/src/main/java/org/apache/bval/jsr303/dynamic/DynamicMetaGraphManagerImpl.java
Wed Feb 23 21:45:01 2011
@@ -16,6 +16,7 @@
  */
 package org.apache.bval.jsr303.dynamic;
 
+import static org.apache.bval.jsr303.dynamic.DynamicModelManager.Features.COMPUTE_RELATIONSHIPS;
 import static org.apache.bval.jsr303.dynamic.DynamicModelManager.Features.DYNAMIC_CONSTRAINT_COLLECTION;
 import static org.apache.bval.jsr303.dynamic.DynamicModelManager.Features.META_CONTAINER;
 
@@ -610,6 +611,10 @@ final class DynamicMetaGraphManagerImpl 
                                 }
                             }
                         }
+                        // mark as fresh result:
+                        result.putFeature(COMPUTE_RELATIONSHIPS, true);
+
+                        // cache result
                         MetaBean mostSpecific = toMerge.getLast();
                         if (mostSpecific instanceof CacheMeta) {
                             @SuppressWarnings("unchecked")

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303d/src/main/java/org/apache/bval/jsr303/dynamic/DynamicModelManager.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303d/src/main/java/org/apache/bval/jsr303/dynamic/DynamicModelManager.java?rev=1073958&r1=1073957&r2=1073958&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303d/src/main/java/org/apache/bval/jsr303/dynamic/DynamicModelManager.java
(original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303d/src/main/java/org/apache/bval/jsr303/dynamic/DynamicModelManager.java
Wed Feb 23 21:45:01 2011
@@ -65,6 +65,10 @@ public class DynamicModelManager {
         /** meta-container key */
         public static final String META_CONTAINER = "metaContainer";
 
+        /**
+         * Dynamic result MetaBean feature indicating whether relationships have yet to be
computed.
+         */
+        public static final String COMPUTE_RELATIONSHIPS = "computeRelationships";
     }
 
     /** static instance */

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303d/src/main/java/org/apache/bval/jsr303/dynamic/DynamicValidatorContext.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303d/src/main/java/org/apache/bval/jsr303/dynamic/DynamicValidatorContext.java?rev=1073958&r1=1073957&r2=1073958&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303d/src/main/java/org/apache/bval/jsr303/dynamic/DynamicValidatorContext.java
(original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303d/src/main/java/org/apache/bval/jsr303/dynamic/DynamicValidatorContext.java
Wed Feb 23 21:45:01 2011
@@ -16,6 +16,8 @@
  */
 package org.apache.bval.jsr303.dynamic;
 
+import static org.apache.bval.jsr303.dynamic.DynamicModelManager.Features.COMPUTE_RELATIONSHIPS;
+
 import java.lang.annotation.Annotation;
 
 import javax.validation.Validator;
@@ -59,7 +61,13 @@ public class DynamicValidatorContext ext
          */
         public MetaBean findForClass(final Class<?> clazz) {
             MetaBean result = metaGraphManager.readOnly().getMetaBean(clazz);
-            computeRelationships(result);
+            boolean isDynamic = result.getFeatures().containsKey(COMPUTE_RELATIONSHIPS);
+            if (!isDynamic || result.<Boolean> getFeature(COMPUTE_RELATIONSHIPS)) {
+                computeRelationships(result);
+                if (isDynamic) {
+                    result.putFeature(COMPUTE_RELATIONSHIPS, false);
+                }
+            }
             return result;
         }
 



Mime
View raw message