Debian Codegraph @

resteasy-wadl-undertow-connector/src/main/java/org/jboss/resteasy/wadl/WadlUndertowConnector.java

raw
1 package org.jboss.resteasy.wadl;
2
3 import io.undertow.servlet.api.DeploymentInfo;
4 import io.undertow.servlet.api.ServletInfo;
5 import org.jboss.resteasy.plugins.server.servlet.HttpServlet30Dispatcher;
6 import org.jboss.resteasy.plugins.server.undertow.UndertowJaxrsServer;
7 import org.jboss.resteasy.spi.ResteasyDeployment;
8
9 import javax.ws.rs.ApplicationPath;
10 import javax.ws.rs.core.Application;
11
12 import static io.undertow.servlet.Servlets.servlet;
13
14 /**
15 * Created by weli on 7/26/16.
16 */
17 public class WadlUndertowConnector {
18 public UndertowJaxrsServer deployToServer(UndertowJaxrsServer server, Class<? extends Application> application) {
19 ApplicationPath appPath = application.getAnnotation(ApplicationPath.class);
20 String path = "/";
21 if (appPath != null) path = appPath.value();
22
23 return deployToServer(server, application, path);
24 }
25
26 public UndertowJaxrsServer deployToServer(UndertowJaxrsServer server, Class<? extends Application> application, String contextPath) {
27 ResteasyDeployment deployment = new ResteasyDeployment();
28 deployment.setApplicationClass(application.getName());
29
30 DeploymentInfo di = server.undertowDeployment(deployment);
31
32 ServletInfo resteasyWadlServlet = servlet("ResteasyWadlServlet", ResteasyWadlServlet.class)
33 .setAsyncSupported(false)
34 .setLoadOnStartup(1)
35 .addMapping("/application.xml");
36 di.addServlet(resteasyWadlServlet);
37
38 di.setClassLoader(application.getClassLoader());
39 di.setContextPath(contextPath);
40 di.setDeploymentName("Resteasy" + contextPath);
41 return server.deploy(di);
42 }
43 }