public virtual Object PostProcessBean(IBeanContextFactory beanContextFactory, IServiceContext beanContext, IBeanConfiguration beanConfiguration, Type beanType, Object targetBean, ISet <Type> requestedTypes) { if (!beanType.IsGenericType) { return(targetBean); } // ViewModelDataChangeController has exactly 1 generic argument Type genericTypeArgument = beanType.GetGenericArguments()[0]; // Instantiate TYPE to generic argument of given bean type if (!dataChangeControllerType.MakeGenericType(genericTypeArgument).IsAssignableFrom(beanType)) { return(targetBean); } Type[] arguments = beanType.GetGenericArguments(); Object eventListener = TypeFilteredDataChangeListener.CreateEventListener((IDataChangeListener)targetBean, arguments[0]); String eventListenerBeanName = beanConfiguration.GetName() + ".eventListener"; beanContextFactory.RegisterExternalBean(eventListenerBeanName, eventListener); if (beanContext.IsRunning) { beanContext.Link(eventListenerBeanName).To <IEventListenerExtendable>().With(typeof(IDataChange)); } else { beanContextFactory.Link(eventListenerBeanName).To <IEventListenerExtendable>().With(typeof(IDataChange)); } return(targetBean); }
public static void Transfer(IServiceContext sourceContext, IBeanContextFactory targetContextFactory, Type autowireableType) { ParamChecker.AssertParamNotNull(sourceContext, "sourceContext"); ParamChecker.AssertParamNotNull(targetContextFactory, "targetContextFactory"); ParamChecker.AssertParamNotNull(autowireableType, "autowireableType"); Object bean = sourceContext.GetService(autowireableType); if (bean == null) { throw new System.Exception("No autowired bean found for type " + autowireableType.FullName); } targetContextFactory.RegisterExternalBean(bean).Autowireable(autowireableType); }
public static void Transfer(IServiceContext sourceContext, IBeanContextFactory targetContextFactory, String beanName) { ParamChecker.AssertParamNotNull(sourceContext, "sourceContext"); ParamChecker.AssertParamNotNull(targetContextFactory, "targetContextFactory"); ParamChecker.AssertParamNotNull(beanName, "beanName"); Object bean = sourceContext.GetService(beanName); if (bean == null) { throw new System.Exception("No bean found with name '" + beanName + "'"); } targetContextFactory.RegisterExternalBean(beanName, bean); }
public virtual void AfterPropertiesSet(IBeanContextFactory beanContextFactory) { beanContextFactory.RegisterBean <SecurityScopeProvider>("securityScopeProvider").Autowireable(typeof(ISecurityScopeProvider), typeof(ISecurityScopeChangeExtendable)); #if SILVERLIGHT beanContextFactory.RegisterBean <WindowFactory>("windowFactory").Autowireable <IWindowFactory>(); #endif beanContextFactory.RegisterBean <BusyController>("busyController").Autowireable <IBusyController>(); //beanContextFactory.RegisterBean<ClientEntityFactory>("clientEntityFactory").Autowireable<IEntityFactory>(); beanContextFactory.RegisterBean <UserControlPostProcessor>("UserControlPostProcessor"); beanContextFactory.RegisterBean <DataChangeControllerPostProcessor>("dataChangeControllerPostProcessor"); #if SILVERLIGHT beanContextFactory.RegisterBean <CommandBindingHelper>("commandBindingHelper").Autowireable <ICommandBindingHelper>(); #endif SynchronizationContext current = SynchronizationContext.Current; if (current != null) { beanContextFactory.RegisterExternalBean("synchronizationContext", current).Autowireable <SynchronizationContext>(); } beanContextFactory.RegisterBean <SharedData>("sharedData").Autowireable(typeof(ISharedData), typeof(ISharedDataHandOnExtendable)); #if SILVERLIGHT beanContextFactory.RegisterBean <FilterDescriptorConverter>("filterDescriptorConverter").Autowireable <IFilterDescriptorConverter>(); #endif //TODO Replace by CacheServiceExtendable Mocks //if (!IsCacheServiceBeanActive) //{ // beanContextFactory.registerBean<CacheServiceMock>("cacheServiceMock").autowireable(/*typeof(ICacheService),*/ typeof(IPersistenceMock)); //} //if (!IsMergeServiceBeanActive) //{ // ParamChecker.AssertNotNull(MergeServiceMockType, "MergeServiceMockType"); // //beanContextFactory.registerBean("mergeServiceMock", MergeServiceMockType).autowireable<IMergeService>(); //} }
public void AfterPropertiesSet(IBeanContextFactory beanContextFactory) { ParamChecker.AssertNotNull(ProxyFactory, "ProxyFactory"); // One of maybe hundred models of any type beanContextFactory.RegisterBean <GenericViewModel <TestEntity> >("model_TestEntity_all"); beanContextFactory.RegisterBean <ModelMultiContainer <TestEntity> >("selected_TestEntity_all"); beanContextFactory.RegisterBean <AllTestEntitiesRefresher>("refresher_TestEntity_all"); ViewModelDataChangeController <TestEntity> vmdccTestEntity = (ViewModelDataChangeController <TestEntity>) beanContextFactory.RegisterBean <ViewModelDataChangeController <TestEntity> >("controller_TestEntity_all") .PropertyRefs("refresher_TestEntity_all", "model_TestEntity_all").GetInstance(); vmdccTestEntity.AddRelationPath("Relation"); beanContextFactory.RegisterBean <GenericViewModel <TestEntity2> >("model_TestEntity2_all"); beanContextFactory.RegisterBean <AllTest2EntitiesRefresher>("refresher_TestEntity2_all"); beanContextFactory.RegisterBean <ViewModelDataChangeController <TestEntity2> >("controller_TestEntity2_all") .PropertyRefs("refresher_TestEntity2_all", "model_TestEntity2_all").GetInstance(); IHelloWorldService service = ProxyFactory.CreateProxy <IHelloWorldService>(); beanContextFactory.RegisterExternalBean("client.helloWorldService", service).Autowireable <IHelloWorldService>(); if (!IsNetworkClientMode || !IsHelloWorldBeanActive) { beanContextFactory.RegisterBean <HelloWorldServiceMock>("helloWorldServiceMock"); beanContextFactory.RegisterBean <RandomDataGenerator>("randomDataGenerator").PropertyRefs(CacheNamedBeans.CacheProviderPrototype); } // Data output // beanContextFactory.registerBean<DataProvider>("dataOutput_model_TestEntity_all").propertyRef("Data", "model_TestEntity_all"); // Data input // beanContextFactory.registerBean<DataConsumer>("model_TestEntity_all_2").propertyValue("Token", "myTokenInSharedData"); }
public void AfterPropertiesSet(IBeanContextFactory beanContextFactory) { beanContextFactory.RegisterExternalBean(apc).Autowireable <IAmbethPlatformContext>(); }
public void AfterPropertiesSet(IBeanContextFactory beanContextFactory) { IHelloWorldService service = ProxyFactory.CreateProxy <IHelloWorldService>(); beanContextFactory.RegisterExternalBean("client.helloWorldService", service).Autowireable <IHelloWorldService>(); }
public void AfterPropertiesSet(IBeanContextFactory beanContextFactory) { IBeanConfiguration registryC = beanContextFactory.RegisterBean <TestRegistry>(LinkContainerTest.REGISTRY_NAME).Autowireable(typeof(ITestListenerExtendable), typeof(ITestRegistry), typeof(INotifyPropertyChanged)); IBeanConfiguration listenerC = beanContextFactory.RegisterBean <TestListener>(LinkContainerTest.LISTENER_NAME); if (ListenerName == null) { ListenerName = LinkContainerTest.LISTENER_NAME; } String registryPropertyName = LinkContainerTest.REGISTRY_PROPERTY_NAME; ILinkRegistryNeededConfiguration link1; switch (ListenerVariant) { case ListenerVariant.BY_NAME: link1 = beanContextFactory.Link(ListenerName); break; case ListenerVariant.BY_NAME_DELEGATE: if (ExtendableType == null) { ExtendableType = typeof(INotifyPropertyChanged); } beanContextFactory.RegisterExternalBean(LinkContainerTest.LISTENER_DELEGATE_NAME, new PropertyChangedEventHandler(((TestListener)listenerC.GetInstance()).HandlePropertyChangedTest)); link1 = beanContextFactory.Link(LinkContainerTest.LISTENER_DELEGATE_NAME); registryPropertyName = LinkContainerTest.REGISTRY_EVENT_PROPERTY_NAME; break; case ListenerVariant.BY_NAME_AND_METHOD: link1 = beanContextFactory.Link(ListenerName, "HandlePropertyChangedTest"); break; case ListenerVariant.BY_CONF: link1 = beanContextFactory.Link(listenerC); break; case ListenerVariant.BY_CONF_DELEGATE: if (ExtendableType == null) { ExtendableType = typeof(INotifyPropertyChanged); } IBeanConfiguration listenerDelegateC = beanContextFactory.RegisterExternalBean(LinkContainerTest.LISTENER_DELEGATE_NAME, new PropertyChangedEventHandler(((TestListener)listenerC.GetInstance()).HandlePropertyChangedTest)); link1 = beanContextFactory.Link(listenerDelegateC); registryPropertyName = LinkContainerTest.REGISTRY_EVENT_PROPERTY_NAME; break; case ListenerVariant.BY_INSTANCE: link1 = beanContextFactory.Link(listenerC.GetInstance()); break; case ListenerVariant.BY_INSTANCE_DELEGATE: if (ExtendableType == null) { ExtendableType = typeof(INotifyPropertyChanged); } link1 = beanContextFactory.Link(new PropertyChangedEventHandler(((TestListener)listenerC.GetInstance()).HandlePropertyChangedTest)); registryPropertyName = LinkContainerTest.REGISTRY_EVENT_PROPERTY_NAME; break; default: throw new System.Exception("Unsupported enum: " + ListenerVariant); } if (ExtendableType == null) { ExtendableType = typeof(ITestListenerExtendable); } ILinkConfigWithOptional link2; switch (RegistryVariant) { case RegistryVariant.BY_EXTENDABLE: link2 = link1.To(ExtendableType); break; case RegistryVariant.BY_NAME_AND_EXTENDABLE: link2 = link1.To(LinkContainerTest.REGISTRY_NAME, ExtendableType); break; case RegistryVariant.BY_NAME_AND_EVENT: link2 = link1.To(LinkContainerTest.REGISTRY_NAME, new EventDelegate <Object>(registryPropertyName)); break; case RegistryVariant.BY_NAME_AND_PROPERTY: link2 = link1.To(LinkContainerTest.REGISTRY_NAME, registryPropertyName); break; case RegistryVariant.BY_INSTANCE_AND_EXTENDABLE: link2 = link1.To(registryC.GetInstance(), ExtendableType); break; case RegistryVariant.BY_INSTANCE_AND_EVENT: link2 = link1.To(registryC.GetInstance(), new EventDelegate <Object>(registryPropertyName)); break; case RegistryVariant.BY_INSTANCE_AND_PROPERTY: link2 = link1.To(registryC.GetInstance(), registryPropertyName); break; default: throw new System.Exception("Unsupported enum: " + RegistryVariant); } if (Optional) { link2.Optional(); link2 = null; } }
protected virtual void RebuildContextDetails(IBeanContextFactory childContextFactory) { childContextFactory.RegisterExternalBean(new TestContext(this)).Autowireable <ITestContext>(); }
public virtual void AfterPropertiesSet(IBeanContextFactory beanContextFactory) { ParamChecker.AssertNotNull(RevertChangesHelper, "RevertChangesHelper"); ParamChecker.AssertNotNull(SharedData, "SharedData"); ParamChecker.AssertNotNull(SharedDataHandOnExtendable, "SharedDataHandOnExtendable"); //TODO: inject Uri as bean #if SILVERLIGHT Uri uri = HtmlPage.Document.DocumentUri; #else Uri uri = null; if (uri == null) { throw new NotSupportedException("This code has to be compatible with .NET first"); } #endif ISet <String> allBeanNames = new HashSet <String>(); if (BeansToConsume != null) { allBeanNames.UnionWith(BeansToConsume.Keys); } IDictionary <String, IModelContainer> data = null; if (Token != null) { data = SharedData.Read(Token); } if (data == null) { // Clear token to suppress handsOn in afterStarted() Token = null; data = new Dictionary <String, IModelContainer>(); } IModelMultiContainer <Uri> uriList = (IModelMultiContainer <Uri>)DictionaryExtension.ValueOrDefault(data, SourceUriBeanName); if (uriList != null) { //Url-list is avaliable uriList.Values.Add(uri); } allBeanNames.UnionWith(data.Keys); if (!allBeanNames.Contains(SourceUriBeanName)) { //Url-list is not avaliable beanContextFactory.RegisterBean <ModelMultiContainer <Uri> >(SourceUriBeanName).PropertyValue("Value", uri); } IdentityHashSet <Object> allProvidedBusinessObjects = new IdentityHashSet <Object>(); foreach (String nameInOwnContext in allBeanNames) { //Proecess the input IModelContainer dataContainer = DictionaryExtension.ValueOrDefault(data, nameInOwnContext); if (dataContainer != null) { if (dataContainer is IModelMultiContainer) { IEnumerable businessObjects = ((IModelMultiContainer)dataContainer).ValuesData; if (businessObjects != null) { allProvidedBusinessObjects.AddAll(businessObjects.Cast <object>()); } } else if (dataContainer is IModelSingleContainer) { Object businessObject = ((IModelSingleContainer)dataContainer).ValueData; if (businessObject != null) { allProvidedBusinessObjects.Add(businessObject); } } //By copying only the data, listeners are unregistered //beanContextFactory.registerBean(name, dataContainer.GetType()).propertyValue("Data", dataContainer.Data); beanContextFactory.RegisterExternalBean(nameInOwnContext, dataContainer); continue; } if (!BeansToConsume.ContainsKey(nameInOwnContext)) { continue; } //Process default-beans String aliasToDefaultBean = BeansToConsume[nameInOwnContext]; if (aliasToDefaultBean == null) { //Mandatory parameter was not present in data throw new Exception("The new Screen has not all mandatory information: \"" + nameInOwnContext + "\" is missing."); } if (!nameInOwnContext.Equals(aliasToDefaultBean)) { beanContextFactory.RegisterAlias(nameInOwnContext, aliasToDefaultBean); } } if (allProvidedBusinessObjects.Count > 0) { IRevertChangesSavepoint savepoint = RevertChangesHelper.CreateSavepoint(allProvidedBusinessObjects); beanContextFactory.RegisterExternalBean(savepoint).Autowireable <IRevertChangesSavepoint>(); } }
public void AfterPropertiesSet(IBeanContextFactory beanContextFactory) { ParamChecker.AssertNotNull(ProxyFactory, "ProxyFactory"); IBeanConfiguration serviceResultcache = beanContextFactory.RegisterBean <ServiceResultCache>().Autowireable <IServiceResultCache>(); beanContextFactory.Link(serviceResultcache, "HandleClearAllCaches").To <IEventListenerExtendable>().With(typeof(ClearAllCachesEvent)); beanContextFactory.RegisterBean <ValueHolderIEC>().Autowireable(typeof(ValueHolderIEC), typeof(IProxyHelper)); beanContextFactory.RegisterBean <CacheHelper>().Autowireable(typeof(ICacheHelper), typeof(ICachePathHelper), typeof(IPrefetchHelper)); IBeanConfiguration prioMembersProvider = beanContextFactory.RegisterBean <PrioMembersProvider>().Autowireable <IPrioMembersProvider>(); beanContextFactory.Link(prioMembersProvider, PrioMembersProvider.handleMetaDataAddedEvent).To <IEventListenerExtendable>() .With(typeof(IEntityMetaDataEvent)); beanContextFactory.RegisterBean <CacheWalker>().Autowireable <ICacheWalker>(); beanContextFactory.RegisterAutowireableBean <ICacheMapEntryTypeProvider, CacheMapEntryTypeProvider>(); beanContextFactory.RegisterAutowireableBean <IRootCacheValueFactory, RootCacheValueFactory>(); //IBeanConfiguration rootCache = beanContextFactory.registerBean<RootCache>("rootCache").autowireable(typeof(RootCache), typeof(IWritableCache)); //if (IsUseSingleChildCache) //{ // beanContextFactory.registerBean<SingletonCacheFactory>("cacheFactory") // .propertyRefs("singletonChildCache") // .autowireable<ICacheFactory>(); // IWritableCache childCache = (IWritableCache)beanContextFactory.registerBean<ChildCache>("singletonChildCache") // .propertyRefs("rootCache") // .autowireable(typeof(ICache)).GetInstance(); // ((RootCache)rootCache.GetInstance()).AddChildCache(childCache); //} //else //{ // rootCache.autowireable(typeof(ICache), typeof(IWritableCache), typeof(ICacheFactory)); //} //beanContextFactory.registerBean<RootCache>(ROOT_CACHE).autowireable<RootCache>(); //beanContextFactory.Link("rootCache").To<IOfflineListenerExtendable>(); beanContextFactory.RegisterBean <CacheRetrieverRegistry>(ROOT_CACHE_RETRIEVER).Autowireable(typeof(ICacheServiceByNameExtendable), typeof(ICacheRetrieverExtendable)); beanContextFactory.RegisterBean <FirstLevelCacheManager>("firstLevelCacheManager").Autowireable(typeof(IFirstLevelCacheExtendable), typeof(IFirstLevelCacheManager)); String rootCacheBridge = "rootCacheBridge"; beanContextFactory.RegisterBean <RootCacheBridge>(rootCacheBridge).PropertyRefs(COMMITTED_ROOT_CACHE, ROOT_CACHE_RETRIEVER); TransactionalRootCacheInterceptor txRcInterceptor = new TransactionalRootCacheInterceptor(); beanContextFactory.RegisterWithLifecycle("txRootCacheInterceptor", txRcInterceptor).PropertyRefs(COMMITTED_ROOT_CACHE, rootCacheBridge) .Autowireable(typeof(ITransactionalRootCache), typeof(ISecondLevelCacheManager)); Object txRcProxy = ProxyFactory.CreateProxy(new Type[] { typeof(IRootCache), typeof(ICacheIntern), typeof(IOfflineListener) }, txRcInterceptor); beanContextFactory.RegisterExternalBean(ROOT_CACHE, txRcProxy).Autowireable(typeof(IRootCache), typeof(ICacheIntern)); if (IsSecondLevelCacheActive) { // One single root cache instance for whole context beanContextFactory.RegisterBean <RootCache>(COMMITTED_ROOT_CACHE).PropertyRef("CacheRetriever", ROOT_CACHE_RETRIEVER) .PropertyValue("Privileged", true); beanContextFactory.Link(CacheModule.COMMITTED_ROOT_CACHE).To <IOfflineListenerExtendable>(); } else { // One root cache instance per thread sequence. Most often used in server environment where the "deactivated" // second level cache means that each thread hold his own, isolated root cache (which gets cleared with each service // request. Effectively this means that the root cache itself only lives per-request and does not hold a longer state IInterceptor threadLocalRootCacheInterceptor = (IInterceptor)beanContextFactory .RegisterBean <ThreadLocalRootCacheInterceptor>("threadLocalRootCacheInterceptor") .PropertyRef("StoredCacheRetriever", CacheModule.ROOT_CACHE_RETRIEVER).PropertyValue("Privileged", true).GetInstance(); RootCache rootCacheProxy = ProxyFactory.CreateProxy <RootCache>(threadLocalRootCacheInterceptor); beanContextFactory.RegisterExternalBean(CacheModule.COMMITTED_ROOT_CACHE, rootCacheProxy).Autowireable <RootCache>(); } beanContextFactory.RegisterBean <CacheEventTargetExtractor>("cacheEventTargetExtractor"); beanContextFactory.Link("cacheEventTargetExtractor").To <IEventTargetExtractorExtendable>().With(typeof(ICache)); beanContextFactory.RegisterBean <CacheFactory>().Autowireable <ICacheFactory>(); IInterceptor cacheProviderInterceptor = (IInterceptor)beanContextFactory .RegisterBean <CacheProviderInterceptor>("cacheProviderInterceptor") .Autowireable(typeof(ICacheProviderExtendable), typeof(ICacheProvider), typeof(ICacheContext)).GetInstance(); ICache cacheProxy = ProxyFactory.CreateProxy <ICache>(new Type[] { typeof(ICacheProvider), typeof(IWritableCache) }, cacheProviderInterceptor); beanContextFactory.RegisterExternalBean("cache", cacheProxy).Autowireable <ICache>(); beanContextFactory.RegisterBean <PagingQueryServiceResultProcessor>("pagingQuerySRP"); beanContextFactory.Link("pagingQuerySRP").To <IServiceResultProcessorExtendable>().With(typeof(IPagingResponse)); beanContextFactory.RegisterBean <CacheProvider>(CacheNamedBeans.CacheProviderSingleton).PropertyValue("CacheType", CacheType.SINGLETON); beanContextFactory.RegisterBean <CacheProvider>(CacheNamedBeans.CacheProviderThreadLocal).PropertyValue("CacheType", CacheType.THREAD_LOCAL); beanContextFactory.RegisterBean <CacheProvider>(CacheNamedBeans.CacheProviderPrototype).PropertyValue("CacheType", CacheType.PROTOTYPE); String defaultCacheProviderBeanName; switch (DefaultCacheType) { case CacheType.PROTOTYPE: { defaultCacheProviderBeanName = CacheNamedBeans.CacheProviderPrototype; break; } case CacheType.SINGLETON: { defaultCacheProviderBeanName = CacheNamedBeans.CacheProviderSingleton; break; } case CacheType.THREAD_LOCAL: { defaultCacheProviderBeanName = CacheNamedBeans.CacheProviderThreadLocal; break; } case CacheType.DEFAULT: { defaultCacheProviderBeanName = CacheNamedBeans.CacheProviderThreadLocal; break; } default: throw new Exception("Not supported type: " + DefaultCacheType); } beanContextFactory.Link(defaultCacheProviderBeanName).To <ICacheProviderExtendable>(); // CacheContextPostProcessor must be registered AFTER CachePostProcessor... Object cachePostProcessor = beanContextFactory.RegisterBean <CachePostProcessor>().GetInstance(); beanContextFactory.RegisterBean <CacheContextPostProcessor>().PropertyValue("CachePostProcessor", cachePostProcessor); if (IsNetworkClientMode && IsCacheServiceBeanActive) { IBeanConfiguration remoteCacheService = beanContextFactory.RegisterBean <ClientServiceBean>(CacheModule.EXTERNAL_CACHE_SERVICE) .PropertyValue("Interface", typeof(ICacheService)) .PropertyValue("SyncRemoteInterface", typeof(ICacheServiceWCF)) .PropertyValue("AsyncRemoteInterface", typeof(ICacheClient)).Autowireable <ICacheService>(); beanContextFactory.RegisterAlias(CacheModule.DEFAULT_CACHE_RETRIEVER, CacheModule.EXTERNAL_CACHE_SERVICE); // register to all entities in a "most-weak" manner beanContextFactory.Link(remoteCacheService).To <ICacheRetrieverExtendable>().With(typeof(Object)); //beanContextFactory.RegisterAlias(CacheModule.ROOT_CACHE_RETRIEVER, CacheModule.EXTERNAL_CACHE_SERVICE); //beanContextFactory.registerBean<CacheServiceDelegate>("cacheService").autowireable<ICacheService>(); } beanContextFactory.RegisterBean <DataObjectMixin>().Autowireable <DataObjectMixin>(); beanContextFactory.RegisterBean <EntityEqualsMixin>().Autowireable <EntityEqualsMixin>(); beanContextFactory.RegisterBean <EmbeddedTypeMixin>().Autowireable <EmbeddedTypeMixin>(); beanContextFactory.RegisterBean <PropertyChangeMixin>().Autowireable(typeof(PropertyChangeMixin), typeof(IPropertyChangeExtensionExtendable), typeof(ICollectionChangeExtensionExtendable)); beanContextFactory.RegisterBean <ValueHolderContainerMixin>().Autowireable <ValueHolderContainerMixin>(); }