public interface Injector
Modifier and Type | Method and Description |
---|---|
<T> void |
bindAspect(Aspect a)
Binds a TANG Aspect to this injector.
|
<T> void |
bindVolatileInstance(Class<T> iface,
T inst)
Binds the given object to the class.
|
<T> void |
bindVolatileParameter(Class<? extends Name<T>> iface,
T inst) |
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(String name) |
<U> U |
getInstance(Class<U> iface)
Gets an instance of iface, or the implementation that has been bound to it.
|
<U> U |
getInstance(String iface)
Gets an instance of iface, or the implementation that has been bound to it.
|
<U> U |
getNamedInstance(Class<? extends Name<U>> iface)
Gets the value stored for the given named parameter.
|
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) |
<U> U getInstance(Class<U> iface) throws InjectionException
U
- a typeiface
- an interfaceInjectionException
- if it fails to find corresponding class<U> U getInstance(String iface) throws InjectionException, NameResolutionException
U
- a typeiface
- a name of interfaceInjectionException
- if it fails to find corresponding classNameResolutionException
- if name resolution fails<U> U getNamedInstance(Class<? extends Name<U>> iface) throws InjectionException
U
- a typeiface
- the name of interfaceInjectionException
- if name resolution fails<T> void bindVolatileInstance(Class<T> iface, T inst) throws BindException
T
- a typeiface
- an interface cassinst
- an instanceBindException
- when trying to re-bind<T> void bindVolatileParameter(Class<? extends Name<T>> iface, T inst) throws BindException
BindException
<T> void bindAspect(Aspect a) throws BindException
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.
T
- a typea
- aspectBindException
- if there exists a bound aspect alreadyAspect getAspect()
Injector forkInjector(Configuration... configurations) throws BindException
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.
configurations
- configurationsBindException
- If any of the configurations conflict with each other, or the
existing Injector's Configuration.boolean isInjectable(String name) throws BindException
name
- a name of objectBindException
- if there is a loop or the name is package nameboolean isParameterSet(String name) throws BindException
BindException
boolean isInjectable(Class<?> clazz) throws BindException
BindException
boolean isParameterSet(Class<? extends Name<?>> name) throws BindException
BindException
InjectionPlan<?> getInjectionPlan(String name) throws NameResolutionException
NameResolutionException
<T> InjectionPlan<T> getInjectionPlan(Class<T> name)
Injector forkInjector()
Copyright © 2017 The Apache Software Foundation. All rights reserved.