I am looking for a single point of interception for Ratpack API based applications. Just like we have Web.xml in our regular Web based applications, does their exists anything in Ratpack API where I can handle or redirect requests to handlers in third party jar?
I fixed the issue myself by developing a common handler and redirecting all incoming request to that handler. So no filters, every thing is handled by handlers in Ratpack.
Related
Hi I am using Spring framework to build REST full web services . I want to log all the incoming request to my service. Is there any way I can log all the incoming request to my web service.
You could use Filter or Interceptor if you need very basic solution. Just inject your service into it, and override "preHandle(HttpServletRequest request..."
Problems will come when you decide that you need to:
log only some requests (E.g. only PUT and POST)
exclude some data (e.g. passwords, keys, etc)
exclude files
parse data to extract information to persist it
know if it return success or failure or exception
Then better solution would be to call that service directly from controllers.
I have a restful web service written using Spring WebMVC that will mostly be used to orchestrate other services. In some cases these services are on the same server, in some cases they are not. I have a few requests (GET and POST) that will be direct pass throughs to another service. Is there a way to blindly forward all GET and POST data from a request for certain URLs without knowing anything about the data in the request?
Ideally, I would like to be able to say all requests for http://server1/myService/user/... should forward to http://server2/user/... with all of the GET and POST parameters forwarded with it.
For the services on the same server, if they're being served by the same Spring MVC application, you could use RedirectViews and/or the "redirect:" prefix.
For those on another server, the best thing I can think of would be to use a servlet filter, similar to the approach suggested by this post: spring mvc redirect path and all children to another domain
My application exposes a RESTful API which when called calls out to a mailbox server and fetches data. I want to be able disable the service during application runtime in the event of some outage on the mailbox server. I wanted to do this in a way that the logic of deciding whether or not to call the mailbox server was abstracted from the actual code that calls the mailbox server. Two options which seem to fit this scenario are filters and interceptors however I'm looking for advice on which one best suits this requirement and what are the difference between each?
Thanks
If you are using Spring MVC then you can use an interceptor, which is like a filter but that has access to the Spring context. If you are using Jersey then you can't use interceptors.
For Requests handling, struts 2 uses FilterDispatcher whereas Spring uses Servlet(dispatcher servlet) for dispatching the requests. What difference does this make? I mean they are doing the same job that is handling the incoming requests but using different strategies, one is using servlet other is using filter dispatcher.
Struts2 and spring mvc are different web frameworks that follow mvc design pattern. The architecture of both differs. Since they are different frameworks, they have different ways of achieving the same thing i.e. request handling. You can read more about FilterDispatcher here.
I've got an OSGi container that hosts several CXF web services at /services/service_a; /services/service_b etc along with a couple of web apps deployed as bundles. I'm trying to SSO enable all the endpoints but am having trouble registering a servlet filter with the Jetty server so I can have Spring Security take over.
Using Pax-web whiteboard I was able to register a filter tied to a simple servlet. However, when I attempted to filter requests at /*, the filter no longer catches the requests. Is it possible to register a filter that will catch all requests either using pax-web or some Jetty-osgi magic?
Not sure it's possible with the http whiteboard.
However you should be able to achieve the same end result using pax-web with Jetty's standard SSO management, by creating a fragment bundle.
Some links:
http://docs.codehaus.org/display/JETTY/Single+Sign+On+-+Jetty+HashSSORealm
http://docs.codehaus.org/display/JETTY/SessionIds
http://team.ops4j.org/wiki/display/paxweb/Advanced+Jetty+Configuration