com.pelzer.util
Class EnvironmentManager

java.lang.Object
  extended by com.pelzer.util.EnvironmentManager

public class EnvironmentManager
extends Object

Very simple wrapper class that pulls a few of the PropertyManager methods out into a more logical location, for instance getBuildNumber() or getHostname(), but ultimately delegates the work back to the PropertyManager. The setDefaultEnvironment(String) method is slightly smarter, as it sets a system property to override the default environment, and then calls PropertyManager.setDefaultEnvironment(String). This will result in a very clean initialization of a static main method class into a particular environment, if the following conditions are met:

  1. The class does not initialize any static variables that reference the pelzer-util system (ie a static logger instance)
  2. The class calls setDefaultEnvironment(String) first, before any pelzer-util method have been called (ie before any pelzer-util static initialization has happened)


Constructor Summary
EnvironmentManager()
           
 
Method Summary
static String getBuildNumber()
          Pulls 'build.number' from PropertyManager.version.properties.
static String getEnvironment()
           
static String getHostname()
          The first part of the hostname of this box, so for 'foo.bar.com', would return 'foo'.
static boolean isInitialized()
           
static void setDefaultEnvironment(String environment)
          Overrides and resets the PropertyManager to a new environment.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EnvironmentManager

public EnvironmentManager()
Method Detail

isInitialized

public static boolean isInitialized()
Returns:
true if the PropertyManager and Logging systems are fully initialized (ie, they've completed loading all property files and system properties.)

setDefaultEnvironment

public static void setDefaultEnvironment(String environment)
Overrides and resets the PropertyManager to a new environment.


getEnvironment

public static String getEnvironment()
Returns:
The current default environment that the PropertyManager is running against.

getBuildNumber

public static String getBuildNumber()
Pulls 'build.number' from PropertyManager.version.properties.


getHostname

public static String getHostname()
The first part of the hostname of this box, so for 'foo.bar.com', would return 'foo'.



Copyright © 2012. All Rights Reserved.