When you have GuiceFilter up and running (has been configued in
web.xml), Guice Servlet is set up. And I install an instance of
ServletModule like following:
public class MyGuiceServletConfig extends GuiceServletContextListener
{
@Override
protected Injector getInjector() {
return Guice.createInjector(new ServletModule() {
@Override
protected void configureServlets() {
serve("*.html").with(MyServlet.class);
}
});
}
}
I know that GuiceFilter has controled the creating of MyServlet.class
object and inject object as you like. I want to find how, so I read
the source code of GuiceFilter but can't figure out. This is the core
code of GuiceFilter, I can't find any clue about guice's creation
controlling.
public void doFilter(ServletRequest servletRequest,
ServletResponse servletResponse, FilterChain filterChain)
throws IOException, ServletException {
Context previous = localContext.get();
FilterPipeline filterPipeline = pipeline;
try {
localContext.set(new Context((HttpServletRequest)
servletRequest,
(HttpServletResponse) servletResponse));
//dispatch across the servlet pipeline, ensuring web.xml's
filterchain is honored
filterPipeline.dispatch(servletRequest, servletResponse,
filterChain);
} finally {
localContext.set(previous);
}
}
Does anybody know how GuiceFilter control the creating process of all
the configured servelts and inject as you want? Thank you for your
answer.
--
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.