@Override protected HttpRequest createHttpRequest(String httpMethod, HttpServletRequest httpServletRequest, ResteasyHttpHeaders httpHeaders, ResteasyUriInfo uriInfo, HttpResponse httpResponse, HttpServletResponse httpServletResponse) { Servlet3AsyncHttpRequest request = new Servlet3AsyncHttpRequest(httpServletRequest, httpServletResponse, getServletContext(), httpResponse, httpHeaders, uriInfo, httpMethod.toUpperCase(), (SynchronousDispatcher) getDispatcher()); request.asyncScheduler = asyncCancelScheduler; return request; }
private static void startServerIfRequired() { if (server != null && server.isStarted()) { return; } server = new Server(0); ServletContextHandler context = new ServletContextHandler(ServletContextHandler.NO_SESSIONS); context.setContextPath("/"); ServletHolder holder = new ServletHolder(new HttpServlet30Dispatcher()); holder.setInitParameter("javax.ws.rs.Application", MockResourcesApplication.class.getCanonicalName()); context.addServlet(holder, "/*"); server.setHandler(context); server.setStopAtShutdown(true); try { server.start(); } catch (Exception e) { throw new RuntimeException(e); } }
@Override protected HttpResponse createServletResponse(HttpServletResponse response) { return new HttpServletResponseWrapper(response, getDispatcher().getProviderFactory()) { @Override public void addNewCookie(NewCookie cookie) { outputHeaders.add(javax.ws.rs.core.HttpHeaders.SET_COOKIE, cookie); } }; } }
@Bean @ConditionalOnMissingBean(name = "resteasyServletRegistration") @ConditionalOnProperty(prefix = "holon.resteasy", name = "type", havingValue = "servlet", matchIfMissing = true) public ServletRegistrationBean<Servlet> resteasyServletRegistration() { final Servlet servlet = new HttpServlet30Dispatcher(); final ServletRegistrationBean<Servlet> registration = new ServletRegistrationBean<>(servlet, this.path); registration.setName(getServletRegistrationName()); registration.setLoadOnStartup(this.resteasy.getServlet().getLoadOnStartup()); registration.setAsyncSupported(true); if (this.path != null && !"/*".equals(this.path)) { String prefix = path; if (prefix.endsWith("*")) { prefix = prefix.substring(0, prefix.length() - 1); } if (prefix.endsWith("/")) { prefix = prefix.substring(0, prefix.length() - 1); } registration.addInitParameter(ResteasyContextParameters.RESTEASY_SERVLET_MAPPING_PREFIX, prefix); } return registration; }
@Override protected HttpResponse createServletResponse(HttpServletResponse response) { return new HttpServletResponseWrapper(response, getDispatcher().getProviderFactory()) { @Override public void addNewCookie(NewCookie cookie) { outputHeaders.add(javax.ws.rs.core.HttpHeaders.SET_COOKIE, cookie); } }; } }
@Bean ServletRegistrationBean keycloakJaxRsApplication(KeycloakServerProperties keycloakServerProperties, DataSource dataSource) throws Exception { mockJndiEnvironment(dataSource); //FIXME: hack to propagate Spring Boot Properties to Keycloak Application EmbeddedKeycloakApplication.keycloakServerProperties = keycloakServerProperties; ServletRegistrationBean servlet = new ServletRegistrationBean(new HttpServlet30Dispatcher()); servlet.addInitParameter("javax.ws.rs.Application", EmbeddedKeycloakApplication.class.getName()); servlet.addInitParameter(ResteasyContextParameters.RESTEASY_SERVLET_MAPPING_PREFIX, keycloakServerProperties.getContextPath()); servlet.addInitParameter(ResteasyContextParameters.RESTEASY_USE_CONTAINER_FORM_PARAMS, "true"); servlet.addUrlMappings(keycloakServerProperties.getContextPath() + "/*"); servlet.setLoadOnStartup(1); servlet.setAsyncSupported(true); return servlet; }
@Override protected HttpRequest createHttpRequest(String httpMethod, HttpServletRequest httpServletRequest, ResteasyHttpHeaders httpHeaders, ResteasyUriInfo uriInfo, HttpResponse httpResponse, HttpServletResponse httpServletResponse) { Servlet3AsyncHttpRequest request = new Servlet3AsyncHttpRequest(httpServletRequest, httpServletResponse, getServletContext(), httpResponse, httpHeaders, uriInfo, httpMethod.toUpperCase(), (SynchronousDispatcher) getDispatcher()); request.asyncScheduler = asyncCancelScheduler; return request; }
@Override protected HttpResponse createServletResponse(HttpServletResponse response) { return new HttpServletResponseWrapper(response, getDispatcher().getProviderFactory()) { @Override public void addNewCookie(NewCookie cookie) { outputHeaders.add(javax.ws.rs.core.HttpHeaders.SET_COOKIE, cookie); } }; } }
public ServletRegistrationBean build(String applicationClassName, String path, Set<Class<?>> resources, Set<Class<?>> providers) { Servlet servlet = new HttpServlet30Dispatcher();
@Override protected HttpRequest createHttpRequest(String httpMethod, HttpServletRequest httpServletRequest, ResteasyHttpHeaders httpHeaders, ResteasyUriInfo uriInfo, HttpResponse httpResponse, HttpServletResponse httpServletResponse) { Servlet3AsyncHttpRequest request = new Servlet3AsyncHttpRequest(httpServletRequest, httpServletResponse, getServletContext(), httpResponse, httpHeaders, uriInfo, httpMethod.toUpperCase(), (SynchronousDispatcher) getDispatcher()); request.asyncScheduler = asyncCancelScheduler; return request; }
@Override protected HttpResponse createServletResponse(HttpServletResponse response) { return new HttpServletResponseWrapper(response, getDispatcher().getProviderFactory()) { @Override public void addNewCookie(NewCookie cookie) { Cookie cook = new Cookie(cookie.getName(), cookie.getValue()); cook.setMaxAge(cookie.getMaxAge()); cook.setVersion(cookie.getVersion()); if (cookie.getDomain() != null) cook.setDomain(cookie.getDomain()); if (cookie.getPath() != null) cook.setPath(cookie.getPath()); cook.setSecure(cookie.isSecure()); if (cookie.getComment() != null) cook.setComment(cookie.getComment()); if (cookie.isHttpOnly()) cook.setHttpOnly(true); this.response.addCookie(cook); } }; } }
public ServletRegistrationBean build(String applicationClassName, String path, Set<Class<?>> resources, Set<Class<?>> providers) { Servlet servlet = new HttpServlet30Dispatcher();
@Override protected HttpRequest createHttpRequest(String httpMethod, HttpServletRequest httpServletRequest, ResteasyHttpHeaders httpHeaders, ResteasyUriInfo uriInfo, HttpResponse httpResponse, HttpServletResponse httpServletResponse) { Servlet3AsyncHttpRequest request = new Servlet3AsyncHttpRequest(httpServletRequest, httpServletResponse, getServletContext(), httpResponse, httpHeaders, uriInfo, httpMethod.toUpperCase(), (SynchronousDispatcher) getDispatcher()); request.asyncScheduler = asyncCancelScheduler; return request; }
public ServletRegistrationBean build(String applicationClassName, String path, Set<Class<?>> resources, Set<Class<?>> providers) { Servlet servlet = new HttpServlet30Dispatcher();
public ServletRegistrationBean build(String applicationClassName, String path, Set<Class<?>> resources, Set<Class<?>> providers) { Servlet servlet = new HttpServlet30Dispatcher();