Search in sources :

Example 1 with DecorationHelper

use of org.jboss.weld.bean.proxy.DecorationHelper in project core by weld.

the class Decorators method getOuterDelegate.

public static <T> T getOuterDelegate(Bean<T> bean, T instance, CreationalContext<T> creationalContext, Class<T> proxyClass, InjectionPoint originalInjectionPoint, BeanManagerImpl manager, List<Decorator<?>> decorators) {
    TargetBeanInstance beanInstance = new TargetBeanInstance(bean, instance);
    DecorationHelper<T> decorationHelper = new DecorationHelper<T>(beanInstance, bean, proxyClass, manager, manager.getServices().get(ContextualStore.class), decorators);
    DecorationHelper.push(decorationHelper);
    try {
        final T outerDelegate = decorationHelper.getNextDelegate(originalInjectionPoint, creationalContext);
        if (outerDelegate == null) {
            throw new WeldException(BeanLogger.LOG.proxyInstantiationFailed(bean));
        }
        return outerDelegate;
    } finally {
        DecorationHelper.pop();
    }
}
Also used : DecorationHelper(org.jboss.weld.bean.proxy.DecorationHelper) WeldException(org.jboss.weld.exceptions.WeldException) ContextualStore(org.jboss.weld.serialization.spi.ContextualStore) TargetBeanInstance(org.jboss.weld.bean.proxy.TargetBeanInstance)

Example 2 with DecorationHelper

use of org.jboss.weld.bean.proxy.DecorationHelper in project core by weld.

the class AbstractDecoratorApplyingInstantiator method getOuterDelegate.

protected T getOuterDelegate(T instance, CreationalContext<T> creationalContext, InjectionPoint originalInjectionPoint, BeanManagerImpl manager) {
    TargetBeanInstance beanInstance = new TargetBeanInstance(bean, instance);
    DecorationHelper<T> decorationHelper = new DecorationHelper<T>(beanInstance, bean, proxyClass, manager, manager.getServices().get(ContextualStore.class), decorators);
    DecorationHelper.push(decorationHelper);
    try {
        final T outerDelegate = decorationHelper.getNextDelegate(originalInjectionPoint, creationalContext);
        if (outerDelegate == null) {
            throw new WeldException(BeanLogger.LOG.proxyInstantiationFailed(this));
        }
        return outerDelegate;
    } finally {
        DecorationHelper.pop();
    }
}
Also used : DecorationHelper(org.jboss.weld.bean.proxy.DecorationHelper) WeldException(org.jboss.weld.exceptions.WeldException) ContextualStore(org.jboss.weld.serialization.spi.ContextualStore) TargetBeanInstance(org.jboss.weld.bean.proxy.TargetBeanInstance)

Aggregations

DecorationHelper (org.jboss.weld.bean.proxy.DecorationHelper)2 TargetBeanInstance (org.jboss.weld.bean.proxy.TargetBeanInstance)2 WeldException (org.jboss.weld.exceptions.WeldException)2 ContextualStore (org.jboss.weld.serialization.spi.ContextualStore)2