-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
115 lines (104 loc) · 3.85 KB
/
Main.java
File metadata and controls
115 lines (104 loc) · 3.85 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
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package monto.service.java8;
import java.util.ArrayList;
import java.util.List;
import monto.service.MontoService;
import monto.service.ZMQConfiguration;
import monto.service.resources.ResourceServer;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.Options;
import org.zeromq.ZContext;
public class Main {
private static ResourceServer resourceServer;
public static void main(String[] args) throws Exception {
ZContext context = new ZContext(1);
List<MontoService> services = new ArrayList<>();
Runtime.getRuntime()
.addShutdownHook(
new Thread() {
@Override
public void run() {
System.out.println("terminating...");
try {
for (MontoService service : services) {
service.stop();
}
resourceServer.stop();
} catch (Exception e) {
e.printStackTrace();
}
context.destroy();
System.out.println("everything terminated, good bye");
}
});
Options options = new Options();
options
.addOption("highlighter", false, "enable Java syntax highlighter")
.addOption("antlrparser", false, "enable Java ANTLR parser")
.addOption("javaccparser", false, "enable JavaCC parser")
.addOption("outliner", false, "enable Java outliner")
.addOption("identifierfinder", false, "enable Java identifier finder")
.addOption("codecompletioner", false, "enable Java code completioner")
.addOption("runner", false, "enable Java runtime service")
.addOption("debugger", false, "enable Java debugger service")
.addOption("logicalnameextractor", false, "enable logical name extractor")
.addOption("address", true, "address of services")
.addOption("registration", true, "address of broker registration")
.addOption("resources", true, "port for http resource server")
.addOption("debug", false, "enable debugging output");
CommandLineParser parser = new DefaultParser();
CommandLine cmd = parser.parse(options, args);
ZMQConfiguration zmqConfig =
new ZMQConfiguration(
context,
cmd.getOptionValue("address"),
cmd.getOptionValue("registration"),
Integer.parseInt(cmd.getOptionValue("resources")));
resourceServer =
new ResourceServer(
Main.class.getResource("/icons").toExternalForm(), zmqConfig.getResourcePort());
try {
resourceServer.start();
} catch (Exception e) {
e.printStackTrace();
}
if (cmd.hasOption("highlighter")) {
services.add(new JavaHighlighter(zmqConfig));
}
if (cmd.hasOption("javaccparser")) {
services.add(new JavaJavaCCParser(zmqConfig));
}
if (cmd.hasOption("antlrparser")) {
services.add(new ANTLRJavaParser(zmqConfig));
}
if (cmd.hasOption("outliner")) {
services.add(new JavaOutliner(zmqConfig));
}
if (cmd.hasOption("identifierfinder")) {
services.add(new JavaIdentifierFinder(zmqConfig));
}
if (cmd.hasOption("codecompletioner")) {
services.add(new JavaCodeCompletioner(zmqConfig));
}
if (cmd.hasOption("logicalnameextractor")) {
services.add(new JavaLogicalNameExtractor(zmqConfig));
}
if (cmd.hasOption("runner")) {
services.add(new JavaRunner(zmqConfig));
}
if (cmd.hasOption("debugger")) {
services.add(new JavaDebugger(zmqConfig));
}
if (cmd.hasOption("debug")) {
services.forEach(MontoService::enableDebugging);
}
for (MontoService service : services) {
try {
service.start();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}