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); } }
@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; }
@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; }
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();
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();