001package runwar.options; 002 003import java.io.File; 004import java.net.MalformedURLException; 005import java.net.URL; 006 007public class ServerOptions { 008 private String serverName = "default", processName = "RunWAR", loglevel = "WARN"; 009 private String host = "127.0.0.1", contextPath = "/"; 010 private int portNumber = 8088, ajpPort = 8009, sslPort = 443, socketNumber = 8779; 011 private boolean enableAJP = false, enableSSL = false, enableHTTP = true, enableURLRewrite = false; 012 private boolean debug = false, isBackground = true, keepRequestLog = false, openbrowser = false; 013 private String pidFile, openbrowserURL, cfmlDirs, libDirs = null; 014 private int launchTimeout = 50 * 1000; // 50 secs 015 private URL jarURL = null; 016 private File warFile, webXmlFile, logDir, urlRewriteFile, trayConfig, statusFile = null; 017 private String iconImage = null; 018 private String cfmlServletConfigWebDir = null, cfmlServletConfigServerDir = null; 019 private boolean directoryListingEnabled = true; 020 private boolean cacheEnabled = false; 021 private String[] welcomeFiles = new String[] { "index.cfm", "index.cfml", "default.cfm", "index.html", "index.htm", 022 "default.html", "default.htm" }; 023 private File sslCertificate, sslKey, configFile; 024 private char[] sslKeyPass; 025 private char[] stopPassword = "klaatuBaradaNikto".toCharArray(); 026 private String action; 027 private String cfengineName = "lucee"; 028 private boolean customHTTPStatusEnabled = true; 029 private boolean gzipEnabled = false; 030 private Long transferMinSize = (long) 100; 031 private boolean mariadb4jEnabled = false; 032 private int mariadb4jPort = 13306; 033 private File mariadb4jBaseDir, mariadb4jDataDir, mariadb4jImportSQLFile = null; 034 035 public String getServerName() { 036 return serverName; 037 } 038 public ServerOptions setServerName(String serverName) { 039 this.serverName = serverName; 040 return this; 041 } 042 public String getLoglevel() { 043 return loglevel; 044 } 045 public ServerOptions setLoglevel(String loglevel) { 046 this.loglevel = loglevel.toUpperCase(); 047 return this; 048 } 049 public String getContextPath() { 050 return contextPath; 051 } 052 public File getConfigFile() { 053 return configFile; 054 } 055 public ServerOptions setConfigFile(File file) { 056 this.configFile = file; 057 return this; 058 } 059 public ServerOptions setContextPath(String contextPath) { 060 this.contextPath = contextPath; 061 return this; 062 } 063 public String getHost() { 064 return host; 065 } 066 public ServerOptions setHost(String host) { 067 this.host = host; 068 return this; 069 } 070 public int getPortNumber() { 071 return portNumber; 072 } 073 public ServerOptions setPortNumber(int portNumber) { 074 this.portNumber = portNumber; 075 return this; 076 } 077 public int getAJPPort() { 078 return ajpPort; 079 } 080 public ServerOptions setAJPPort(int ajpPort) { 081 this.ajpPort = ajpPort; 082 return this; 083 } 084 public int getSSLPort() { 085 return sslPort; 086 } 087 public ServerOptions setSSLPort(int sslPort) { 088 this.sslPort = sslPort; 089 return this; 090 } 091 public boolean isEnableSSL() { 092 return enableSSL; 093 } 094 public ServerOptions setEnableSSL(boolean enableSSL) { 095 this.enableSSL = enableSSL; 096 return this; 097 } 098 public boolean isEnableHTTP() { 099 return enableHTTP; 100 } 101 public ServerOptions setEnableHTTP(boolean bool) { 102 this.enableHTTP = bool; 103 return this; 104 } 105 public boolean isEnableURLRewrite() { 106 return enableURLRewrite; 107 } 108 public ServerOptions setEnableURLRewrite(boolean bool) { 109 this.enableURLRewrite = bool; 110 return this; 111 } 112 public ServerOptions setURLRewriteFile(File file) { 113 this.urlRewriteFile = file; 114 return this; 115 } 116 public File getURLRewriteFile() { 117 return this.urlRewriteFile; 118 } 119 public int getSocketNumber() { 120 return socketNumber; 121 } 122 public ServerOptions setSocketNumber(int socketNumber) { 123 this.socketNumber = socketNumber; 124 return this; 125 } 126 public File getLogDir() { 127 return logDir; 128 } 129 public ServerOptions setLogDir(String logDir) { 130 if(logDir!= null && logDir.length() > 0) 131 this.logDir = new File(logDir); 132 return this; 133 } 134 public ServerOptions setLogDir(File logDir) { 135 this.logDir = logDir; 136 return this; 137 } 138 public String getCfmlDirs() { 139 return cfmlDirs; 140 } 141 public ServerOptions setCfmlDirs(String cfmlDirs) { 142 this.cfmlDirs = cfmlDirs; 143 return this; 144 } 145 public boolean isBackground() { 146 return isBackground; 147 } 148 public ServerOptions setBackground(boolean isBackground) { 149 this.isBackground = isBackground; 150 return this; 151 } 152 public boolean isKeepRequestLog() { 153 return keepRequestLog; 154 } 155 public ServerOptions setKeepRequestLog(boolean keepRequestLog) { 156 this.keepRequestLog = keepRequestLog; 157 return this; 158 } 159 public boolean isOpenbrowser() { 160 return openbrowser; 161 } 162 public ServerOptions setOpenbrowser(boolean openbrowser) { 163 this.openbrowser = openbrowser; 164 return this; 165 } 166 public String getOpenbrowserURL() { 167 return openbrowserURL; 168 } 169 public ServerOptions setOpenbrowserURL(String openbrowserURL) { 170 this.openbrowserURL = openbrowserURL; 171 return this; 172 } 173 public String getPidFile() { 174 return pidFile; 175 } 176 public ServerOptions setPidFile(String pidFile) { 177 this.pidFile = pidFile; 178 return this; 179 } 180 public boolean isEnableAJP() { 181 return enableAJP; 182 } 183 public ServerOptions setEnableAJP(boolean enableAJP) { 184 this.enableAJP = enableAJP; 185 return this; 186 } 187 public int getLaunchTimeout() { 188 return launchTimeout; 189 } 190 public ServerOptions setLaunchTimeout(int launchTimeout) { 191 this.launchTimeout = launchTimeout; 192 return this; 193 } 194 public String getProcessName() { 195 return processName; 196 } 197 public ServerOptions setProcessName(String processName) { 198 this.processName = processName; 199 return this; 200 } 201 public String getLibDirs() { 202 return libDirs; 203 } 204 public ServerOptions setLibDirs(String libDirs) { 205 this.libDirs = libDirs; 206 return this; 207 } 208 public URL getJarURL() { 209 return jarURL; 210 } 211 public ServerOptions setJarURL(URL jarURL) { 212 this.jarURL = jarURL; 213 return this; 214 } 215 public boolean isDebug() { 216 return debug; 217 } 218 public ServerOptions setDebug(boolean debug) { 219 this.debug = debug; 220 return this; 221 } 222 public File getWarFile() { 223 return warFile; 224 } 225 public ServerOptions setWarFile(File warFile) { 226 this.warFile = warFile; 227 return this; 228 } 229 public File getWebXmlFile() { 230 return webXmlFile; 231 } 232 public String getWebXmlPath() throws MalformedURLException { 233 return webXmlFile.toURI().toURL().toString(); 234 } 235 public ServerOptions setWebXmlFile(File webXmlFile) { 236 this.webXmlFile = webXmlFile; 237 return this; 238 } 239 public String getIconImage() { 240 return iconImage; 241 } 242 public ServerOptions setIconImage(String iconImage) { 243 this.iconImage = iconImage; 244 return this; 245 } 246 public File getTrayConfig() { 247 return trayConfig; 248 } 249 public ServerOptions setTrayConfig(File trayConfig) { 250 this.trayConfig = trayConfig; 251 return this; 252 } 253 public File getStatusFile() { 254 return statusFile; 255 } 256 public ServerOptions setStatusFile(File statusFile) { 257 this.statusFile = statusFile; 258 return this; 259 } 260 public String getCFMLServletConfigWebDir() { 261 return cfmlServletConfigWebDir; 262 } 263 public ServerOptions setCFMLServletConfigWebDir(String cfmlServletConfigWebDir) { 264 this.cfmlServletConfigWebDir = cfmlServletConfigWebDir; 265 return this; 266 } 267 public String getCFMLServletConfigServerDir() { 268 return cfmlServletConfigServerDir; 269 } 270 public ServerOptions setCFMLServletConfigServerDir(String cfmlServletConfigServerDir) { 271 this.cfmlServletConfigServerDir = cfmlServletConfigServerDir; 272 return this; 273 } 274 public boolean isCacheEnabled() { 275 return cacheEnabled; 276 } 277 public ServerOptions setCacheEnabled(boolean cacheEnabled) { 278 this.cacheEnabled = cacheEnabled; 279 return this; 280 } 281 public boolean isDirectoryListingEnabled() { 282 return directoryListingEnabled; 283 } 284 public ServerOptions setDirectoryListingEnabled(boolean directoryListingEnabled) { 285 this.directoryListingEnabled = directoryListingEnabled; 286 return this; 287 } 288 public String[] getWelcomeFiles() { 289 return welcomeFiles; 290 } 291 public ServerOptions setWelcomeFiles(String[] welcomeFiles) { 292 this.welcomeFiles = welcomeFiles; 293 return this; 294 } 295 public String getWarPath() throws MalformedURLException { 296 return getWarFile().toURI().toURL().toString(); 297 } 298 public ServerOptions setSSLCertificate(File file) { 299 this.sslCertificate = file; 300 return this; 301 } 302 public File getSSLCertificate() { 303 return this.sslCertificate; 304 } 305 public ServerOptions setSSLKey(File file) { 306 this.sslKey = file; 307 return this; 308 } 309 public File getSSLKey() { 310 return this.sslKey; 311 } 312 public ServerOptions setSSLKeyPass(char[] pass) { 313 this.sslKeyPass = pass; 314 return this; 315 } 316 public char[] getSSLKeyPass() { 317 return this.sslKeyPass; 318 } 319 public ServerOptions setStopPassword(char[] password) { 320 this.stopPassword = password; 321 return this; 322 } 323 public char[] getStopPassword() { 324 return this.stopPassword; 325 } 326 public ServerOptions setAction(String action) { 327 this.action = action; 328 return this; 329 } 330 public String getAction() { 331 return this.action; 332 } 333 public ServerOptions setCFEngineName(String cfengineName) { 334 if(cfengineName.toLowerCase().equals("lucee") 335 || cfengineName.toLowerCase().equals("adobe") 336 || cfengineName.toLowerCase().equals("railo") 337 || cfengineName.toLowerCase().equals("")) { 338 this.cfengineName = cfengineName.toLowerCase(); 339 } else { 340 throw new RuntimeException("Unknown engine type: " + cfengineName + ", must be one of: lucee, adobe, railo"); 341 } 342 return this; 343 } 344 public String getCFEngineName() { 345 return this.cfengineName ; 346 } 347 348 public ServerOptions setCustomHTTPStatusEnabled(boolean enabled) { 349 this.customHTTPStatusEnabled = enabled; 350 return this; 351 } 352 public boolean isCustomHTTPStatusEnabled() { 353 return this.customHTTPStatusEnabled; 354 } 355 356 public ServerOptions setSendfileEnabled(boolean enabled) { 357 if(!enabled) { 358 this.transferMinSize = Long.MAX_VALUE; 359 } 360 return this; 361 } 362 public ServerOptions setTransferMinSize(Long minSize) { 363 this.transferMinSize = minSize; 364 return this; 365 } 366 367 public Long getTransferMinSize() { 368 return this.transferMinSize; 369 } 370 371 public ServerOptions setGzipEnabled(boolean enabled) { 372 this.gzipEnabled = enabled; 373 return this; 374 } 375 public boolean isGzipEnabled() { 376 return this.gzipEnabled; 377 } 378 379 public ServerOptions setMariaDB4jEnabled(boolean enabled) { 380 this.mariadb4jEnabled = enabled; 381 return this; 382 } 383 public boolean isMariaDB4jEnabled() { 384 return this.mariadb4jEnabled; 385 } 386 public ServerOptions setMariaDB4jPort(int port) { 387 this.mariadb4jPort = port; 388 return this; 389 } 390 public int getMariaDB4jPort() { 391 return this.mariadb4jPort; 392 } 393 public ServerOptions setMariaDB4jBaseDir(File dir) { 394 this.mariadb4jBaseDir= dir; 395 return this; 396 } 397 public File getMariaDB4jBaseDir() { 398 return this.mariadb4jBaseDir; 399 } 400 public ServerOptions setMariaDB4jDataDir(File dir) { 401 this.mariadb4jDataDir= dir; 402 return this; 403 } 404 public File getMariaDB4jDataDir() { 405 return this.mariadb4jDataDir; 406 } 407 public ServerOptions setMariaDB4jImportSQLFile(File file) { 408 this.mariadb4jImportSQLFile= file; 409 return this; 410 } 411 public File getMariaDB4jImportSQLFile() { 412 return this.mariadb4jImportSQLFile; 413 } 414 415}