1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.deploy;
17
18 import java.util.List;
19 import java.util.Properties;
20
21 import org.kuali.common.util.FormatUtils;
22 import org.kuali.common.util.LoggerLevel;
23 import org.kuali.common.util.execute.Executable;
24 import org.kuali.common.util.secure.Result;
25 import org.kuali.common.util.secure.SecureChannel;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
28
29 public class TomcatApplicationServer implements ApplicationServer {
30
31 private static final Logger logger = LoggerFactory.getLogger(TomcatApplicationServer.class);
32
33 SecureChannel channel;
34 boolean validateShutdownExitValue = false;
35 String username;
36 String group;
37 String shutdown;
38 String startup;
39
40 List<String> pathsToDelete;
41
42 List<String> dirsToCreate;
43
44 List<String> pathsToChown;
45
46 List<Deployable> deployables;
47
48 Properties filterProperties;
49
50 boolean skipFiles;
51
52 Executable httpWait;
53
54 @Override
55 public void stop() {
56 long start = System.currentTimeMillis();
57 logger.info("[tomcat:stopping]");
58 Result result = DeployUtils.runscript(channel, username, shutdown, false);
59 if (result.getExitValue() != 0) {
60 DeployUtils.logResult(result, logger, LoggerLevel.WARN);
61 }
62 logger.info("[tomcat:stopped] - {}", FormatUtils.getTime(System.currentTimeMillis() - start));
63 }
64
65 @Override
66 public void prepare() {
67 long start = System.currentTimeMillis();
68 logger.info("[tomcat:preparing]");
69
70 DeployUtils.delete(channel, pathsToDelete);
71
72 DeployUtils.mkdirs(channel, dirsToCreate);
73
74 if (!skipFiles) {
75
76 DeployUtils.copyFiles(channel, deployables, filterProperties);
77 }
78
79 DeployUtils.chown(channel, username, group, pathsToChown);
80 logger.info("[tomcat:prepared] - {}", FormatUtils.getTime(System.currentTimeMillis() - start));
81 }
82
83 @Override
84 public void start() {
85 long start = System.currentTimeMillis();
86 logger.info("[tomcat:start]");
87 DeployUtils.runscript(channel, username, startup);
88 httpWait.execute();
89 logger.info("[tomcat:started] - {}", FormatUtils.getTime(System.currentTimeMillis() - start));
90 }
91
92 public boolean isValidateShutdownExitValue() {
93 return validateShutdownExitValue;
94 }
95
96 public void setValidateShutdownExitValue(boolean validateShutdownExitValue) {
97 this.validateShutdownExitValue = validateShutdownExitValue;
98 }
99
100 public SecureChannel getChannel() {
101 return channel;
102 }
103
104 public void setChannel(SecureChannel channel) {
105 this.channel = channel;
106 }
107
108 public String getUsername() {
109 return username;
110 }
111
112 public void setUsername(String username) {
113 this.username = username;
114 }
115
116 public String getShutdown() {
117 return shutdown;
118 }
119
120 public void setShutdown(String shutdown) {
121 this.shutdown = shutdown;
122 }
123
124 public String getStartup() {
125 return startup;
126 }
127
128 public void setStartup(String startup) {
129 this.startup = startup;
130 }
131
132 public String getGroup() {
133 return group;
134 }
135
136 public void setGroup(String group) {
137 this.group = group;
138 }
139
140 public List<String> getPathsToDelete() {
141 return pathsToDelete;
142 }
143
144 public void setPathsToDelete(List<String> pathsToDelete) {
145 this.pathsToDelete = pathsToDelete;
146 }
147
148 public List<String> getDirsToCreate() {
149 return dirsToCreate;
150 }
151
152 public void setDirsToCreate(List<String> dirsToCreate) {
153 this.dirsToCreate = dirsToCreate;
154 }
155
156 public List<String> getPathsToChown() {
157 return pathsToChown;
158 }
159
160 public void setPathsToChown(List<String> pathsToChown) {
161 this.pathsToChown = pathsToChown;
162 }
163
164 public List<Deployable> getDeployables() {
165 return deployables;
166 }
167
168 public void setDeployables(List<Deployable> deployables) {
169 this.deployables = deployables;
170 }
171
172 public boolean isSkipFiles() {
173 return skipFiles;
174 }
175
176 public void setSkipFiles(boolean skipFiles) {
177 this.skipFiles = skipFiles;
178 }
179
180 public Properties getFilterProperties() {
181 return filterProperties;
182 }
183
184 public void setFilterProperties(Properties filterProperties) {
185 this.filterProperties = filterProperties;
186 }
187
188 public Executable getHttpWait() {
189 return httpWait;
190 }
191
192 public void setHttpWait(Executable httpWait) {
193 this.httpWait = httpWait;
194 }
195
196 }