I have a unit test with this field (I think this is user error so read
through please)...

    @Inject
    private MockSimpleEditAddGridFactory<EPWFormularyMsg> mockFactory;

If I erase the <EPWFormularyMsg>, the test passes, add back the
generic part and it fails.  I dug into this and it is specifically in
the Guice code

 key = Annotations.getKey(type.getFieldType(field), field,
annotations, errors);

where getFieldType(field) is

  public TypeLiteral<?> getFieldType(Field field) {
    checkArgument(field.getDeclaringClass().isAssignableFrom(rawType),
        "%s is not defined by a supertype of %s", field, type);
    return resolve(field.getGenericType());
  }

So the Key ends up being MockSimpleEditAddGridFactory<EPWFormularyMsg>
not MockSimpleEditAddGridFactory

This means my binding code must be wrong which is...(notice the second
line)....

 
b.bind(SimpleEditAddGridFactory.class).to(MockSimpleEditAddGridFactory.class);
 
b.bind(MockSimpleEditAddGridFactory.class).in(Singleton.class);

so, how do I bind a generic instead????? because Guice is not
injecting the singleton to my field above from that binding unless I
untype the field of course removing the <EPWFormularyMsg>

thanks,
Dean




-- 
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.

Reply via email to