public class InjectionContext extends Object implements Closeable
| Constructor and Description |
|---|
InjectionContext()
Constructor.
|
InjectionContext(InjectionContext parent)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(ObjectProvider provider)
Add an object provider.
|
void |
close() |
<T> T |
getObject(Class<T> type)
Retrieve an object by its implemented type.
|
Object |
getObjectById(String id)
Retrieve an object by its id.
|
<T> T |
getObjectById(String id,
Class<T> type)
Retrieve an object by its id and implemented type.
|
InjectionContext |
getParent() |
String |
getProperty(String name)
Return a property or null if not set.
|
static InjectionContext |
getRoot() |
Object |
searchObjectInChildren(String id)
Search an object by ID in this context and its descendents.
|
void |
setObject(String id,
Class<?> type,
Object instance,
ObjectMethod destroy)
Add a singleton by id, equivalent to call
add(new Singleton(type, instance, id)). |
void |
setParent(InjectionContext parent)
Set the parent context, and add this context to the children of the given parent.
|
void |
setProperty(String name,
String value)
Set a property.
|
public InjectionContext(InjectionContext parent)
public InjectionContext()
public static InjectionContext getRoot()
public InjectionContext getParent()
public void setParent(InjectionContext parent)
public void close()
close in interface Closeableclose in interface AutoCloseablepublic Object getObjectById(String id) throws InjectionException
InjectionExceptionpublic <T> T getObjectById(String id, Class<T> type) throws InjectionException
InjectionExceptionpublic <T> T getObject(Class<T> type) throws InjectionException
InjectionExceptionpublic Object searchObjectInChildren(String id) throws InjectionException
InjectionExceptionpublic void add(ObjectProvider provider) throws InjectionException
InjectionExceptionpublic void setObject(String id, Class<?> type, Object instance, ObjectMethod destroy) throws InjectionException
add(new Singleton(type, instance, id)).InjectionExceptionCopyright © 2018. All rights reserved.