Wow, that actually works!

My final code, if it can help someone, one day :

@SuppressWarnings({ "unchecked", "rawtypes" })
protected void bindServer() {
    
    bind(getServerClass()).in(Scopes.SINGLETON);
    bind(new TypeLiteral<IServer<?>>(){}).to(getServerClass()).in(Scopes.
SINGLETON);
    
    TypeLiteral<?> serverType = TypeLiteral.get(getServerClass()).
getSupertype(IServer.class);
    Type exchangeType = ((ParameterizedType) serverType.getType()).
getActualTypeArguments()[0];
    Type parameterizedType = Types.newParameterizedType(IServer.class, 
exchangeType);
    TypeLiteral<?> typeLiteral = TypeLiteral.get(parameterizedType);
    bind(typeLiteral).to((Class)getServerClass()); 
}

protected Class<? extends IServer<?>> getServerClass() {
    return UndertowServer.class;
}



Thanks a lot for the help Tavian!

-- 
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 https://groups.google.com/group/google-guice.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-guice/751bc31d-e38e-4d3f-820a-30aeedd6b74a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to