|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | PROPERTY | CONSTR | METHOD | DETAIL: FIELD | PROPERTY | CONSTR | METHOD |
java.lang.Objectgeb.ConfigurationLoader
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 createBuildAdapter()
Nested Class Summary | |
---|---|
static class |
ConfigurationLoader.UnableToLoadException
|
Property Summary | |
---|---|
BuildAdapter |
buildAdapter
|
String |
environment
|
Properties |
properties
|
GroovyClassLoader |
specialClassLoader
|
Constructor Summary | |
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. |
Method Summary | |
---|---|
protected BuildAdapter
|
createBuildAdapter(GroovyClassLoader classLoader)
Uses the build adapter factory to load a build adapter with the classLoader we were constructed with. |
protected def
|
createConf(groovy.util.ConfigObject rawConfig, GroovyClassLoader classLoader)
Creates a new Configuration backed by rawConfig with the properties and classLoader we were constructed with, 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. |
Configuration
|
getConf()
Creates a config using the default path for the config script. |
Configuration
|
getConf(String configFileResourcePath)
Creates a config backed by the classpath config script resource at the given path. |
Configuration
|
getConf(URL configLocation, GroovyClassLoader classLoader)
Creates a config backed by the config script at the given URL. |
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() |
Methods inherited from class Object | |
---|---|
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
Property Detail |
---|
final BuildAdapter buildAdapter
final String environment
final Properties properties
final GroovyClassLoader specialClassLoader
Constructor Detail |
---|
ConfigurationLoader()
ConfigurationLoader(String environment)
ConfigurationLoader(String environment, Properties properties, GroovyClassLoader classLoader)
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
Method Detail |
---|
protected BuildAdapter createBuildAdapter(GroovyClassLoader classLoader)
protected def createConf(groovy.util.ConfigObject rawConfig, GroovyClassLoader classLoader)
protected groovy.util.ConfigSlurper createSlurper(GroovyClassLoader classLoader)
Configuration getConf()
Uses getDefaultConfigScriptResourcePath() for the path.
Configuration getConf(String configFileResourcePath)
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).
Configuration getConf(URL configLocation, GroovyClassLoader classLoader)
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)
String getDefaultConfigScriptResourcePath()
protected String getDefaultEnvironment()
protected Properties getDefaultProperties()
protected GroovyClassLoader getDefaultSpecialClassLoader()
protected groovy.util.ConfigObject loadRawConfig(URL configLocation, GroovyClassLoader classLoader)
Groovy API Documentation for geb-core 0.6.0 - Licensed under the Apache License, Version 2.0 - http://www.gebish.org