Take a look at this test. It runs successfully. Is it very different
from how you do your code?
class MyClass{
Date date;
@Inject
public MyClass(@Named("date") Date dt){
this.date = dt;
}
}
class DateTypeConverter implements TypeConverter{
public Object convert(String value, TypeLiteral<?> toType) {
return new Date();
}
}
public class SimpleTest extends TestCase {
class MyModule extends AbstractModule{
@Override
protected void configure() {
Map<String, String> map = new HashMap<String, String>();
map.put("date","something");
Names.bindProperties(binder(), map);
bind(MyClass.class);
convertToTypes(Matchers.only(TypeLiteral.get(Date.class)), new
DateTypeConverter());
}
}
public void test(){
Injector injector = Guice.createInjector(new MyModule());
MyClass aClass = injector.getInstance(MyClass.class);
}
}
--
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.