You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ds...@apache.org on 2010/07/29 10:43:11 UTC

svn commit: r980360 - /felix/trunk/sigil/common/obr/src/org/apache/felix/sigil/obr/OBRRepositoryProvider.java

Author: dsavage
Date: Thu Jul 29 08:43:11 2010
New Revision: 980360

URL: http://svn.apache.org/viewvc?rev=980360&view=rev
Log:
fix hardcoded update period - now checks config props and falls back to default if that fails (FELIX-1610)

Modified:
    felix/trunk/sigil/common/obr/src/org/apache/felix/sigil/obr/OBRRepositoryProvider.java

Modified: felix/trunk/sigil/common/obr/src/org/apache/felix/sigil/obr/OBRRepositoryProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/obr/src/org/apache/felix/sigil/obr/OBRRepositoryProvider.java?rev=980360&r1=980359&r2=980360&view=diff
==============================================================================
--- felix/trunk/sigil/common/obr/src/org/apache/felix/sigil/obr/OBRRepositoryProvider.java (original)
+++ felix/trunk/sigil/common/obr/src/org/apache/felix/sigil/obr/OBRRepositoryProvider.java Thu Jul 29 08:43:11 2010
@@ -33,6 +33,12 @@ import org.apache.felix.sigil.repository
 
 public class OBRRepositoryProvider implements IRepositoryProvider
 {
+    private static final String IN_MEMORY = "inmemory";
+    private static final String UPDATE_PERIOD = "updatePeriod";
+    private static final String AUTH_FILE = "auth";
+    private static final String CACHE_DIRECTORY = "cache";
+    private static final String INDEX_CACHE_FILE = "index";
+
     public IBundleRepository createRepository(String id, Properties preferences)
         throws RepositoryException
     {
@@ -45,10 +51,11 @@ public class OBRRepositoryProvider imple
             File urlFile = new File(urlStr);
             URL repositoryURL = urlFile.exists() ? urlFile.toURI().toURL() : new URL(urlStr);
             URL testURL = urlFile.exists() ? urlFile.toURI().toURL() : new URL(urlStr);
-            File indexCache = new File(preferences.getProperty("index"));
-            File localCache = new File(preferences.getProperty("cache"));
-            String auth = preferences.getProperty("auth");
+            File indexCache = new File(preferences.getProperty(INDEX_CACHE_FILE));
+            File localCache = new File(preferences.getProperty(CACHE_DIRECTORY));
+            String auth = preferences.getProperty(AUTH_FILE);
             File authFile = auth == null ? null : new File(auth);
+            Long up = preferences.containsKey(UPDATE_PERIOD) ? Long.parseLong( preferences.getProperty(UPDATE_PERIOD) ) : 60 * 60 * 24 * 7; 
 
             if (testURL.openConnection().getLastModified() == 0)
             {
@@ -58,10 +65,8 @@ public class OBRRepositoryProvider imple
                 System.err.println("WARNING: " + msg + "using cache: " + urlStr);
             }
 
-            // TODO create user configurable updatePeriod
-            long updatePeriod = TimeUnit.MILLISECONDS.convert(60 * 60 * 24 * 7,
-                TimeUnit.SECONDS);
-            if (preferences.getProperty("inmemory") == null)
+            long updatePeriod = TimeUnit.MILLISECONDS.convert(up,TimeUnit.SECONDS);
+            if (preferences.getProperty(IN_MEMORY) == null)
             {
                 return new NonCachingOBRBundleRepository(id, repositoryURL, indexCache,
                     localCache, updatePeriod, authFile);