cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r430106 - /incubator/cayenne/main/trunk/core/cayenne-jdk1.4-core/src/main/java/org/apache/cayenne/cache/OSQueryCache.java
Date Wed, 09 Aug 2006 17:45:21 GMT
Author: aadamchik
Date: Wed Aug  9 10:45:20 2006
New Revision: 430106

URL: http://svn.apache.org/viewvc?rev=430106&view=rev
Log:
exposing properties and init methods of OSQueryCache provider for the benefit of subclassing.

Modified:
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4-core/src/main/java/org/apache/cayenne/cache/OSQueryCache.java

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4-core/src/main/java/org/apache/cayenne/cache/OSQueryCache.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4-core/src/main/java/org/apache/cayenne/cache/OSQueryCache.java?rev=430106&r1=430105&r2=430106&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4-core/src/main/java/org/apache/cayenne/cache/OSQueryCache.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4-core/src/main/java/org/apache/cayenne/cache/OSQueryCache.java
Wed Aug  9 10:45:20 2006
@@ -40,31 +40,31 @@
  * look like this:
  * 
  * <pre>
- *                # OSCache configuration file
- *               
- *                # OSCache standard configuration per
- *                #     http://www.opensymphony.com/oscache/wiki/Configuration.html
- *                # ---------------------------------------------------------------
- *               
- *                #cache.memory=true
- *                cache.capacity=5000
- *                cache.algorithm=com.opensymphony.oscache.base.algorithm.LRUCache
- *               
- *               
- *                # Cayenne specific properties
- *                # ---------------------------------------------------------------
- *               
- *                # Default refresh period in seconds:
- *                cayenne.default.refresh = 60
- *               
- *                # Default expiry specified as cron expressions per
- *                #    http://www.opensymphony.com/oscache/wiki/Cron%20Expressions.html
- *                # expire entries every hour on the 10's minute
- *                cayenne.default.cron = 10 * * * *
- *               
- *                # Same parameters can be overriden per query
- *                cayenne.group.xyz.refresh = 120
- *                cayenne.group.xyz.cron = 10 1 * * *
+ *                       # OSCache configuration file
+ *                      
+ *                       # OSCache standard configuration per
+ *                       #     http://www.opensymphony.com/oscache/wiki/Configuration.html
+ *                       # ---------------------------------------------------------------
+ *                      
+ *                       #cache.memory=true
+ *                       cache.capacity=5000
+ *                       cache.algorithm=com.opensymphony.oscache.base.algorithm.LRUCache
+ *                      
+ *                      
+ *                       # Cayenne specific properties
+ *                       # ---------------------------------------------------------------
+ *                      
+ *                       # Default refresh period in seconds:
+ *                       cayenne.default.refresh = 60
+ *                      
+ *                       # Default expiry specified as cron expressions per
+ *                       #    http://www.opensymphony.com/oscache/wiki/Cron%20Expressions.html
+ *                       # expire entries every hour on the 10's minute
+ *                       cayenne.default.cron = 10 * * * *
+ *                      
+ *                       # Same parameters can be overriden per query
+ *                       cayenne.group.xyz.refresh = 120
+ *                       cayenne.group.xyz.cron = 10 1 * * *
  * </pre>
  * 
  * Further extension of OSQueryCache is possible by using OSCache listener API.
@@ -87,6 +87,7 @@
 
     RefreshSpecification defaultRefreshSpecification;
     Map refreshSpecifications;
+    Properties properties;
 
     public OSQueryCache() {
         OSCacheAdministrator admin = new OSCacheAdministrator();
@@ -104,8 +105,16 @@
         return osCache;
     }
 
-    void init(GeneralCacheAdministrator cache, Properties properties) {
+    /**
+     * Returns configuration properties. Usually this is the contents of
+     * "oscache.properties" file.
+     */
+    public Properties getProperties() {
+        return properties;
+    }
 
+    void init(GeneralCacheAdministrator cache, Properties properties) {
+        this.properties = properties;
         this.osCache = cache;
         this.defaultRefreshSpecification = new RefreshSpecification();
 
@@ -140,18 +149,35 @@
                         String name = key.substring(GROUP_PREFIX.length(), key.length()
                                 - REFRESH_SUFFIX.length());
 
-                        nonNullSpec(name).setRefreshPeriod(entry.getValue());
+                        initRefreshPolicy(name, entry.getValue());
                     }
                     else if (key.endsWith(CRON_SUFFIX)) {
                         String name = key.substring(GROUP_PREFIX.length(), key.length()
                                 - CRON_SUFFIX.length());
 
-                        nonNullSpec(name).cronExpression = entry.getValue().toString();
+                        initCronPolicy(name, entry.getValue());
                     }
-
                 }
             }
         }
+    }
+
+    /**
+     * Called internally for each group that is configured with cron policy in the
+     * properties. Exposed mainly for the benefit of subclasses. When overriding, call
+     * 'super'.
+     */
+    protected void initCronPolicy(String groupName, Object value) {
+        nonNullSpec(groupName).cronExpression = value != null ? value.toString() : null;
+    }
+
+    /**
+     * Called internally for each group that is configured with refresh policy in the
+     * properties. Exposed mainly for the benefit of subclasses. When overriding, call
+     * 'super'.
+     */
+    protected void initRefreshPolicy(String groupName, Object value) {
+        nonNullSpec(groupName).setRefreshPeriod(value);
     }
 
     private RefreshSpecification nonNullSpec(String name) {



Mime
View raw message