public interface GroovyBindingsSpec extends BindingsSpec
BindingsSpec
.Modifier and Type | Method and Description |
---|---|
GroovyBindingsSpec |
add(Class<? extends Module> moduleClass) |
<C,T extends ConfigurableModule<C>> |
add(Class<T> moduleClass,
Action<? super C> configuration) |
GroovyBindingsSpec |
add(Module module)
Adds the bindings from the given modules.
|
GroovyBindingsSpec |
bind(Class<?> type)
Add a binding for the given type.
|
<T> GroovyBindingsSpec |
bind(Class<T> publicType,
Class<? extends T> implType)
Add a binding for the given public type, to the given implementation type.
|
GroovyBindingsSpec |
binder(Action<? super Binder> action)
Adds bindings by directly configuring a
Binder . |
<T> GroovyBindingsSpec |
bindInstance(Class<? super T> publicType,
T instance)
Add a binding for the given public type, to the given implementing instance.
|
<T> GroovyBindingsSpec |
bindInstance(T instance)
Add a binding for the given object to its concrete type.
|
<T extends Module> |
config(Class<T> moduleClass,
Consumer<? super T> configurer)
Retrieves the module that has been added with the given type for configuration.
|
GroovyBindingsSpec |
init(Action<? super Injector> action)
Registers an action to operate on the injector when it has been finalized.
|
GroovyBindingsSpec |
init(Class<? extends Runnable> clazz)
Registers a runnable to instantiated via dependency injection when the injector is created from this module registry.
|
GroovyBindingsSpec |
init(Closure<?> closure)
Adds a closure based application initializer.
|
<T> GroovyBindingsSpec |
provider(Class<T> publicType,
Provider<? extends T> provider)
Add a binding for the given public type, to the given provider.
|
<T> GroovyBindingsSpec |
providerType(Class<T> publicType,
Class<? extends Provider<? extends T>> providerType)
Add a binding for the given public type, to the given provider type.
|
getLaunchConfig
GroovyBindingsSpec init(@DelegatesTo(value=java.lang.Void.class,strategy=2) Closure<?> closure)
The closure can declare parameters, that will be injected. That is, parameters must be typed and implementations of such types must be provided by the modules.
closure
- The initializerthis
GroovyBindingsSpec add(Module module)
add
in interface BindingsSpec
module
- modules whose bindings should be addedGroovyBindingsSpec add(Class<? extends Module> moduleClass)
add
in interface BindingsSpec
<C,T extends ConfigurableModule<C>> GroovyBindingsSpec add(Class<T> moduleClass, Action<? super C> configuration)
add
in interface BindingsSpec
<T extends Module> GroovyBindingsSpec config(Class<T> moduleClass, Consumer<? super T> configurer) throws NoSuchModuleException
This can be used to configure modules that have already been added by some other mechanism.
config
in interface BindingsSpec
T
- the type of the module to retrievemoduleClass
- the type of the module to retrieveconfigurer
- the configurer of the moduleNoSuchModuleException
- if no module has been added with the given typeGroovyBindingsSpec binder(Action<? super Binder> action)
Binder
.binder
in interface BindingsSpec
action
- the binder configurationGroovyBindingsSpec bind(Class<?> type)
bind
in interface BindingsSpec
type
- the type to add a binding for<T> GroovyBindingsSpec bind(Class<T> publicType, Class<? extends T> implType)
bind
in interface BindingsSpec
T
- the public type of the bindingpublicType
- the public type of the bindingimplType
- the class implementing the public type<T> GroovyBindingsSpec bindInstance(Class<? super T> publicType, T instance)
bindInstance
in interface BindingsSpec
T
- the public type of the bindingpublicType
- the public type of the bindinginstance
- the instance that implements the public type<T> GroovyBindingsSpec bindInstance(T instance)
bindInstance
in interface BindingsSpec
T
- the type of the bindinginstance
- the instance to bind<T> GroovyBindingsSpec providerType(Class<T> publicType, Class<? extends Provider<? extends T>> providerType)
providerType
in interface BindingsSpec
T
- The public type of the objectpublicType
- the public type of the objectproviderType
- the type of the provider for the object<T> GroovyBindingsSpec provider(Class<T> publicType, Provider<? extends T> provider)
provider
in interface BindingsSpec
T
- The public type of the objectpublicType
- the public type of the objectprovider
- the provider for the objectGroovyBindingsSpec init(Action<? super Injector> action)
This can be used to do post processing of registered objects or application initialisation.
init
in interface BindingsSpec
action
- the action to execute against the constructed injectorGroovyBindingsSpec init(Class<? extends Runnable> clazz)
This facilitates writing a Runnable
implementation that uses constructor injection to get hold of what it needs to for the initialization.
init
in interface BindingsSpec
clazz
- the class of the runnable to execute as an init action