Yes I think it would be great to have a small complete example containing
best practices for guice integration.
In fact my rest application works fine without shiro. Andit's not so easy to
add shiro and make it work.
First of all I need the ServletContext to construct MyShiroWebModule. Where
do I get it ?
I have used this snippet found on this forum but I'm not sure this is the
best way to achieve that
*********************
public class MyGuiceServletContextListener extends
GuiceServletContextListener {
private ServletContext servletContext;
....other stuff ...
@Override
public void contextInitialized(ServletContextEvent servletContextEvent)
{
servletContext = servletContextEvent.getServletContext();
super.contextInitialized(servletContextEvent);
}
}
*********************
Then, when I add the ShiroWebModule I have to add the following jars :
guice-multibinding
org.apache.common.BeanUtils
org.apache.common.Logging
I've not found those dependencies in the doc except for the
org.apache.common.BeanUtils which is normally "only" required if using INI
config. That's not my case.
By the way I'm not sure to understand why guice multibinding is needed
here.
and then when it's added, I get the following warning :
******************************
com.google.inject.servlet.InternalServletModule$BackwardsCompatibleServletContextProvider
get
ATTENTION: You are attempting to use a deprecated API (specifically,
attempting to @Inject ServletContext inside an eagerly created singleton.
While we allow this for backwards compatibility, be warned that this MAY
have unexpected behavior if you have more than one injector (with
ServletModule) running in the same JVM. Please consult the Guice
documentation at http://code.google.com/p/google-guice/wiki/Servlets for
more information.
******************************
I've seen that you have already fixed this issue :
https://issues.apache.org/jira/browse/SHIRO-318
I'm not sure to understand why we do not use the regular way to add a filter
to guice :
filter("/*").through(org.apache.shiro.web.servlet.ShiroFilter.class);
instead of
ShiroWebModule.bindGuiceFilter(binder());
That's why maybe a small example should help.
Thanks in advance for your help.
--
View this message in context:
http://shiro-user.582556.n2.nabble.com/Guice-shiro-jersey-tp6673315p6677020.html
Sent from the Shiro User mailing list archive at Nabble.com.