you can try somthing like this:

   @Provides public MyInterface myInterface(Injector injector) {
   return injector.getInstance(MyInterfaceImpl.class);
   }

peace,
surya


On Sun, Dec 11, 2011 at 8:28 AM, <[email protected]> wrote:

>   Today's Topic Summary
>
> Group: http://groups.google.com/group/google-guice/topics
>
>    - Injecting values into a bean provided by 
> @Provides<#1342d4fb07228500_group_thread_0>[2 Updates]
>
>   Injecting values into a bean provided by 
> @Provides<http://groups.google.com/group/google-guice/t/9569151d30139cd3>
>
>    zonski <[email protected]> Dec 10 04:38PM -0800
>
>    If I bind my bean using either of the following:
>
>    bind(MyInterface.class).to(MyInterfaceImpl.class);
>
>    or
>
>    bind(MyInterface.class).toInstance(new MyInterfaceImpl());
>
>    The resulting bean will have all it's fields marked with @Inject
>    automatically injected, just as I'd expect.
>
>    However if I use an @Provides marked method to do exactly the same
>    thing then my fields are not injected:
>
>    // resulting bean is not injected?
>    @Provides public MyInterface myInterface() {
>    return new MyInterfaceImpl();
>    }
>
>    This seems a bit odd for me. I'm guessing this is done to allow
>    developers to control the wiring for their provided classes, but in my
>    case I don't want to control this, I just want to control how the bean
>    gets instantiated (because in my real scenario I actually have to load
>    my bean from an XML file) and have Guice still do all the autowiring.
>
>    Is this really not possible?
>
>
>
>
>    "Willi Schönborn" <[email protected]> Dec 11 01:43AM +0100
>
>    You could inject the Injector into your method and call
>    Injector.injectMembers(bean);
>
>
>
>  You received this message because you are subscribed to the Google Group
> google-guice.
> You can post via email <[email protected]>.
> To unsubscribe from this group, 
> send<[email protected]>an empty message.
> For more options, 
> visit<http://groups.google.com/group/google-guice/topics>this group.
>
> --
> 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.
>

-- 
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