There are some scenarios where we need to get constant configurable values to the MEC mapper. For example sometime we have to get email addresses, database schema, user name PW like that.
For such a scenario we have few possible options
· Hard Code.
· Read From table
· Read from external text file (referred as java properties file /in .net config file ).
Hard coding is not good option because when change is needed have to modify the map and restart the MEC environment and need to seek help from technical consultant. Reading from table also good option and need to maintain separate table and all.
But reading from external file is very easy and implementation time also short.
Create a text file with the information that you require. In my case I want to add some email address .So my text will be like below.I will name this file as M3Properties.properties. properties will be the ext.
Then copy this file to the MEC central file location . you can keep this file anyware but when it added to the central file location its easy to access file . Other wise we have to hard code the file location .
Using below java code you can access properties file. Use this code place where you want information from properties .
String centralFileFolder = com.intentia.ec.server.DocServer.getEcProperties().getProperty("mec.central.file.path");
String PropertiesFile = centralFileFolder+"/Properties/M3Interface";
System.out.println(getClass().getName() + "[:] PropertiesFile: '" + PropertiesFile + "'");
cat.info(strUUID + "[:] PropertiesFile: '" + PropertiesFile + "'");
// Read properties file if it exists
boolean propertiesOK = false;
java.util.Properties properties = new java.util.Properties();
properties.load(new java.io.FileInputStream(PropertiesFile + ".properties"));
propertiesOK = true;
System.out.println("IO Error occurred reading properties file for " + getClass() + ".\n");
System.out.println("Default values will be used.");
// If properties ok then get each one
oemailAddress = properties.getProperty("EMAIL.FROM");
com.intentia.ec.server.DocServer.getEcProperties().getProperty("mec.central.file.path") can be used to get MEC central file location path .