1 30 31 32 package org.hsqldb; 33 34 import org.hsqldb.lib.FileUtil; 35 import org.hsqldb.persist.HsqlProperties; 36 import org.hsqldb.resources.BundleHandler; 37 38 45 121 public class WebServer extends Server { 122 123 127 static int webBundleHandle = BundleHandler.getBundleHandle("webserver", 128 null); 129 130 public WebServer() { 131 super(ServerConstants.SC_PROTOCOL_HTTP); 132 } 133 134 141 public static void main(String [] args) { 142 143 String propsPath = FileUtil.canonicalOrAbsolutePath("webserver"); 144 HsqlProperties fileProps = 145 ServerConfiguration.getPropertiesFromFile(propsPath); 146 HsqlProperties props = fileProps == null ? new HsqlProperties() 147 : fileProps; 148 HsqlProperties stringProps = HsqlProperties.argArrayToProps(args, 149 ServerConstants.SC_KEY_PREFIX); 150 151 if (stringProps != null) { 152 if (stringProps.getErrorKeys().length != 0) { 153 printHelp("webserver.help"); 154 155 return; 156 } 157 158 props.addProperties(stringProps); 159 } 160 161 ServerConfiguration.translateDefaultDatabaseProperty(props); 162 163 ServerConfiguration.translateDefaultNoSystemExitProperty(props); 168 169 Server server = new WebServer(); 171 172 server.setProperties(props); 173 174 server.print("Startup sequence initiated from main() method"); 176 177 if (fileProps != null) { 178 server.print("Loaded properties from [" + propsPath 179 + ".properties]"); 180 } else { 181 server.print("Could not load properties from file"); 182 server.print("Using cli/default properties only"); 183 } 184 185 server.start(); 186 } 187 188 198 public String getDefaultWebPage() { 199 return serverProperties.getProperty( 200 ServerConstants.SC_KEY_WEB_DEFAULT_PAGE); 201 } 202 203 209 public String getHelpString() { 210 return BundleHandler.getString(serverBundleHandle, "webserver.help"); 211 } 212 213 224 public String getProductName() { 225 return "HSQLDB web server"; 226 } 227 228 238 public String getProtocol() { 239 return isTls() ? "HTTPS" 240 : "HTTP"; 241 } 242 243 256 public String getWebRoot() { 257 return serverProperties.getProperty(ServerConstants.SC_KEY_WEB_ROOT); 258 } 259 } 260 | Popular Tags |