eeproperties

Introduction

EEProperties is the main class for the EEProperties package. The package provides a simple, consistent approach to configuration while allowing configuration files to be managed or overridden externally to the application.

The simplest usage is:

  • EEProperties.loadAll(<path list>); – to load all the configuration files from the list of paths specified
    • Path list is an ArrayList<String> object
  • EEProperties.get(“com.mysite.some.property.name”)

For configurations in a servlet container, two paths are usually needed:

  • First, the base path for the servlet
    • In Java, in the ‘init(servletConfig)’ servlet method – ‘servletConfig.getServletContext().getRealPath(“/”)’
    • In Groovy, in any controller – servletContext.getRealPath(“/”)
  • Second, the (external) directory tree root with the configuration files that override those in the application (WAR)
  • See also the bootstrap file option – net.olioinfo.eeproperties.runtime.additionalConfigurationPaths

The model supports standard Java properties file syntax, extended by eproperties syntax

EEProperties provides a mechanism for loading multiple set of Java properties files based on certain conventions.

  • Managed files have names of the form [environment]-ee.properties
  • Environment represents one of the strings ‘defaults’,‘production’,‘development’,‘test’
  • In any set of files, the ‘defaults’ file is always guaranteed to be loaded before any other
  • Later values of particular properties override earlier values
  • Properties loaded through this mechanism all share the same root (namespace)
  • A bootstrap configuration is loaded first to get things off the ground (this can be overridden) See EEPropertiesConfiguration documentation for further information.

Note particularly:

  • Since all properties share the same root, the names of properties themselves must be distinct

Internal Configuration

EEPropertiesConfiguration manages internal configuration for the EEProperties package itself.

All the core settings listed below may be overridden by suitable settings in a file named ‘net.olioinfo.eeproperties.bootstrap.fileName’, whose location is specified when starting the JVM using -D=net.olioinfo.eeproperties.bootstrap.properties=<absolute path>

The contents of the current bootstrap configuration file

net.olioinfo.eeproperties.runtime.environments = ("defaults","production","development","test")
net.olioinfo.eeproperties.runtime.environments.defaults = "defaults"
net.olioinfo.eeproperties.runtime.environment = "development"
#To specify additional paths to search for configuration files, specify a list of fully qualified directories
#separated by the ":" character, as for a standard Unix search path
#net.olioinfo.eeproperties.runtime.additionalConfigurationPaths = "
net.olioinfo.eeproperties.core.logging.level = "DEBUG"
net.olioinfo.eeproperties.core.logging.layout.class = "org.apache.log4j.PatternLayout"
# Beware the embedded tabs in the conversion pattern below - Do not change these (unless you know what you're doing)
net.olioinfo.eeproperties.core.logging.layout.conversionPattern = "%d{ISO8601}	[%z]	[%p]	[%h]	[%i]	[net.olioinfo.eeproperties]	%m%n"
#net.olioinfo.eeproperties.core.logging.appender.class = "org.apache.log4j.DailyRollingFileAppender"
net.olioinfo.eeproperties.core.logging.appender.filePattern = ".yyyy-MM-dd"
net.olioinfo.eeproperties.core.logging.logFileDir = "logs"
net.olioinfo.eeproperties.core.logging.logFileName = "net.olioinfo.eeproperties.log"

Build and other information

Source repository is at git://github.com/tflynn/eeproperties.git

Maven Access

    <dependency>
        <groupId>net.olioinfo</groupId>
        <artifactId>eeproperties</artifactId>
        <version>0.2</version>
    </dependency>
    ...
    <repository>
      <id>net-oilinfo</id>
      <url>http://myowndemo.com:8080/nexus/content/repositories/net-olioinfo</url>
    </repository>

(c) Copyright 1999-2010 - All rights reserved