Author: etnu
Date: Sun Nov  9 02:52:26 2008
New Revision: 712482

URL: http://svn.apache.org/viewvc?rev=712482&view=rev
Log:
Merged ehcache properties into main properties config

Normalized names of caching-related properties.

Added a little bit of extra logic in LruCacheProvider to make it at least as 
useful as it was before switching to EhCache.

Switched EhCache property discovery to support file-based as well as 
resource-based configuration files.


Added:
    
incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/common/cache/LruCacheProviderTest.java
Modified:
    incubator/shindig/trunk/java/common/conf/shindig.properties
    
incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/cache/LruCache.java
    
incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/cache/LruCacheProvider.java
    
incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/cache/ehcache/EhCacheCacheProvider.java
    
incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/cache/ehcache/EhCacheModule.java
    
incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/common/cache/ehcache/EhCacheCacheProviderTest.java
    
incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/DefaultGadgetSpecFactory.java
    
incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/DefaultMessageBundleFactory.java
    
incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/http/HttpResponse.java
    
incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/http/DefaultHttpCacheTest.java
    
incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/http/EhCacheBackedDefaultHttpCacheTest.java

Modified: incubator/shindig/trunk/java/common/conf/shindig.properties
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/common/conf/shindig.properties?rev=712482&r1=712481&r2=712482&view=diff
==============================================================================
--- incubator/shindig/trunk/java/common/conf/shindig.properties (original)
+++ incubator/shindig/trunk/java/common/conf/shindig.properties Sun Nov  9 
02:52:26 2008
@@ -1,18 +1,46 @@
+# Location of feature manifests (comma separated)
 shindig.features.default=res://features/features.txt
+
+# Location of container configurations (comma separated)
 shindig.containers.default=res://containers/default/container.js
+
+# A file containing blacklisted gadgets.
 shindig.blacklist.file=
+
+# OAuth confiugration
 shindig.oauth.state-key=
 shindig.signing.key-name=
 shindig.signing.key-file=
+
+# If enabled here, configuration values can be found in container 
configuration files.
 shindig.locked-domain.enabled=false
-shindig.locked-domain.embed-host=127.0.0.1:8080
+
+# TODO: This needs to be moved to container configuration.
 shindig.content-rewrite.include-urls=.*
 shindig.content-rewrite.exclude-urls=
 shindig.content-rewrite.include-tags=link,script,embed,img,style
 shindig.content-rewrite.expires=86400
 shindig.content-rewrite.proxy-url=http://localhost:8080/gadgets/proxy?url=
 shindig.content-rewrite.concat-url=http://localhost:8080/gadgets/concat?
-shindig.http.cache.defaultTtl=3600000
-shindig.http.cache.negativeCacheTtl=60000
-shindig.cache.capacity=10000
-shindig.cache.expirationMs=300000
+
+# These values provide default TTLs for HTTP responses that don't use caching 
headers.
+shindig.cache.http.defaultTtl=3600000
+shindig.cache.http.negativeCacheTtl=60000
+
+# A default refresh interval for XML files, since there is no natural way for 
developers to
+# specify this value, and most HTTP responses don't include good cache control 
headers.
+shindig.cache.xml.refreshInterval=300000
+
+# Add entries in the form shindig.cache.lru.<name>.capacity to specify 
capacities for different
+# caches when using the LruCacheProvider.
+# It is highly recommended that the EhCache implementation be used instead of 
the LRU cache.
+shindig.cache.lru.default.capacity=1000
+shindig.cache.lru.gadgetSpecs.capacity=1000
+shindig.cache.lru.messageBundles.capacity=1000
+shindig.cache.lru.httpResponses.capacity=10000
+
+# The location of the EhCache configuration file.
+shindig.cache.ehcache.config=res://org/apache/shindig/common/cache/ehcache/ehcacheConfig.xml
+
+# true to enable JMX stats.
+shindig.cache.ehcache.jmx.stats=true

Modified: 
incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/cache/LruCache.java
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/cache/LruCache.java?rev=712482&r1=712481&r2=712482&view=diff
==============================================================================
--- 
incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/cache/LruCache.java
 (original)
+++ 
incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/cache/LruCache.java
 Sun Nov  9 02:52:26 2008
@@ -25,7 +25,7 @@
  * A basic LRU cache. Prefer using EhCache for most purposes to this class.
  */
 public class LruCache<K, V> extends LinkedHashMap<K, V> implements Cache<K, V> 
{
-  private final int capacity;
+  final int capacity;
 
   public LruCache(int capacity) {
     super(capacity, 0.75f, true);

Modified: 
incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/cache/LruCacheProvider.java
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/cache/LruCacheProvider.java?rev=712482&r1=712481&r2=712482&view=diff
==============================================================================
--- 
incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/cache/LruCacheProvider.java
 (original)
+++ 
incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/cache/LruCacheProvider.java
 Sun Nov  9 02:52:26 2008
@@ -18,25 +18,77 @@
  */
 package org.apache.shindig.common.cache;
 
+import com.google.common.collect.Maps;
 import com.google.inject.Inject;
+import com.google.inject.Injector;
+import com.google.inject.Key;
 import com.google.inject.name.Named;
+import com.google.inject.name.Names;
+
+import java.util.Map;
+import java.util.logging.Logger;
 
 /**
- * A cache provider that always produces LRU caches. Generally only useful for 
testing, as it always
- * returns an anonymous cache with a fixed capacity.
+ * A cache provider that always produces LRU caches.
+ *
+ * LRU cache sizes can be configured by specifying property names in the form
+ *
+ * shindig.cache.lru.<cache name>.capacity=foo
+ *
+ * The default value is expected under shindig.cache.lru.default.capacity
  *
- * For a production-worthy cache, use [EMAIL PROTECTED] EhCacheCacheProvider}.
+ * An in memory LRU cache only scales so far. For a production-worthy cache, 
use
+ * [EMAIL PROTECTED] EhCacheCacheProvider}.
  */
 public class LruCacheProvider implements CacheProvider {
-  private final int capacity;
+  private static final Logger LOG = 
Logger.getLogger(LruCacheProvider.class.getName());
+  private final int defaultCapacity;
+  private final Injector injector;
+  private final Map<String, Cache<?, ?>> caches = Maps.newConcurrentHashMap();
 
   @Inject
-  public LruCacheProvider(@Named("shindig.cache.capacity") int capacity) {
-    this.capacity = capacity;
+  public LruCacheProvider(Injector injector,
+      @Named("shindig.cache.lru.default.capacity") int defaultCapacity) {
+    this.injector = injector;
+    this.defaultCapacity = defaultCapacity;
+  }
+
+  public LruCacheProvider(int capacity) {
+    this(null, capacity);
+  }
+
+  private int getCapacity(String name) {
+    if (injector != null && name != null) {
+      String key = "shindig.cache.lru." + name + ".capacity";
+      Key<String> guiceKey = Key.get(String.class, Names.named(key));
+      if (injector.getBinding(guiceKey) == null) {
+        LOG.warning("No LRU capacity configured for " + name);
+      } else {
+        String value = injector.getInstance(guiceKey);
+        try {
+          return Integer.parseInt(value);
+        } catch (NumberFormatException e) {
+          LOG.warning("Invalid LRU capacity configured for " + name);
+        }
+      }
+    }
+    return defaultCapacity;
   }
 
   @SuppressWarnings("unchecked")
   public <K, V> Cache<K, V> createCache(String name) {
-    return new LruCache<K, V>(capacity);
+    int capacity = getCapacity(name);
+    if (name == null) {
+      LOG.info("Creating anonymous cache");
+      return new LruCache<K, V>(capacity);
+    } else {
+      Cache<K, V> cache = (Cache<K, V>) caches.get(name);
+      if (cache == null) {
+        LOG.info("Creating cache named " + name);
+        cache = new LruCache<K, V>(capacity);
+        caches.put(name, cache);
+      }
+      return cache;
+    }
   }
 }

Modified: 
incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/cache/ehcache/EhCacheCacheProvider.java
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/cache/ehcache/EhCacheCacheProvider.java?rev=712482&r1=712481&r2=712482&view=diff
==============================================================================
--- 
incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/cache/ehcache/EhCacheCacheProvider.java
 (original)
+++ 
incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/cache/ehcache/EhCacheCacheProvider.java
 Sun Nov  9 02:52:26 2008
@@ -20,6 +20,7 @@
 
 import org.apache.shindig.common.cache.Cache;
 import org.apache.shindig.common.cache.CacheProvider;
+import org.apache.shindig.common.util.ResourceLoader;
 
 import com.google.common.collect.Maps;
 import com.google.inject.Inject;
@@ -28,8 +29,9 @@
 import net.sf.ehcache.CacheManager;
 import net.sf.ehcache.management.ManagementService;
 
+import java.io.IOException;
+import java.io.InputStream;
 import java.lang.management.ManagementFactory;
-import java.net.URL;
 import java.util.Map;
 import java.util.logging.Logger;
 
@@ -41,10 +43,11 @@
   private final Map<String, Cache<?, ?>> caches = Maps.newConcurrentHashMap();
 
   @Inject
-  public EhCacheCacheProvider(@Named("cache.config") String configPath,
-                              @Named("cache.jmx.stats") boolean 
withCacheStats) {
-    URL url = getClass().getResource(configPath);
-    cacheManager = new CacheManager(url);
+  public EhCacheCacheProvider(@Named("shindig.cache.ehcache.config") String 
configPath,
+                              @Named("shindig.cache.ehcache.jmx.stats") 
boolean withCacheStats)
+      throws IOException {
+    InputStream configStream = ResourceLoader.open(configPath);
+    cacheManager = new CacheManager(configStream);
     create(withCacheStats);
   }
 

Modified: 
incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/cache/ehcache/EhCacheModule.java
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/cache/ehcache/EhCacheModule.java?rev=712482&r1=712481&r2=712482&view=diff
==============================================================================
--- 
incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/cache/ehcache/EhCacheModule.java
 (original)
+++ 
incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/cache/ehcache/EhCacheModule.java
 Sun Nov  9 02:52:26 2008
@@ -19,50 +19,16 @@
 package org.apache.shindig.common.cache.ehcache;
 
 import org.apache.shindig.common.cache.CacheProvider;
-import org.apache.shindig.common.util.ResourceLoader;
 
 import com.google.inject.AbstractModule;
-import com.google.inject.CreationException;
 import com.google.inject.Scopes;
-import com.google.inject.name.Names;
-import com.google.inject.spi.Message;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Arrays;
-import java.util.Properties;
 
 /**
  * Creates a module to supply a EhCache Provider
  */
 public class EhCacheModule extends AbstractModule {
-  private final Properties properties;
-  private final static String DEFAULT_PROPERTIES = "ehcache.properties";
-
-  /** [EMAIL PROTECTED] */
   @Override
   protected void configure() {
-    Names.bindProperties(this.binder(), properties);
     
bind(CacheProvider.class).to(EhCacheCacheProvider.class).in(Scopes.SINGLETON);
   }
-
-  public EhCacheModule(Properties properties) {
-    this.properties = properties;
-  }
-
-  /**
-   * Creates module with standard properties.
-   */
-  public EhCacheModule() {
-    Properties properties = null;
-    try {
-      InputStream is = ResourceLoader.openResource(DEFAULT_PROPERTIES);
-      properties = new Properties();
-      properties.load(is);
-    } catch (IOException e) {
-      throw new CreationException(Arrays.asList(new Message("Unable to load 
properties: "
-          + DEFAULT_PROPERTIES)));
-    }
-    this.properties = properties;
-  }
 }

Added: 
incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/common/cache/LruCacheProviderTest.java
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/common/cache/LruCacheProviderTest.java?rev=712482&view=auto
==============================================================================
--- 
incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/common/cache/LruCacheProviderTest.java
 (added)
+++ 
incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/common/cache/LruCacheProviderTest.java
 Sun Nov  9 02:52:26 2008
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.shindig.common.cache;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Module;
+import com.google.inject.name.Names;
+
+import org.junit.Test;
+
+public class LruCacheProviderTest {
+
+  private LruCache<Object, Object> getCache(CacheProvider provider, String 
name) {
+    Cache<Object, Object> base = provider.createCache(name);
+    return (LruCache<Object, Object>)base;
+  }
+
+  @Test
+  public void defaultCapacityForNamedCache() throws Exception {
+    LruCacheProvider provider = new LruCacheProvider(10);
+    assertEquals(10, getCache(provider, "foo").capacity);
+  }
+
+  @Test
+  public void defaultCapacityForAnonCache() throws Exception {
+    LruCacheProvider provider = new LruCacheProvider(10);
+    assertEquals(10, getCache(provider, null).capacity);
+  }
+
+  LruCacheProvider createProvider(final String name, final String capacity, 
int defaultCapacity) {
+    Module module = new AbstractModule() {
+      @Override
+      public void configure() {
+        binder().bindConstant()
+            .annotatedWith(Names.named("shindig.cache.lru." + name + 
".capacity"))
+            .to(capacity);
+      }
+    };
+
+    Injector injector = Guice.createInjector(module);
+
+    return new LruCacheProvider(injector, defaultCapacity);
+  }
+
+  @Test
+  public void configuredMultipleCalls() throws Exception {
+    LruCacheProvider provider = createProvider("foo", "100", 10);
+    assertSame(getCache(provider, "foo"), getCache(provider, "foo"));
+  }
+
+  @Test
+  public void configuredCapacity() throws Exception {
+    LruCacheProvider provider = createProvider("foo", "100", 10);
+    assertEquals(100, getCache(provider, "foo").capacity);
+  }
+
+  @Test
+  public void missingConfiguredCapacity() throws Exception {
+    LruCacheProvider provider = createProvider("foo", "100", 10);
+    assertEquals(10, getCache(provider, "bar").capacity);
+  }
+
+  @Test
+  public void malformedConfiguredCapacity() throws Exception {
+    LruCacheProvider provider = createProvider("foo", "adfdf", 10);
+    assertEquals(10, getCache(provider, "foo").capacity);
+  }
+
+}

Modified: 
incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/common/cache/ehcache/EhCacheCacheProviderTest.java
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/common/cache/ehcache/EhCacheCacheProviderTest.java?rev=712482&r1=712481&r2=712482&view=diff
==============================================================================
--- 
incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/common/cache/ehcache/EhCacheCacheProviderTest.java
 (original)
+++ 
incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/common/cache/ehcache/EhCacheCacheProviderTest.java
 Sun Nov  9 02:52:26 2008
@@ -21,9 +21,6 @@
 import org.apache.shindig.common.cache.Cache;
 import org.apache.shindig.common.cache.CacheProvider;
 
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -33,9 +30,9 @@
 public class EhCacheCacheProviderTest {
 
   @Test
-  public void getAnonCache() {
+  public void getAnonCache() throws Exception {
     CacheProvider defaultProvider = new EhCacheCacheProvider(
-        "/org/apache/shindig/common/cache/ehcache/ehcacheConfig.xml", true);
+        "res://org/apache/shindig/common/cache/ehcache/ehcacheConfig.xml", 
true);
     Cache<String, String> cache = defaultProvider.createCache(null);
     Assert.assertNotNull(cache);
     Assert.assertNull(cache.getElement("test"));
@@ -47,9 +44,9 @@
   }
 
   @Test
-  public void getNamedCache() {
+  public void getNamedCache() throws Exception {
     CacheProvider defaultProvider = new EhCacheCacheProvider(
-        "/org/apache/shindig/common/cache/ehcache/ehcacheConfig.xml", true);
+        "res://org/apache/shindig/common/cache/ehcache/ehcacheConfig.xml", 
true);
     Cache<String, String> cache = defaultProvider.createCache("testcache");
     Cache<String, String> cache2 = defaultProvider.createCache("testcache");
     Assert.assertNotNull(cache);
@@ -59,20 +56,5 @@
     Assert.assertEquals(cache.getElement("test"), "value1");
     cache.removeElement("test");
     Assert.assertNull(cache.getElement("test"));
-  }  
-
-  @Test
-  public void testGuiceModule() {
-    Injector i = Guice.createInjector(new EhCacheModule());
-    CacheProvider cacheProvider = i.getInstance(CacheProvider.class);
-    Cache<String, String> cache = cacheProvider.createCache("testcache");
-    Cache<String, String> cache2 = cacheProvider.createCache("testcache");
-    Assert.assertNotNull(cache);
-    Assert.assertEquals(cache, cache2);
-    Assert.assertNull(cache.getElement("test"));
-    cache.addElement("test", "value1");
-    Assert.assertEquals(cache.getElement("test"), "value1");
-    cache.removeElement("test");
-    Assert.assertNull(cache.getElement("test"));
   }
 }

Modified: 
incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/DefaultGadgetSpecFactory.java
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/DefaultGadgetSpecFactory.java?rev=712482&r1=712481&r2=712482&view=diff
==============================================================================
--- 
incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/DefaultGadgetSpecFactory.java
 (original)
+++ 
incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/DefaultGadgetSpecFactory.java
 Sun Nov  9 02:52:26 2008
@@ -49,16 +49,16 @@
 
   private final HttpFetcher fetcher;
   private final SoftExpiringCache<Uri, GadgetSpec> cache;
-  private final long expiration;
+  private final long refresh;
 
   @Inject
   public DefaultGadgetSpecFactory(HttpFetcher fetcher,
                                   CacheProvider cacheProvider,
-                                  @Named("shindig.cache.expirationMs") long 
expiration) {
+                                  @Named("shindig.cache.xml.refreshInterval") 
long refresh) {
     this.fetcher = fetcher;
     Cache<Uri, GadgetSpec> baseCache = cacheProvider.createCache(CACHE_NAME);
     this.cache = new SoftExpiringCache<Uri, GadgetSpec>(baseCache);
-    this.expiration = expiration;
+    this.refresh = refresh;
   }
 
   public GadgetSpec getGadgetSpec(GadgetContext context) throws 
GadgetException {
@@ -98,7 +98,7 @@
           spec.setAttribute(ERROR_KEY, e);
         }
         LOG.info("GadgetSpec fetch failed for " + uri + " - using cached.");
-        cache.addElement(uri, spec, expiration);
+        cache.addElement(uri, spec, refresh);
       }
     } else {
       spec = cached.obj;
@@ -119,7 +119,7 @@
     HttpRequest request = new HttpRequest(url).setIgnoreCache(ignoreCache);
     // Since we don't allow any variance in cache time, we should just force 
the cache time
     // globally. This ensures propagation to shared caches when this is set.
-    request.setCacheTtl((int) (expiration / 1000));
+    request.setCacheTtl((int) (refresh / 1000));
 
     HttpResponse response = fetcher.fetch(request);
     if (response.getHttpStatusCode() != HttpResponse.SC_OK) {
@@ -129,7 +129,7 @@
     }
 
     GadgetSpec spec = new GadgetSpec(url, response.getResponseAsString());
-    cache.addElement(url, spec, expiration);
+    cache.addElement(url, spec, refresh);
     return spec;
   }
 }

Modified: 
incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/DefaultMessageBundleFactory.java
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/DefaultMessageBundleFactory.java?rev=712482&r1=712481&r2=712482&view=diff
==============================================================================
--- 
incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/DefaultMessageBundleFactory.java
 (original)
+++ 
incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/DefaultMessageBundleFactory.java
 Sun Nov  9 02:52:26 2008
@@ -43,16 +43,16 @@
   static final Logger LOG = 
Logger.getLogger(DefaultMessageBundleFactory.class.getName());
   private final HttpFetcher fetcher;
   private final SoftExpiringCache<Uri, MessageBundle> cache;
-  private final long expiration;
+  private final long refresh;
 
   @Inject
   public DefaultMessageBundleFactory(HttpFetcher fetcher,
                                      CacheProvider cacheProvider,
-                                     @Named("shindig.cache.expirationMs") long 
expiration) {
+                                     
@Named("shindig.cache.xml.refreshInterval") long refresh) {
     this.fetcher = fetcher;
     Cache<Uri, MessageBundle> baseCache = 
cacheProvider.createCache(CACHE_NAME);
     this.cache = new SoftExpiringCache<Uri, MessageBundle>(baseCache);
-    this.expiration = expiration;
+    this.refresh = refresh;
   }
 
   @Override
@@ -79,7 +79,7 @@
           bundle = MessageBundle.EMPTY;
         }
         LOG.info("MessageBundle fetch failed for " + uri + " - using cached.");
-        cache.addElement(uri, bundle, expiration);
+        cache.addElement(uri, bundle, refresh);
       }
     } else {
       bundle = cached.obj;
@@ -94,7 +94,7 @@
     HttpRequest request = new HttpRequest(url).setIgnoreCache(ignoreCache);
     // Since we don't allow any variance in cache time, we should just force 
the cache time
     // globally. This ensures propagation to shared caches when this is set.
-    request.setCacheTtl((int) (expiration / 1000));
+    request.setCacheTtl((int) (refresh / 1000));
 
     HttpResponse response = fetcher.fetch(request);
     if (response.getHttpStatusCode() != HttpResponse.SC_OK) {
@@ -104,7 +104,7 @@
     }
 
     MessageBundle bundle  = new MessageBundle(locale, 
response.getResponseAsString());
-    cache.addElement(url, bundle, expiration);
+    cache.addElement(url, bundle, refresh);
     return bundle;
   }
 }

Modified: 
incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/http/HttpResponse.java
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/http/HttpResponse.java?rev=712482&r1=712481&r2=712482&view=diff
==============================================================================
--- 
incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/http/HttpResponse.java
 (original)
+++ 
incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/http/HttpResponse.java
 Sun Nov  9 02:52:26 2008
@@ -119,10 +119,10 @@
 
   static final String DEFAULT_ENCODING = "UTF-8";
 
-  @Inject @Named("shindig.http.cache.negativeCacheTtl")
+  @Inject @Named("shindig.cache.http.negativeCacheTtl")
   private static long negativeCacheTtl = DEFAULT_NEGATIVE_CACHE_TTL;
 
-  @Inject @Named("shindig.http.cache.defaultTtl")
+  @Inject @Named("shindig.cache.http.defaultTtl")
   private static long defaultTtl = DEFAULT_TTL;
 
   // Holds character sets for fast conversion

Modified: 
incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/http/DefaultHttpCacheTest.java
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/http/DefaultHttpCacheTest.java?rev=712482&r1=712481&r2=712482&view=diff
==============================================================================
--- 
incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/http/DefaultHttpCacheTest.java
 (original)
+++ 
incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/http/DefaultHttpCacheTest.java
 Sun Nov  9 02:52:26 2008
@@ -50,7 +50,7 @@
    * gets the cache provider to use for the set of tests
    * @return default cache provider
    */
-  protected CacheProvider getCacheProvider() {
+  protected CacheProvider getCacheProvider() throws Exception {
     return new LruCacheProvider(5);
   }
 

Modified: 
incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/http/EhCacheBackedDefaultHttpCacheTest.java
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/http/EhCacheBackedDefaultHttpCacheTest.java?rev=712482&r1=712481&r2=712482&view=diff
==============================================================================
--- 
incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/http/EhCacheBackedDefaultHttpCacheTest.java
 (original)
+++ 
incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/http/EhCacheBackedDefaultHttpCacheTest.java
 Sun Nov  9 02:52:26 2008
@@ -26,8 +26,8 @@
  */
 public class EhCacheBackedDefaultHttpCacheTest extends DefaultHttpCacheTest {
   @Override
-  protected CacheProvider getCacheProvider() {
+  protected CacheProvider getCacheProvider() throws Exception {
     return new EhCacheCacheProvider(
-        "/org/apache/shindig/common/cache/ehcache/ehcacheConfig.xml", true);
+        "res://org/apache/shindig/common/cache/ehcache/ehcacheConfig.xml", 
true);
   }
 }


Reply via email to