Vaadin 8: how to intercept every call?

Hello,

regarding to ticket

https://vaadin.com/forum/#!/thread/2742856

it was very difficult to catch all the calls in Vaadin 7. I made a working but dirty implementation and it’s not working for the push mechanism. I found no way to manipulate the push servlet in any way - in consequence I can’t use it.

In Vaadin 6 it was very easy to intercept code before and after every http request via event. Did you implement the feature again? Is there some ‘policy’ against it?

The usecase is very simple and important. I need to initialize the running thread with the actual user context.

Thanks for Help,
Mike

Hi Mike,

Is there some reason that simply adding a VaadinRequestHandler, as noted in the thread, does not suffice? Not exactly sure at which point you need to get access to the application for the initialization part.

But just in case, some other options would be to add a SessionInitListener and set that information into the session?
https://vaadin.com/docs/framework/application/application-lifecycle.html

Another option would maybe be to extend the VaadinServlet class and override the service method to get access to all of the servlet requests, but then you would have to keep track of them yourself.

  @WebServlet(urlPatterns = "/*", name = "MyUIServlet", asyncSupported = true)
    @VaadinServletConfiguration(ui = MyUI.class, productionMode = false)
    public static class MyUIServlet extends VaadinServlet {
        @Override
        protected void service(HttpServletRequest request,
                HttpServletResponse response)
                throws ServletException, IOException {
            super.service(request, response);
        }
    }

Currently I’m using this way. But it’s not working for push mechanism. Its using another servlet.