incubator-bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r1080684 - /incubator/bval/sandbox/lang3-work/bval-jsr303d/src/main/java/org/apache/bval/jsr303/dynamic/Timestamped.java
Date Fri, 11 Mar 2011 17:23:35 GMT
Author: mbenson
Date: Fri Mar 11 17:23:34 2011
New Revision: 1080684

URL: http://svn.apache.org/viewvc?rev=1080684&view=rev
Log:
fix indexed caching

Modified:
    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/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=1080684&r1=1080683&r2=1080684&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
Fri Mar 11 17:23:34 2011
@@ -498,7 +498,7 @@ interface Timestamped {
             }
 
             private volatile long millis;
-            private final Object owner;
+            private Object owner;
             private transient MetaBean cached;
 
             /**
@@ -596,6 +596,7 @@ interface Timestamped {
              */
             public InIterableBean(Bean cacheMeta) {
                 this.bean = cacheMeta;
+                this.millis = Utils.read(cacheMeta);
             }
 
             /**
@@ -616,7 +617,7 @@ interface Timestamped {
              * {@inheritDoc}
              */
             public void touch() {
-                this.millis = System.currentTimeMillis();
+                // noop
             }
 
             /**
@@ -675,10 +676,17 @@ interface Timestamped {
                 int last = sources.length - 1;
                 Bean cacheHolder = (Bean) sources[last];
 
+                // if we have gotten here, we've proven that any cached result held by our
cacheHolder is outdated,
+                // right?
+                cacheHolder.cache(null);
                 InIterableBean result = new InIterableBean(cacheHolder);
                 for (MetaBean source : sources) {
                     DynamicModelManager.get().copy(result, source);
                 }
+                // ensure result carries the later timestamp of its sources:
+                if (sources.length > 1 && Utils.COMPARATOR.compare(sources[0],
cacheHolder) > 0) {
+                    result.millis = Utils.read(sources[0]);
+                }
                 cache.put(id, result);
                 return result;
             }
@@ -701,6 +709,7 @@ interface Timestamped {
             private AwareCollection(Type type, Object owner) {
                 super(type);
                 this.owner = owner;
+                ((Bean) prototype).owner = owner;
             }
 
             /**
@@ -738,6 +747,7 @@ interface Timestamped {
             private AwareMap(Type type, FeaturesCapable owner) {
                 super(type);
                 this.owner = owner;
+                ((Bean) prototype).owner = owner;
             }
 
             /**



Mime
View raw message