Errai 3.0.1-SNAPSHOT

org.jboss.errai.ioc.client.container
Interface CreationalContext

All Known Implementing Classes:
AbstractCreationalContext, AsyncCreationalContext, SimpleCreationalContext

public interface CreationalContext

The CreationalContext is as its name implies, the context used in the creation of beans. There is a one-to-one relationship between a CreationalContext and a scope. The creation of new dependent scope beans and forced new-instance creation of normal-scoped beans are contained in their own CreationalContext.

The context is used for regulating lifecycle activities as well as managing proxies generated in the creation of the beans.

Author:
Mike Brock

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 addProxyReference(Object proxyRef, Object realRef)
          Adds a lookup from a proxy to the actual bean instance that it is proxying.
 void addUnresolvedProxy(ProxyResolver proxyResolver, Class<?> beanType, Annotation[] qualifiers)
          Adds an unresolved proxy into the creational context.
 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.
 

Method Detail

addInitializationCallback

void addInitializationCallback(Object beanInstance,
                               InitializationCallback callback)
Records a InitializationCallback to the creational context.

Parameters:
beanInstance - the instance of the bean associated with the InitializationCallback
callback - the instance of the InitializationCallback

addDestructionCallback

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.

Parameters:
beanInstance - the instance of the bean associated with the DestructionCallback.
callback - the instance of the DestructionCallback

addProxyReference

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

getBeanReference

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.

Parameters:
beanType - the type of the bean
qualifiers - the qualifiers for the bean
Returns:
a BeanRef matching the specified type and qualifiers.

addBean

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.

Parameters:
beanType - the type of the bean
qualifiers - the qualifiers for the bean
instance - the instance to the bean

addBean

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.

Parameters:
ref - the BeanRef representing the bean
instance - the instance of the bean

getAllCreatedBeans

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

Returns:
An unmodifiable set of all the created beans within this creational context.

getAllCreatedBeanInstances

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

Returns:
An unmodifiable collection of every bean instance within the creational context.

addUnresolvedProxy

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.

Parameters:
proxyResolver - the ProxyResolver used for handling closure of the cycle.
beanType - the type of the bean
qualifiers - the qualifiers for the bean

Errai 3.0.1-SNAPSHOT

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