Well, I should have RTFM <https://github.com/google/guice/wiki/Scopes> indeed : 
I 
see that the "*in(Scopes.SINGLETON**)*;" are in fact not required once the 
implementation class is bound.

So the final code would be :

@SuppressWarnings({ "unchecked", "rawtypes" })
protected void bindServer() {
    
    bind(getServerClass()).in(Scopes.SINGLETON);
    bind(new TypeLiteral<IServer<?>>(){}).to(getServerClass());
    
    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;
}


-- 
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/38f521ef-341a-4d70-91b3-145e6c6ad53d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to