How to read a property off a properties file in IBM Sterling B2B Map:
Starting off with a couple of problems here:
A: There is no method available in the mapping tool’s native language that could enable the developer to access and manipulate the properties (retrieve, delete, add, update etc.) therefore the only option is going the user exit way
B: the properties are manipulated by use of static methods provided for in the API but through the mapper’s own native language, a java static method cannot be called.
Solution: still userexit but with the overhead of wrapping the static methods of the core API in a custom class that can be instantiated. The class is then packaged as a jar file and the deployed to the system’s runtime. Following are the details:
- It’s better to have MESA developer Studio installed, as the platform’s jar files become available easily that way. Anyhow, for this task, “Studio-API.jar” is required, that can be found in (if MESA is installed): <Eclipse install directory>\plugins\com.sterlingcommerce.mesa.servicesdk_1020401.0.0\lib\1020401
- Following is the sample java code:
package com.Somthing.SBI.HelperLib;
import com.sterlingcommerce.woodstock.util.frame.Manager; //made available by Studio-API
public class PropertyReader
{
public String getProperty(String _propertyFileName, String _propertyName)
{
String _propertyValue = Manager.getProperty(_propertyFileName, _propertyName, true); //This is the static function that fetches the value of the given key inside the given properties file
return _propertyValue;
}
}
- Package this class in a jar file. I used Eclipse’s export->Java->Jar file functionality
- Its time to install this jar file to SBI. Execute the following command:
install3rdparty <VendorName> <VendorVersion> -j <fully qualified path><jar file>
- The following code sample shows how to instantiate the deployed class and calling its method, inside the map’s session/extended rule:
object _obj;
String[256] _str;
_obj = new(“com.Somthing.SBI.HelperLib.PropertyReader”); //instantiating an object of type PropertyReader
_str = _obj.getProperty(“Property Filename”, “Property Key Name”); //calling the method