I am new to Guice and attempting to implement a logging example based
on this tutorial:
http://code.google.com/docreader/#p=google-guice&s=google-guice&t=CustomInjections
I would like to create an abstract base class with some utility
methods that include logging and then have subclasses reuse that
functionality. However, the Logger field in the superclass never gets
injected. Here is a simple example:
public abstract class AbstractServlet {
@InjectLogger Logger logger;
public void test1() {
logger.info("test1");
}
}
public class CustomServlet extends AbstractServlet {
public void test2() {
test1(); // Throws a NullPointerException for logger
}
}
After doing some more debugging it looks like the TypeListener never
gets called for the superclass field. I thought of passing a logger
using constructors, but that seems annoying to do for every class just
to get logging.
Can anyone give me a pointer on how to make this work or suggest a
better design practice?
Thanks,
Chris
--
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=.