MCPcopy Create free account
hub / github.com/apache/tomcat / main

Method main

java/org/apache/catalina/startup/Tomcat.java:1267–1324  ·  view source on GitHub ↗

Main executable method for use with a Maven packager. @param args the command line arguments @throws Exception if an error occurs

(String[] args)

Source from the content-addressed store, hash-verified

1265 * @throws Exception if an error occurs
1266 */
1267 public static void main(String[] args) throws Exception {
1268 // Process some command line parameters
1269 String[] catalinaArguments = null;
1270 for (int i = 0; i < args.length; i++) {
1271 if (args[i].equals("--no-jmx")) {
1272 Registry.disableRegistry();
1273 } else if (args[i].equals("--catalina")) {
1274 // This was already processed before
1275 // Skip the rest of the arguments as they are for Catalina
1276 ArrayList<String> result = new ArrayList<>(Arrays.asList(args).subList(i + 1, args.length));
1277 catalinaArguments = result.toArray(new String[0]);
1278 break;
1279 }
1280 }
1281 Tomcat tomcat = new Tomcat();
1282 // Create a Catalina instance and let it parse the configuration files
1283 // It will also set a shutdown hook to stop the Server when needed
1284 // Use the default configuration source
1285 tomcat.init(null, catalinaArguments);
1286 boolean await = false;
1287 String path = "";
1288 // Process command line parameters
1289 label:
1290 for (int i = 0; i < args.length; i++) {
1291 switch (args[i]) {
1292 case "--war":
1293 if (++i >= args.length) {
1294 throw new IllegalArgumentException(sm.getString("tomcat.invalidCommandLine", args[i - 1]));
1295 }
1296 File war = new File(args[i]);
1297 tomcat.addWebapp(path, war.getAbsolutePath());
1298 break;
1299 case "--path":
1300 if (++i >= args.length) {
1301 throw new IllegalArgumentException(sm.getString("tomcat.invalidCommandLine", args[i - 1]));
1302 }
1303 path = args[i];
1304 break;
1305 case "--await":
1306 await = true;
1307 break;
1308 case "--no-jmx":
1309 // This was already processed before
1310 break;
1311 case "--catalina":
1312 // This was already processed before
1313 // Skip the rest of the arguments as they are for Catalina
1314 break label;
1315 default:
1316 throw new IllegalArgumentException(sm.getString("tomcat.invalidCommandLine", args[i]));
1317 }
1318 }
1319 tomcat.start();
1320 // Ideally the utility threads are non daemon
1321 if (await) {
1322 tomcat.getServer().await();
1323 }
1324 }

Callers

nothing calls this directly

Calls 10

disableRegistryMethod · 0.95
initMethod · 0.95
addWebappMethod · 0.95
startMethod · 0.95
getServerMethod · 0.95
equalsMethod · 0.65
getStringMethod · 0.65
awaitMethod · 0.65
toArrayMethod · 0.45
getAbsolutePathMethod · 0.45

Tested by

no test coverage detected