static final int pport = Integer.parseInt(System.getProperty("io.undertow.examples.proxy.PORT", "8000"));
public static void main(final String[] args) {
final Undertow server;
final ModCluster modCluster = ModCluster.builder().build();
try {
if (chost == null) {
// We are going to guess it.
chost = java.net.InetAddress.getLocalHost().getHostName();
System.out.println("Using: " + chost + ":" + cport);
}
modCluster.start();
// Create the proxy and mgmt handler
final HttpHandler proxy = modCluster.getProxyHandler();
final MCMPConfig config = MCMPConfig.webBuilder()
.setManagementHost(chost)
.setManagementPort(cport)
.enableAdvertise()
.getParent()
.build();
final HttpHandler mcmp = config.create(modCluster, proxy);
server = Undertow.builder()
.addHttpListener(cport, chost)
.addHttpListener(pport, phost)
.setHandler(mcmp)
.build();
server.start();
// Start advertising the mcmp handler
modCluster.advertise(config);
} catch (Exception e) {
e.printStackTrace();
}
}