By using the TypeLiterals you put in the bind(..) statements in the .implement(..) parameters and removing the bind statement, most likely.
sam On Wed, Jul 6, 2011 at 10:17 PM, Alex Luya <[email protected]> wrote: > Yeah,but how to solve this problem? > > > On Thu, Jul 7, 2011 at 9:58 AM, Sam Berlin <[email protected]> wrote: > >> Briefly glancing over it, you probably want to use .implement with >> TypeLiterals, not classes. >> >> sam >> >> On Wed, Jul 6, 2011 at 9:51 PM, Alex Luya <[email protected]>wrote: >> >>> Actually,I am using gin for GWT.Following are my code: >>> >>> --------------------------------------------------------------------------------------------- >>> interface A<M extends Model> >>> { >>> //interface A >>> } >>> >>> ------------------------------------------------------------------------------------------------- >>> class B<M extends Model> implements A<M> >>> { >>> // implementation of A >>> } >>> >>> ------------------------------------------------------------------------------------------------- >>> class MExt extend Model >>> { >>> //this is inheritance of Model >>> } >>> >>> ------------------------------------------------------------------------------------------------- >>> interface Factory<M extends Model,V extends A<M>> >>> { >>> V createA(M model); >>> } >>> >>> ------------------------------------------------------------------------------------------------- >>> public class ClientModule extends AbstractGinModule >>> { >>> @Override >>> protected void configure() >>> { >>> bind(new TypeLiteral<A<MExt >>(){}).to(new TypeLiteral<B<MExt>>(){}); >>> install(new GinFactoryModuleBuilder().implement(A.class, >>> B.class).build(Factory.class)); >>> } >>> } >>> >>> ------------------------------------------------------------------------------------------------- >>> When trying to run,get these errors: >>> >>> ----------------------------------------------------------------------------------------------------- >>> ...... >>> >>> 1)V cannot be used as a key; It is not fully specified. >>> ...... >>> >>> ----------------------------------------------------------------------------------------------------- >>> >>> So I tried to do this:add >>> >>> ----------------------------------------------------------------------------------------------------- >>> interface FactoryExt extend Factory<MExt,A<MExt>>{ >>> .................................................... >>> } >>> >>> ----------------------------------------------------------------------------------------------------- >>> and reconfigure module to >>> >>> ----------------------------------------------------------------------------------------------------- >>> public class ClientModule extends AbstractGinModule >>> { >>> @Override >>> protected void configure() >>> { >>> bind(new TypeLiteral<A<MExt >>(){}).to(new TypeLiteral<B<MExt>>(){}); >>> install(new GinFactoryModuleBuilder().implement(A.class, >>> B.class).build(FactoryExt.class)); >>> } >>> } >>> >>> ----------------------------------------------------------------------------------------------------- >>> get this error: >>> >>> ----------------------------------------------------------------------------------------------------- >>> ...... >>> 1) Could not find a suitable constructor in com.domain.client.ui.A. >>> Classes must have either one (and only one) constructor annotated with >>> @Inject or a zero-argument constructor that is not private. >>> ...... >>> >>> ----------------------------------------------------------------------------------------------------- >>> it seems that guice didn't recognize this clause: >>> ------------------------------------------------- >>> bind(new TypeLiteral<A<MExt >>(){}).to(new TypeLiteral<B<MExt>>(){}); >>> ---------------------------------------------------- >>> >>> So,how can I solve this problem? >>> >>> -- >>> 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. >> > > -- > 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.
