-
-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add PippoFilter as Guice Filter #369
Comments
I was in a mini vacation. I will try a look and I will come back with a response/solution. |
@kiru |
It's not a problem for me to add a a new |
Hello @decebals I had no time to response quicker. In your example (https://dzone.com/articles/pippo-and-jersey-jax-rs), you get your dependency from the ServletContext
With ServletModule (assuming you would have used Guice ) you might just inject it directly:
But your example is a different one, you use Pippo and add the Jersey Servlet additionally. My use case is, that I have an application with few servlets and want to add the PippoFilter. Is there maybe a PippoServlet, so I can add it directly instead of the Filter (with the Filter, I have another problem, that if Pippo cannot find a routing, then it'll send a 404, but I would like to follow the filter chain instead ). Thank you, |
Thanks for your explanation.
The reason is because I don't use a DI library in that demo and I need to "share" the
See PippoServlet.
I can take a look to see if I can do something in this direction. I use filters from inside (simple routes) of my application. If I need to add external filters I make it via And by the way, related to approach described in http://www.pippo.ro/mod/guice.html. Maybe the code snippet and the explanation are not the best. For example, that section describe only how to use Guice in controllers. When I use plain routes approach (without controllers) with DI (Spring) in my application, I instantiate my Application class via DI and pass it to PippoServer( Pippo is very flexible in my opinion and you can achieve a behavior on several ways. |
Awesome, I have not seen PippoServlet. Actually, that is what I've been searching for. Just added these to my servlet-bindings and it works as expected:
I had to subclass PippoServlet, so I can inject the Application:
I saw that documentation, but it focuses on using Guice to Inject dependencies ( and not using Pippo as a dependency in an existing application ). |
I am glad to see that your problem is resolved so easy 😄
You are right. If you encounter other problems, please let me know. |
I would like to use Pippo with Guice, but not the way described here: http://www.pippo.ro/mod/guice.html
Instead I use the GuiceServlet, Gucie allows to configure all the filters and servlets without the need for web.xm ( expect for GuiceFilter), as described here: https://github.com/google/guice/wiki/ServletModule
I use the ServletModule from Guice and try to add the PippoFilter like this:
Unfortunately I get the following exception:
GuiceFilter looks like this:
I guess Pippo expects a web.xml configuration and reads the properties from web.xml and fails. My workaround for now is to set the "filterPath" string to empty.
Is it possible to fix this properly? Maybe add a protected setter for filterPath so I can set it from the outside.
The text was updated successfully, but these errors were encountered: