Errai 3.0.1-SNAPSHOT

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

java.lang.Object
  extended by org.jboss.errai.ioc.client.container.AbstractCreationalContext
      extended by org.jboss.errai.ioc.client.container.SimpleCreationalContext
All Implemented Interfaces:
CreationalContext

public class SimpleCreationalContext
extends AbstractCreationalContext

A SimpleCreationalContext is used for representing context associated with the creation of a bean and its dependencies. A SimpleCreationalContext captures InitializationCallbacks and DestructionCallbacks associated with the graph being constructed.

This class is relied upon by the SyncBeanManagerImpl itself and should not generally be used directly.

Author:
Mike Brock

Field Summary
 
Fields inherited from class org.jboss.errai.ioc.client.container.AbstractCreationalContext
destructionCallbacks, immutableContext, initializationCallbacks, scope, unresolvedProxies, wired
 
Constructor Summary
SimpleCreationalContext(boolean immutableContext, SyncBeanManager beanManager, Class<? extends Annotation> scope)
           
SimpleCreationalContext(SyncBeanManagerImpl beanManager, Class<? extends Annotation> scopeName)
           
 
Method Summary
 void addProxyReference(Object proxyRef, Object realRef)
          Adds a lookup from a proxy to the actual bean instance that it is proxying.
 void finish()
          Called to indicate all beans have been added to the context.
<T> T
getBeanInstance(Class<T> beanType, Annotation[] qualifiers)
          Obtains an instance of the bean within the creational context based on the specified bean type and qualifiers.
<T> T
getInstanceOrNew(BeanProvider<T> callback, Class<?> beanType, Annotation[] qualifiers)
          Returns the instance of the specified bean of matching type and qualifiers, or if there is no matching bean within the context, the specified BeanProvider is called to instantiate and add the bean to the context.
<T> T
getSingletonInstanceOrNew(SimpleInjectionContext injectionContext, BeanProvider<T> callback, Class<?> beanType, Annotation[] qualifiers)
          Returns the instance of the specified bean of matching type and qualifiers, or if there is no matching bean within the context, an instance of the bean will be obtained from the SimpleInjectionContext.
 
Methods inherited from class org.jboss.errai.ioc.client.container.AbstractCreationalContext
addBean, addBean, addDestructionCallback, addInitializationCallback, addUnresolvedProxy, destroyContext, fireAllInitCallbacks, getAllCreatedBeanInstances, getAllCreatedBeans, getBeanReference, getWiredOrNew
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleCreationalContext

public SimpleCreationalContext(SyncBeanManagerImpl beanManager,
                               Class<? extends Annotation> scopeName)

SimpleCreationalContext

public SimpleCreationalContext(boolean immutableContext,
                               SyncBeanManager beanManager,
                               Class<? extends Annotation> scope)
Method Detail

addProxyReference

public void addProxyReference(Object proxyRef,
                              Object realRef)
Adds a lookup from a proxy to the actual bean instance that it is proxying. This is called directly by the bootstrapping code.

Parameters:
proxyRef - the reference to the proxy instance
realRef - the reference to the actual bean instance which the proxy wraps

getInstanceOrNew

public <T> T getInstanceOrNew(BeanProvider<T> callback,
                              Class<?> beanType,
                              Annotation[] qualifiers)
Returns the instance of the specified bean of matching type and qualifiers, or if there is no matching bean within the context, the specified BeanProvider is called to instantiate and add the bean to the context.

Type Parameters:
T - the type of the bean
Parameters:
callback - the BeanProvider to be called in order to instantiate the bean if it is not already available without he current creational context.
beanType - the type of the bean
qualifiers - the qualifiers for the bean
Returns:
the instance of the bean
See Also:
getSingletonInstanceOrNew(org.jboss.errai.ioc.client.SimpleInjectionContext, BeanProvider, Class, java.lang.annotation.Annotation[])

getBeanInstance

public <T> T getBeanInstance(Class<T> beanType,
                             Annotation[] qualifiers)
Obtains an instance of the bean within the creational context based on the specified bean type and qualifiers.

Type Parameters:
T - the type of the bean
Parameters:
beanType - the type of the bean
qualifiers - the qualifiers fo the bean
Returns:
the actual instance of the bean

getSingletonInstanceOrNew

public <T> T getSingletonInstanceOrNew(SimpleInjectionContext injectionContext,
                                       BeanProvider<T> callback,
                                       Class<?> beanType,
                                       Annotation[] qualifiers)
Returns the instance of the specified bean of matching type and qualifiers, or if there is no matching bean within the context, an instance of the bean will be obtained from the SimpleInjectionContext. This method assumes that the caller knows that the bean is a singleton bean. It is called directly by the IOC bootstrapping code.

In the event that bean is not available within the SimpleInjectionContext, the specified BeanProvider is invoked and the bean is added to the SimpleInjectionContext. This functionality primarily enables proper behavior for singleton producers.

Type Parameters:
T - the type of the bean
Parameters:
injectionContext - the SimpleInjectionContext of the container
callback - the BeanProvider to be called in order to instantiate the bean if it is not already available without he current creational context. * @param beanType
qualifiers - the qualifiers for the bean
Returns:
the instance of the bean
See Also:
getInstanceOrNew(BeanProvider, Class, java.lang.annotation.Annotation[])

finish

public void finish()
Called to indicate all beans have been added to the context. Calling this method results in all post-initialization tasks (such as @PostConstruct) and proxy closures to occur.


Errai 3.0.1-SNAPSHOT

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