-
Task
-
Resolution: Won't Fix
-
Neutral
-
None
-
None
-
None
-
None
-
-
Empty show more show less
-
Empty show more show less
With MGNLCACHE-55, one can cache arbitrary objects (that was already the case, but the API was awkward, and the cache could not be configured), but one still has to :
public class FooBar { private final Cache cache; @Inject public FooBar(CacheModule cacheModule) { // or keep a ref to module and retrieve the cache when needed this.cache = cacheModule.getCacheFactory().getCache("foo-cache"); } }
It'd be nice if one could do this instead:
public class FooBar { private final Cache cache; @Inject public FooBar(@Named("foo-cache") Cache cache) { this.cache = cache; } }
Another approach (or additional) would let one inject an unnamed Cache, and the name would, by convention, be the class name of the injectee.
package zim.zam; public class FooBar { private final Cache cache; @Inject public FooBar(Cache cache) { assert cache.getName().equals("zim.zam.FooBar"); this.cache = cache; } }
Acceptance criteria
- is related to
-
MGNLCACHE-74 Implement a javax.inject.Provider for CacheFactory
- Closed