How to set application's properties

by Michela Frigerio
874 views Published on Feb 16, 2023
Applies to: 9.0 or higher
Table of contents

Introduction

The use of static values is often required when designing an application. Static values may depend on the application’s deployment environment. You can set these static values in a dedicated *.properties file, which is loaded at the application startup. This file contains a list of key-value pairs. You can then use the keys inside Web, Mobile, DataService and BPM apps as placeholders. At runtime, all the keys are replaced with the corresponding values.

Properties File Name and Location

By default, each project’s type has a dedicated application’s properties file name and location. Have a look at the following table to know the default configuration for each project:

PROJECT TYPE FILE NAME LOCATION

BPM

webratio-server.properties

WEB-INF/conf

Web

webratio-client.properties

WEB-INF/conf

Mobile

webratio-client.properties

www/conf

DataService

webratio-server.properties

WEB-INF/conf

Change default file name and location

You can change the file name and location of the application’s properties file in the AppConfig.properties file placed in the WEB-INF/conf directory of the application. This feature allows you to share the same properties file among different applications. You need to configure the name of a system property containing the location of the file and, optionally, a new name for the properties file.

#Name of the JVMArg containing the path for all property files (both server and client).
externalPropertyDirectoryJVMArg=<properties-file-system-property-name>

#File name to use instead of webratio-client.properties (for Web projects)
externalClientPropertyFileName=<custom-name>

File name to use instead of webratio-server.properties (for Web, DataService, BPM projects)
externalServerPropertyFileName=<custom-name>

# Example
externalLogPropertyDirectoryJVMArg=propertiesConfigDir
externalClientPropertyFileName=WebRatio.properties
externalServerPropertyFileName=WebRatio.properties

The system property must then be configured in the application server using the following syntax. Please be aware that this configuration must be merged with the one already present in the application server.

set JAVA_OPTS = -propertiesConfigDir=<absolute-path-to-properties-file-directory>

# Example
set JAVA_OPTS = -propertiesConfigDir=C:\myComputer\myApp\application-properties