Updates:
Status: Fixed
Comment #4 on issue 171 by limpbizkit:
bind(SomeConcreteType.class).toConstructor()
http://code.google.com/p/google-guice/issues/detail?id=171
Implemented over a series of changes:
r1005 adds SPI access
r1022 implements it
r1023, r1024 r1025: tests, tests, tweaks
We may consider implementing "@New" on top of toConstructor() bindings.
One interesting consequence of toConstructor is the impact on scoping.
Suppose you bind the same type
under two different keys:
@Singleton
class A {}
public class BindSomeAsModule extends AbstractModule {
public void configure() {
bind(A.class).annotatedWith(named("1")).toConstructor(A.class.getDeclaredConstructor());
bind(A.class).annotatedWith(named("2")).toConstructor(A.class.getDeclaredConstructor());
}
}
Ultimately, you'll get two instances of A, one for each binding. It seems
awkward until you consider the fact
that the two bindings could be pointing at distinct constructors, in which
case it would be impossible to use a
single instance.
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"google-guice-dev" 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-dev?hl=en
-~----------~----~----~----~------~----~------~--~---