blob: d25f4ae9a37913d4aec9f7eeb547a69cf3d600d1 (
plain) (
blame)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
/*
* generated by Xtext 2.25.0
*/
package org.eclipse.viatra.solver.language.web;
import java.net.InetSocketAddress;
import org.eclipse.jetty.annotations.AnnotationConfiguration;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.log.Slf4jLog;
import org.eclipse.jetty.webapp.Configuration;
import org.eclipse.jetty.webapp.MetaInfConfiguration;
import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.webapp.WebInfConfiguration;
import org.eclipse.jetty.webapp.WebXmlConfiguration;
/**
* This program starts an HTTP server for testing the web integration of your DSL.
* Just execute it and point a web browser to http://localhost:8080/
*/
public class ServerLauncher {
public static void main(String[] args) {
Server server = new Server(new InetSocketAddress("localhost", 1313));
WebAppContext ctx = new WebAppContext();
ctx.setResourceBase("src/main/webapp");
ctx.setWelcomeFiles(new String[] {"index.html"});
ctx.setContextPath("/");
ctx.setConfigurations(new Configuration[] {
new AnnotationConfiguration(),
new WebXmlConfiguration(),
new WebInfConfiguration(),
new MetaInfConfiguration()
});
ctx.setAttribute(WebInfConfiguration.CONTAINER_JAR_PATTERN,
".*/org\\.eclipse\\.viatra\\.solver\\.language\\.web/.*,.*\\.jar");
ctx.setInitParameter("org.eclipse.jetty.servlet.Default.useFileMappedBuffer", "false");
server.setHandler(ctx);
Slf4jLog log = new Slf4jLog(ServerLauncher.class.getName());
try {
server.start();
log.info("Server started " + server.getURI() + "...");
new Thread() {
public void run() {
try {
log.info("Press enter to stop the server...");
int key = System.in.read();
if (key != -1) {
server.stop();
} else {
log.warn(
"Console input is not available. In order to stop the server, you need to cancel process manually.");
}
} catch (Exception e) {
log.warn(e);
}
}
}.start();
server.join();
} catch (Exception exception) {
log.warn(exception.getMessage());
System.exit(1);
}
}
}
|