public class InjectorImpl extends Object implements Injector
Constructor and Description |
---|
InjectorImpl(Configuration c) |
Modifier and Type | Method and Description |
---|---|
<T> void |
bindAspect(Aspect a)
Binds a TANG Aspect to this injector.
|
<T> void |
bindVolatileInstance(Class<T> cl,
T o)
Binds the given object to the class.
|
<T> void |
bindVolatileParameter(Class<? extends Name<T>> cl,
T o) |
Injector |
forkInjector() |
Injector |
forkInjector(Configuration... configurations)
Create a copy of this Injector that inherits the instances that were already
created by this Injector, but reflects additional Configuration objects.
|
Aspect |
getAspect()
Allows InjectionFuture to tell the aspect when get() is invoked.
|
<T> InjectionPlan<T> |
getInjectionPlan(Class<T> name) |
InjectionPlan<?> |
getInjectionPlan(Node n)
Return an injection plan for the given class / parameter name.
|
InjectionPlan<?> |
getInjectionPlan(String name) |
<U> U |
getInstance(Class<U> clazz)
Gets an instance of iface, or the implementation that has been bound to it.
|
<U> U |
getInstance(String clazz)
Gets an instance of iface, or the implementation that has been bound to it.
|
<T> T |
getNamedInstance(Class<? extends Name<T>> clazz)
Gets the value stored for the given named parameter.
|
<T> T |
getNamedParameter(Class<? extends Name<T>> clazz) |
boolean |
isInjectable(Class<?> clazz) |
boolean |
isInjectable(String name)
Returns true if this Injector is able to instantiate the object named by
name.
|
boolean |
isParameterSet(Class<? extends Name<?>> name) |
boolean |
isParameterSet(String name) |
public InjectorImpl(Configuration c) throws BindException
BindException
public InjectionPlan<?> getInjectionPlan(Node n)
n
- The name of an injectable class or interface, or a NamedParameter.NameResolutionException
public InjectionPlan<?> getInjectionPlan(String name) throws NameResolutionException
getInjectionPlan
in interface Injector
NameResolutionException
public <T> InjectionPlan<T> getInjectionPlan(Class<T> name)
getInjectionPlan
in interface Injector
public boolean isInjectable(String name) throws NameResolutionException
Injector
isInjectable
in interface Injector
name
- a name of objectNameResolutionException
public boolean isInjectable(Class<?> clazz)
isInjectable
in interface Injector
public boolean isParameterSet(String name) throws NameResolutionException
isParameterSet
in interface Injector
NameResolutionException
public boolean isParameterSet(Class<? extends Name<?>> name) throws BindException
isParameterSet
in interface Injector
BindException
public <U> U getInstance(Class<U> clazz) throws InjectionException
Injector
getInstance
in interface Injector
U
- a typeclazz
- an interfaceInjectionException
- if it fails to find corresponding classpublic <U> U getInstance(String clazz) throws InjectionException, NameResolutionException
Injector
getInstance
in interface Injector
U
- a typeclazz
- a name of interfaceInjectionException
- if it fails to find corresponding classNameResolutionException
- if name resolution failspublic <T> T getNamedInstance(Class<? extends Name<T>> clazz) throws InjectionException
Injector
getNamedInstance
in interface Injector
T
- a typeclazz
- the name of interfaceInjectionException
- if name resolution failspublic <T> T getNamedParameter(Class<? extends Name<T>> clazz) throws InjectionException
InjectionException
public <T> void bindVolatileInstance(Class<T> cl, T o) throws BindException
Injector
bindVolatileInstance
in interface Injector
T
- a typecl
- an interface casso
- an instanceBindException
- when trying to re-bindpublic <T> void bindVolatileParameter(Class<? extends Name<T>> cl, T o) throws BindException
bindVolatileParameter
in interface Injector
BindException
public Injector forkInjector()
forkInjector
in interface Injector
public Injector forkInjector(Configuration... configurations) throws BindException
Injector
Except for the fact that the child Injector will have references to this injector's instances, the returned Injector is equivalent to the one you would get by using ConfigurationBuilder to build a merged Configuration, and then using the merged Configuration to create an Injector. Injectors returned by ConfigurationBuilders are always independent, and never share references to the same instances of injected objects.
forkInjector
in interface Injector
configurations
- configurationsBindException
- If any of the configurations conflict with each other, or the
existing Injector's Configuration.public <T> void bindAspect(Aspect a) throws BindException
Injector
A given aspect will be invoked once for each object that Tang injects, and aspects will be copied in a way that mirrors the scoping that Tang creates at runtime.
bindAspect
in interface Injector
T
- a typea
- aspectBindException
- if there exists a bound aspect alreadyCopyright © 2017 The Apache Software Foundation. All rights reserved.