1
2
3
4
5
6 package uk.ac.ebi.intenz.tools.sib;
7
8 import org.apache.log4j.Logger;
9
10 import java.util.PropertyResourceBundle;
11 import java.io.InputStream;
12 import java.io.IOException;
13 import java.io.FileInputStream;
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 public class ApplicationResources extends PropertyResourceBundle {
37
38 private static Logger LOGGER =
39 Logger.getLogger(ApplicationResources.class.getName());
40
41 static ApplicationResources resources;
42
43
44
45
46
47
48 private ApplicationResources (InputStream stream) throws IOException {
49 super(stream);
50 }
51
52
53
54
55
56
57
58 public static ApplicationResources getInstance () {
59 if ( resources == null ) {
60 synchronized ( ApplicationResources.class ) {
61 if ( resources == null ) {
62 try {
63
64
65 InputStream in = ApplicationResources.class.getClassLoader()
66 .getResourceAsStream("application.properties");
67 resources = new ApplicationResources(in);
68 } catch ( IOException e ) {
69 LOGGER.fatal("Application properties file could not be loaded.", e);
70 System.exit(1);
71 }
72 }
73 }
74 }
75 return resources;
76 }
77
78
79
80 public String getDbUrl(){
81 return resources.getString("application.db.url");
82 }
83
84 public String getDbUserName(){
85 return resources.getString("application.db.login");
86 }
87
88 public String getDbPassword(){
89 return resources.getString("application.db.password");
90 }
91
92 public String getDbConfig(){
93 return resources.getString("application.db.config");
94 }
95
96 public String getInputFlatFileName(){
97 return resources.getString("application.input.fileName");
98 }
99
100 public String getExportFlatFileName(){
101 return resources.getString("application.export.fileName");
102 }
103
104 public String getSpecialCharactersFileName(){
105 return resources.getString("application.xml.file");
106 }
107
108 }