Repository navigation
Expand file tree
/
Copy pathConfig.java
More file actions
49 lines (40 loc) · 1.47 KB
/
Copy pathConfig.java
File metadata and controls
49 lines (40 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package com.javaops.config;
import com.javaops.storage.SqlStorage;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class Config {
// private static File PROPS = new File(getHomeDir(), "config\\resumes.properties");
private static final String PROPS = "/resumes.properties";
private static final Config INSTANCE = new Config();
private final File storageDir;
private final SqlStorage storage;
public static Config get() {
return INSTANCE;
}
private Config() {
try (InputStream is = Config.class.getResourceAsStream(PROPS)) {
Properties props = new Properties();
props.load(is);
storageDir = new File(props.getProperty("storage.dir"));
storage = new SqlStorage(props.getProperty("db.url"), props.getProperty("db.user"), props.getProperty("db.password"));
} catch (IOException e) {
throw new IllegalStateException("Invalid config file " + PROPS);
}
}
public File getStorageDir() {
return storageDir;
}
public SqlStorage getStorage() {
return storage;
}
// private static File getHomeDir() {
// String prop = System.getProperty("homeDir");
// File homeDir = new File(prop == null ? "." : prop);
// if (!homeDir.isDirectory()) {
// throw new IllegalStateException(homeDir + " is not directory");
// }
// return homeDir;
// }
}