Groovy Documentation

groovy.util
[Groovy] Class ConfigSlurper

java.lang.Object
  groovy.util.ConfigSlurper

class ConfigSlurper
extends java.lang.Object

ConfigSlurper is a utility class for reading configuration files defined in the form of Groovy scripts. Configuration settings can be defined using dot notation or scoped using closures


   grails.webflow.stateless = true
    smtp {
        mail.host = 'smtp.myisp.com'
        mail.auth.user = 'server'
    }
    resources.URL = "http://localhost:80/resources"
 

Settings can either be bound into nested maps or onto a specified JavaBean instance. In the case of the latter an error will be thrown if a property cannot be bound.

Authors:
Graeme Rocher
Since:
1.5


Property Summary
static java.lang.Object ENV_SETTINGS

GroovyClassLoader classLoader

java.lang.String environment

 
Constructor Summary
ConfigSlurper()

ConfigSlurper(java.lang.String env)

Constructs a new ConfigSlurper instance using the given environment

 
Method Summary
ConfigObject parse(java.util.Properties properties)

Parses a ConfigObject instances from an instance of java.util.Properties

ConfigObject parse(java.lang.String script)

Parse the given script as a string and return the configuration object

ConfigObject parse(java.lang.Class scriptClass)

Create a new instance of the given script class and parse a configuration object from it

ConfigObject parse(Script script)

Parse the given script into a configuration object (a Map) (This method creates a new class to parse the script each time it is called.)

ConfigObject parse(java.net.URL scriptLocation)

Parses a Script represented by the given URL into a ConfigObject

ConfigObject parse(Script script, java.net.URL location)

Parses the passed groovy.lang.Script instance using the second argument to allow the ConfigObject to retain an reference to the original location other Groovy script

void setBinding(java.util.Map vars)

Sets any additional variables that should be placed into the binding when evaluating Config scripts

 
Methods inherited from class java.lang.Object
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Property Detail

ENV_SETTINGS

static final java.lang.Object ENV_SETTINGS


classLoader

GroovyClassLoader classLoader


environment

java.lang.String environment


 
Constructor Detail

ConfigSlurper

ConfigSlurper()


ConfigSlurper

ConfigSlurper(java.lang.String env)
Constructs a new ConfigSlurper instance using the given environment
Parameters:
env - The Environment to use


 
Method Detail

parse

ConfigObject parse(java.util.Properties properties)
Parses a ConfigObject instances from an instance of java.util.Properties
Parameters:
The - java.util.Properties instance


parse

ConfigObject parse(java.lang.String script)
Parse the given script as a string and return the configuration object
See Also:
ConfigSlurper.parse


parse

ConfigObject parse(java.lang.Class scriptClass)
Create a new instance of the given script class and parse a configuration object from it
See Also:
ConfigSlurper.parse


parse

ConfigObject parse(Script script)
Parse the given script into a configuration object (a Map) (This method creates a new class to parse the script each time it is called.)
Parameters:
script - The script to parse
Returns:
A Map of maps that can be navigating with dot de-referencing syntax to obtain configuration entries


parse

ConfigObject parse(java.net.URL scriptLocation)
Parses a Script represented by the given URL into a ConfigObject
Parameters:
scriptLocation - The location of the script to parse
Returns:
The ConfigObject instance


parse

ConfigObject parse(Script script, java.net.URL location)
Parses the passed groovy.lang.Script instance using the second argument to allow the ConfigObject to retain an reference to the original location other Groovy script
Parameters:
script - The groovy.lang.Script instance
location - The original location of the Script as a URL
Returns:
The ConfigObject instance


setBinding

void setBinding(java.util.Map vars)
Sets any additional variables that should be placed into the binding when evaluating Config scripts


 

Groovy Documentation