Java Code Examples for io.undertow.servlet.api.DeploymentInfo#setClassLoader()
The following examples show how to use
io.undertow.servlet.api.DeploymentInfo#setClassLoader() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UndertowAutoConfigurationIT.java From joinfaces with Apache License 2.0 | 6 votes |
@Test void customize() throws IOException { UndertowServletWebServerFactory factory = new UndertowServletWebServerFactory(); this.jsfUndertowFactoryCustomizer.customize(factory); UndertowDeploymentInfoCustomizer undertowDeploymentInfoCustomizer = factory.getDeploymentInfoCustomizers().iterator().next(); DeploymentInfo deploymentInfo = new DeploymentInfo(); deploymentInfo.setClassLoader(this.getClass().getClassLoader()); undertowDeploymentInfoCustomizer.customize(deploymentInfo); assertThat(deploymentInfo.getResourceManager().getResource("testUndertow.txt")) .isNotNull(); }
Example 2
Source File: Demo.java From resteasy-examples with Apache License 2.0 | 6 votes |
public static UndertowJaxrsServer buildServer() { UndertowJaxrsServer server; System.setProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager"); try { LogManager.getLogManager().readConfiguration(Main.class.getClassLoader().getResourceAsStream("logging.jboss.properties")); } catch (IOException e) { e.printStackTrace(); } server = new UndertowJaxrsServer().start(); ResteasyDeployment deployment = new ResteasyDeploymentImpl(); deployment.setApplicationClass(TracingApp.class.getName()); DeploymentInfo di = server.undertowDeployment(deployment); di.setClassLoader(TracingApp.class.getClassLoader()); di.setContextPath(""); di.setDeploymentName("Resteasy"); di.getServlets().get("ResteasyServlet").addInitParam(ResteasyContextParameters.RESTEASY_TRACING_TYPE, ResteasyContextParameters.RESTEASY_TRACING_TYPE_ALL) .addInitParam(ResteasyContextParameters.RESTEASY_TRACING_THRESHOLD, ResteasyContextParameters.RESTEASY_TRACING_LEVEL_VERBOSE); server.deploy(di); return server; }
Example 3
Source File: Main.java From resteasy-examples with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { UndertowJaxrsSpringServer server = new UndertowJaxrsSpringServer(); server.start(); DeploymentInfo deployment = server.undertowDeployment("classpath:resteasy-spring-mvc-servlet.xml", null); deployment.setDeploymentName(Main.class.getName()); deployment.setContextPath("/"); deployment.setClassLoader(Main.class.getClassLoader()); server.deploy(deployment); System.out.println("UNDERTOW SERVER STARTED"); Thread.currentThread().join(); }
Example 4
Source File: UndertowHTTPServerEngine.java From cxf with Apache License 2.0 | 5 votes |
private ServletContext buildServletContext(String contextName) throws ServletException { ServletContainer servletContainer = new ServletContainerImpl(); DeploymentInfo deploymentInfo = new DeploymentInfo(); deploymentInfo.setClassLoader(Thread.currentThread().getContextClassLoader()); deploymentInfo.setDeploymentName("cxf-undertow"); deploymentInfo.setContextPath(contextName); ServletInfo asyncServlet = new ServletInfo(ServletPathMatches.DEFAULT_SERVLET_NAME, CxfUndertowServlet.class); deploymentInfo.addServlet(asyncServlet); servletContainer.addDeployment(deploymentInfo); DeploymentManager deploymentManager = servletContainer.getDeployment(deploymentInfo.getDeploymentName()); deploymentManager.deploy(); deploymentManager.start(); return deploymentManager.getDeployment().getServletContext(); }
Example 5
Source File: UndertowServer.java From pippo with Apache License 2.0 | 5 votes |
protected DeploymentManager createPippoDeploymentManager() { DeploymentInfo info = Servlets.deployment(); info.setDeploymentName("Pippo"); info.setClassLoader(this.getClass().getClassLoader()); info.setContextPath(getSettings().getContextPath()); info.setIgnoreFlush(true); // inject application as context attribute info.addServletContextAttribute(PIPPO_APPLICATION, getApplication()); // add pippo filter addPippoFilter(info); // add initializers info.addListener(new ListenerInfo(PippoServletContextListener.class)); // add listeners listeners.forEach(listener -> info.addListener(new ListenerInfo(listener))); ServletInfo defaultServlet = new ServletInfo("DefaultServlet", DefaultServlet.class); defaultServlet.addMapping("/"); MultipartConfigElement multipartConfig = createMultipartConfigElement(); defaultServlet.setMultipartConfig(multipartConfig); info.addServlets(defaultServlet); DeploymentManager deploymentManager = Servlets.defaultContainer().addDeployment(info); deploymentManager.deploy(); return deploymentManager; }
Example 6
Source File: KeycloakOnUndertow.java From keycloak with Apache License 2.0 | 5 votes |
private DeploymentInfo createAuthServerDeploymentInfo() { ResteasyDeployment deployment = new ResteasyDeployment(); deployment.setApplicationClass(KeycloakApplication.class.getName()); // RESTEASY-2034 deployment.setProperty(ResteasyContextParameters.RESTEASY_DISABLE_HTML_SANITIZER, true); DeploymentInfo di = undertow.undertowDeployment(deployment); di.setClassLoader(getClass().getClassLoader()); di.setContextPath("/auth"); di.setDeploymentName("Keycloak"); if (configuration.getKeycloakConfigPropertyOverridesMap() != null) { try { di.addInitParameter(JsonConfigProviderFactory.SERVER_CONTEXT_CONFIG_PROPERTY_OVERRIDES, JsonSerialization.writeValueAsString(configuration.getKeycloakConfigPropertyOverridesMap())); } catch (IOException ex) { throw new RuntimeException(ex); } } di.setDefaultServletConfig(new DefaultServletConfig(true)); di.addWelcomePage("theme/keycloak/welcome/resources/index.html"); FilterInfo filter = Servlets.filter("SessionFilter", TestKeycloakSessionServletFilter.class); di.addFilter(filter); di.addFilterUrlMapping("SessionFilter", "/*", DispatcherType.REQUEST); filter.setAsyncSupported(true); return di; }