示例#1
0
        protected override void DoConfigure(IConfigSectionNode node)
        {
            base.DoConfigure(node);
            if (node == null)
            {
                return;
            }

            var nbundled = node[CONFIG_BUNDLED_MONGO_SECTION];

            if (nbundled.Exists)
            {
                DisposeAndNull(ref m_Bundled);
                m_Bundled = FactoryUtils.MakeAndConfigureDirectedComponent <BundledMongoDb>(this, nbundled, typeof(BundledMongoDb));

                m_EffectiveServerNode = m_Bundled.ServerNode;
            }
            else
            {
                var n = node.Of(CONFIG_SERVER_NODE_ATTR);
                if (!n.Exists || n.Value.IsNullOrWhiteSpace())
                {
                    throw new CallGuardException(nameof(MongoDbAppliance), CONFIG_SERVER_NODE_ATTR, "Attribute must be specified when no bundled Mongo instance hosted");
                }

                m_EffectiveServerNode = new Node(n.Value);
            }
        }
示例#2
0
        protected override void DoConfigure(IConfigSectionNode node)
        {
            const string CONFIG = "configuring";

            base.DoConfigure(node);

            foreach (var pnode in node[CONFIG_PROVIDERS_SECTION].Children.Where(n => n.IsSameName(CONFIG_PROVIDER_SECTION)))
            {
                var name = pnode.AttrByName(CONFIG_NAME_ATTR).ValueAsString();
                run(() => FactoryUtils.MakeAndConfigureDirectedComponent <Provider>(this, pnode, null, new object[] { name }), CONFIG, "provider", name);
            }

            foreach (var bnode in node[CONFIG_BINDINGS_SECTION].Children.Where(n => n.IsSameName(CONFIG_BINDING_SECTION)))
            {
                var name = bnode.AttrByName(CONFIG_NAME_ATTR).ValueAsString();
                run(() => FactoryUtils.MakeAndConfigureDirectedComponent <Binding>(this, bnode, null, new object[] { name, null }), CONFIG, "binding", name);
            }

            foreach (var snode in node[CONFIG_SERVERS_SECTION].Children.Where(n => n.IsSameName(CONFIG_SERVER_SECTION)))
            {
                var name = snode.AttrByName(CONFIG_NAME_ATTR).ValueAsString();
                run(() => FactoryUtils.MakeAndConfigure <ServerEndPoint>(snode,
                                                                         defaultType: typeof(ServerEndPoint), args: new object[] { this, name }), CONFIG, "server", name);
            }

            run(() => MsgInspectorConfigurator.ConfigureClientInspectors(App, m_ClientMsgInspectors, node), CONFIG, "ClientInspectors");
            run(() => MsgInspectorConfigurator.ConfigureServerInspectors(App, m_ServerMsgInspectors, node), CONFIG, "ServerInspectors");
        }
示例#3
0
        protected override void DoConfigure(IConfigSectionNode node)
        {
            node.NonEmpty(nameof(GdidProviderModule) + ".conf");
            base.DoConfigure(node);

            var isLocal = node.Of(CONFIG_LOCAL_ATTR).ValueAsBool(false);

            var naccessor = node[CONFIG_ACCESSOR_SECT];

            if (!isLocal && naccessor.Exists)
            {
                var accessor = FactoryUtils.MakeAndConfigureDirectedComponent <IGdidAuthorityAccessor>(this, naccessor);
                m_Generator = new GdidGenerator(this, nameof(GdidProviderModule), ScopePrefix, SequencePrefix, accessor);
            }
            else
            {
                if (isLocal)
                {
                    m_Generator = new LocalGdidGenerator(this);
                }
                else
                {
                    m_Generator = new GdidGenerator(this, nameof(GdidProviderModule));
                }
            }

            var ngen = node[CONFIG_GENERATOR_SECT];

            if (ngen.Exists && m_Generator is IConfigurable configurable)
            {
                configurable.Configure(ngen);
            }
        }
示例#4
0
文件: Event.cs 项目: erxdkh/azos
        public virtual void Configure(IConfigSectionNode config)
        {
            if (Disposed)
            {
                return;
            }

            if (EventHandler?.ComponentDirector == this)
            {
                DisposeIfDisposableAndNull(ref EventHandler);
            }

            if (config == null)
            {
                return;
            }
            ConfigAttribute.Apply(this, config);

            var loc = config[TimeLocation.CONFIG_TIMELOCATION_SECTION];

            if (loc.Exists)
            {
                m_TimeLocation = FactoryUtils.MakeAndConfigure <TimeLocation>(loc, typeof(TimeLocation));
            }

            var ehnode = config[CONFIG_HANDLER_SECTION];

            if (ehnode.Exists)
            {
                EventHandler = FactoryUtils.MakeAndConfigureDirectedComponent <IEventHandler>(this, ehnode);
            }
        }
示例#5
0
        protected override void DoConfigure(IConfigSectionNode node)
        {
            base.DoConfigure(node);
            DisposeAndNull(ref m_LogArchiveGraph);
            DisposeAndNull(ref m_Log);
            DisposeAndNull(ref m_Instrumentation);

            if (node == null)
            {
                return;
            }

            var nArchive = node[CONFIG_LOG_ARCHIVE_SECTION];

            if (nArchive.Exists)
            {
                m_LogArchiveGraph = FactoryUtils.MakeAndConfigureDirectedComponent <ILogImplementation>(this, nArchive, typeof(LogDaemon));
            }

            var nStore = node[CONFIG_STORE_SECTION];

            if (nStore.Exists)
            {
                m_Log             = FactoryUtils.MakeAndConfigureDirectedComponent <ILogChronicleStoreImplementation>(this, nStore);
                m_Instrumentation = m_Log.CastTo <IInstrumentationChronicleStoreImplementation>("cfg section `{0}`".Args(CONFIG_STORE_SECTION));
            }
            else
            {
                m_Log = FactoryUtils.MakeAndConfigureDirectedComponent <ILogChronicleStoreImplementation>(this,
                                                                                                          node[CONFIG_LOG_STORE_SECTION].NonEmpty(CONFIG_LOG_STORE_SECTION));

                m_Instrumentation = FactoryUtils.MakeAndConfigureDirectedComponent <IInstrumentationChronicleStoreImplementation>(this,
                                                                                                                                  node[CONFIG_INSTRUMENTATION_STORE_SECTION].NonEmpty(CONFIG_INSTRUMENTATION_STORE_SECTION));
            }
        }
示例#6
0
文件: CacheModule.cs 项目: azist/azos
        protected override void DoConfigure(IConfigSectionNode node)
        {
            base.DoConfigure(node);

            if (node == null || !node.Exists)
            {
                return;
            }

            DisposeAndNull(ref m_Cache);
            DisposeAndNull(ref m_Pile);

            var ncache = node[CONFIG_CACHE_SECTION];

            m_Cache = FactoryUtils.MakeAndConfigureDirectedComponent <ICacheImplementation>(this,
                                                                                            ncache,
                                                                                            typeof(LocalCache),
                                                                                            new[] { "Cache::{0}::{1}".Args(nameof(CacheModule), Name) });
            if (m_Cache is LocalCache lcache)
            {
                var npile = node[CONFIG_PILE_SECTION];
                m_Pile = FactoryUtils.MakeAndConfigureDirectedComponent <IPileImplementation>(this,
                                                                                              npile,
                                                                                              typeof(DefaultPile),
                                                                                              new[] { "Pile::{0}::{1}".Args(nameof(CacheModule), Name) });
                lcache.Pile = m_Pile;
            }
        }
示例#7
0
        protected override void DoConfigure(IConfigSectionNode node)
        {
            base.DoConfigure(node);
            if (node == null || !node.Exists)
            {
                return;
            }

            var nsec = node[CONFIG_CLIENT_SECURITY_SECTION];

            if (nsec.Exists)
            {
                m_ClientSecurity = FactoryUtils.MakeAndConfigureDirectedComponent <ISecurityManagerImplementation>(this, nsec, typeof(ConfigSecurityManager));
                if (m_ClientSecurity is Daemon daemon)
                {
                    daemon.Start();
                }
            }

            var nring = node[CONFIG_TOKEN_RING_SECTION];

            if (nring.Exists)
            {
                m_TokenRing = FactoryUtils.MakeAndConfigureDirectedComponent <ITokenRingImplementation>(this, nring);
                if (m_TokenRing is Daemon daemon)
                {
                    daemon.Start();
                }
            }
        }
示例#8
0
        protected override void DoConfigure(IConfigSectionNode node)
        {
            base.DoConfigure(node);
            var ndata = node.NonEmpty(nameof(node))[CONFIG_DATA_SECTION]
                        .NonEmpty($"section `{CONFIG_DATA_SECTION}`");

            m_Data = FactoryUtils.MakeAndConfigureDirectedComponent <IForestDataSource>(this, ndata, typeof(ForestDataSource));
        }
示例#9
0
        protected override void DoConfigure(IConfigSectionNode node)
        {
            var nlog = node.NonEmpty(nameof(node))[CommonApplicationLogic.CONFIG_LOG_SECTION]
                       .NonEmpty($"`{CommonApplicationLogic.CONFIG_LOG_SECTION}` config section");

            DisposeAndNull(ref m_Log);

            m_Log = FactoryUtils.MakeAndConfigureDirectedComponent <ILogImplementation>(this, nlog, typeof(LogDaemon));

            base.DoConfigure(node);
        }
示例#10
0
        protected override void DoConfigure(IConfigSectionNode node)
        {
            if (node == null || !node.Exists)
            {
                throw new WaveException(StringConsts.CONFIG_PORTAL_HUB_NODE_ERROR);
            }

            foreach (var cn in node.Children.Where(cn => cn.IsSameName(CONFIG_PORTAL_SECTION)))
            {
                var portal = FactoryUtils.MakeDirectedComponent <Portal>(this, cn, extraArgs: new [] { cn });
                if (!m_Portals.Register(portal))
                {
                    throw new WaveException(StringConsts.PORTAL_HUB_MODULE_ALREADY_CONTAINS_PORTAL_ERROR.Args(portal.Name));
                }
            }


            //Make File System
            var fsNode = node[CONFIG_CONTENT_FS_SECTION];

            m_ContentFS = FactoryUtils.MakeAndConfigureDirectedComponent <FileSystem>(this, fsNode, typeof(IO.FileSystem.Local.LocalFileSystem));
            var fsPNode = fsNode[CONFIG_FS_CONNECT_PARAMS_SECTION];

            if (fsPNode.Exists)
            {
                m_ContentFSConnect = FileSystemSessionConnectParams.Make <FileSystemSessionConnectParams>(fsPNode);
            }
            else
            {
                m_ContentFSConnect = new FileSystemSessionConnectParams()
                {
                    User = Azos.Security.User.Fake
                };
            }

            m_ContentFSRootPath = fsNode.AttrByName(CONFIG_FS_ROOT_PATH_ATTR).Value;
            if (m_ContentFSRootPath.IsNullOrWhiteSpace())
            {
                throw new WaveException(StringConsts.CONFIG_PORTAL_HUB_FS_ROOT_PATH_ERROR.Args(CONFIG_CONTENT_FS_SECTION, CONFIG_FS_ROOT_PATH_ATTR));
            }

            //todo temporary - uncomment after done
            //var cmsNode = node[CONFIG_CMS_BANK_SECTION];
            //if (cmsNode.Exists)
            //{
            //  m_CMSBank = FactoryUtils.MakeAndConfigure<CMS.ICMSBankImplementation>(cmsNode, typeof(CMS.CMSBank));
            //  var svc = m_CMSBank as ServiceModel.Service;
            //  if (svc!=null)
            //    svc.Start();
            //}
            //else
            m_CMSBank = CMS.NOPCMSBank.Instance;
        }
示例#11
0
        protected override void DoConfigure(IConfigSectionNode node)
        {
            node.NonEmpty(nameof(GdidAuthorityModule) + ".conf");

            base.DoConfigure(node);

            var nauth = node[CONFIG_AUTHORITY_SECT];

            nauth.NonEmpty("cfg section `{0}`".Args(CONFIG_AUTHORITY_SECT));

            DisposeAndNull(ref m_Svc);
            m_Svc = FactoryUtils.MakeAndConfigureDirectedComponent <GdidAuthorityService>(this, nauth, typeof(GdidAuthorityService));
        }
示例#12
0
        protected override void DoConfigure(IConfigSectionNode node)
        {
            base.DoConfigure(node);
            DisposeAndNull(ref m_Bundled);
            if (node == null)
            {
                return;
            }

            var nbundled = node[CONFIG_BUNDLED_MONGO_SECTION];

            if (nbundled.Exists)
            {
                m_Bundled = FactoryUtils.MakeAndConfigureDirectedComponent <BundledMongoDb>(this, nbundled, typeof(BundledMongoDb));
            }
        }
示例#13
0
        protected override void DoConfigure(IConfigSectionNode node)
        {
            base.DoConfigure(node);
            m_Config = node;

            DisposeAndNull(ref m_Cryptography);
            m_Cryptography = FactoryUtils.MakeAndConfigureDirectedComponent <ICryptoManagerImplementation>(
                this,
                node[CONFIG_CRYPTOGRAPHY_SECTION],
                typeof(DefaultCryptoManager));

            DisposeAndNull(ref m_PasswordManager);
            m_PasswordManager = FactoryUtils.MakeAndConfigureDirectedComponent <IPasswordManagerImplementation>(
                this,
                node[CONFIG_PASSWORD_MANAGER_SECTION],
                typeof(DefaultPasswordManager));
        }
示例#14
0
        protected override void DoConfigure(IConfigSectionNode node)
        {
            base.DoConfigure(node);

            if (node == null || !node.Exists)
            {
                return;
            }

            var ndata = node[CONFIG_DATA_STORE_SECTION];

            if (!ndata.Exists)
            {
                return;
            }

            m_Data = FactoryUtils.MakeAndConfigureDirectedComponent <ICrudDataStoreImplementation>(this, ndata);
        }
示例#15
0
        /// <summary>
        /// Override to perform custom population/registration of modules
        /// </summary>
        protected virtual void DoConfigureChildModules(IConfigSectionNode node)
        {
            cleanupChildren(false);
            if (node == null || !node.Exists)
            {
                return;
            }

            var allModules = DoGetAllChildModuleConfigNodes(node);

            foreach (var mnode in allModules)
            {
                var module = FactoryUtils.MakeAndConfigureDirectedComponent <ModuleBase>(this, mnode);
                if (!m_Children.Register(module))
                {
                    throw new AzosException(StringConsts.APP_MODULE_DUPLICATE_CHILD_ERROR.Args(this, module));
                }
            }
        }
示例#16
0
        protected override void DoConfigure(IConfigSectionNode node)
        {
            if (node == null || !node.Exists)
            {
                throw new WaveException(StringConsts.CONFIG_PORTAL_HUB_NODE_ERROR);
            }

            foreach (var cn in node.Children.Where(cn => cn.IsSameName(CONFIG_PORTAL_SECTION)))
            {
                var portal = FactoryUtils.MakeDirectedComponent <Portal>(this, cn, extraArgs: new [] { cn });
                if (!m_Portals.Register(portal))
                {
                    throw new WaveException(StringConsts.PORTAL_HUB_MODULE_ALREADY_CONTAINS_PORTAL_ERROR.Args(portal.Name));
                }
            }


            //Make File System
            var fsNode = node[CONFIG_CONTENT_FS_SECTION];

            m_ContentFS = FactoryUtils.MakeAndConfigureDirectedComponent <FileSystem>(this, fsNode, typeof(IO.FileSystem.Local.LocalFileSystem));
            var fsPNode = fsNode[CONFIG_FS_CONNECT_PARAMS_SECTION];

            if (fsPNode.Exists)
            {
                m_ContentFSConnect = FileSystemSessionConnectParams.Make <FileSystemSessionConnectParams>(fsPNode);
            }
            else
            {
                m_ContentFSConnect = new FileSystemSessionConnectParams()
                {
                    User = Azos.Security.User.Fake
                };
            }

            m_ContentFSRootPath = fsNode.AttrByName(CONFIG_FS_ROOT_PATH_ATTR).Value;
            if (m_ContentFSRootPath.IsNullOrWhiteSpace())
            {
                throw new WaveException(StringConsts.CONFIG_PORTAL_HUB_FS_ROOT_PATH_ERROR.Args(CONFIG_CONTENT_FS_SECTION, CONFIG_FS_ROOT_PATH_ATTR));
            }
        }
示例#17
0
        public void Configure(IConfigSectionNode node)
        {
            if (node == null || !node.Exists)
            {
                return;
            }

            //making FileSystem instance along with connect parameters
            var fsNode = node[CONFIG_FILE_SYSTEM_SECTION];

            DisposeAndNull(ref m_FS);//dispose existing

            //make new virtual FS instance
            m_FS = FactoryUtils.MakeAndConfigureDirectedComponent <FileSystem>(this, fsNode, typeof(Azos.IO.FileSystem.Local.LocalFileSystem));

            var paramsNode = fsNode[CONFIG_SESSION_CONNECT_PARAMS_SECTION];

            if (paramsNode.Exists)
            {
                m_FSConnectParams = FileSystemSessionConnectParams.Make <FileSystemSessionConnectParams>(paramsNode);
            }
            else
            {
                m_FSConnectParams = new FileSystemSessionConnectParams()
                {
                    User = User.Fake
                }
            };

            m_FSRootPath = fsNode.AttrByName(CONFIG_ROOT_PATH_ATTR)
                           .ValueAsString()
                           .NonBlank(CONFIG_ROOT_PATH_ATTR);

            WriteLog(MessageType.Trace,
                     nameof(FileSystemCmsSource),
                     $"Configured FS: '{m_FS.GetType().FullName}' type, using '{m_FSConnectParams.GetType().Name}' connect parameters. Root path: '{m_FSRootPath}'");
        }
示例#18
0
        protected override void DoConfigure(IConfigSectionNode node)
        {
            if (node == null)
            {
                node = App.ConfigRoot[CONFIG_DAEMON_COMPOSITE_SECTION];
            }

            foreach (var snode in node.Children
                     .Where(cn => cn.IsSameName(CONFIG_DAEMON_SECTION))
                     .OrderBy(cn => cn.AttrByName(Configuration.CONFIG_ORDER_ATTR).ValueAsInt(0)))         //the order here is needed so that child services get CREATED in order,
                                                                                                           // not only launched in order
            {
                var ignored = snode.AttrByName(CONFIG_IGNORE_THIS_DAEMON_ATTR).ValueAsBool(false);
                if (ignored)
                {
                    WriteLog(MessageType.Warning, nameof(DoConfigure), "Service {0} is ignored".Args(snode.AttrByName("name").Value));
                    continue;
                }

                var svc   = FactoryUtils.MakeAndConfigureDirectedComponent <Daemon>(this, snode);
                var abort = snode.AttrByName(CONFIG_ABORT_START_ATTR).ValueAsBool(true);
                RegisterService(svc, snode.AttrByName(Configuration.CONFIG_ORDER_ATTR).ValueAsInt(0), abort);
            }
        }
示例#19
0
        protected override void DoConfigure(IConfigSectionNode node)
        {
            base.DoConfigure(node);
            if (node == null)
            {
                return;
            }

            cleanup();

            //build forests
            foreach (var nforest in node.ChildrenNamed(CONFIG_FOREST_SECTION))
            {
                var idForest = nforest.Of(Configuration.CONFIG_NAME_ATTR, "id").ValueAsAtom(Atom.ZERO);
                if (idForest.IsZero || !idForest.IsValid)
                {
                    throw new ConfigException($"{nameof(ForestDataSource)} config `forest` section is missing a valid atom `$id`");
                }

                var trees  = new Registry <IDataStoreImplementation>();
                var forest = new _forest(idForest, trees);

                if (!m_Forests.Register(forest))
                {
                    throw new ConfigException($"{nameof(ForestDataSource)} config duplicate section: ./forest[name='{forest.Name}']");
                }

                //build trees
                foreach (var ntree in nforest.ChildrenNamed(CONFIG_TREE_SECTION))
                {
                    var idTree = ntree.Of(Configuration.CONFIG_NAME_ATTR).ValueAsAtom(Atom.ZERO);
                    if (idTree.IsZero || !idTree.IsValid)
                    {
                        throw new ConfigException($"{nameof(ForestDataSource)} config `tree` section is missing a valid atom `$id`");
                    }

                    var tree = FactoryUtils.MakeAndConfigureDirectedComponent <IDataStoreImplementation>(this, ntree);

                    if (!trees.Register(tree))
                    {
                        throw new ConfigException($"{nameof(ForestDataSource)} config duplicate section: ./forest[name='{forest.Name}']/tree['{tree.Name}']");
                    }
                }
            }

            //Build CACHE
            var ncache = node[CONFIG_CACHE_SECTION];

            m_Cache = FactoryUtils.MakeAndConfigureDirectedComponent <ICacheImplementation>(this,
                                                                                            ncache,
                                                                                            typeof(LocalCache),
                                                                                            new[] { "Cache::{0}::{1}".Args(nameof(ForestDataSource), Name) });
            if (m_Cache is LocalCache lcache)
            {
                var npile = node[CONFIG_PILE_SECTION];
                m_Pile = FactoryUtils.MakeAndConfigureDirectedComponent <IPileImplementation>(this,
                                                                                              npile,
                                                                                              typeof(DefaultPile),
                                                                                              new[] { "Pile::{0}::{1}".Args(nameof(ForestDataSource), Name) });
                lcache.Pile = m_Pile;
            }
        }
示例#20
0
 protected override void DoConfigure(IConfigSectionNode node)
 {
     base.DoConfigure(node);
     DisposeAndNull(ref m_Source);
     m_Source = FactoryUtils.MakeAndConfigureDirectedComponent <ICmsSource>(this, node[CONFIG_SOURCE_SECTION], typeof(FileSystemCmsSource));
 }