public IBeanContextHolder <I> CreateService <I>(String contextName, IBackgroundWorkerParamDelegate <IBeanContextFactory> registerPhaseDelegate, params Type[] serviceModuleTypes) { CheckNotDisposed(); IBeanContextInitializer beanContextInitializer = RegisterBean <BeanContextInitializer>().Finish(); if (contextName == null && registerPhaseDelegate == null && serviceModuleTypes.Length == 1) { contextName = serviceModuleTypes[0].Name; } BeanContextFactory childBeanContextFactory = beanContextFactory.CreateChildContextFactory(beanContextInitializer, this); IServiceContext childContext = childBeanContextFactory.Create(contextName, this, registerPhaseDelegate, serviceModuleTypes); writeLock.Lock(); try { if (children == null) { children = new IdentityHashSet <IServiceContext>(); } children.Add(childContext); } finally { writeLock.Unlock(); } return(new BeanContextHolder <I>(childContext)); }
public BeanContextFactory CreateChildContextFactory(IBeanContextInitializer beanContextInitializer, IServiceContext serviceContext) { IProxyFactory proxyFactory = serviceContext.GetService <IProxyFactory>(); ITypeInfoProvider typeInfoProvider = serviceContext.GetService <ITypeInfoProvider>(false); IProperties props = serviceContext.GetService <IProperties>(); Properties newProps = new Properties(props); return(new BeanContextFactory(linkController, beanContextInitializer, proxyFactory, typeInfoProvider, newProps, this)); }
public void Dispose() { beanConfigurations = null; nameToBeanConfMap = null; aliasToBeanNameMap = null; beanNameToAliasesMap = null; linkController = null; parent = null; beanContextInitializer = null; typeInfoProvider = null; props = null; }
public BeanContextFactory(ILinkController linkController, IBeanContextInitializer beanContextInitializer, IProxyFactory proxyFactory, ITypeInfoProvider typeInfoProvider, Properties properties, BeanContextFactory parent) { ParamChecker.AssertParamNotNull(linkController, "linkController"); ParamChecker.AssertParamNotNull(beanContextInitializer, "beanContextInitializer"); ParamChecker.AssertParamNotNull(proxyFactory, "proxyFactory"); ParamChecker.AssertParamNotNull(properties, "properties"); this.linkController = linkController; this.beanContextInitializer = beanContextInitializer; this.proxyFactory = proxyFactory; this.typeInfoProvider = typeInfoProvider; this.props = properties; this.parent = parent; }
public V Finish() { BeanContextFactory beanContextFactory = serviceContext.GetBeanContextFactory(); IBeanContextInitializer beanContextInitializer = beanContextFactory.GetBeanContextInitializer(); IList <IBeanConfiguration> beanConfHierarchy = beanContextInitializer.FillParentHierarchyIfValid(serviceContext, beanContextFactory, beanConfiguration); V bean = beanInstance; if (bean == null) { Type beanType = this.beanType; if (beanType == null) { beanType = beanContextInitializer.ResolveTypeInHierarchy(beanConfHierarchy); } bean = (V)Activator.CreateInstance(beanType); } bean = (V)beanContextInitializer.InitializeBean(serviceContext, beanContextFactory, beanConfiguration, bean, beanConfHierarchy, joinLifecycle); return(bean); }