com.pelzer.util
Class PropertyManager

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

public class PropertyManager
extends Object

This class is used to condense and maintain the myriad .property files used by the system. It provides a layer of abstraction which allows us to migrate from *many* files, down to one, or even to pull our properties from a database, with little or no code modifications on dependent classes.


Nested Class Summary
static class PropertyManager.ManagedProperties
          This class emulates a java.util.Properties object, but doesn't quite support all its methods.
static class PropertyManager.PropertyProcessor
          Performs preprocessing on the PropertyManager.properties file, performing #include processing, obfuscation, etc.
 
Method Summary
static List<Map.Entry<String,String>> getAllProperties(String environment)
           
static String getBuildNumber()
           
static String getEnvironment()
           
static String getHostname()
           
static String getLocalizedProperty(String key)
           
static String getLocalizedProperty(String namespace, String key)
           
static String getLocalizedProperty(String namespace, String key, String defaultValue)
          Allows retrieval of localized properties set up for SPECIFIC hosts.
static PropertyManager.ManagedProperties getProperties(String namespace)
           
static String getProperty(String key)
           
static String getProperty(String namespace, String key)
           
static String getProperty(String namespace, String key, String defaultValue)
           
static boolean isDEV()
           
static boolean isPROD()
           
static boolean isTEST()
           
static void override(String key, String value)
          Sets a property manually: You'd generally only call this method from a unit-test, to make sure a certain property was set correctly...
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getBuildNumber

public static String getBuildNumber()

getHostname

public static String getHostname()

getProperties

public static PropertyManager.ManagedProperties getProperties(String namespace)

getProperty

public static String getProperty(String key)

getProperty

public static String getProperty(String namespace,
                                 String key)

getProperty

public static String getProperty(String namespace,
                                 String key,
                                 String defaultValue)

getLocalizedProperty

public static String getLocalizedProperty(String key)

getLocalizedProperty

public static String getLocalizedProperty(String namespace,
                                          String key)

getLocalizedProperty

public static String getLocalizedProperty(String namespace,
                                          String key,
                                          String defaultValue)
Allows retrieval of localized properties set up for SPECIFIC hosts. Calling getLocalizedProperty("foo.bar.BLAH") on the machine 'wintermute' is equivilant to doing getProperty("WINTERMUTE.foo.bar.BLAH"). Machine names are always uppercase, and never have sub-domains (ie WINTERMUTE and not WINTERMUTE.PELZER.COM)


getEnvironment

public static String getEnvironment()

isDEV

public static boolean isDEV()
Returns:
true if the environment is DEV

isTEST

public static boolean isTEST()
Returns:
true if the environment is TEST

isPROD

public static boolean isPROD()
Returns:
true if the environment is PROD

getAllProperties

public static List<Map.Entry<String,String>> getAllProperties(String environment)

override

public static void override(String key,
                            String value)
Sets a property manually: You'd generally only call this method from a unit-test, to make sure a certain property was set correctly...



Copyright © 2012. All Rights Reserved.