protected IRootCache AcquireRootCache(bool privileged, ThreadLocal <RootCache> currentRootCacheTL, ICacheRetriever cacheRetriever, Lock readLock, Lock writeLock)
        {
            IBeanRuntime <RootCache> rootCacheBR = ServiceContext.RegisterBean <RootCache>()        //
                                                   .PropertyValue("CacheRetriever", cacheRetriever) //
                                                   .PropertyValue("BoundThread", Thread.CurrentThread);

            if (readLock != null)
            {
                rootCacheBR.PropertyValue("ReadLock", readLock);
            }
            if (writeLock != null)
            {
                rootCacheBR.PropertyValue("WriteLock", writeLock);
            }
            RootCache rootCache = PostProcessRootCacheConfiguration(rootCacheBR).PropertyValue("Privileged", privileged).Finish();

            if (OfflineListenerExtendable != null)
            {
                OfflineListenerExtendable.AddOfflineListener(rootCache);
            }
            currentRootCacheTL.Value = rootCache;
            return(rootCache);
        }
Пример #2
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);
        }
Пример #3
0
        public IObjectCommand Build(ICommandTypeRegistry commandTypeRegistry, IObjectFuture objectFuture, Object parent, params Object[] optionals)
        {
            IObjectCommand command;

            if (parent == null)
            {
                command = BuildIntern <ResolveObjectCommand>(commandTypeRegistry, objectFuture, parent).Finish();
            }
            else if (parent.GetType().IsArray)
            {
                command = BuildIntern <ArraySetterCommand>(commandTypeRegistry, objectFuture, parent).PropertyValue("Index", optionals[0]).Finish();
            }
            else if (parent is IEnumerable && !(parent is String))
            {
                IBeanRuntime <CollectionSetterCommand> beanRuntime = BuildIntern <CollectionSetterCommand>(commandTypeRegistry, objectFuture, parent);
                if (optionals.Length > 0)
                {
                    beanRuntime.PropertyValue("AddMethod", optionals[0]);
                }
                if (optionals.Length > 1)
                {
                    beanRuntime.PropertyValue("Obj", optionals[1]);
                }
                command = beanRuntime.Finish();
            }
            else if (parent is CreateContainer || parent is UpdateContainer)
            {
                command = BuildIntern <MergeCommand>(commandTypeRegistry, objectFuture, parent).Finish();
            }
            else
            {
                command = BuildIntern <ObjectSetterCommand>(commandTypeRegistry, objectFuture, parent).PropertyValue("Member", optionals[0]).Finish();
            }

            return(command);
        }