Bind caches as eager singletons

All H2 caches must be created before the enclosing LifecycleManager
starts, therefore they must be created eagerly. If they are not, it is
possible for an assisted factory to attempt to create the cache for
the first time only when that factory's create() method is called (as
opposed to when the factory is injected).

Change-Id: I058d8783161ffc4274dd78337842ce55c53de183
This commit is contained in:
Dave Borowitz
2013-10-09 12:43:44 -07:00
parent 5e9470a98f
commit 0f62e836d5

View File

@@ -85,7 +85,7 @@ public abstract class CacheModule extends AbstractModule {
CacheProvider<K, V> m =
new CacheProvider<K, V>(this, name, keyType, valType);
bind(key).toProvider(m).in(Scopes.SINGLETON);
bind(key).toProvider(m).asEagerSingleton();
bind(ANY_CACHE).annotatedWith(Exports.named(name)).to(key);
return m.maximumWeight(1024);
}