Thanks very much, but could someone help me by fixing the following code (I 
hope the intention is clear):

    private void bindList(Binder pBinder) {
        final List<?> list = new ArrayList<Object>();
        final Provider<O extends List> provider = new Provider<O>(){
            public O get() {
                return list;
            }
        };
        pBinder.bind(List.class).toProvider((com.google.inject.Provider<? 
extends List>) provider);
    }

Additionally, is it possible to have something like

        private <O> void bind(Binder pBinder, Class<O> pInterfaceClass, O 
pImplementation) {
             // ?
        };

Jochen




On Friday, January 10, 2014 1:46:15 PM UTC+1, Stuart McCulloch wrote:
>
> On 10 Jan 2014, at 11:58, Fred Faber <[email protected] <javascript:>> 
> wrote: 
>
> > binder.bind(IFoo.class).toProvider<
> https://google-guice.googlecode.com/git/javadoc/com/google/inject/binder/LinkedBindingBuilder.html#toProvider(com.google.inject.Provider<?
>  
>
> > extends T>)>(myProvider) does this. 
>
> and if you have existing javax.inject.Provider instances you can use 
> Providers.guicify(myStandardProvider) to convert them to 
> com.google.inject.Provider 
>
>         
> http://google-guice.googlecode.com/git/javadoc/com/google/inject/util/Providers.html
>  
>
>         bind( IFoo.class ).toProvider( Providers.guicify( 
> myStandardProvider ) ); 
>
> > On Fri, Jan 10, 2014 at 4:50 AM, Jochen Wiedmann 
> > <[email protected] <javascript:>>wrote: 
> > 
> >> 
> >> Hi, 
> >> 
> >> I am currently converting an existing application to Guice. To simplify 
> >> the migartion, I'd like to do somehing like 
> >> 
> >> 
> >>    Foo someInstance; 
> >>    Provider<Foo> myProvider = new Provider<Foo>(){ 
> >>        Foo get() { return someInstance; } 
> >>    } 
> >> 
> >>    binder.bind(IFoo.class).toProviderInstance(myProvider); 
> >> 
> >> Is that possible? 
> >> 
> >> Thanks, 
> >> 
> >> Jochen 
> >> 
> >> 
> >> 
> >> -- 
> >> You received this message because you are subscribed to the Google 
> Groups 
> >> "google-guice" group. 
> >> To unsubscribe from this group and stop receiving emails from it, send 
> an 
> >> email to [email protected] <javascript:>. 
> >> To post to this group, send email to 
> >> [email protected]<javascript:>. 
>
> >> Visit this group at http://groups.google.com/group/google-guice. 
> >> For more options, visit https://groups.google.com/groups/opt_out. 
> >> 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups "google-guice" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to [email protected] <javascript:>. 
> > To post to this group, send email to 
> > [email protected]<javascript:>. 
>
> > Visit this group at http://groups.google.com/group/google-guice. 
> > For more options, visit https://groups.google.com/groups/opt_out. 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to