4.2.8.2. Storing Properties in Files

The properties, which determine configuration and deployment parameters, are specified in special properties files, named using *-app.properties pattern. Each application block contains a set of such files, including files from platform base projects and the current application file. Properties files set is defined as follows:

  • For web applications blocks (Middleware, Web Client, Web Portal) properties files set should be specified in web.xml in appPropertiesConfig parameter.

  • For Desktop Client block the standard way to specify properties files set is to override getDefaultAppPropertiesConfig() method in com.haulmont.cuba.desktop.App descendant class.

For example, properties files set of the Middleware block is specified in web/WEB-INF/web.xml file of the core module, and looks as follows:

classpath:cuba-app.properties
classpath:app.properties
file:${catalina.home}/conf/app-core/local.app.properties

The classpath: prefix means that corresponding file can be found in Java classpath, while file: prefix means that it should be accessed using file system path. Java system properties can be used, in this example it is catalina.homeTomcat root path.

Files declaration order is important as the values, specified in each subsequent file override the values of the same named properties, specified in the preceding files. This allows you to override platform properties in application.

The last file in the above set is local.app.properties. It can be used to override application properties upon deployment. If the file does not exist, it is ignored. However if application installation requires overriding of certain parameters (usually different URLs) you can create such file and place all overridden properties into it. It is easy to retain such file during further system updates.

For Desktop Client JVM command line arguments serve as an equivalent of local.app.properties. Properties loader of this block treats all the arguments containing "=" sign as a key/value pair and uses them to replace corresponding application properties specified in app.properties files.

The rules for data definition in *.properties files:

  • File encoding – UTF-8.

  • The key can contain Latin letters, numbers, periods and underscores.

  • The value is entered after (=) sign.

  • Do not quote values using " or ' brackets.

  • Set file paths either in UNIX (/opt/haulmont/) or Windows (c:\\haulmont\\) format.

  • You can use \n \t \r codes. The sign \ is a reserved code, use (\\) to insert it in value. See more in: http://docs.oracle.com/javase/tutorial/java/data/characters.html.

  • Use \ sign at the end of each line to enter a multi-line value.