About the Properties file

Version 10.1 by Kieran Kelleher on 2007/10/10 15:23

Introduction

Most applications need a place to hold application configuration information. In java, a file with simple entries in traditional java.util.Properties format can be read and merged with the System properties, usually at application launch time. The traditional (as distinct from the XML format supported by java 1.5) simple format of a java properties file is like this:

myproperty=12345
myotherproperty=This is a sentence

WebObjects manages application preferences using a similar mechanism implemented by its com.webobjects.foundation.NSProperties class. The file format is as per the spec. In many references you will see specs say that a certain file is in java.io.Properties file format, however if I am not mistaken, they really mean the java.util.Properties, since even as far back as Java 1.1 API, there was no such class as java.io.Properties.

In any case, WebObjects directly supports the use of Java 1.4 style properties entries in the file named Resources/Properties in the woa and framework bundle format.

Using Properties in WebObjects

For a traditional WebObjects application, Properties are read first from the framework bundles and finally from the application bundle. Hence frameworks can have default values in their Properties file and those framework configuration properties can be over-ridden in the application's Properties file

No coding is needed to use property entries in the Properties file. WebObjects automatically reads them in at application launch time and merges them with the system properties, so they can be accessed using System.getProperty

Enhanced Properties management in WOnder

Project WOnder enhances the use of the traditional WebObjects Properties file in a number of ways:

ERXProperties

WOnder introduces the class ERXProperties that provides enhancements to the kind and format of Properties files

Configurability

Firstly, WOnder makes many useful settings available as Properties which are not available as simple Properties entries in traditional WebObjects applications. Some examples are:

{

User Properties

If your user name is 'joe', then in your WebObjects application, you can create a file named Properties.joe which is read in last when joe launches his WebObjects app in his Eclipse development enviromnent. This is useful for development teams. Each team member can have properties specific to his/her own development enviromnent such as smtp server, logging properties, databasem connection dictionary settings, etc.