From 0ea90ef7c62dcdbc68fb250b1066340401c9d450 Mon Sep 17 00:00:00 2001 From: LukePulverenti Date: Sat, 2 Mar 2013 21:47:04 -0500 Subject: added IServerEntryPoint to replace plugin.initialize --- MediaBrowser.Common/Kernel/BaseKernel.cs | 80 +------------------------- MediaBrowser.Common/Kernel/IApplicationHost.cs | 15 ++++- MediaBrowser.Common/Kernel/IKernel.cs | 15 +---- 3 files changed, 18 insertions(+), 92 deletions(-) (limited to 'MediaBrowser.Common/Kernel') diff --git a/MediaBrowser.Common/Kernel/BaseKernel.cs b/MediaBrowser.Common/Kernel/BaseKernel.cs index 78277ed2f3..d35ee42c93 100644 --- a/MediaBrowser.Common/Kernel/BaseKernel.cs +++ b/MediaBrowser.Common/Kernel/BaseKernel.cs @@ -1,16 +1,13 @@ using MediaBrowser.Common.Events; -using MediaBrowser.Common.Plugins; using MediaBrowser.Common.Security; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Serialization; using MediaBrowser.Model.System; using System; -using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading; -using System.Threading.Tasks; namespace MediaBrowser.Common.Kernel { @@ -121,12 +118,6 @@ namespace MediaBrowser.Common.Kernel /// The application paths. public TApplicationPathsType ApplicationPaths { get; private set; } - /// - /// Gets the list of currently loaded plugins - /// - /// The plugins. - public IEnumerable Plugins { get; protected set; } - /// /// Gets or sets the TCP manager. /// @@ -211,9 +202,9 @@ namespace MediaBrowser.Common.Kernel /// Initializes the Kernel /// /// Task. - public async Task Init() + public void Init() { - await ReloadInternal().ConfigureAwait(false); + ReloadInternal(); OnReloadCompleted(); @@ -224,64 +215,11 @@ namespace MediaBrowser.Common.Kernel /// Performs initializations that can be reloaded at anytime /// /// Task. - protected virtual async Task ReloadInternal() + protected virtual void ReloadInternal() { - // Set these to null so that they can be lazy loaded again - Configuration = null; - - await OnConfigurationLoaded().ConfigureAwait(false); - - FindParts(); - - await OnComposablePartsLoaded().ConfigureAwait(false); - ServerManager = ApplicationHost.Resolve(); } - /// - /// Called when [configuration loaded]. - /// - /// Task. - protected virtual Task OnConfigurationLoaded() - { - return Task.FromResult(null); - } - - /// - /// Composes the parts with ioc container. - /// - protected virtual void FindParts() - { - Plugins = ApplicationHost.GetExports(); - } - - /// - /// Fires after MEF finishes finding composable parts within plugin assemblies - /// - /// Task. - protected virtual Task OnComposablePartsLoaded() - { - return Task.Run(() => - { - // Start-up each plugin - Parallel.ForEach(Plugins, plugin => - { - Logger.Info("Initializing {0} {1}", plugin.Name, plugin.Version); - - try - { - plugin.Initialize(this, _xmlSerializer, Logger); - - Logger.Info("{0} {1} initialized.", plugin.Name, plugin.Version); - } - catch (Exception ex) - { - Logger.ErrorException("Error initializing {0}", ex, plugin.Name); - } - }); - }); - } - /// /// Notifies that the kernel that a change has been made that requires a restart /// @@ -442,17 +380,5 @@ namespace MediaBrowser.Common.Kernel /// /// The resource pools. public ResourcePool ResourcePools { get; set; } - - /// - /// Removes the plugin. - /// - /// The plugin. - public void RemovePlugin(IPlugin plugin) - { - var list = Plugins.ToList(); - list.Remove(plugin); - Plugins = list; - } - } } diff --git a/MediaBrowser.Common/Kernel/IApplicationHost.cs b/MediaBrowser.Common/Kernel/IApplicationHost.cs index bb007ddff1..29934988a2 100644 --- a/MediaBrowser.Common/Kernel/IApplicationHost.cs +++ b/MediaBrowser.Common/Kernel/IApplicationHost.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Model.Updates; +using MediaBrowser.Common.Plugins; +using MediaBrowser.Model.Updates; using System; using System.Collections.Generic; using System.Threading; @@ -97,5 +98,17 @@ namespace MediaBrowser.Common.Kernel /// Shuts down. /// void Shutdown(); + + /// + /// Gets the plugins. + /// + /// The plugins. + IEnumerable Plugins { get; } + + /// + /// Removes the plugin. + /// + /// The plugin. + void RemovePlugin(IPlugin plugin); } } diff --git a/MediaBrowser.Common/Kernel/IKernel.cs b/MediaBrowser.Common/Kernel/IKernel.cs index d02f0af209..0d123476ca 100644 --- a/MediaBrowser.Common/Kernel/IKernel.cs +++ b/MediaBrowser.Common/Kernel/IKernel.cs @@ -40,7 +40,7 @@ namespace MediaBrowser.Common.Kernel /// Inits this instance. /// /// Task. - Task Init(); + void Init(); /// /// Gets or sets a value indicating whether this instance has pending kernel reload. @@ -71,12 +71,6 @@ namespace MediaBrowser.Common.Kernel /// void PerformPendingRestart(); - /// - /// Gets the plugins. - /// - /// The plugins. - IEnumerable Plugins { get; } - /// /// Gets the UDP server port number. /// @@ -123,12 +117,5 @@ namespace MediaBrowser.Common.Kernel /// /// The resource pools. ResourcePool ResourcePools { get; set; } - - /// - /// Removes the plugin. - /// - /// The plugin. - void RemovePlugin(IPlugin plugin); - } } -- cgit v1.2.3