Contents Hide
This section explains what how to define and use server side configuration property files.
One of the issues that mobile server side developers face is deploying BEP projects to different servers in different environments. One good example would be to develop the solution on a test server, and then deploy it a to production server. Naturally both test and production environments would have different configuration options such as the database server addresses, database names and user credentials etc. It would be impractical to change the BEP configuration details every time it is deployed from one environment to other.
This is handled by the configuration property files and the use of the #BR# reference markers in BEP projects.
The name and value pairs of which format is given in the following section below are accessed using #BR# reference markers in BEP projects. For instance you can parameterise a Sync Point database properties using these reference markers and point to the parameter values stored in the properties file. In the below sample database properties dialog, the database IP address is parameterised via using the DB_IP_ADDRESS property. Note that this parameter name is enclosed between #BR# tags.
Typically, parameterised values in BEP files will be populated when the BrightServer Project is deployed to a BrightServer instance.
A sample content of a property file is provided below. Please note the following syntactical features of the text:
Each property name and value pair must be put onto its own line in the file
Name and value pairs are separated by an equal (=) sign, the name of the parameter being on the left hand side and the string value of the parameter being on the right hand side.
Any line starting with # is assumed to a comment line, and it will be ignored. If any comment or note needs to be entered in the file, then add lines starting with # to place them in the file.
Empty lines or lines with white spaces will also be ignored.
#comment Line
DB_IP_ADDRESS=192.168.12.123
DB_PORT=1434
DB_NAME=mytestdb
DB_USER=myuser
DB_PASS=myuserpwd
MYPARAM=Hello world!
When deploying a BrightServer Project file to a BrightServer instance, any parameterised fields will appear in the 'Release Description' dialog. Initially, the status of these properties will be listed as 'Unassigned', which indicates that the values have not been assigned for the deployment, and may cause errors if deployed as-is.
To assign parameters from this dialog, the 'Load Configuration Properties File...' button may be tapped, which will open a file selector to select a file containing the parameters listed. Once loaded, the dialog will display as follows:
'Ok' denotes the values could be parsed from the properties file with no issue, whereas 'Unreferenced' indicates that the parameter was found in the configuration file, but not in the BEP Sync Points panel.
Tapping 'Deploy' from this screen will continue to deploy the BEP file with the properties as listed. This process must be performed for every BEP deployment to the server.
Property files can also be used from server scripts to parameterise the script configuration items. In reader and writer scripts, for instance, the developer may choose to make certain aspect of the scripts being written configurable. This way scripts written would not have to be changed from deployment to deployment. Also running system attributes can be changed at runtime by placing these parameters into a property file to eliminate the project redeployment.
The ScriptSession object provides two methods to retrieve parameters stored in property files. The getConfigProperty() method may be used to retrieve parameters from the configuration file uploaded to the server at deployment. The method takes in a single argument, specifying the parameter name.
databaseName = ScriptSession.getConfigProperty("DB_NAME");
The getConfigFileProperty() method may also to provide access to parameters stored a named property file which is independent to the one uploaded to the server. This method has two arguments. The first one specifies the file name and path of the file, and the second one specifies the parameter name to be fetched from the property file.
databaseName = ScriptSession.getConfigFileProperty("../conf/config.properties", "DB_NAME");
If
the file supplied as the first parameter to this method does not
exist, the method will throw an exception. If the file exists,
but the parameter does not exist within the file, the method will
return NULL.
Please also note, if using the file method, the path specified is relative to the BrightServer executable. The example above is if BrightServer is running as a service, but if the root directory's 'run.bat' is being used, the path would be "./conf/config.properties".