Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

Organize applications' multiple environment configurations

Use a mechanism to classify configuration parameters

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone

Configuration parameters are the values that allow you to configure the behavior of your applications without changing any code. These values control how parts of the application look or act. String messages, IP addresses, user interface layout measures, and the maximum number of objects in cache memory are sample configuration parameters commonly found in software applications.

Property files and XML document files are often used to organize application configuration parameters. Usually these configuration files are read by an application when it first starts up. A property file contains a set of strings, where properties are stated with the syntax name=value. On the other hand, XML document files, when used as configuration files, provide configuration parameters in an XML element <name>value</name> syntax. The following are sample configuration parameters displayed as a property file and as an XML configuration file.

Sample author.properties configuration file

 name.first=paulo
name.last=caroli
url=www.caroli.org


Sample author.xml configuration file

 <?xml version="1.0" encoding="ISO-8859-1" ?>
<author>
    <name>
        <first>paulo</first>
        <last>caroli</last>
    </name>
    <url>www.caroli.org</url>
</author>



In simplistic application development, configuration parameters and configuration files are not explicitly delineated. In such applications, configuration values are embedded in the application's code; these are usually called hard-coded values. Applications containing hard-coded values are difficult to alter. To simply change a hard-coded value, the application's code must be altered, recompiled, and redeployed. Also, hard-coded values require a developer's expertise. While property files can be easily altered by nondevelopers, hard-coded value changes require a developer to locate and implement the configuration value changes.

Using configuration files is highly recommended, but managing configuration parameters grows more complicated for applications that execute in several environments. Common in software organizations, some applications execute in distinct runtime environments according to the company's development phases. In my company, during an application release lifecycle, the application executes in development, integration, quality assurance, staging, and production environments. Each environment requires different configuration files and values. For example, the maximum number of objects in cache memory might be 10,000 in a production environment, while, in a development environment, a much lower value is used during alpha tests.

This article introduces a configuration mechanism, a uniform solution for dealing with all of a Java application's configuration parameters regardless of environments. The proposed configuration mechanism is composed of three interconnecting parts: configuration folder schema, configuration parameter reader, and launch command outline. The figure below illustrates each of the mechanism's parts. The following sections address each part.

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone
Comment
Login
Forgot your account info?
Add comment
Anonymous comments subject to approval. Register here for member benefits.
Have a JavaWorld account? Log in here. Register now for a free account.
Resources