class ConfigurationLoader extends Object
Manages the process of creating Configuration objects, which control the runtime behaviour of Geb.
Typically usage of this class is hidden from the user as the Browser uses this class internally to load configuration based on its construction. If however custom configuration loading mechanics are necessary, users can use this class or a subclass of to create a Configuration object and construct the Browser with that.
Another avenue for custom configuration is usage of the build adapter. The build adapter that will be used with any loaded configurations will be what is provided by ConfigurationLoader.createBuildAdapter.
Type | Name and description |
---|---|
String |
environment |
Properties |
properties |
GroovyClassLoader |
specialClassLoader |
Constructor and description |
---|
ConfigurationLoader
() Configures the loader using the defaults. |
ConfigurationLoader
(String environment) Configures the loader with the given environment for parsing config scripts, and defaults for everything else. |
ConfigurationLoader
(String environment, Properties properties, GroovyClassLoader classLoader) Sets the loader environment. |
Type Params | Return Type | Name and description |
---|---|---|
|
protected BuildAdapter |
createBuildAdapter(GroovyClassLoader classLoader) Uses the build adapter factory to load a build adapter with the classLoader passed in. |
|
protected Object |
createConf(groovy.util.ConfigObject rawConfig, GroovyClassLoader classLoader) Creates a new Configuration backed by rawConfig with the properties
we were constructed with, the classLoader passed in and a build adapter. |
|
protected groovy.util.ConfigSlurper |
createSlurper(GroovyClassLoader classLoader) Creates a config slurper with environment we were constructed with (if any) and sets the slurpers classloader to the classloader we were constructed with. |
|
protected groovy.util.ConfigSlurper |
createSlurper() Creates a config slurper with environment we were constructed with (if any). |
|
protected Configuration |
doGetConf(String configFileResourcePath) |
|
protected Configuration |
doGetConfFromClass(String className) |
|
Configuration |
getConf() Creates a config using the default path for the config script and the default config class name. |
|
Configuration |
getConf(String configFileResourcePath) |
|
Configuration |
getConf(URL configLocation, GroovyClassLoader classLoader) Creates a config backed by the config script at the given URL. |
|
Configuration |
getConf(Class configClass, GroovyClassLoader classLoader) Creates a config backed by a given class. |
|
Configuration |
getConfFromClass(String className) |
|
protected Configuration |
getDefaultConf() Result of this method is used as the default configuration when there is no configuration script or class. |
|
String |
getDefaultConfigClassName() This implementation returns "GebConfig" |
|
String |
getDefaultConfigScriptResourcePath() This implementation returns "GebConfig.groovy" |
|
protected String |
getDefaultEnvironment() This implementation returns System.properties["geb.env"] |
|
protected Properties |
getDefaultProperties() This implementation returns System.properties |
|
protected GroovyClassLoader |
getDefaultSpecialClassLoader() This implementation returns a new GroovyClassLoader which uses the Thread.currentThread ( ) .contextClassLoader as the parent. |
|
protected groovy.util.ConfigObject |
loadRawConfig(URL configLocation, GroovyClassLoader classLoader) Reads the config scripts at configLocation with the createSlurper() |
|
protected groovy.util.ConfigObject |
loadRawConfig(Class configClass) Reads the config class with the createSlurper() |
|
protected groovy.util.ConfigObject |
loadRawConfig(groovy.util.ConfigSlurper slurper, URL source) |
|
protected groovy.util.ConfigObject |
loadRawConfig(groovy.util.ConfigSlurper slurper, Class source) |
|
protected Class |
tryToLoadClass(String className, ClassLoader loader) |
Configures the loader using the defaults.
Configures the loader with the given environment for parsing config scripts, and defaults for everything else.
Sets the loader environment.
If any of the parameters are null
, the appropriate getDefaultĀ«somethingĀ»()
method will be used to supply the value.
classLoader
- The loader to use to find classpath resources and to
load the build adapterenvironment
- If loading a config script, the environment to load it withproperties
- The properties given to created Configuration objects Uses the build adapter factory to load
a build adapter with the classLoader
passed in.
Creates a new Configuration backed by rawConfig
with the properties
we were constructed with, the classLoader
passed in and a build adapter.
Creates a config slurper with environment we were constructed with (if any) and sets the slurpers classloader to the classloader we were constructed with.
Creates a config slurper with environment we were constructed with (if any).
Creates a config backed by the classpath config script resource at the given path. This method is used by getConf(String).
The resource is first searched for using the special class loader (thread context loader by default), and then the class loader of this class if it wasn't found. If no classpath resource can be found at the given path null is returned.
The class loader that is used is then propagated to the created configuration object. This means that if it is the special loader it must have the same copy of the Geb classes as this class loader and any other classes Geb depends on.
configFileResourcePath
- the classpath relative path to the config script to use (if null
, default will be used).
Creates a config backed by the config class with a given name. This method is used by getConfFromClass(String).
The class is first searched for using the special class loader (thread context loader by default), and then the class loader of this class if it wasn't found. If no such class can be found, null is returned.
The class loader that is used is then propagated to the created configuration object. This means that if it is the special loader it must have the same copy of the Geb classes as this class loader and any other classes Geb depends on.
configFileResourcePath
- the classpath relative path to the config script to use (if null
, default will be used).Creates a config using the default path for the config script and the default config class name. It loads the configuration from class only if the configuration script was not found.
Uses getDefaultConfigScriptResourcePath() for the path and getDefaultConfigClassName() for the class name.
Creates a config backed by the classpath config script resource at the given path.
The resource is first searched for using the special class loader (thread context loader by default), and then the class loader of this class if it wasn't found. If no classpath resource can be found at the given path, an empty config object will be used with the class loader of this class.
The class loader that is used is then propagated to the created configuration object. This means that if it is the special loader it must have the same copy of the Geb classes as this class loader and any other classes Geb depends on.
configFileResourcePath
- the classpath relative path to the config script to use (if null
, default will be used).Creates a config backed by the config script at the given URL.
If URL is null
or doesn't exist, an exception will be thrown.
configLocation
- The absolute URL to the config script to use for the config (cannot be null
)classLoader
- The class loader to load the config script with (must be the same or a child of the class loader of this class)Creates a config backed by a given class.
configClass
- Class that contains configurationclassLoader
- The class loader to load the config script with (must be the same or a child of the class loader of this class)
Creates a config backed by the config class with a given name.
The class is first searched for using the special class loader (thread context loader by default), and then the class loader of this class if it wasn't found. If no such class can be found, an empty config object will be used with the class loader of this class.
The class loader that is used is then propagated to the created configuration object. This means that if it is the special loader it must have the same copy of the Geb classes as this class loader and any other classes Geb depends on.
configFileResourcePath
- the classpath relative path to the config script to use (if null
, default will be used).Result of this method is used as the default configuration when there is no configuration script or class. This implementation returns a configuration as if the loaded configuration script/class was empty.
This implementation returns "GebConfig"
This implementation returns "GebConfig.groovy"
This implementation returns System.properties["geb.env"]
This implementation returns System.properties
This implementation returns a new GroovyClassLoader which uses the
Thread.currentThread ( ) .contextClassLoader
as the parent.
Reads the config scripts at configLocation
with the createSlurper()
Reads the config class with the createSlurper()
Groovy API Documentation for Geb 6.0 - Licensed under the Apache License, Version 2.0 - http://www.gebish.org