I have an application (not webapplication) with its property file. And I need to load into its context several properties from a file on a server, but I couldn't (because I don't know how or I have misunderstood something about that). I have a class which represent a SFtp and I can connect to the server to download and retrieve the file.
How can I include and use all of those properties on my context as a configuration properties or maybe how can modify the XML of context to include that file?
Is a better idea to create a Bean to use the read properties in this way:
public class ServerProperties{
public static ServerPropertiesgetInstance() {
if (ServerProperties.instance == null) {
try {
final InputStream file = ServerProperties.getFileFromServer();
ServerProperties.instance = new CommonProperties();
ServerProperties.instance.environmentsProperties.load(file);
} catch (final IOException e) {
}
}
return ServerProperties.instance;
}
public String getterProp1() { return this.environmentsProperties.get("Prop1"); }
public String getterProp2() return this.environmentsProperties.get("Prop2");}
[...]
public String getterPropN() { return this.environmentsProperties.get("PropN");}