Generally I prefer breaking my AbstractModule's into as many @Provides as I 
can.

However, I'm having problems making a dynamical @Provides method (as per 
https://groups.google.com/forum/?fromgroups=#!topic/google-guice/TO_OUo7jjeo ) 
and I'm here resorting to having to use a more programmatic 
AbstractModule.configure() way of defining up front all the various 
possible bindings I might need.

Is there any way my AbstractModule.configure() method can rely on other 
@Provides methods defined in the class? I haven't found any way of doing 
this. this.getProvider(MyDesiredClass.class) throws an exception, I've 
tried using an @Inject'ed private member, which also throws: it seems like 
configure() is the first thing that gets run and one is SOL w/r/t the 
@Providers being able to help it.

Example of desired use:

@Provides
public String provideString(){return "yes";}

@Override
protected void configure(){
  final String input = this.getProvider(String.class).get();
  this.bind(String.class).annotateWith("special").toInstance(input);
}

Fails, but demonstrates use of a @Provides to satisfy my configure(), which 
is what I'd like to do.

Regards,
MF

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-guice/-/ShC2Ee1H_uAJ.
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