aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller
diff options
context:
space:
mode:
authorLukePulverenti <luke.pulverenti@gmail.com>2013-03-02 21:47:04 -0500
committerLukePulverenti <luke.pulverenti@gmail.com>2013-03-02 21:47:04 -0500
commit0ea90ef7c62dcdbc68fb250b1066340401c9d450 (patch)
treebecb6c780a2964a442fedae12087053584e00d8b /MediaBrowser.Controller
parent71fe785c6de047a09f6f585fd407332e73415f0e (diff)
added IServerEntryPoint to replace plugin.initialize
Diffstat (limited to 'MediaBrowser.Controller')
-rw-r--r--MediaBrowser.Controller/Kernel.cs24
-rw-r--r--MediaBrowser.Controller/MediaBrowser.Controller.csproj1
-rw-r--r--MediaBrowser.Controller/Plugins/IServerEntryPoint.cs15
-rw-r--r--MediaBrowser.Controller/Updates/InstallationManager.cs6
4 files changed, 33 insertions, 13 deletions
diff --git a/MediaBrowser.Controller/Kernel.cs b/MediaBrowser.Controller/Kernel.cs
index 16175783f..99e0ef783 100644
--- a/MediaBrowser.Controller/Kernel.cs
+++ b/MediaBrowser.Controller/Kernel.cs
@@ -183,7 +183,7 @@ namespace MediaBrowser.Controller
/// <summary>
/// Composes the parts with ioc container.
/// </summary>
- protected override void FindParts()
+ protected void FindParts()
{
// For now there's no real way to inject this properly
BaseItem.LibraryManager = ApplicationHost.Resolve<ILibraryManager>();
@@ -194,8 +194,6 @@ namespace MediaBrowser.Controller
ProviderManager = (ProviderManager)ApplicationHost.CreateInstance(typeof(ProviderManager));
SecurityManager = (PluginSecurityManager)ApplicationHost.CreateInstance(typeof(PluginSecurityManager));
- base.FindParts();
-
UserDataRepositories = ApplicationHost.GetExports<IUserDataRepository>();
UserRepositories = ApplicationHost.GetExports<IUserRepository>();
DisplayPreferencesRepositories = ApplicationHost.GetExports<IDisplayPreferencesRepository>();
@@ -211,15 +209,24 @@ namespace MediaBrowser.Controller
/// Performs initializations that can be reloaded at anytime
/// </summary>
/// <returns>Task.</returns>
- protected override async Task ReloadInternal()
+ protected override async void ReloadInternal()
{
- await base.ReloadInternal().ConfigureAwait(false);
+ base.ReloadInternal();
+
+ FindParts();
+
+ await LoadRepositories().ConfigureAwait(false);
ReloadResourcePools();
ReloadFileSystemManager();
await ApplicationHost.Resolve<IUserManager>().RefreshUsersMetadata(CancellationToken.None).ConfigureAwait(false);
+
+ foreach (var entryPoint in ApplicationHost.GetExports<IServerEntryPoint>())
+ {
+ entryPoint.Run();
+ }
}
/// <summary>
@@ -263,11 +270,8 @@ namespace MediaBrowser.Controller
/// Called when [composable parts loaded].
/// </summary>
/// <returns>Task.</returns>
- protected override async Task OnComposablePartsLoaded()
+ protected Task LoadRepositories()
{
- // The base class will start up all the plugins
- await base.OnComposablePartsLoaded().ConfigureAwait(false);
-
// Get the current item repository
ItemRepository = GetRepository(ItemRepositories, Configuration.ItemRepository);
var itemRepoTask = ItemRepository.Initialize();
@@ -284,7 +288,7 @@ namespace MediaBrowser.Controller
DisplayPreferencesRepository = GetRepository(DisplayPreferencesRepositories, Configuration.DisplayPreferencesRepository);
var displayPreferencesRepoTask = DisplayPreferencesRepository.Initialize();
- await Task.WhenAll(itemRepoTask, userRepoTask, userDataRepoTask, displayPreferencesRepoTask).ConfigureAwait(false);
+ return Task.WhenAll(itemRepoTask, userRepoTask, userDataRepoTask, displayPreferencesRepoTask);
}
/// <summary>
diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
index 71116881e..63468a8e8 100644
--- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj
+++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
@@ -131,6 +131,7 @@
<Compile Include="Persistence\IUserRepository.cs" />
<Compile Include="Library\IIntroProvider.cs" />
<Compile Include="Plugins\IPluginConfigurationPage.cs" />
+ <Compile Include="Plugins\IServerEntryPoint.cs" />
<Compile Include="Plugins\PluginSecurityManager.cs" />
<Compile Include="Providers\FanartBaseProvider.cs" />
<Compile Include="Providers\IImageEnhancer.cs" />
diff --git a/MediaBrowser.Controller/Plugins/IServerEntryPoint.cs b/MediaBrowser.Controller/Plugins/IServerEntryPoint.cs
new file mode 100644
index 000000000..de6de8f84
--- /dev/null
+++ b/MediaBrowser.Controller/Plugins/IServerEntryPoint.cs
@@ -0,0 +1,15 @@
+using System;
+
+namespace MediaBrowser.Controller.Plugins
+{
+ /// <summary>
+ /// Interface IServerEntryPoint
+ /// </summary>
+ public interface IServerEntryPoint : IDisposable
+ {
+ /// <summary>
+ /// Runs this instance.
+ /// </summary>
+ void Run();
+ }
+}
diff --git a/MediaBrowser.Controller/Updates/InstallationManager.cs b/MediaBrowser.Controller/Updates/InstallationManager.cs
index d616e8898..f67f690ae 100644
--- a/MediaBrowser.Controller/Updates/InstallationManager.cs
+++ b/MediaBrowser.Controller/Updates/InstallationManager.cs
@@ -287,7 +287,7 @@ namespace MediaBrowser.Controller.Updates
{
var catalog = await GetAvailablePackages(cancellationToken).ConfigureAwait(false);
- var plugins = Kernel.Plugins;
+ var plugins = ApplicationHost.Plugins;
if (withAutoUpdateEnabled)
{
@@ -424,7 +424,7 @@ namespace MediaBrowser.Controller.Updates
if (!(Path.GetExtension(package.targetFilename) ?? "").Equals(".zip", StringComparison.OrdinalIgnoreCase))
{
// Set last update time if we were installed before
- var plugin = Kernel.Plugins.FirstOrDefault(p => p.Name.Equals(package.name, StringComparison.OrdinalIgnoreCase));
+ var plugin = ApplicationHost.Plugins.FirstOrDefault(p => p.Name.Equals(package.name, StringComparison.OrdinalIgnoreCase));
if (plugin != null)
{
@@ -460,7 +460,7 @@ namespace MediaBrowser.Controller.Updates
plugin.OnUninstalling();
// Remove it the quick way for now
- Kernel.RemovePlugin(plugin);
+ ApplicationHost.RemovePlugin(plugin);
File.Delete(plugin.AssemblyFilePath);