Exemple #1
0
        public virtual void AfterPropertiesSet(IBeanContextFactory beanContextFactory)
        {
            beanContextFactory.RegisterAutowireableBean <IMergeController, MergeController>();
            beanContextFactory.RegisterAutowireableBean <IMergeProcess, MergeProcess>();
            beanContextFactory.RegisterAutowireableBean <ICUDResultApplier, CUDResultApplier>();
            beanContextFactory.RegisterAutowireableBean <ICUDResultComparer, CUDResultComparer>();

            beanContextFactory.RegisterAutowireableBean <CompositeIdMixin, CompositeIdMixin>();
            beanContextFactory.RegisterAutowireableBean <ObjRefMixin, ObjRefMixin>();

            beanContextFactory.RegisterBean <SecurityScopeProvider>().Autowireable(typeof(ISecurityScopeProvider), typeof(ISecurityScopeChangeListenerExtendable));
            beanContextFactory.RegisterBean <SecurityActivation>().Autowireable <ISecurityActivation>();

            beanContextFactory.RegisterBean <CacheModification>().Autowireable <ICacheModification>();

            beanContextFactory.RegisterAutowireableBean <IObjRefHelper, ObjRefHelper>();
            beanContextFactory.RegisterBean <CUDResultHelper>().Autowireable(typeof(ICUDResultHelper), typeof(ICUDResultExtendable));

            beanContextFactory.RegisterBean <EntityMetaDataReader>().Autowireable <IEntityMetaDataReader>();

            beanContextFactory.RegisterBean <MergeServiceRegistry>().Autowireable(typeof(IMergeService), typeof(IMergeServiceExtensionExtendable), typeof(IMergeListenerExtendable),
                                                                                  typeof(IMergeTimeProvider));

            IBeanConfiguration valueObjectMap = beanContextFactory.RegisterBean <ValueObjectMap>();

            IBeanConfiguration entityMetaDataProvider = beanContextFactory.RegisterBean <EntityMetaDataProvider>()
                                                        .PropertyRef("ValueObjectMap", valueObjectMap)
                                                        .Autowireable <IEntityMetaDataProvider>()
                                                        .Autowireable <IEntityMetaDataRefresher>()
                                                        .Autowireable <IValueObjectConfigExtendable>()
                                                        .Autowireable <IEntityLifecycleExtendable>()
                                                        .Autowireable <ITechnicalEntityTypeExtendable>()
                                                        .Autowireable <IEntityMetaDataExtendable>()
                                                        .Autowireable <IEntityInstantiationExtensionExtendable>();

            beanContextFactory.RegisterBean <IndependentEntityMetaDataReader>(INDEPENDENT_META_DATA_READER).Precedence(PrecedenceType.HIGH);

            if (!IndependentMetaData)
            {
                IBeanConfiguration entityMetaDataConverter = beanContextFactory.RegisterBean <EntityMetaDataConverter>();
                DedicatedConverterUtil.BiLink(beanContextFactory, entityMetaDataConverter, typeof(EntityMetaData), typeof(EntityMetaDataTransfer));

                beanContextFactory.RegisterBean <EntityMetaDataClient>(REMOTE_ENTITY_METADATA_PROVIDER);
            }
            else
            {
            }

            IBeanConfiguration ormConfigGroupProvider = beanContextFactory.RegisterBean <OrmConfigGroupProvider>().Autowireable <IOrmConfigGroupProvider>();

            beanContextFactory.Link(ormConfigGroupProvider, OrmConfigGroupProvider.handleClearAllCachesEvent).To <IEventListenerExtendable>()
            .With(typeof(ClearAllCachesEvent));

            IBeanConfiguration ormXmlReaderLegathy = beanContextFactory.RegisterBean <OrmXmlReaderLegathy>();

            ExtendableBean.RegisterExtendableBean(beanContextFactory, typeof(IOrmXmlReaderRegistry), typeof(IOrmXmlReaderExtendable))        //
            .PropertyRef(ExtendableBean.P_DEFAULT_BEAN, ormXmlReaderLegathy);
            IBeanConfiguration ormXmlReader20BC = beanContextFactory.RegisterBean <OrmXmlReader20>();

            beanContextFactory.Link(ormXmlReader20BC).To <IOrmXmlReaderExtendable>().With(OrmXmlReader20.ORM_XML_NS);

            beanContextFactory.RegisterBean <XmlConfigUtil>().Autowireable <IXmlConfigUtil>();

            beanContextFactory.RegisterBean <RelationProvider>().Autowireable(typeof(IRelationProvider), typeof(INoEntityTypeExtendable));

            beanContextFactory.RegisterBean <MemberTypeProvider>().Autowireable <IMemberTypeProvider>().Autowireable <IIntermediateMemberTypeProvider>();
            beanContextFactory.RegisterBean <EmbeddedMemberMixin>().Autowireable <EmbeddedMemberMixin>();

            beanContextFactory.RegisterBean <ObjRefFactory>().Autowireable <IObjRefFactory>();
            IBeanConfiguration objRefObjectCopierExtension = beanContextFactory.RegisterBean <ObjRefObjectCopierExtension>();

            beanContextFactory.Link(objRefObjectCopierExtension).To <IObjectCopierExtendable>().With(typeof(IObjRef));

            Type entityFactoryType = this.EntityFactoryType;

            if (entityFactoryType == null)
            {
                entityFactoryType = typeof(EntityFactory);
            }
            beanContextFactory.RegisterBean("entityFactory", entityFactoryType).Autowireable <IEntityFactory>();

            beanContextFactory.RegisterBean <ObjRefStoreEntryProvider>().Autowireable <IObjRefStoreEntryProvider>();

            if (IsNetworkClientMode && IsMergeServiceBeanActive)
            {
                IBeanConfiguration remoteMergeServiceExtension = beanContextFactory.RegisterBean <ClientServiceBean>(DEFAULT_MERGE_SERVICE_EXTENSION)
                                                                 .PropertyValue("Interface", typeof(IMergeServiceExtension))
                                                                 .PropertyValue("SyncRemoteInterface", typeof(IMergeServiceWCF))
                                                                 .PropertyValue("AsyncRemoteInterface", typeof(IMergeClient));

                // register to all entities in a "most-weak" manner
                beanContextFactory.Link(remoteMergeServiceExtension).To <IMergeServiceExtensionExtendable>().With(typeof(Object));
            }
        }
Exemple #2
0
        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>();
        }