public class MockContainer extends Object implements Container
DEFAULT_NAME
Constructor and Description |
---|
MockContainer() |
Modifier and Type | Method and Description |
---|---|
<T> T |
getInstance(Class<T> type)
Convenience method. Equivalent to
getInstance(type,
DEFAULT_NAME) . |
<T> T |
getInstance(Class<T> type,
String name)
Gets an instance of the given dependency which was declared in
ContainerBuilder . |
Set<String> |
getInstanceNames(Class<?> type)
Gets a set of all registered names for the given type
|
<T> T |
inject(Class<T> implementation)
Creates and injects a new instance of type
implementation . |
void |
inject(Object o)
Injects dependencies into the fields and methods of an existing object.
|
void |
removeScopeStrategy()
Removes the scope strategy for the current thread.
|
void |
setScopeStrategy(Scope.Strategy scopeStrategy)
Sets the scope strategy for the current thread.
|
public void inject(Object o)
Container
public <T> T inject(Class<T> implementation)
Container
implementation
.public <T> T getInstance(Class<T> type, String name)
Container
ContainerBuilder
.getInstance
in interface Container
T
- typetype
- of dependencyname
- of dependencypublic <T> T getInstance(Class<T> type)
Container
getInstance(type,
DEFAULT_NAME)
.getInstance
in interface Container
T
- typetype
- of dependencypublic Set<String> getInstanceNames(Class<?> type)
Container
getInstanceNames
in interface Container
type
- The instance typepublic void setScopeStrategy(Scope.Strategy scopeStrategy)
Container
setScopeStrategy
in interface Container
scopeStrategy
- scope strategypublic void removeScopeStrategy()
Container
removeScopeStrategy
in interface Container
Copyright © 2000–2020 Apache Software Foundation. All rights reserved.