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 package org.utgenome.shell.tomcat;
26
27 import java.io.File;
28
29
30
31
32
33
34
35 public class TomcatServerConfiguration {
36 private int port = 8088;
37 private int ajp13port = 8009;
38 private String catalinaBase;
39
40 public TomcatServerConfiguration() {
41 String workDir = getSystemProperty("user.dir", "");
42
43 this.catalinaBase = new File(getSystemProperty("catalina.base", workDir), "target/tomcat").getPath();
44 }
45
46 public static TomcatServerConfiguration newInstance(int port) {
47 TomcatServerConfiguration config = new TomcatServerConfiguration();
48 config.setPort(port);
49 return config;
50 }
51
52 private static String getSystemProperty(String key, String defaultValue) {
53 String value = System.getProperty("user.dir");
54 return value != null ? value : defaultValue;
55 }
56
57 public int getPort() {
58 return port;
59 }
60
61 public void setPort(int port) {
62 if (port < 0)
63 throw new IllegalArgumentException("invalid port number: " + port);
64 this.port = port;
65 }
66
67 public String getCatalinaBase() {
68 return catalinaBase;
69 }
70
71 public void setCatalinaBase(String catalinaBase) {
72
73
74
75
76
77 this.catalinaBase = catalinaBase;
78 }
79
80 public int getAjp13port() {
81 return ajp13port;
82 }
83
84 public void setAjp13port(int ajp13port) {
85 this.ajp13port = ajp13port;
86 }
87
88 }