public abstract class AbstractCreationalContext extends Object implements CreationalContext
Modifier and Type | Field and Description |
---|---|
protected List<Tuple<Object,DestructionCallback>> |
destructionCallbacks |
protected boolean |
immutableContext |
protected List<Tuple<Object,InitializationCallback>> |
initializationCallbacks |
protected Class<? extends Annotation> |
scope |
protected Map<BeanRef,List<ProxyResolver>> |
unresolvedProxies |
protected Map<BeanRef,Object> |
wired |
Modifier | Constructor and Description |
---|---|
protected |
AbstractCreationalContext(boolean immutableContext,
Class<? extends Annotation> scope) |
protected |
AbstractCreationalContext(Class<? extends Annotation> scope) |
Modifier and Type | Method and Description |
---|---|
void |
addBean(BeanRef ref,
Object instance)
Adds a bean to the creational context based on the
BeanRef with a reference to the an actual instantiated
instance of the bean. |
void |
addBean(Class<?> beanType,
Annotation[] qualifiers,
Object instance)
Adds a bean to the creational context based on the specified bean type and qualifiers with a reference to an
actual instantiated instance of the bean.
|
void |
addDestructionCallback(Object beanInstance,
DestructionCallback callback)
Records a
DestructionCallback to the creational context. |
void |
addInitializationCallback(Object beanInstance,
InitializationCallback callback)
Records a
InitializationCallback to the creational context. |
void |
addUnresolvedProxy(ProxyResolver proxyResolver,
Class<?> beanType,
Annotation[] qualifiers)
Adds an unresolved proxy into the creational context.
|
void |
destroyContext()
Fires all
DestructionCallback s within the context. |
protected void |
fireAllInitCallbacks()
Fires all
InitializationCallback s which were declared during creation of the beans. |
Collection<Object> |
getAllCreatedBeanInstances()
Returns a list of the instances of every created bean within this creational context.
|
Set<BeanRef> |
getAllCreatedBeans()
Returns a list of all created beans within this creational context.
|
BeanRef |
getBeanReference(Class<?> beanType,
Annotation[] qualifiers)
Returns a
BeanRef which matches the specified type and qualifiers whether or not the bean is within
the creational context or not. |
<T> T |
getWiredOrNew(BeanRef ref,
javax.inject.Provider<T> provider)
Return a wired instance within the current creational context, or in the absence of an existing context,
invoke the specified provider to create the instance.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addProxyReference
protected final boolean immutableContext
protected final Class<? extends Annotation> scope
protected final List<Tuple<Object,InitializationCallback>> initializationCallbacks
protected final List<Tuple<Object,DestructionCallback>> destructionCallbacks
protected final Map<BeanRef,List<ProxyResolver>> unresolvedProxies
protected AbstractCreationalContext(Class<? extends Annotation> scope)
protected AbstractCreationalContext(boolean immutableContext, Class<? extends Annotation> scope)
public void addInitializationCallback(Object beanInstance, InitializationCallback callback)
InitializationCallback
to the creational context. All initialization callbacks are executed
when the finish() method is called.addInitializationCallback
in interface CreationalContext
beanInstance
- the instance of the bean associated with the InitializationCallback
callback
- the instance of the InitializationCallback
public void addDestructionCallback(Object beanInstance, DestructionCallback callback)
DestructionCallback
to the creational context. All destruction callbacks are executed
by the bean manager for a creational context when any of the beans within the creational context are
destroyed.addDestructionCallback
in interface CreationalContext
beanInstance
- the instance of the bean associated with the DestructionCallback
.callback
- the instance of the DestructionCallback
public BeanRef getBeanReference(Class<?> beanType, Annotation[] qualifiers)
BeanRef
which matches the specified type and qualifiers whether or not the bean is within
the creational context or not.getBeanReference
in interface CreationalContext
beanType
- the type of the beanqualifiers
- the qualifiers for the beanBeanRef
matching the specified type and qualifiers.public void addBean(Class<?> beanType, Annotation[] qualifiers, Object instance)
addBean
in interface CreationalContext
beanType
- the type of the beanqualifiers
- the qualifiers for the beaninstance
- the instance to the beanpublic void addBean(BeanRef ref, Object instance)
BeanRef
with a reference to the an actual instantiated
instance of the bean.addBean
in interface CreationalContext
ref
- the BeanRef
representing the beaninstance
- the instance of the beanpublic Set<BeanRef> getAllCreatedBeans()
getAllCreatedBeans
in interface CreationalContext
public Collection<Object> getAllCreatedBeanInstances()
getAllCreatedBeanInstances
in interface CreationalContext
public void addUnresolvedProxy(ProxyResolver proxyResolver, Class<?> beanType, Annotation[] qualifiers)
ProxyResolver
callback, for implementing its own proxy closing strategy.
After a creational context has added all beans to the context, calling finish() will result in all of
the provided ProxyResolver
s being executed.
This method is typically called directly by the generated bootstrapper.addUnresolvedProxy
in interface CreationalContext
proxyResolver
- the ProxyResolver
used for handling closure of the cycle.beanType
- the type of the beanqualifiers
- the qualifiers for the beanprotected void fireAllInitCallbacks()
InitializationCallback
s which were declared during creation of the beans.public <T> T getWiredOrNew(BeanRef ref, javax.inject.Provider<T> provider)
T
- the bean typeref
- the bean referenceprovider
- the provider to create the instance if it does not already exist.public void destroyContext()
DestructionCallback
s within the context.Copyright © 2013-2015 JBoss, a division of Red Hat. All Rights Reserved.