58 lines
1.5 KiB
Java
58 lines
1.5 KiB
Java
import java.io.File;
|
|
import java.io.FileInputStream;
|
|
import java.io.IOException;
|
|
import java.util.Properties;
|
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
/**
|
|
* Config provides access to runtime configuration properties defined
|
|
* in a Java properties file. The file is located in
|
|
* "config/config.properties" relative to the installation root.
|
|
*/
|
|
public class Config {
|
|
static final Logger log = LoggerFactory.getLogger("Config");
|
|
private Properties properties = new Properties();
|
|
|
|
|
|
/**
|
|
* Load the configuration properties file.
|
|
*/
|
|
public Config() {
|
|
try {
|
|
String cwd = System.getProperty("user.dir");
|
|
String configFile = cwd + File.separator + "config" +
|
|
File.separator + "config.properties";
|
|
log.info("Loading config file " + configFile);
|
|
properties.load(new FileInputStream(configFile));
|
|
} catch (IOException e) {
|
|
log.error("Error loading config.properties", e);
|
|
System.exit(1);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Return the OANDA account id.
|
|
*/
|
|
public String accountID() {
|
|
return properties.getProperty("OANDA.accountID");
|
|
}
|
|
|
|
/**
|
|
* Return true if the OANDA account is on the live ('fxlive') site.
|
|
* Return false if it is on the practice ('fxpractice') site.
|
|
*/
|
|
public boolean isLiveAccount() {
|
|
return Boolean.parseBoolean(properties.getProperty("OANDA.isLiveAccount"));
|
|
}
|
|
|
|
/**
|
|
*
|
|
*/
|
|
public String accessToken() {
|
|
return properties.getProperty("OANDA.accessToken");
|
|
}
|
|
}
|