public abstract class BindingsSpecAction extends Object implements Action<BindingsSpec>, BindingsSpec
Action<BindingsSpec> implementations.| Constructor and Description |
|---|
BindingsSpecAction() |
| Modifier and Type | Method and Description |
|---|---|
void |
add(Iterable<? extends Module> modules)
Adds the bindings from the given modules.
|
void |
add(Module... modules)
Adds the bindings from the given modules.
|
void |
bind(Class<?> type)
Add a binding for the given type.
|
<T> void |
bind(Class<? super T> publicType,
T instance)
Add a binding for the given public type, to the given implementing instance.
|
<T> void |
bind(Class<T> publicType,
Class<? extends T> implType)
Add a binding for the given public type, to the given implementation type.
|
<T> void |
bind(T instance)
Add a binding for the given object to its concrete type.
|
<T extends Module> |
config(Class<T> moduleClass)
Retrieves the module that has been added with the given type for configuration.
|
protected abstract void |
execute()
Implementations can naturally use the
BindingsSpec API for the duration of this method. |
void |
execute(BindingsSpec bindingsSpec)
Delegates to
execute(), using the given chain for delegation. |
protected BindingsSpec |
getBindingsSpec() |
LaunchConfig |
getLaunchConfig()
The launch config for the application.
|
void |
init(Action<Injector> action)
Registers an action to operate on the injector when it has been finalized.
|
void |
init(Class<? extends Runnable> clazz)
Registers a runnable to instantiated via dependency injection when the injector is created from this module registry.
|
<T> void |
provider(Class<T> publicType,
Class<? extends javax.inject.Provider<? extends T>> providerType)
Add a binding for the given public type, to the given provider type.
|
protected BindingsSpec getBindingsSpec() throws IllegalStateException
IllegalStateExceptionpublic final void execute(BindingsSpec bindingsSpec) throws Exception
execute(), using the given chain for delegation.execute in interface Action<BindingsSpec>bindingsSpec - the bindings specException - any thrown by execute()protected abstract void execute()
throws Exception
BindingsSpec API for the duration of this method.Exception - anypublic LaunchConfig getLaunchConfig()
getLaunchConfig in interface BindingsSpecpublic void add(Module... modules)
add in interface BindingsSpecmodules - modules whose bindings should be addedpublic void add(Iterable<? extends Module> modules)
add in interface BindingsSpecmodules - modules whose bindings should be addedpublic <T extends Module> T config(Class<T> moduleClass) throws NoSuchModuleException
This can be used to configure modules that have already been added by some other mechanism.
config in interface BindingsSpecT - the type of the module to retrievemoduleClass - the type of the module to retrieveNoSuchModuleException - if no module has been added with the given typepublic void bind(Class<?> type)
bind in interface BindingsSpectype - the type to add a binding forpublic <T> void bind(Class<T> publicType, Class<? extends T> implType)
bind in interface BindingsSpecT - the public type of the bindingpublicType - the public type of the bindingimplType - the class implementing the public typepublic <T> void bind(Class<? super T> publicType, T instance)
bind in interface BindingsSpecT - the public type of the bindingpublicType - the public type of the bindinginstance - the instance that implements the public typepublic <T> void bind(T instance)
bind in interface BindingsSpecT - the type of the bindinginstance - the instance to bindpublic <T> void provider(Class<T> publicType, Class<? extends javax.inject.Provider<? extends T>> providerType)
provider in interface BindingsSpecT - The public type of the objectpublicType - the public type of the objectproviderType - the type of the provider for the objectpublic void init(Action<Injector> action)
This can be used to do post processing of registered objects or application initialisation.
init in interface BindingsSpecaction - the action to execute against the constructed injectorpublic void 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 BindingsSpecclazz - the class of the runnable to execute as an init action