Hello,
I've been using the CustomInjections example to do Logger injection as
described on https://github.com/google/guice/wiki/CustomInjections
However when using abstract classes / super classes the fields are not
visible when typeLiteral.getRawType().getDeclaredFields() is called.
This bit me and I changed the code to the following:
Class<?> clazz = typeLiteral.getRawType();
while (clazz != null) {
for (Field field : clazz.getDeclaredFields()) {
if (field.getType() == Logger.class &&
field.isAnnotationPresent(InjectLogger.class)) {
encounter.register(new Log4JMembersInjector<T>(field));
}
}
clazz = clazz.getSuperclass();
}
What do you think about updating the example with the code above? Is this
the correct way of doing it if you have super classes or is it bad
performance wise?
Kind regards
Jonas
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-guice/22d471fc-a59b-45cd-b519-741eb72611d8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.