- Timestamp:
- 2009-04-01T19:31:09+13:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
greenstone3/trunk/src/java/org/greenstone/server/BaseServer.java
r18770 r18868 24 24 static protected final int SERVER_START_FAILED = 1; 25 25 static protected final int BROWSER_LAUNCHED = 2; 26 static protected final int BROWSER_LAUNCH_FAILED = 3; 26 static protected final int BROWSER_LAUNCH_FAILED = 3; 27 static protected final int START_SERVER = 4; 27 28 28 static protected Properties build_properties;29 static protected Properties config_properties; 29 30 static protected Logger logger_; 30 31 31 static public File build_properties_file;32 static public File config_properties_file; 32 33 static public Dictionary dictionary; 33 34 static public BaseProperty Property; … … 37 38 protected String gsdl_home; 38 39 protected String logs_folder; 40 protected boolean start_browser; 41 39 42 protected BaseServerControl server_control_; 40 43 41 protected BaseServer(String gsdl_home, String lang, String build_properties_path, String logs)44 protected BaseServer(String gsdl_home, String lang, String config_properties_path, String logs) 42 45 { 43 46 this.gsdl_home = gsdl_home; … … 49 52 logger_ = Logger.getLogger(BaseServer.class.getName()); 50 53 51 build_properties_file = new File(build_properties_path);52 53 if (! build_properties_file.exists()) {54 logger_.fatal("Can't find build.properties file "+build_properties_path);54 config_properties_file = new File(config_properties_path); 55 56 if (!config_properties_file.exists()) { 57 logger_.fatal("Can't find configuration file "+config_properties_path); 55 58 System.exit(1); 56 59 } 57 60 58 build_properties = new Properties();59 reload BuildProperties();60 61 config_properties = new Properties(); 62 reloadConfigProperties(); 63 61 64 dictionary = new Dictionary("server", lang, this.getClass().getClassLoader()); 62 65 … … 65 68 public void autoStart() 66 69 { 67 String auto_start = build_properties.getProperty(BaseServer.Property.AUTOSTART); 68 if (auto_start != null && auto_start.equals("true")) { 69 restart(); 70 } 71 else{ 72 start(); 73 } 74 70 String auto_start = config_properties.getProperty(BaseServer.Property.AUTOSTART, "true"); 71 72 if (auto_start.equals("true") || auto_start.equals("1")) { 73 String start_browser = config_properties.getProperty(BaseServer.Property.START_BROWSER, "true"); 74 75 if (start_browser.equals("true") || start_browser.equals("1")) { 76 restart(); 77 } 78 else{ 79 start(); 80 } 81 } else { 82 reload(); // browser URL or other important properties may not yet be initialised 83 server_state_ = START_SERVER; 84 server_control_.updateControl(); 85 } 75 86 } 76 87 … … 91 102 public abstract String getBrowserURL(); 92 103 public abstract void reload(); // reload properties, since they may have changed 104 protected void preStop() {} 93 105 94 106 public void reconfigRequired() … … 118 130 } 119 131 else{ 120 recordSuccess(CONFIGURE_CMD); 132 recordSuccess(CONFIGURE_CMD); 121 133 } 122 134 … … 162 174 String url = getBrowserURL(); 163 175 //recordError("**** browserURL: " + url); 164 BrowserLauncher launcher = new BrowserLauncher( build_properties.getProperty(BaseServer.Property.BROWSER_PATH),url);176 BrowserLauncher launcher = new BrowserLauncher(config_properties.getProperty(BaseServer.Property.BROWSER_PATH, ""),url); 165 177 logger_.info(message); 166 178 … … 203 215 204 216 public void stop(boolean silent) { 217 preStop(); 205 218 if(!silent) { 206 219 server_control_.displayMessage(dictionary.get("ServerControl.Stopping")); … … 217 230 } 218 231 219 public void reload BuildProperties() {232 public void reloadConfigProperties() { 220 233 try { 221 FileInputStream in = new FileInputStream( build_properties_file);234 FileInputStream in = new FileInputStream(config_properties_file); 222 235 223 236 if (in != null) { 224 logger_.info("loading build properties");225 build_properties.load(in);237 logger_.info("loading configuration properties: " + config_properties_file); 238 config_properties.load(in); 226 239 in.close(); 227 240 } else { 228 logger_.error("Couldn't load build properties!");241 logger_.error("Couldn't load configuration properties from " + config_properties_file + "!"); 229 242 } 230 243 } catch (Exception e) { 231 logger_.error("Exception trying to reload build.properties: "+e);244 logger_.error("Exception trying to reload configuration properties " +config_properties_file + ": " +e); 232 245 } 233 246
Note:
See TracChangeset
for help on using the changeset viewer.