Java Code Examples for org.jboss.resteasy.spi.ResteasyDeployment#setApplicationClass()
The following examples show how to use
org.jboss.resteasy.spi.ResteasyDeployment#setApplicationClass() .
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: 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 2
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; }
Example 3
Source File: UndertowAppServer.java From keycloak with Apache License 2.0 | 4 votes |
@Override public ProtocolMetaData deploy(Archive<?> archive) throws DeploymentException { log.info("Deploying archive " + archive.getName()); // Remove jsps String ioTMPDir = System.getProperty("java.io.tmpdir", ""); // My Intellij and Terminal stores tmp directory in this property if (!ioTMPDir.isEmpty()) { ioTMPDir = ioTMPDir.endsWith("/") ? ioTMPDir : ioTMPDir + "/"; File tmpUndertowJSPDirectory = new File(ioTMPDir + "org/apache/jsp"); if (tmpUndertowJSPDirectory.exists()) { try { FileUtils.deleteDirectory(tmpUndertowJSPDirectory); } catch (IOException e) { e.printStackTrace(); } } } DeploymentInfo di; if (archive instanceof UndertowWebArchive) { di = ((UndertowWebArchive) archive).getDeploymentInfo(); } else if (archive instanceof WebArchive) { WebArchive webArchive = (WebArchive)archive; Optional<Node> applicationClassNode = archive.getContent(archivePath -> archivePath.get().startsWith("/WEB-INF/classes/") && archivePath.get().endsWith("Application.class")) .values().stream().findFirst(); if (isJaxrsApp(webArchive)) { di = new UndertowDeployerHelper().getDeploymentInfo(configuration, webArchive, undertow.undertowDeployment(discoverPathAnnotatedClasses(webArchive))); } else if (applicationClassNode.isPresent()) { String applicationPath = applicationClassNode.get().getPath().get(); ResteasyDeployment deployment = new ResteasyDeployment(); deployment.setApplicationClass(extractClassName(applicationPath)); di = new UndertowDeployerHelper().getDeploymentInfo(configuration, (WebArchive) archive, undertow.undertowDeployment(deployment)); } else { di = new UndertowDeployerHelper().getDeploymentInfo(configuration, webArchive); } } else { throw new IllegalArgumentException("UndertowContainer only supports UndertowWebArchive or WebArchive."); } if ("ROOT.war".equals(archive.getName())) { di.setContextPath("/"); } ClassLoader parentCl = Thread.currentThread().getContextClassLoader(); UndertowWarClassLoader classLoader = new UndertowWarClassLoader(parentCl, archive); Thread.currentThread().setContextClassLoader(classLoader); try { undertow.deploy(di); } finally { Thread.currentThread().setContextClassLoader(parentCl); } deployedArchivesToContextPath.put(archive.getName(), di.getContextPath()); return new ProtocolMetaData().addContext( createHttpContextForDeploymentInfo(di)); }