/**
* @author David Roden <droden@gmail.com>
- * @version $Id: Configuration.java 418 2006-03-29 17:49:16Z bombe $
+ * @version $Id$
*/
public class Configuration {
private SimpleXML rootNode;
public Configuration() {
- filename = System.getProperty("user.home") + "/.jSite/config7";
- lockFilename = System.getProperty("user.home") + "/.jSite/lock7";
+ this(System.getProperty("user.home") + "/.jSite/config7");
+ }
+
+ public Configuration(String filename) {
+ this(filename, filename + ".lock");
+ }
+
+ public Configuration(String filename, String lockFilename) {
+ this.filename = filename;
+ this.lockFilename = lockFilename;
readConfiguration();
}
private boolean createConfigDirectory() {
- File configDirectory = new File(System.getProperty("user.home"), ".jSite");
+ File configDirectory = new File(filename).getAbsoluteFile().getParentFile();
return (configDirectory.exists() && configDirectory.isDirectory()) || configDirectory.mkdirs();
}
public boolean save() {
File configurationFile = new File(filename);
if (!configurationFile.exists()) {
- File configurationFilePath = configurationFile.getParentFile();
+ File configurationFilePath = configurationFile.getAbsoluteFile().getParentFile();
if (!configurationFilePath.exists() && !configurationFilePath.mkdirs()) {
return false;
}
* @return The hostname of the node
* @deprecated Use {@link #getSelectedNode()} instead
*/
+ @Deprecated
public String getNodeAddress() {
return getNodeValue(new String[] { "node-address" }, "localhost");
}
* @param nodeAddress The hostname of the node
* @deprecated Use {@link #setSelectedNode(Node)} instead
*/
+ @Deprecated
public void setNodeAddress(String nodeAddress) {
rootNode.replace("node-address", nodeAddress);
}
* @return The port number of the node
* @deprecated Use {@link #getSelectedNode()} instead.
*/
+ @Deprecated
public int getNodePort() {
return getNodeIntValue(new String[] { "node-port" }, 9481);
}
* @param nodePort The port number of the node
* @deprecated Use {@link #setSelectedNode(Node)} instead
*/
+ @Deprecated
public void setNodePort(int nodePort) {
rootNode.replace("node-port", String.valueOf(nodePort));
}