Errai 3.0.1-SNAPSHOT

org.jboss.errai.ioc.client.container
Class AbstractCreationalContext

java.lang.Object
  extended by org.jboss.errai.ioc.client.container.AbstractCreationalContext
All Implemented Interfaces:
CreationalContext
Direct Known Subclasses:
AsyncCreationalContext, SimpleCreationalContext

public abstract class AbstractCreationalContext
extends Object
implements CreationalContext

Author:
Mike Brock

Field Summary
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
           
 
Constructor Summary
protected AbstractCreationalContext(boolean immutableContext, Class<? extends Annotation> scope)
           
protected AbstractCreationalContext(Class<? extends Annotation> scope)
           
 
Method Summary
 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 DestructionCallbacks within the context.
protected  void fireAllInitCallbacks()
          Fires all InitializationCallbacks 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.errai.ioc.client.container.CreationalContext
addProxyReference
 

Field Detail

immutableContext

protected final boolean immutableContext

scope

protected final Class<? extends Annotation> scope

initializationCallbacks

protected final List<Tuple<Object,InitializationCallback>> initializationCallbacks

destructionCallbacks

protected final List<Tuple<Object,DestructionCallback>> destructionCallbacks

unresolvedProxies

protected final Map<BeanRef,List<ProxyResolver>> unresolvedProxies

wired

protected final Map<BeanRef,Object> wired
Constructor Detail

AbstractCreationalContext

protected AbstractCreationalContext(Class<? extends Annotation> scope)

AbstractCreationalContext

protected AbstractCreationalContext(boolean immutableContext,
                                    Class<? extends Annotation> scope)
Method Detail

addInitializationCallback

public void addInitializationCallback(Object beanInstance,
                                      InitializationCallback callback)
Records a InitializationCallback to the creational context. All initialization callbacks are executed when the finish() method is called.

Specified by:
addInitializationCallback in interface CreationalContext
Parameters:
beanInstance - the instance of the bean associated with the InitializationCallback
callback - the instance of the InitializationCallback

addDestructionCallback

public void addDestructionCallback(Object beanInstance,
                                   DestructionCallback callback)
Records a 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.

Specified by:
addDestructionCallback in interface CreationalContext
Parameters:
beanInstance - the instance of the bean associated with the DestructionCallback.
callback - the instance of the DestructionCallback

getBeanReference

public 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.

Specified by:
getBeanReference in interface CreationalContext
Parameters:
beanType - the type of the bean
qualifiers - the qualifiers for the bean
Returns:
a BeanRef matching the specified type and qualifiers.

addBean

public 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.

Specified by:
addBean in interface CreationalContext
Parameters:
beanType - the type of the bean
qualifiers - the qualifiers for the bean
instance - the instance to the bean

addBean

public 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.

Specified by:
addBean in interface CreationalContext
Parameters:
ref - the BeanRef representing the bean
instance - the instance of the bean

getAllCreatedBeans

public Set<BeanRef> getAllCreatedBeans()
Returns a list of all created beans within this creational context.

Specified by:
getAllCreatedBeans in interface CreationalContext
Returns:
An unmodifiable set of all the created beans within this creational context.

getAllCreatedBeanInstances

public Collection<Object> getAllCreatedBeanInstances()
Returns a list of the instances of every created bean within this creational context.

Specified by:
getAllCreatedBeanInstances in interface CreationalContext
Returns:
An unmodifiable collection of every bean instance within the creational context.

addUnresolvedProxy

public void addUnresolvedProxy(ProxyResolver proxyResolver,
                               Class<?> beanType,
                               Annotation[] qualifiers)
Adds an unresolved proxy into the creational context. This is called to indicate a proxy was required while building a bean, due to a forward reference in a cycle situation. The caller is responsible, through the providing of the 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 ProxyResolvers being executed.

This method is typically called directly by the generated bootstrapper.

Specified by:
addUnresolvedProxy in interface CreationalContext
Parameters:
proxyResolver - the ProxyResolver used for handling closure of the cycle.
beanType - the type of the bean
qualifiers - the qualifiers for the bean

fireAllInitCallbacks

protected void fireAllInitCallbacks()
Fires all InitializationCallbacks which were declared during creation of the beans.


getWiredOrNew

public <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. This is should only called by generated code. A wired instance is an instance which exists within this creational context specifically. For instance, a dependent scoped bean.

Type Parameters:
T - the bean type
Parameters:
ref - the bean reference
provider - the provider to create the instance if it does not already exist.
Returns:
the instance

destroyContext

public void destroyContext()
Fires all DestructionCallbacks within the context.


Errai 3.0.1-SNAPSHOT

Copyright © 2013-2014 JBoss, a division of Red Hat. All Rights Reserved.