Hi!

I spent some time wondering if it is possible to write a guice module
which itself is parametrized with type T and uses
its type parameter to specify bindings.

Like in this (not working) example:

<code>
    interface A<T> {}
    class AImpl<T> implements A<T>{}
    interface B<T> {}
    class BImpl<T> implements B<T> {}

    class MyModule<T> extends AbstractModule {
        @Override
        protected void configure() {
            bind(new TypeLiteral<A<T>>(){}).to(new
TypeLiteral<AImpl<T>>(){});
            bind(new TypeLiteral<B<T>>(){}).to(new
TypeLiteral<BImpl<T>>(){});
        }
    }
</code>

I tried different approaches passing trying to pass T as instance of
Class/TypeLiteral but none of them worked.
Help appreciated.

Regards, Łukasz Osipiuk

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