|
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. |
protected groovy.util.ConfigSlurper
|
createSlurper()
Creates a config slurper with environment we were constructed with (if any). |
protected Configuration
|
doGetConf(String configFileResourcePath)
Creates a config backed by the classpath config script resource at the given path. |
protected Configuration
|
doGetConfFromClass(String className)
Creates a config backed by the config class with a given name. |
Configuration
|
getConf()
Creates a config using the default path for the config script and the default config class name. |
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. |
Configuration
|
getConf(Class configClass, GroovyClassLoader classLoader)
Creates a config backed by a given class. |
Configuration
|
getConfFromClass(String className)
Creates a config backed by the config class with a given name. |
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, def source)
|
protected Class
|
tryToLoadClass(String className, ClassLoader loader)
|
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)
protected groovy.util.ConfigSlurper createSlurper()
protected Configuration doGetConf(String configFileResourcePath)
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).
protected Configuration doGetConfFromClass(String className)
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).
Configuration getConf()
Uses getDefaultConfigScriptResourcePath() for the path and getDefaultConfigClassName() for the class name.
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)
Configuration getConf(Class configClass, GroovyClassLoader classLoader)
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)
Configuration getConfFromClass(String className)
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).
protected Configuration getDefaultConf()
String getDefaultConfigClassName()
String getDefaultConfigScriptResourcePath()
protected String getDefaultEnvironment()
protected Properties getDefaultProperties()
protected GroovyClassLoader getDefaultSpecialClassLoader()
protected groovy.util.ConfigObject loadRawConfig(URL configLocation, GroovyClassLoader classLoader)
protected groovy.util.ConfigObject loadRawConfig(Class configClass)
protected groovy.util.ConfigObject loadRawConfig(groovy.util.ConfigSlurper slurper, def source)
protected Class tryToLoadClass(String className, ClassLoader loader)
Groovy API Documentation for geb-core 0.6.3 - Licensed under the Apache License, Version 2.0 - http://www.gebish.org