--- /dev/null
+# Hatch Properties File
+
+# Full path to the data storage directory. Defaults to the $HOME/.evergreen/
+# If you change this you may also want to change the
+# java.util.logging.FileHandler.pattern property in logging.properties.
+#data.directory=/tmp/foo
+
package org.evergreen_ils.hatch;
import java.util.Map;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
import java.util.logging.*;
import org.json.*;
printRequestQueue = new LinkedBlockingQueue<JSONObject>();
static final Logger logger = Logger.getLogger("org.evergreen_ils.hatch");
+
+ private static Properties configProps;
/**
* Printable region containing a browser.
}
}
+ /**
+ * Read the configuration properties file.
+ */
+ private static void readProps() {
+ if (configProps != null) return; // already loaded.
+ configProps = new Properties();
+ InputStream input = null;
+
+ try {
+ input = new FileInputStream("hatch.properties");
+ configProps.load(input);
+ } catch (IOException e) {
+ logger.warning("Unable to open Hatch properties file: " + e);
+ } finally {
+ if (input != null) {
+ try { input.close(); } catch (Exception e2) {}
+ }
+ }
+ }
+
+ /**
+ * Get values for configurable properties
+ */
+ public static String getProp(String name) {
+ readProps();
+ return configProps.getProperty(name);
+ }
+
/**
* Hatch main.
// Find the profile directory.
// The profile directory + origin string represent the base
// directory for all file I/O for this session.
- if (profileDirectory == null) { // TODO: make configurable
- String home = System.getProperty("user.home");
- profileDirectory = new File(home, ".evergreen").getPath();
+ if (profileDirectory == null) {
+
+ // first see if a value is set in the properties file.
+ profileDirectory = Hatch.getProp("data.directory");
+
if (profileDirectory == null) {
- logger.warning("Unable to set profile directory");
+ // otherwise set the directory to the users's home
+ // directory + .evergreen
+ String home = System.getProperty("user.home");
+ profileDirectory = new File(home, ".evergreen").getPath();
+
+ if (profileDirectory == null) {
+ logger.warning("Unable to set profile directory");
+ }
}
+
+ logger.info("Using data directory: " + profileDirectory);
}
}