public override IClassVisitor Extend(IClassVisitor visitor, IBytecodeBehaviorState state, IList <IBytecodeBehavior> remainingPendingBehaviors,
                                             IList <IBytecodeBehavior> cascadePendingBehaviors)
        {
            if (state.GetContext <EntityEnhancementHint>() == null && state.GetContext <EmbeddedEnhancementHint>() == null)
            {
                // ensure LazyRelationsBehavior was invoked
                return(visitor);
            }
            // DefaultPropertiesBehavior executes in this cascade
            IEntityMetaData metaData        = EntityMetaDataProvider.GetMetaData(EntityUtil.GetEntityType(state.Context));
            CascadeBehavior cascadeBehavior = BeanContext.RegisterBean <CascadeBehavior>().PropertyValue("MetaData", metaData).Finish();

            cascadePendingBehaviors.Add(cascadeBehavior);

            // // NotifyPropertyChangedBehavior executes in this cascade
            // Type currentType = state.getCurrentType();
            // if (!IPropertyChanged.class.isAssignableFrom(currentType))
            // {
            // if (!isAnnotationPresent(currentType, PropertyChangeAspect.class) && !isAnnotationPresent(currentType, DataObjectAspect.class))
            // {
            // // behavior not applied
            // return visitor;
            // }
            //
            // // add IPropertyChanged
            // visitor = new InterfaceAdder(visitor, Type.getInternalName(IPropertyChanged.class));
            // }
            //
            // IPropertyInfo[] propertyInfos = propertyInfoProvider.getProperties(currentType);
            // visitor = new NotifyPropertyChangedMethodVisitor(visitor, propertyInfos, objectCollector);
            // visitor = new PublicConstructorVisitor(visitor);
            return(visitor);
        }
Пример #2
0
        public virtual IRevertChangesSavepoint CreateSavepoint(Object source)
        {
            if (source == null)
            {
                return(null);
            }
            List <Object>  objList = new List <Object>();
            List <IObjRef> objRefs = new List <IObjRef>();

            FindAllObjectsToBackup(source, objList, objRefs, new IdentityHashSet <Object>());

            IDictionary <Object, RevertChangesSavepoint.IBackup> originalToValueBackup = new IdentityDictionary <Object, RevertChangesSavepoint.IBackup>();

            // Iterate manually through the list because the list itself should not be 'backuped'
            for (int a = objList.Count; a-- > 0;)
            {
                BackupObjects(objList[a], originalToValueBackup);
            }
            WeakDictionary <Object, RevertChangesSavepoint.IBackup> weakObjectsToBackup = new WeakDictionary <Object, RevertChangesSavepoint.IBackup>(new IdentityEqualityComparer <Object>());

            DictionaryExtension.Loop(originalToValueBackup, delegate(Object obj, RevertChangesSavepoint.IBackup backup)
            {
                if (backup != null)
                {
                    weakObjectsToBackup.Add(obj, backup);
                }
            });

            return(BeanContext.RegisterBean <RevertChangesSavepoint>().PropertyValue("Changes", weakObjectsToBackup).Finish());
        }
Пример #3
0
        protected void MergePhase1(Object objectToMerge, Object objectToDelete, ProceedWithMergeHook proceedHook, MergeFinishedCallback mergeFinishedCallback, bool addNewEntitiesToCache)
        {
            ICUDResult       cudResult;
            MergeHandle      mergeHandle;
            IDisposableCache childCache = CacheFactory.Create(CacheFactoryDirective.NoDCE, false, false, "MergeProcess.ORIGINAL");

            try
            {
                mergeHandle = BeanContext.RegisterBean <MergeHandle>() //
                              .PropertyValue("Cache", childCache)      //
                              .Finish();
                cudResult         = MergeController.MergeDeep(objectToMerge, mergeHandle);
                mergeHandle.Cache = null;
            }
            finally
            {
                childCache.Dispose();
                childCache = null;
            }
            if (GuiThreadHelper.IsInGuiThread())
            {
                MergePhase2(objectToMerge, objectToDelete, mergeHandle, cudResult, proceedHook, mergeFinishedCallback, addNewEntitiesToCache);
            }
            else
            {
                GuiThreadHelper.InvokeInGui(delegate()
                {
                    MergePhase2(objectToMerge, objectToDelete, mergeHandle, cudResult, proceedHook, mergeFinishedCallback, addNewEntitiesToCache);
                });
            }
        }
            public override IClassVisitor Extend(IClassVisitor visitor, IBytecodeBehaviorState state, IList <IBytecodeBehavior> remainingPendingBehaviors,
                                                 IList <IBytecodeBehavior> cascadePendingBehaviors)
            {
                // LazyRelationsBehavior executes in this cascade
                CascadeBehavior2 cascadeBehavior2 = BeanContext.RegisterBean <CascadeBehavior2>().PropertyValue("MetaData", MetaData).Finish();

                cascadePendingBehaviors.Add(cascadeBehavior2);
                return(visitor);
            }
Пример #5
0
        public SyncInterface GetService <AsyncInterface, SyncInterface>(params ISecurityScope[] securityScopes)
            where AsyncInterface : class, ICommunicationObject
            where SyncInterface : class
        {
            AsyncInterface service = BeanContext.GetService <IServiceFactory>().GetService <AsyncInterface>(securityScopes);

            SyncCallInterceptor synchronizedInterceptor = BeanContext.RegisterBean <SyncCallInterceptor>().PropertyValue("AsyncService", service).PropertyValue("AsyncServiceInterface", typeof(AsyncInterface)).Finish();

            return((SyncInterface)ProxyFactory.CreateProxy(typeof(SyncInterface), synchronizedInterceptor));
        }
Пример #6
0
        protected void UpdateEntityMetaDataWithLifecycleExtensions(IEntityMetaData entityMetaData)
        {
            if (Object.ReferenceEquals(entityMetaData, alreadyHandled))
            {
                return;
            }
            if (entityMetaData.EnhancedType == null)
            {
                return;
            }
            IList <IEntityLifecycleExtension> extensionList = entityLifecycleExtensions.GetExtensions(entityMetaData.EntityType);
            List <IEntityLifecycleExtension>  allExtensions = new List <IEntityLifecycleExtension>();

            if (extensionList != null)
            {
                allExtensions.AddRange(extensionList);
            }
            List <MethodInfo> prePersistMethods = new List <MethodInfo>();

            FillMethodsAnnotatedWith(entityMetaData.RealType, prePersistMethods, typeof(PrePersistAttribute));

            List <MethodInfo> postLoadMethods = new List <MethodInfo>();

            FillMethodsAnnotatedWith(entityMetaData.RealType, postLoadMethods, typeof(PostLoadAttribute));

            foreach (MethodInfo prePersistMethod in prePersistMethods)
            {
                PrePersistMethodLifecycleExtension extension = BeanContext.RegisterBean <PrePersistMethodLifecycleExtension>()
                                                               .PropertyValue("Method", prePersistMethod).Finish();
                allExtensions.Add(extension);
            }
            foreach (MethodInfo postLoadMethod in postLoadMethods)
            {
                PostLoadMethodLifecycleExtension extension = BeanContext.RegisterBean <PostLoadMethodLifecycleExtension>()
                                                             .PropertyValue("Method", postLoadMethod).Finish();
                allExtensions.Add(extension);
            }
            ((EntityMetaData)entityMetaData).EntityLifecycleExtensions = allExtensions.ToArray();
        }
Пример #7
0
        protected IDisposableCache CreateIntern(CacheFactoryDirective cacheFactoryDirective, bool privileged, bool foreignThreadAware, bool?useWeakEntries, String name)
        {
            IBeanRuntime <ChildCache> firstLevelCacheBC = BeanContext.RegisterBean <ChildCache>();

            if (!foreignThreadAware)
            {
                // Do not inject EventQueue because caches without foreign interest will never receive async DCEs
                firstLevelCacheBC.IgnoreProperties("EventQueue");
            }
            if (useWeakEntries.HasValue)
            {
                firstLevelCacheBC.PropertyValue("WeakEntries", useWeakEntries.Value);
            }
            if (name != null)
            {
                firstLevelCacheBC.PropertyValue("Name", name);
            }
            firstLevelCacheBC.PropertyValue("Privileged", privileged);
            ChildCache firstLevelCache = firstLevelCacheBC.Finish();

            FirstLevelCacheExtendable.RegisterFirstLevelCache(firstLevelCache, cacheFactoryDirective, foreignThreadAware, name);
            return(firstLevelCache);
        }
Пример #8
0
 public IIncrementalMergeState AcquireNewState(ICache stateCache)
 {
     return(BeanContext.RegisterBean <IncrementalMergeState>() //
            .PropertyValue("StateCache", stateCache)           //
            .Finish());
 }
Пример #9
0
 public IPrefetchConfig CreatePrefetch()
 {
     return(BeanContext.RegisterBean <PrefetchConfig>().Finish());
 }