You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2006/07/31 21:32:33 UTC
svn commit: r427227 -
/incubator/cayenne/main/trunk/core/cayenne-jdk1.4-core/src/main/java/org/apache/cayenne/cache/OSQueryCache.java
Author: aadamchik
Date: Mon Jul 31 12:32:33 2006
New Revision: 427227
URL: http://svn.apache.org/viewvc?rev=427227&view=rev
Log:
CAY-613 - support for per-query expiration policy - handling incomplete query properties
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=427227&r1=427226&r2=427227&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 Mon Jul 31 12:32:33 2006
@@ -40,31 +40,31 @@
* may 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.query.xyz.refresh = 120
- * cayenne.query.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.query.xyz.refresh = 120
+ * cayenne.query.xyz.cron = 10 1 * * *
* </pre>
*
* @since 3.0
@@ -106,6 +106,19 @@
// load defaults and per-query settings
if (properties != null) {
+
+ // first extract defaults...
+ String defaultRefresh = properties.getProperty(DEFAULT_REFRESH_KEY);
+ if (defaultRefresh != null) {
+ defaultRefreshSpecification.setRefreshPeriod(defaultRefresh);
+ }
+
+ String defaultCron = properties.getProperty(DEFAULT_CRON_KEY);
+ if (defaultCron != null) {
+ defaultRefreshSpecification.cronExpression = defaultCron;
+ }
+
+ // now check for per-query settings
Iterator it = properties.entrySet().iterator();
while (it.hasNext()) {
@@ -132,14 +145,6 @@
}
}
- else if (key.equals(DEFAULT_REFRESH_KEY)) {
- defaultRefreshSpecification.setRefreshPeriod(entry.getValue());
- }
- else if (key.equals(DEFAULT_CRON_KEY)) {
- defaultRefreshSpecification.cronExpression = entry
- .getValue()
- .toString();
- }
}
}
@@ -154,6 +159,8 @@
.get(name);
if (spec == null) {
spec = new RefreshSpecification();
+ spec.cronExpression = defaultRefreshSpecification.cronExpression;
+ spec.refreshPeriod = defaultRefreshSpecification.refreshPeriod;
refreshSpecifications.put(name, spec);
}