incubator-bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r1073097 - in /incubator/bval/sandbox/lang3-work/bval-jsr303d/src/main/java/org/apache/bval/jsr303/dynamic: DynamicMetaGraphManagerImpl.java Timestamped.java
Date Mon, 21 Feb 2011 18:06:57 GMT
Author: mbenson
Date: Mon Feb 21 18:06:56 2011
New Revision: 1073097

URL: http://svn.apache.org/viewvc?rev=1073097&view=rev
Log:
tweaks

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/Timestamped.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=1073097&r1=1073096&r2=1073097&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
Mon Feb 21 18:06:56 2011
@@ -40,6 +40,7 @@ import javax.validation.ValidationExcept
 import org.apache.bval.MetaBeanFinder;
 import org.apache.bval.jsr303.AnnotationProcessor;
 import org.apache.bval.jsr303.AppendValidationToMeta;
+import org.apache.bval.jsr303.Jsr303Features;
 import org.apache.bval.jsr303.UnknownPropertyException;
 import org.apache.bval.jsr303.util.ClassHelper;
 import org.apache.bval.jsr303.util.NodeImpl;
@@ -121,8 +122,8 @@ final class DynamicMetaGraphManagerImpl 
     private static class TypePathIterator implements Iterator<Pair<? extends PathImpl,
Class<?>>>,
         Iterable<Pair<? extends PathImpl, Class<?>>> {
         private final PathImpl fullPath;
-        private ArrayList<Pair<? extends PathImpl, Class<?>>> cache;
         private ArrayList<Path.Node> nodes;
+        private List<Pair<? extends PathImpl, Class<?>>> cache;
 
         private Class<?> rawType;
         private Type type;
@@ -144,11 +145,18 @@ final class DynamicMetaGraphManagerImpl 
             this.bean = rootBean;
             this.pos = 0;
 
-            nodes = new ArrayList<Path.Node>();
-            for (Path.Node node : fullPath) {
-                nodes.add(node);
+            if (fullPath.isRootPath()) {
+                nodes = null;
+                cache =
+                    Collections.<Pair<? extends PathImpl, Class<?>>> singletonList(Pair.<PathImpl,
Class<?>> of(
+                        fullPath, rootType));
+            } else {
+                nodes = new ArrayList<Path.Node>();
+                for (Path.Node node : fullPath) {
+                    nodes.add(node);
+                }
+                cache = new ArrayList<Pair<? extends PathImpl, Class<?>>>(nodes.size());
             }
-            cache = new ArrayList<Pair<? extends PathImpl, Class<?>>>(nodes.size());
         }
 
         /**
@@ -607,7 +615,6 @@ final class DynamicMetaGraphManagerImpl 
                         if (mostSpecific instanceof CacheMeta) {
                             @SuppressWarnings("unchecked")
                             CacheMeta<MetaBean> cacheMeta = (CacheMeta<MetaBean>)
mostSpecific;
-                            Timestamped.Utils.stamp(result);
                             cacheMeta.cache(result);
                         }
                         return result;
@@ -719,7 +726,7 @@ final class DynamicMetaGraphManagerImpl 
      * @param beanType
      * @param propertyPath
      * @param annotation
-     * @return whether applying the specified annotation resulted in a change 
+     * @return whether applying the specified annotation resulted in a change
      */
     boolean constrain(Class<?> beanType, String propertyPath, Annotation annotation)
{
         final boolean setManager = DynamicModelManager.THREAD_BOUND_MANAGER.get() == null;

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303d/src/main/java/org/apache/bval/jsr303/dynamic/Timestamped.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303d/src/main/java/org/apache/bval/jsr303/dynamic/Timestamped.java?rev=1073097&r1=1073096&r2=1073097&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303d/src/main/java/org/apache/bval/jsr303/dynamic/Timestamped.java
(original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303d/src/main/java/org/apache/bval/jsr303/dynamic/Timestamped.java
Mon Feb 21 18:06:56 2011
@@ -119,10 +119,14 @@ interface Timestamped {
              * {@inheritDoc}
              */
             public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
{
+                Throwable caught = null;
                 try {
                     return method.invoke(iter, args);
+                } catch (Throwable t) {
+                    caught = t;
+                    throw t;
                 } finally {
-                    fireChange("remove".equals(method.getName()));
+                    fireChange(caught == null && "remove".equals(method.getName()));
                 }
             }
         }
@@ -776,17 +780,6 @@ interface Timestamped {
         };
 
         /**
-         * Stamp a {@link Timestamped} argument.
-         * 
-         * @param o
-         */
-        public static void stamp(Object o) {
-            if (o instanceof Timestamped) {
-                ((Timestamped) o).touch();
-            }
-        }
-
-        /**
          * Get a usable timestamp value.
          * 
          * @param o



Mime
View raw message