forked from janbodnar/Java-Advanced
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContextEx.java
More file actions
33 lines (25 loc) · 1.23 KB
/
ContextEx.java
File metadata and controls
33 lines (25 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package com.zetcode;
import com.zetcode.conf.AppConfig;
import io.undertow.Undertow;
import io.undertow.servlet.Servlets;
import io.undertow.servlet.api.DeploymentInfo;
import org.jboss.resteasy.core.ResteasyDeploymentImpl;
import org.jboss.resteasy.plugins.server.undertow.UndertowJaxrsServer;
import org.jboss.resteasy.spi.ResteasyDeployment;
import org.jboss.weld.environment.servlet.Listener;
public class ContextEx {
public static void main(String[] args) {
var server = new UndertowJaxrsServer();
Undertow.Builder serverBuilder = Undertow.builder().addHttpListener(8080, "0.0.0.0");
ResteasyDeployment deployment = new ResteasyDeploymentImpl();
DeploymentInfo deploymentInfo = server.undertowDeployment(deployment, "/");
deployment.setApplicationClass(AppConfig.class.getName());
deployment.setInjectorFactoryClass("org.jboss.resteasy.cdi.CdiInjectorFactory");
deploymentInfo.setClassLoader(ContextEx.class.getClassLoader());
deploymentInfo.setDeploymentName("My Application");
deploymentInfo.setContextPath("/api");
deploymentInfo.addListeners(Servlets.listener(Listener.class));
server.deploy(deploymentInfo);
server.start(serverBuilder);
}
}