GuiceServletContextListener.getInjector should have one param: servletContext

145 views
Skip to first unread message

Rex Sheng

unread,
Feb 26, 2009, 10:06:30 AM2/26/09
to google-guice
Hi, Dhanji,

How getInjector() get to know about the servletContext, when sometime
we measure relative paths at that point?

So, in my projects, I replaced it with getInjector(ServletContext sc).

Is this right?

Thanks,

Rex

Dhanji R. Prasanna

unread,
Feb 26, 2009, 5:40:30 PM2/26/09
to google...@googlegroups.com
Hmm.. The ServletContext is accessible from @Inject anywhere--does this solve your problem? Or do you require it inside the module?

Dhanji.

Rex Sheng

unread,
Feb 26, 2009, 9:21:28 PM2/26/09
to google-guice
Yes, modules. My widget module should init with servletContextPath.
Sure, I can get it by using @Providers mechanism or so. But it's not
clear to the module: 'when the sc is provided', or 'what if the sc is
null by that time?'

Rex

Dhanji R. Prasanna

unread,
Feb 27, 2009, 1:59:27 AM2/27/09
to google...@googlegroups.com
Hmm, yea you're right. Well you can just override contextInitialized() instead, this is what calls getInjector().

Gian Marco Gherardi

unread,
Jan 29, 2011, 1:42:35 PM1/29/11
to google...@googlegroups.com
+1 for having ServletContext or ServletContextEvent as a parameter to GuiceServletContextListener.getInjector()

Gian Marco Gherardi

unread,
Feb 16, 2011, 11:06:30 AM2/16/11
to google-guice
I've created a Guice issue for this

http://code.google.com/p/google-guice/issues/detail?id=603

On Jan 29, 7:42 pm, Gian Marco Gherardi <gianmarco.ghera...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages