Get and Set Properties on SI Server - User Exit

Mirjana's picture

Get/Set Property on SI through the Map

Get/Set property User Exit steps:
  1. User Exit code for get/set SI/nonSI properties
  2. Create the class from java code
  3. Create jar package from class
  4. Install SIProperty.jar
  5. Input data - example
  6. Property files used for test – example
  7. Translation Map and extended rule used for test – example
  8. Result - explanation
  1. Java code (User Exit) for getting and setting properties in SI property file as well as any other file.
  • This java code contains 4 methods:
Ø       getProperty() – similar to sci-get-property() function that takes a property value from SI property based on key/name
Ø       setProperty() – similar to sci-set-property() function that sets a property value to SI property based on key/name
Ø       readPropertyFromFile() – read property value from a specific file and for a specific property name
Ø       addPropertyToFile() – set name-value pair into a file
·         User Exit java code
package com.tis.custom.userexit;
import com.sterlingcommerce.woodstock.util.frame.Manager;
import java.util.Properties;
publicclass SIProperty {
      public String getProperty(String vendorName, String propName)
            String propValue = Manager.getProperty(vendorName, propName, true);
            System.out.println("SI Custom Property log ... gotten property is: " + propValue);
            return propValue;
      public void setProperty(String vendorName, String propName, String propValue)
            Properties props = Manager.getProperties(vendorName);
          if (props == null) {
            props = new Properties();
          props.setProperty(propName, propValue);
          Manager.setVendorProperties(vendorName, props);
          System.out.println("SI Custom Property log ... set property is: " + propValue);
      public String readPropertyFromFile(String vendorFileName, String propName)
            String propValue = null;
            try {
                  FileInputStream fis = new FileInputStream(vendorFileName);
                  Properties props = new Properties();
                  propValue = props.getProperty(propName);
            } catch(IOException e) {
            System.out.println("SI Custom Property log ... gotten property from file: " + propValue);
            return propValue;
      public void addPropertyToFile(String vendorFileName, String propName, String propValue)
            try {
                  Properties pro = new Properties();
                  FileOutputStream fos = new FileOutputStream(vendorFileName);
                  pro.setProperty(propName, propValue);
                  } catch (IOException e) {
                  System.out.println("SI Custom Property log ... set property to file: " + propValue);
  1. Compile java code 
·         As java class is created in the following packagecom.tis.custom.userexit, we can save the code in the following folder
And create the file with the name
·         Command for compiling java code into class is:
C:\SterlingCommerce\SI50\install\jdk\bin>javac -classpath pathToPackage\Studio-API.jar c:\temp\com\tis\custom\userexit\
·         Go to GIS/SI install folder, jdk/bin and use the same java, GIS/SI is using, for compiling java code. In that way we will avoid problems that can happen because of different java versions between compilation and running versions.
·         classpath setting in the command can be different depending on GIS/SI version. I presume, it can be woodstock.jar in GIS 4.x (in SIinstall/jar folder).
  1. Create jar package from SIProperty.class 
·         Delete from C:\temp\com\tis\custom\userexit
·         Change directory up to c:\temp and run the following command to create SIProperty.jar:
C:\temp>C:\SterlingCommerce\SI50\install\jdk\bin\jar cvf SIProperty.jar com
·   Output of jar command is as follows:
added manifest
adding: com/tis/(in = 0) (out= 0)(stored 0%)
adding: com/tis/custom/(in = 0) (out= 0)(stored 0%)
adding: com/tis/custom/userexit/(in = 0) (out= 0)(stored 0%)
adding: com/tis/custom/userexit/SIProperty.class(in = 2108) (out= 982)(deflated
  1. Install SIProperty.jar 
Install SIProperty.jar with install3rdParty.cmd/sh on SI
  1. Input Data 
·         Input data is:
It can be anything, input data is as simple as possible, just to have anything to test the map.
  1. Property Files 
  • There is file created in \install\properties folder and its content is:
keyHome = NikaDino
  • BP that will refresh that property so we can access the value:
<process name="default">
                   <operation name="Cache Refresh Service">
                             <participant name="CacheRefreshService"/>
                             <output message="CacheRefreshServiceTypeInputMessage">
                                      <assign to="." from="*"/>
                                      <assign to="cache_name">mirjana</assign>
                                      <assign to="cache_type">properties</assign>
                             <input message="inmsg">
                                      <assign to="." from="*"/>
  • There is a file with properties that is not a part of SI installation, but simple file somewhere in the file system, e.g. c:\temp\, and its content is:
  1. Translation Map  
  • The map is simple, and 4 fields in the output will be populated by extended rule written in, that means property values before setting and after setting of SI property as well as non-SI property file

Extended rule in #filed, at the output side, is:
// instantiate an object for SIProperty class
object SIProperty;
SIProperty = new("com.tis.custom.userexit.SIProperty");
// read/get property 'keyHome' from
#propertyBeforeSetting = SIProperty.getProperty("", "keyHome");
// set property 'keyHome' in, from NikaDino to NEW_VALUE
SIProperty.setProperty("", "keyHome", "NEW_VALUE");
// read/get property 'keyHome' from after setting a new value
#propertyAfterSetting = SIProperty.getProperty("", "keyHome");
// read/get property 'fileKey' from
#propertyFromFileBeforeSetting = SIProperty.readPropertyFromFile("c://temp//", "fileKey");
// set property name 'a' to value 'b'in
SIProperty.addPropertyToFile("c://temp//", "a", "b");
// read/get property 'a' from after setting a new value
#propertyFromFileAfterSetting = SIProperty.readPropertyFromFile("c://temp//", "a");
  1. Result - explanation 
Map is run twice.
After running the map for the first and second time, the results are:
propValue1             NikaDino               NEW_VALUE              fileVal               b  
propValue1             NEW_VALUE          NEW_VALUE                                      b 
Property read from, for key/prop name (keyHome) is NikaDino, but another time it will be NEW_VALUE as property is set like that.
Also, contains fileKey=fileVal in the beginning but after setting it will contain a=b.
·         Keep in mind that setProperty() method set a value for a specific property name just in memory and after restarting SI, it will not be updated, but one from the property file will be loaded again. It will just live as long as the application (SI) lives.
·         After setting a new property in a file (, we do not create/append a new property in an existent file, but override it with new one. So this functionallity will always rewrite an old name-value pair with a new one.