This change is big, and it makes Guice slower. I'll need to follow-up with some optimizations that make TypeResolver quicker.
Suppose you have a parameterized class:
class Foo<T> {
@Inject Set<T> tees;
}
This change makes it so that as long as you have the required dependencies, parameterized injection points will be resolved. For example:
Injector injector = Guice.createInjector(new AbstractModule() {
protected void configure() {
bind(new TypeLiteral<Set<String>>() {})
.toInstance(ImmutableSet.of("A", "B", "C"));
}
});
Foo<String> foo = injector.getInstance(new TypeLiteral<Foo<String>>() {});
assertEquals(ImmutableSet.of("A", "B", "C"), foo.tees);
This builds on my earlier work for TypeResolver. That class is currently pretty slow (it builds a ton of HashMaps eagerly), but it shouldn't be too hard to make it lazy - that way everything will work nice and fast if you're not leveraging this feature.
git-svn-id: https://google-guice.googlecode.com/svn/trunk@660 d779f126-a31b-0410-b53b-1d3aecad763e
11 files changed