is bind(MyConcreteClass.class); the same as
@Provides
MyConcreteClass provideMyConcreteClass(){
...
}
?
For more information:
http://code.google.com/p/google-guice/wiki/UntargettedBindings
is {{{bind(MyConcreteClass?.class);}}} the same as
{{{
@Provides MyConcreteClass? provideMyConcreteClass(){ ... }
No.
An untargetted binding simply tells the injector that whenever an instance
of MyConcreteClass is requested it should create one and inject it. Whereas
the provides method tells the injector that this method should be invoked
whenever an instance of MyConcreteClass is requested and use the returned
value to inject.
The key difference is that the instance will be created by Guice in one
case and by your code in the other. There are a few things that will only
work for instance created by Guice - AOP method interception being the main
one.
In general I'd recommend that you only use provider methods when you've got
non-trivial logic required to create the instance. Usually this means that
you'll have a non-zero number of parameters to the provider method that
you'd use to create the instance.