From d1df44912c5519158603f75a21e70d40742623ed Mon Sep 17 00:00:00 2001 From: vnugent Date: Tue, 2 Jan 2024 02:33:18 -0500 Subject: breaking changes: plugin service pools & move plugin api away from web related --- .../src/O2AuthenticationPluginEntry.cs | 31 +++++++++++----------- .../SessionProvider/src/SessionProviderEntry.cs | 24 ++++------------- 2 files changed, 21 insertions(+), 34 deletions(-) diff --git a/libs/VNLib.Plugins.Sessions.OAuth/src/O2AuthenticationPluginEntry.cs b/libs/VNLib.Plugins.Sessions.OAuth/src/O2AuthenticationPluginEntry.cs index 1d74b7e..8181193 100644 --- a/libs/VNLib.Plugins.Sessions.OAuth/src/O2AuthenticationPluginEntry.cs +++ b/libs/VNLib.Plugins.Sessions.OAuth/src/O2AuthenticationPluginEntry.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) 2023 Vaughn Nugent +* Copyright (c) 2024 Vaughn Nugent * * Library: VNLib * Package: VNLib.Plugins.Essentials.Sessions.OAuth @@ -22,42 +22,43 @@ * along with this program. If not, see https://www.gnu.org/licenses/. */ -using System; +/* + * This file exists to make this library standalone. Meaining is can be loaded + * directly by the host as a plugin instead of being loaded by the session + * provider plugin as an asset. + */ -using System.ComponentModel.Design; +using System; using VNLib.Utils.Logging; -using VNLib.Plugins.Attributes; using VNLib.Plugins.Essentials.Sessions; using VNLib.Plugins.Extensions.Loading; namespace VNLib.Plugins.Sessions.OAuth { + public sealed class O2AuthenticationPluginEntry : PluginBase { - public override string PluginName => "Essentials.Oauth.Authentication"; - - private OAuth2SessionProvider? SessionProvider; + /// + public override string PluginName => "Essentials.Oauth.Authentication"; - [ServiceConfigurator] - public void OnServicesLoading(IServiceContainer services) - { - //Expose the OAuth2 session provider as a service singleton - services.AddService(SessionProvider!); - } - + /// protected override void OnLoad() { - SessionProvider = this.GetOrCreateSingleton(); + OAuth2SessionProvider sessionProvider = this.GetOrCreateSingleton(); + this.ExportService(sessionProvider); + Log.Information("Plugin loaded"); } + /// protected override void OnUnLoad() { Log.Information("Plugin unloaded"); } + /// protected override void ProcessHostCommand(string cmd) { throw new NotImplementedException(); diff --git a/plugins/SessionProvider/src/SessionProviderEntry.cs b/plugins/SessionProvider/src/SessionProviderEntry.cs index b5ba6fa..11a2639 100644 --- a/plugins/SessionProvider/src/SessionProviderEntry.cs +++ b/plugins/SessionProvider/src/SessionProviderEntry.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) 2023 Vaughn Nugent +* Copyright (c) 2024 Vaughn Nugent * * Library: VNLib * Package: SessionProvider @@ -27,12 +27,10 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using System.Collections.Generic; -using System.ComponentModel.Design; using VNLib.Net.Http; using VNLib.Utils; using VNLib.Utils.Logging; -using VNLib.Plugins.Attributes; using VNLib.Plugins.Extensions.Loading; namespace VNLib.Plugins.Essentials.Sessions @@ -44,21 +42,6 @@ namespace VNLib.Plugins.Essentials.Sessions { /// public override string PluginName => "Essentials.Sessions"; - - private SessionProvider _provider = new(); - - /* - * Declare a service configuration method to - * expose the session provider, the service container - * will dispose the provider instance - */ - - [ServiceConfigurator] - public void ConfigureServices(IServiceContainer services) - { - //publish the service - services.AddService(_provider); - } protected override void OnLoad() @@ -95,9 +78,12 @@ namespace VNLib.Plugins.Essentials.Sessions if (providers.Count > 0) { //Create array for searching for providers - _provider = new(providers.ToArray()); + SessionProvider provider = new(providers.ToArray()); Log.Information("Loaded {count} session providers", providers.Count); + + //Export the session provider as it's interface type + this.ExportService(provider); } else { -- cgit