com.isomorphic.base

## Class Config

- java.lang.Object
- - org.apache.commons.collections.map.AbstractMapDecorator
  - - com.isomorphic.collections.DataTypeMap
    - - com.isomorphic.base.Config

- All Implemented Interfaces:
    java.util.Map

      public class Config
      extends DataTypeMap

  This class provides config parameters to all the Java classes in the SmartClient Framework by reading a series of .properties files including server.properties.

  If running in a servlets environment, you must use the "Init" servlet and use <load-on-startup> to ensure it initializes before any calls are made to this class.

  Then the Config class can be used to read settings as follows: ``

       Config config = Config.getGlobal();
       String propertyValue = (String)config.getProperty("propertyName");

  If running outside of a servlet environment, the following call should be made from the startup thread of the application before any Config APIs are called:

  ``

       Config.initGlobalConfig();

- - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.lang.Object` | `getProperty(java.lang.String propertyName)` Returns a property extracted from the SmartClient global configuration file, server.properties.
    `java.lang.Object` | `put(java.lang.Object key, java.lang.Object value)` Programmatically inject a value into the global config.
    `void` | `putAll(java.util.Map map)` Programmatically inject a set of values in a Map into the global config.

- - ### Method Detail

    - #### getProperty

          public static java.lang.Object getProperty(java.lang.String propertyName)

      Returns a property extracted from the SmartClient global configuration file, server.properties. Note that the Init servlet must be used if you wish to make use of this API.
      Parameters:
        `propertyName` - The name of the property to retrieve
      Returns:
        The property value, or null if it was not found

    - #### put

          public java.lang.Object put(java.lang.Object key,
                                      java.lang.Object value)

      Programmatically inject a value into the global config. Note, the timing of this is key. Your programmatic overrides or additions must take place after the core config has loaded from the framework's various `.properties` files, but before anything else in the system.

      The simplest way to achieve this is to have your programmatic changes to config invoked from a servlet which is configured in `web.xml` with a `load-on-startup` parameter of 2, like this:

           <servlet>
               <servlet-name>MyConfigChanges</servlet-name>
               <servlet-class>com.company.servlet.MyConfigChanges</servlet-class>
               <load-on-startup>2</load-on-startup>
           </servlet>

      The setting of "2" is important, because your code needs to run after the SmartClient Init servlet, but before anything else.

      If running outside of a servlet environment, you should invoke your config override code from the startup thread of the application, after the call to `Config.initGlobalConfig()` described in the class overview docs, but before any Config APIs are called.

      Overrides:
        `put` in class `org.apache.commons.collections.map.AbstractMapDecorator`
      Parameters:
        `key` - The key of the property to set
        `value` - The new value for the property
      Returns:
        The property's old value, or null if it was not previously set

    - #### putAll

          public void putAll(java.util.Map map)

      Programmatically inject a set of values in a Map into the global config. See `Config.put(Object, Object)` for important information about timing issues associated with this API.
      Overrides:
        `putAll` in class `org.apache.commons.collections.map.AbstractMapDecorator`
      Parameters:
        `map` - A Map of property values to apply to the config