cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r649246 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne: map/MapLoader.java query/BaseQueryMetadata.java query/QueryCacheStrategy.java
Date Thu, 17 Apr 2008 19:37:27 GMT
Author: aadamchik
Date: Thu Apr 17 12:37:20 2008
New Revision: 649246

URL: http://svn.apache.org/viewvc?rev=649246&view=rev
Log:
CAY-1035 Replace QueryMetadata String cache policies with an enum
(loading/storing strategies)

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/MapLoader.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/BaseQueryMetadata.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/QueryCacheStrategy.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/MapLoader.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/MapLoader.java?rev=649246&r1=649245&r2=649246&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/MapLoader.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/MapLoader.java
Thu Apr 17 12:37:20 2008
@@ -49,7 +49,7 @@
 
     // TODO: andrus, 7/17/2006 - these variables, and project upgrade logic should be
     // refactored out of the MapLoader. In fact we should either modify raw XML during the
-    // upgrade, or implement some consistent upgrade API across variou loaders
+    // upgrade, or implement some consistent upgrade API across various loaders
     final static String _1_2_PACKAGE_PREFIX = "org.objectstyle.cayenne.";
     final static String _2_0_PACKAGE_PREFIX = "org.apache.cayenne.";
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/BaseQueryMetadata.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/BaseQueryMetadata.java?rev=649246&r1=649245&r2=649246&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/BaseQueryMetadata.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/BaseQueryMetadata.java
Thu Apr 17 12:37:20 2008
@@ -79,6 +79,7 @@
         this.refreshingObjects = info.isRefreshingObjects();
         this.resolvingInherited = info.isResolvingInherited();
         this.cachePolicy = info.getCachePolicy();
+        this.cacheStrategy = info.getCacheStrategy();
         this.cacheKey = info.getCacheKey();
 
         setPrefetchTree(info.getPrefetchTree());
@@ -161,7 +162,10 @@
         Object resolvingInherited = properties
                 .get(QueryMetadata.RESOLVING_INHERITED_PROPERTY);
 
+        // deprecated cache policy... handle it for backwards compatibility.
         Object cachePolicy = properties.get(QueryMetadata.CACHE_POLICY_PROPERTY);
+        Object cacheStrategy = properties.get(QueryMetadata.CACHE_STRATEGY_PROPERTY);
+
         Object cacheGroups = properties.get(QueryMetadata.CACHE_GROUPS_PROPERTY);
 
         // init ivars from properties
@@ -189,6 +193,10 @@
                 ? cachePolicy.toString()
                 : QueryMetadata.CACHE_POLICY_DEFAULT;
 
+        this.cacheStrategy = (cacheStrategy != null) ? QueryCacheStrategy
+                .safeValueOf(cacheStrategy.toString()) : QueryCacheStrategy
+                .getDefaultStrategy();
+
         this.cacheGroups = null;
         if (cacheGroups instanceof String[]) {
             this.cacheGroups = (String[]) cacheGroups;
@@ -201,7 +209,7 @@
             }
         }
     }
-    
+
     /**
      * @since 3.0
      */
@@ -241,6 +249,12 @@
             encoder.printProperty(QueryMetadata.CACHE_POLICY_PROPERTY, cachePolicy);
         }
 
+        if (cacheStrategy != null
+                && QueryCacheStrategy.getDefaultStrategy() != cacheStrategy) {
+            encoder.printProperty(QueryMetadata.CACHE_STRATEGY_PROPERTY, cacheStrategy
+                    .name());
+        }
+
         if (prefetchTree != null) {
             prefetchTree.encodeAsXML(encoder);
         }
@@ -295,7 +309,7 @@
     public ClassDescriptor getClassDescriptor() {
         return classDescriptor;
     }
-    
+
     /**
      * Always returns null, as this is not supported for most classic queries.
      * 
@@ -364,7 +378,7 @@
     public int getPageSize() {
         return pageSize;
     }
-    
+
     public Query getOrginatingQuery() {
         return null;
     }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/QueryCacheStrategy.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/QueryCacheStrategy.java?rev=649246&r1=649245&r2=649246&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/QueryCacheStrategy.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/QueryCacheStrategy.java
Thu Apr 17 12:37:20 2008
@@ -57,7 +57,20 @@
      * treat current cache state as expired, and force the database fetch.
      */
     SHARED_CACHE_REFRESH;
-    
+
+    /**
+     * Returns QueryCacheStrategy for the specified string name or default strategy for
+     * invalid names.
+     */
+    public static QueryCacheStrategy safeValueOf(String string) {
+        try {
+            return QueryCacheStrategy.valueOf(string);
+        }
+        catch (IllegalArgumentException e) {
+            return getDefaultStrategy();
+        }
+    }
+
     public static QueryCacheStrategy getDefaultStrategy() {
         return NO_CACHE;
     }



Mime
View raw message