Hi all,
I'm just starting to use scopes, and I'm wondering how to do this:

I have an object which can sometimes be cached. I want to consult the
cache and/or create a new object and then put that in the request
scope for DI. So I have something like this

    public void doGet(HttpServletRequest request, HttpServletResponse
response)
            throws ServletException {
        Widget widget = getFromCacheOrMakeNew(request);

        //now bind this widget instance to request scope...


I naively tried this kind of thing:

        ServletScopes.REQUEST.scope(Key.get(Widget.class), new
Provider<Widget>(){
            public Widget get() {
                return widget;
            }
        });

But guice is still looking for a constructor for Widget. Any guidance
here? I think that really what's going on is that Widget lives in a
custom scope, but I'd like to avoid implementing one if possible.

TIA,
A
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to