Ejemplo n.º 1
0
        protected internal override object resolveValue(object value)
        {
            BeanDefinition definition = null;
            string         beanName   = null;

            if (value is BeanDefinition)
            {
                definition = (BeanDefinition)value;
                beanName   = BeanDefinitionReaderUtils.generateBeanName(definition, registry);
            }
            else if (value is BeanDefinitionHolder)
            {
                BeanDefinitionHolder holder = (BeanDefinitionHolder)value;
                definition = holder.BeanDefinition;
                beanName   = holder.BeanName;
            }

            if (definition != null)
            {
                bool nestedScoped             = scope.Equals(definition.Scope);
                bool scopeChangeRequiresProxy = !scoped && nestedScoped;
                if (scopeChangeRequiresProxy)
                {
                    // Exit here so that nested inner bean definitions are not
                    // analysed
                    return(createScopedProxy(beanName, definition, registry, proxyTargetClass));
                }
            }

            // Nested inner bean definitions are recursively analysed here
            value = base.resolveValue(value);
            return(value);
        }
Ejemplo n.º 2
0
        public static BeanDefinitionHolder createScopedProxy(string beanName, BeanDefinition definition, BeanDefinitionRegistry registry, bool proxyTargetClass)
        {
            BeanDefinitionHolder proxyHolder = ScopedProxyUtils.createScopedProxy(new BeanDefinitionHolder(definition, beanName), registry, proxyTargetClass);

            registry.registerBeanDefinition(beanName, proxyHolder.BeanDefinition);
            return(proxyHolder);
        }