Property File is simple but smart phenomenon discussed in this blog. Use of property file is not new in integration arena, but not discussed/used widely in XI context. This blog describes only some of usages of property file, however it can be used with great versatility if deployed with little intelligent.
Many times In Message Mapping we required to use hardcode or constant values to be incorporated in validations and mapping rules. These hardcode/ constants are mainly required in form of properties like data formats, ranges or default values for passing to target, system specific values etc. Many time these property values are system and environment dependent ( Dev, QA, Prod etc.). This makes us to change Message Mapping code every time whenever there is change in these hardcode values. We can avoid disturbing Message Mapping using Property Files to store these values and read generically from Message Mapping code. It will certainly save lot of time in changing the mapping frequently. Also it avoids complexity in case of User Defined functions or java mapping. Whenever there is change in any of values we just need to update property file without changing actual mapping program.
What is Property file?
- >>To explain in simple language; Property file is text file with .properties as an extension. It can be created and edited using NOTEPAD.
Where to put this property file in XI?
- >>Property file can be stored in local folder in XI system.
How to access property file?
- >> It can be accessed by file path using JAVA I/O. Piece of JAVA code (demonstrated below)can be used in form of either User Defined Function in graphical mapping or in JAVA mapping.
Example of file path.
/home/xiuser/folder/xiprop.properties e.q. /home/user name/folder name/file name.properties
Sample Property file contents
# String Key values string_key1 = 1258 string_key2 = 8974 # Project IDs PROJECT_ID_1 = 9500 PROJECT_ID_2 = 2400 # Interface IDs O01.INTERFACE_ID = 3000304 O02.INTERFACE_ID = 3000344 # Control For 310 Client 310RCVPRN = GP0CLNT310 # Control For 810 Client 810RCVPRN = GP0CLNT810
JAVA code demonstrated to read a property file.
(Also code can be added with trace and catch for IO exceptions to know more about errors)
import java.util.properties; private properties _propSet; _propSet= new Properties(); _propSet.load(new FileInputStream(("/home/xiuser/folder/xiprop.properties")); String value = _propSet.getProperty("string_key1"); return value;