public static IServiceContext CreateBootstrap(IProperties properties, Type[] bootstrapModules, params Object[] bootstrapModuleInstances) { if (properties == null) { properties = Properties.Application; } // create own sub-instance of properties Properties newProps = new Properties(properties); ThreadLocalCleanupController threadLocalCleanupController = new ThreadLocalCleanupController(); ConversionHelper conversionHelper = new ConversionHelper(); DelegatingConversionHelper delegatingConversionHelper = new DelegatingConversionHelper(); LinkController linkController = new LinkController(); LoggerHistory loggerHistory = new LoggerHistory(); AccessorTypeProvider accessorTypeProvider = new AccessorTypeProvider(); ExtendableRegistry extendableRegistry = new ExtendableRegistry(); GarbageProxyFactory garbageProxyFactory = new GarbageProxyFactory(); PropertyInfoProvider propertyInfoProvider = new PropertyInfoProvider(); BeanContextInitializer beanContextInitializer = new BeanContextInitializer(); CallingProxyPostProcessor callingProxyPostProcessor = new CallingProxyPostProcessor(); ProxyFactory proxyFactory = new ProxyFactory(); DelegateFactory delegateFactory = new DelegateFactory(); AutoLinkPreProcessor threadLocalCleanupPreProcessor = new AutoLinkPreProcessor(); callingProxyPostProcessor.PropertyInfoProvider = propertyInfoProvider; delegatingConversionHelper.DefaultConversionHelper = conversionHelper; linkController.ExtendableRegistry = extendableRegistry; linkController.Props = newProps; linkController.ProxyFactory = proxyFactory; beanContextInitializer.CallingProxyPostProcessor = callingProxyPostProcessor; beanContextInitializer.ConversionHelper = delegatingConversionHelper; beanContextInitializer.PropertyInfoProvider = propertyInfoProvider; garbageProxyFactory.AccessorTypeProvider = accessorTypeProvider; propertyInfoProvider.AccessorTypeProvider = accessorTypeProvider; threadLocalCleanupPreProcessor.SetExtendableRegistry(extendableRegistry); threadLocalCleanupPreProcessor.SetExtendableType(typeof(IThreadLocalCleanupBeanExtendable)); LoggerInstancePreProcessor loggerInstancePreProcessor = new LoggerInstancePreProcessor(); propertyInfoProvider.AfterPropertiesSet(); ScanForLogInstance(loggerInstancePreProcessor, propertyInfoProvider, newProps, accessorTypeProvider); ScanForLogInstance(loggerInstancePreProcessor, propertyInfoProvider, newProps, callingProxyPostProcessor); ScanForLogInstance(loggerInstancePreProcessor, propertyInfoProvider, newProps, delegatingConversionHelper); ScanForLogInstance(loggerInstancePreProcessor, propertyInfoProvider, newProps, extendableRegistry); ScanForLogInstance(loggerInstancePreProcessor, propertyInfoProvider, newProps, linkController); ScanForLogInstance(loggerInstancePreProcessor, propertyInfoProvider, newProps, loggerHistory); ScanForLogInstance(loggerInstancePreProcessor, propertyInfoProvider, newProps, beanContextInitializer); ScanForLogInstance(loggerInstancePreProcessor, propertyInfoProvider, newProps, propertyInfoProvider); ScanForLogInstance(loggerInstancePreProcessor, propertyInfoProvider, newProps, threadLocalCleanupController); ScanForLogInstance(loggerInstancePreProcessor, propertyInfoProvider, newProps, threadLocalCleanupPreProcessor); accessorTypeProvider.AfterPropertiesSet(); callingProxyPostProcessor.AfterPropertiesSet(); delegatingConversionHelper.AfterPropertiesSet(); extendableRegistry.AfterPropertiesSet(); linkController.AfterPropertiesSet(); loggerHistory.AfterPropertiesSet(); beanContextInitializer.AfterPropertiesSet(); threadLocalCleanupController.AfterPropertiesSet(); threadLocalCleanupPreProcessor.AfterPropertiesSet(); PropertiesPreProcessor propertiesPreProcessor = new PropertiesPreProcessor(); propertiesPreProcessor.ConversionHelper = delegatingConversionHelper; propertiesPreProcessor.PropertyInfoProvider = propertyInfoProvider; propertiesPreProcessor.AfterPropertiesSet(); // The DelegatingConversionHelper is functional, but has yet no properties set propertiesPreProcessor.PreProcessProperties(null, null, newProps, "delegatingConversionHelper", delegatingConversionHelper, typeof(DelegatingConversionHelper), null, EmptySet.Empty <String>(), null); delegatingConversionHelper.AfterPropertiesSet(); BeanContextFactory parentContextFactory = new BeanContextFactory(linkController, beanContextInitializer, proxyFactory, null, newProps, null); parentContextFactory.RegisterWithLifecycle(loggerHistory).Autowireable <ILoggerHistory>(); parentContextFactory.RegisterWithLifecycle(proxyFactory).Autowireable <IProxyFactory>(); parentContextFactory.RegisterWithLifecycle(threadLocalCleanupController).Autowireable(typeof(IThreadLocalCleanupController), typeof(IThreadLocalCleanupBeanExtendable)); parentContextFactory.RegisterExternalBean(delegatingConversionHelper).Autowireable(typeof(IConversionHelper), typeof(IDedicatedConverterExtendable)); parentContextFactory.RegisterWithLifecycle(accessorTypeProvider).Autowireable <IAccessorTypeProvider>(); parentContextFactory.RegisterExternalBean(loggerInstancePreProcessor).Autowireable <ILoggerCache>(); parentContextFactory.RegisterWithLifecycle(extendableRegistry).Autowireable <IExtendableRegistry>(); parentContextFactory.RegisterWithLifecycle(garbageProxyFactory).Autowireable <IGarbageProxyFactory>(); parentContextFactory.RegisterWithLifecycle(callingProxyPostProcessor).Autowireable <CallingProxyPostProcessor>(); parentContextFactory.RegisterWithLifecycle(propertyInfoProvider).Autowireable <IPropertyInfoProvider>(); parentContextFactory.RegisterWithLifecycle(delegateFactory).Autowireable <IDelegateFactory>(); if (bootstrapModules != null) { for (int a = 0, size = bootstrapModules.Length; a < size; a++) { parentContextFactory.RegisterBean(bootstrapModules[a]); } } if (bootstrapModuleInstances != null) { for (int a = 0, size = bootstrapModuleInstances.Length; a < size; a++) { parentContextFactory.RegisterExternalBean(bootstrapModuleInstances[a]); } } List <IBeanPreProcessor> preProcessors = new List <IBeanPreProcessor>(); preProcessors.Add(propertiesPreProcessor); preProcessors.Add(loggerInstancePreProcessor); preProcessors.Add(threadLocalCleanupPreProcessor); return(parentContextFactory.Create("bootstrap", null, preProcessors, null)); }
public RelationUpdateItemBuild CreateRUIBuild(String memberName, IList <IObjRef> oldOriList, IList <IObjRef> newOriList) { if (oldOriList.Count == 0 && newOriList.Count == 0) { return(null); } IISet <IObjRef> oldSet = oldOriList.Count > 0 ? new CHashSet <IObjRef>(oldOriList) : EmptySet.Empty <IObjRef>(); IISet <IObjRef> newSet = newOriList.Count > 0 ? new CHashSet <IObjRef>(newOriList) : EmptySet.Empty <IObjRef>(); IISet <IObjRef> smallerSet = ((ICollection)oldSet).Count > ((ICollection)newSet).Count ? newSet : oldSet; IISet <IObjRef> greaterSet = ((ICollection)oldSet).Count > ((ICollection)newSet).Count ? oldSet : newSet; // Check unchanged ORIs Iterator <IObjRef> smallerIter = smallerSet.Iterator(); while (smallerIter.MoveNext()) { // Old ORIs, which exist as new ORIs, too, are unchanged IObjRef objRef = smallerIter.Current; if (greaterSet.Remove(objRef)) { smallerIter.Remove(); } } if (((ICollection)oldSet).Count == 0 && ((ICollection)newSet).Count == 0) { return(null); } // Old ORIs are now handled as REMOVE, New ORIs as ADD RelationUpdateItemBuild rui = new RelationUpdateItemBuild(memberName); if (((ICollection)oldSet).Count > 0) { rui.RemoveObjRefs(oldSet); } if (((ICollection)newSet).Count > 0) { rui.AddObjRefs(newSet); } return(rui); }
protected static void ScanForLogInstance(IBeanPreProcessor beanPreProcessor, IPropertyInfoProvider propertyInfoProvider, IProperties properties, Object bean) { IPropertyInfo[] props = propertyInfoProvider.GetProperties(bean.GetType()); beanPreProcessor.PreProcessProperties(null, null, properties, null, bean, bean.GetType(), null, EmptySet.Empty <String>(), props); }