I have some properties in a property file that I referenced in a singleton so that I can access them easily from different parts of my application. For each property, I put the properties along with some additional information for each property in a list of objects. I'm doing this in the singleton's private constructor. Is this the correct way to store/access static data on a server?
Any help or guidance is appreciated.
Added example of what I'm currently doing
public class PropertiesSingleton {
private static PropertiesSingleton instance = null;
private List<MyPropertyObject> properties = new ArrayList<>();
private static PropertyManager pm = PropertyManager.getInstance();
private PropertiesSingleton() {
properties.add("first property description",
"other property info",
new MyPropertyObject(pm.getProperty("firstProperty")));
properties.add("second property description",
"other property info",
new MyPropertyObject(pm.getProperty("secondProperty")));
properties.add("third property description",
"other property info",
new MyPropertyObject(pm.getProperty("thirdProperty")));
}
public static getInstance() {
if (instance == null) {
instance = new PropertiesSingleton();
}
return instance;
}
public getProperties() {
return this.properties;
}
}
PropertiesSingleton
. – unholysampler Apr 17 '17 at 11:18