Thanks so much for the reply. Hmmm, this is starting to seem like DI
for its own sake. For now I'll pass through this dependency manually,
and I'll revisit this if that approach gets to be a hassle. Maybe I do
ultimately want a custom scope.
A
On Dec 3, 2:08 pm, "Dhanji R. Prasanna" <[EMAIL PROTECTED]> wrote:
> On Thu, Dec 4, 2008 at 9:07 AM, Dhanji R. Prasanna <[EMAIL PROTECTED]> wrote:
>
> > So you have 2 caching levels (cache, request)? I recommend making a
> > request-scoped container object, inject that instead. then that can
> > look up the cache and store it in a map locally if needed:
>
> > @RequestScoped
> > public class MyCache {
> > private final Map<Class<Widget>, Widget> cache = new ...;
>
> > @Inject Cache mainCache; //the main cache
>
> > public Widget getFromCacheOrMakeNew(Class<Widget> cl) {
> > if (cache.containsKey(cl)) return cache.get(cl);
>
> > Widget w = cache.get(cl);
> > mainCache.put(cl, w);
>
> woops, this should be:
>
> Widget = mainCache.get(c);
> cache.put(cl, w);
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/google-guice?hl=en
-~----------~----~----~----~------~----~------~--~---