}
}
if (proxyClass != null)
{
InterceptorDecoratorProxyFactory pf = webBeansContext.getInterceptorDecoratorProxyFactory();
// register the bean itself for self-interception
if (interceptorInfo.getSelfInterceptorBean() != null)
{
interceptorInstances.put(interceptorInfo.getSelfInterceptorBean(), instance);
}
T delegate = instance;
if (interceptorInfo.getDecorators() != null && !isDelegateInjection(creationalContext))
{
List<Decorator<?>> decorators = interceptorInfo.getDecorators();
Map<Decorator<?>, Object> instances = new HashMap<Decorator<?>, Object>();
for (int i = decorators.size(); i > 0; i--)
{
Decorator decorator = decorators.get(i - 1);
creationalContextImpl.putContextual(decorator);
creationalContextImpl.putDelegate(delegate);
Object decoratorInstance = decorator.create((CreationalContext) creationalContext);
instances.put(decorator, decoratorInstance);
delegate = pf.createProxyInstance(proxyClass, instance, new DecoratorHandler(interceptorInfo, instances, i - 1, instance, beanPassivationId));
}
}
InterceptorHandler interceptorHandler = new DefaultInterceptorHandler<T>(instance, delegate, methodInterceptors, interceptorInstances, beanPassivationId);
T proxyInstance = pf.createProxyInstance(proxyClass, instance, interceptorHandler);
instance = proxyInstance;
creationalContextImpl.putContextual(oldContextual);
}
return instance;