commandbox.system.util

Class SystemSettings

lucee.Component
    extended by commandbox.system.util.SystemSettings

Copyright Since 2014 CommandBox by Ortus Solutions, Corp www.coldbox.org | www.ortussolutions.com I handled accessing environment variables and system properties

Class Attributes:
  • singleton
  •  
  • synchronized : false
  •  
  • accessors : false
  •  
  • persistent : false
  •  
  • author : Brad Wood, Luis Majano, Denny Valliant
  •  
    Property Summary
    type property default serializable required
    any commandService


    • access = public
    • returntype = any
    • inject = CommandService
    true false
    any interceptorService


    • access = public
    • returntype = any
    • inject = interceptorService
    true false
    Method Summary
    any expandDeepSystemSettings(any dataStructure, [any context='[runtime expression]'])
         Expands placeholders like ${foo} in all deep struct keys and array elements with the matching java prop or env var.
    any expandSystemSettings(string text, [any context='[runtime expression]'])
         Expands placeholders like ${foo} in a string with the matching java prop or env var.
    array getAllEnvironments()
         Return an array of environemnt context with the current one at the top.
    struct getAllEnvironmentsFlattened()
         Return a representation of the environemnt context including all parent contexts.
    struct getCurrentEnvironment([any parent='false'])
         Return current environment for the shell.
    any getEnv(string key, [any defaultValue])
         Retrieve an env value by name.
    any getSystemProperty(string key, [any defaultValue])
         Retrieve a Java System property by name.
    any getSystemSetting(string key, [any defaultValue])
         Retrieve a Java System property or env value by name.
    any setDeepSystemSettings([any dataStructure], [string prefix='interceptData'])
         Take a struct of data and set system settings for each deep key.
    any setSystemProperty(string key, string value)
         Set a Java System property.
    any setSystemSetting(string key, string value, [any inParent='false'])
         Set a System Setting into the current environment.
     
    Methods inherited from class lucee.Component
    None

    Property Detail

    commandService

    property any commandService

    Attributes:
    access - public
    required - false
    returntype - any
    inject - CommandService
    serializable - true

    interceptorService

    property any interceptorService

    Attributes:
    access - public
    required - false
    returntype - any
    inject - interceptorService
    serializable - true

    Method Detail

    expandDeepSystemSettings

    public any expandDeepSystemSettings(any dataStructure, [any context='[runtime expression]'])

    Expands placeholders like ${foo} in all deep struct keys and array elements with the matching java prop or env var. Will replace as many place holders that exist, but will skip escaped ones like \${do.not.expand.me} This will recursivley follow all nested structs and arrays.

    Parameters:
    dataStructure - A string, struct, or array to perform deep replacement on.
    context

    expandSystemSettings

    public any expandSystemSettings(string text, [any context='[runtime expression]'])

    Expands placeholders like ${foo} in a string with the matching java prop or env var. Will replace as many place holders that exist, but will skip escaped ones like \${do.not.expand.me}

    Parameters:
    text - The string to do the replacement on
    context

    getAllEnvironments

    public array getAllEnvironments()

    Return an array of environemnt context with the current one at the top


    getAllEnvironmentsFlattened

    public struct getAllEnvironmentsFlattened()

    Return a representation of the environemnt context including all parent contexts but not including Java system props and OS env vars flattended into a single struct.


    getCurrentEnvironment

    public struct getCurrentEnvironment([any parent='false'])

    Return current environment for the shell.

    Parameters:
    parent - Get the parent environment

    getEnv

    public any getEnv(string key, [any defaultValue])

    Retrieve an env value by name.

    Parameters:
    key - The name of the setting to look up.
    defaultValue - The default value to use if the key does not exist in the env

    getSystemProperty

    public any getSystemProperty(string key, [any defaultValue])

    Retrieve a Java System property by name.

    Parameters:
    key - The name of the setting to look up.
    defaultValue - The default value to use if the key does not exist in the system properties

    getSystemSetting

    public any getSystemSetting(string key, [any defaultValue])

    Retrieve a Java System property or env value by name.

    Parameters:
    key - The name of the setting to look up.
    defaultValue - The default value to use if the key does not exist in the system properties

    setDeepSystemSettings

    public any setDeepSystemSettings([any dataStructure], [string prefix='interceptData'])

    Take a struct of data and set system settings for each deep key

    Parameters:
    dataStructure - A string, struct, or array. Initial value should be a struct.
    prefix

    setSystemProperty

    public any setSystemProperty(string key, string value)

    Set a Java System property.

    Parameters:
    key - The name of the setting to set.
    value - The value to use

    setSystemSetting

    public any setSystemSetting(string key, string value, [any inParent='false'])

    Set a System Setting into the current environment

    Parameters:
    key - The name of the setting to set.
    value - The value to use
    inParent - Pass true to set the variable in the parent environment