Package org.apache.struts2.inject
Class ContainerBuilder
java.lang.Object
org.apache.struts2.inject.ContainerBuilder
Builds a dependency injection 
Container. The combination of
 dependency type and name uniquely identifies a dependency mapping; you can
 use the same name for two different types. Not safe for concurrent use.
 Adds the following factories by default:
- Author:
- crazybob@google.com (Bob Lee)
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic interfaceImplemented by classes which participate in building a container.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescription<T> ContainerBuilderConvenience method. Equivalent toalias(type, Container.DEFAULT_NAME, type).<T> ContainerBuilderMaps an existing factory to a new name.Maps a constant value to the given name.Maps a constant value to the given name.Maps a constant value to the given name.Maps a constant value to the given name.Maps a constant value to the given name.Maps a constant value to the given name.Maps a constant value to the given name.<E extends Enum<E>>
 ContainerBuilderMaps an enum to the given name.Maps a class to the given name.Maps a constant value to the given name.booleanConvenience method. Equivalent tocontains(type, Container.DEFAULT_NAME).booleancreate(boolean loadSingletons) Creates aContainerinstance.<T> ContainerBuilderConvenience method. Equivalent tofactory(type, Container.DEFAULT_NAME, type).<T> ContainerBuilderConvenience method. Equivalent tofactory(type, Container.DEFAULT_NAME, implementation).<T> ContainerBuilderConvenience method. Equivalent tofactory(type, Container.DEFAULT_NAME, implementation, scope).<T> ContainerBuilderConvenience method. Equivalent tofactory(type, name, type).<T> ContainerBuilderMaps an implementation class to a given dependency type and name.<T> ContainerBuilderMaps an implementation class to a given dependency type and name.<T> ContainerBuilderConvenience method. Equivalent tofactory(type, name, factory, Scope.PROTOTYPE).<T> ContainerBuilderMaps a factory to a given dependency type and name.<T> ContainerBuilderConvenience method. Equivalent tofactory(type, name, type, scope).<T> ContainerBuilderConvenience method. Equivalent tofactory(type, Container.DEFAULT_NAME, factory, Scope.PROTOTYPE).<T> ContainerBuilderConvenience method. Equivalent tofactory(type, Container.DEFAULT_NAME, factory, scope).<T> ContainerBuilderConvenience method. Equivalent tofactory(type, Container.DEFAULT_NAME, type, scope).injectStatics(Class<?>... types) Upon creation, theContainerwill inject static fields and methods into the given classes.voidsetAllowDuplicates(boolean val) 
- 
Constructor Details- 
ContainerBuilderpublic ContainerBuilder()Constructs a new builder.
 
- 
- 
Method Details- 
factorypublic <T> ContainerBuilder factory(Class<T> type, String name, Factory<? extends T> factory, Scope scope) Maps a factory to a given dependency type and name.- Type Parameters:
- T- type
- Parameters:
- type- of dependency
- name- of dependency
- factory- creates objects to inject
- scope- scope of injected instances
- Returns:
- this builder
 
- 
factoryConvenience method. Equivalent tofactory(type, Container.DEFAULT_NAME, factory, scope).- Type Parameters:
- T- type
- Parameters:
- type- of dependency
- factory- of dependency
- scope- scope of injected instances
- Returns:
- a container builder
- See Also:
 
- 
factoryConvenience method. Equivalent tofactory(type, name, factory, Scope.PROTOTYPE).- Type Parameters:
- T- type
- Parameters:
- type- of dependency
- name- of dependency
- factory- of dependency
- Returns:
- a container builder
- See Also:
 
- 
factoryConvenience method. Equivalent tofactory(type, Container.DEFAULT_NAME, factory, Scope.PROTOTYPE).- Type Parameters:
- T- type
- Parameters:
- type- of dependency
- factory- of dependency
- Returns:
- a container builder
- See Also:
 
- 
factorypublic <T> ContainerBuilder factory(Class<T> type, String name, Class<? extends T> implementation, Scope scope) Maps an implementation class to a given dependency type and name. Creates instances using the container, recursively injecting dependencies.- Type Parameters:
- T- type
- Parameters:
- type- of dependency
- name- of dependency
- implementation- class
- scope- scope of injected instances
- Returns:
- this builder
 
- 
factoryMaps an implementation class to a given dependency type and name. Creates instances using the container, recursively injecting dependencies. Sets scope to value from Scopedannotation on the implementation class. Defaults toScope.PROTOTYPEif no annotation is found.- Type Parameters:
- T- type
- Parameters:
- type- of dependency
- name- of dependency
- implementation- class
- Returns:
- this builder
 
- 
factoryConvenience method. Equivalent tofactory(type, Container.DEFAULT_NAME, implementation).- Type Parameters:
- T- type
- Parameters:
- type- of dependency
- implementation- class
- Returns:
- this builder
- See Also:
 
- 
factoryConvenience method. Equivalent tofactory(type, Container.DEFAULT_NAME, type).- Type Parameters:
- T- type
- Parameters:
- type- of dependency
- Returns:
- this builder
- See Also:
 
- 
factoryConvenience method. Equivalent tofactory(type, name, type).- Type Parameters:
- T- type
- Parameters:
- type- of dependency
- name- of dependency
- Returns:
- this builder
- See Also:
 
- 
factoryConvenience method. Equivalent tofactory(type, Container.DEFAULT_NAME, implementation, scope).- Type Parameters:
- T- type
- Parameters:
- type- of dependency
- implementation- class
- scope- the scope
- Returns:
- this builder
- See Also:
 
- 
factoryConvenience method. Equivalent tofactory(type, Container.DEFAULT_NAME, type, scope).- Type Parameters:
- T- type
- Parameters:
- type- of dependency
- scope- the scope
- Returns:
- this builder
- See Also:
 
- 
factoryConvenience method. Equivalent tofactory(type, name, type, scope).- Type Parameters:
- T- type
- Parameters:
- type- of dependency
- name- of dependency
- scope- the scope
- Returns:
- this builder
- See Also:
 
- 
aliasConvenience method. Equivalent toalias(type, Container.DEFAULT_NAME, type).- Type Parameters:
- T- type
- Parameters:
- type- of dependency
- alias- of dependency
- Returns:
- this builder
- See Also:
 
- 
aliasMaps an existing factory to a new name.- Type Parameters:
- T- type
- Parameters:
- type- of dependency
- name- of dependency
- alias- of to the dependency
- Returns:
- this builder
 
- 
constantMaps a constant value to the given name.- Parameters:
- name- name
- value- value
- Returns:
- this builder
 
- 
constantMaps a constant value to the given name.- Parameters:
- name- name
- value- value
- Returns:
- this builder
 
- 
constantMaps a constant value to the given name.- Parameters:
- name- name
- value- value
- Returns:
- this builder
 
- 
constantMaps a constant value to the given name.- Parameters:
- name- name
- value- value
- Returns:
- this builder
 
- 
constantMaps a constant value to the given name.- Parameters:
- name- name
- value- constant value
- Returns:
- this builder
 
- 
constantMaps a constant value to the given name.- Parameters:
- name- name
- value- value
- Returns:
- this builder
 
- 
constantMaps a constant value to the given name.- Parameters:
- name- name
- value- value
- Returns:
- this builder
 
- 
constantMaps a constant value to the given name.- Parameters:
- name- name
- value- value
- Returns:
- this builder
 
- 
constantMaps a class to the given name.- Parameters:
- name- name
- value- value
- Returns:
- this builder
 
- 
constantMaps an enum to the given name.- Type Parameters:
- E- value type
- Parameters:
- name- name
- value- value
- Returns:
- this builder
 
- 
injectStaticsUpon creation, theContainerwill inject static fields and methods into the given classes.- Parameters:
- types- for which static members will be injected
- Returns:
- this builder
 
- 
contains- Parameters:
- type- type of class
- name- name of class
- Returns:
- true if this builder contains a mapping for the given type and name.
 
- 
containsConvenience method. Equivalent tocontains(type, Container.DEFAULT_NAME).- Parameters:
- type- type of class
- Returns:
- true if this builder contains a mapping for the given type.
 
- 
createCreates aContainerinstance. Injects static members for classes which were registered usinginjectStatics(Class...).- Parameters:
- loadSingletons- If true, the container will load all singletons now. If false, the container will lazily load singletons. Eager loading is appropriate for production use while lazy loading can speed development.
- Returns:
- this builder
- Throws:
- IllegalStateException- if called more than once
 
- 
setAllowDuplicatespublic void setAllowDuplicates(boolean val) 
 
-