@Override public void init() throws ServletException { WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext()); this.target = wac.getBean(getServletName(), HttpRequestHandler.class); }
@Bean public ServletRegistrationBean<?> davServlet() { HttpRequestHandlerServlet handler = new HttpRequestHandlerServlet() { @Override public String getServletName() { return DAV_SERVLET_NAME; } }; ServletRegistrationBean<?> bean = new ServletRegistrationBean<>(handler, PATH_DAV); bean.setName(handler.getServletName()); bean.setOrder(0); return bean; }
servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac); Servlet servlet = new HttpRequestHandlerServlet(); servlet.init(new MockServletConfig(servletContext, "myHandler"));
@Override protected void service(@Nonnull HttpServletRequest request, @Nonnull HttpServletResponse response) throws ServletException, IOException { //When a request comes in, we're required to be initialised. If we're not, the only possible reason is that //the application is Johnsoned. That suggests we will not be able to initialise here, but we still try, on //the assumption that this URL was allowed through the Johnson filter and may, therefore, work. If so, the //request will be processed normally. if (uninitialised) { synchronized (lock) { if (uninitialised) { if (!maybeInit()) { //If we can't initialise at this point, redirect to the Johnson error page. The filter should //not have allowed access to this URL. sendRedirect(response); return; } } } } super.service(request, response); }
@Bean public ServletRegistrationBean<?> davServlet() { HttpRequestHandlerServlet handler = new HttpRequestHandlerServlet() { @Override public String getServletName() { return DAV_SERVLET_NAME; } }; ServletRegistrationBean<?> bean = new ServletRegistrationBean<>(handler, PATH_DAV); bean.setName(handler.getServletName()); bean.setOrder(0); return bean; }
@Override public void init() throws ServletException { WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext()); this.target = wac.getBean(getServletName(), HttpRequestHandler.class); }
@Override public void init() throws ServletException { WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext()); this.target = wac.getBean(getServletName(), HttpRequestHandler.class); }
@Override public void init() throws ServletException { WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext()); this.target = wac.getBean(getServletName(), HttpRequestHandler.class); }