diff options
Diffstat (limited to 'lib/Plugins')
-rw-r--r-- | lib/Plugins/src/Attributes/ServiceConfiguratorAttribute.cs | 58 | ||||
-rw-r--r-- | lib/Plugins/src/ExportFlags.cs (renamed from lib/Plugins/src/Web/IEndpoint.cs) | 17 | ||||
-rw-r--r-- | lib/Plugins/src/IPlugin.cs | 13 | ||||
-rw-r--r-- | lib/Plugins/src/IPluginServicePool.cs (renamed from lib/Plugins/src/Web/IWebPlugin.cs) | 25 |
4 files changed, 33 insertions, 80 deletions
diff --git a/lib/Plugins/src/Attributes/ServiceConfiguratorAttribute.cs b/lib/Plugins/src/Attributes/ServiceConfiguratorAttribute.cs deleted file mode 100644 index 123fb66..0000000 --- a/lib/Plugins/src/Attributes/ServiceConfiguratorAttribute.cs +++ /dev/null @@ -1,58 +0,0 @@ -/* -* Copyright (c) 2023 Vaughn Nugent -* -* Library: VNLib -* Package: VNLib.Plugins -* File: ServiceConfiguratorAttribute.cs -* -* ServiceConfiguratorAttribute.cs is part of VNLib.Plugins which is part of the larger -* VNLib collection of libraries and utilities. -* -* VNLib.Plugins is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published -* by the Free Software Foundation, either version 2 of the License, -* or (at your option) any later version. -* -* VNLib.Plugins is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with VNLib.Plugins. If not, see http://www.gnu.org/licenses/. -*/ - -using System; -using System.ComponentModel.Design; - -namespace VNLib.Plugins.Attributes -{ - /// <summary> - /// <para> - /// Declare this attribute on an <see cref="IPlugin"/> instance method to define the service configuration - /// method. When declared, allows the plugin to expose shared types to the host - /// </para> - /// <para> - /// This method may be runtime dependant, it may not be called on all platforms, and it - /// may not be required. - /// </para> - /// <para> - /// Lifecycle: This method may be called by the runtime anytime after the <see cref="IPlugin.Load"/> - /// method, its exposed services are considered invalid after the <see cref="IPlugin.Unload"/> - /// method is called. - /// </para> - /// <para> - /// Method signature: <code>void OnServiceConfiguration(<see cref="IServiceContainer"/> container)</code> - /// </para> - /// </summary> - [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)] - public sealed class ServiceConfiguratorAttribute : Attribute - { } - - /// <summary> - /// A safe delegate that matches the signature of the <see cref="ServiceConfiguratorAttribute"/> - /// method exposed - /// </summary> - /// <param name="sender"></param> - public delegate void ServiceConfigurator(IServiceContainer sender); -} diff --git a/lib/Plugins/src/Web/IEndpoint.cs b/lib/Plugins/src/ExportFlags.cs index 33d49df..25c1f9f 100644 --- a/lib/Plugins/src/Web/IEndpoint.cs +++ b/lib/Plugins/src/ExportFlags.cs @@ -1,11 +1,11 @@ /* -* Copyright (c) 2022 Vaughn Nugent +* Copyright (c) 2024 Vaughn Nugent * * Library: VNLib * Package: VNLib.Plugins -* File: IEndpoint.cs +* File: ExportFlags.cs * -* IEndpoint.cs is part of VNLib.Plugins which is part of the larger +* ExportFlags.cs is part of VNLib.Plugins which is part of the larger * VNLib collection of libraries and utilities. * * VNLib.Plugins is free software: you can redistribute it and/or modify @@ -22,16 +22,19 @@ * along with VNLib.Plugins. If not, see http://www.gnu.org/licenses/. */ +using System; + namespace VNLib.Plugins { /// <summary> - /// A base class for all entity processing endpoints to listen for requests + /// Service export flags /// </summary> - public interface IEndpoint + [Flags] + public enum ExportFlags { /// <summary> - /// The location path for which to match this handler + /// No flags /// </summary> - public string Path { get; } + None = 0, } }
\ No newline at end of file diff --git a/lib/Plugins/src/IPlugin.cs b/lib/Plugins/src/IPlugin.cs index c1fa6a6..cf581d6 100644 --- a/lib/Plugins/src/IPlugin.cs +++ b/lib/Plugins/src/IPlugin.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) 2023 Vaughn Nugent +* Copyright (c) 2024 Vaughn Nugent * * Library: VNLib * Package: VNLib.Plugins @@ -43,5 +43,16 @@ namespace VNLib.Plugins /// Invoked when the plugin is unloaded from the runtime /// </summary> void Unload(); + + /// <summary> + /// Called directly after the plugin is loaded to allow for service + /// publishing for the host application to use + /// <para> + /// NOTE: A service pool is shared for each assembly, if there are multiple + /// plugins per assembly, they will share the same service pool. + /// </para> + /// </summary> + /// <param name="pool">The service publisher instance</param> + void PublishServices(IPluginServicePool pool); } }
\ No newline at end of file diff --git a/lib/Plugins/src/Web/IWebPlugin.cs b/lib/Plugins/src/IPluginServicePool.cs index ed080d0..a4c5e9a 100644 --- a/lib/Plugins/src/Web/IWebPlugin.cs +++ b/lib/Plugins/src/IPluginServicePool.cs @@ -1,11 +1,11 @@ /* -* Copyright (c) 2023 Vaughn Nugent +* Copyright (c) 2024 Vaughn Nugent * * Library: VNLib * Package: VNLib.Plugins -* File: IWebPlugin.cs +* File: IPluginServicePool.cs * -* IWebPlugin.cs is part of VNLib.Plugins which is part of the larger +* IPluginServicePool.cs is part of VNLib.Plugins which is part of the larger * VNLib collection of libraries and utilities. * * VNLib.Plugins is free software: you can redistribute it and/or modify @@ -22,24 +22,21 @@ * along with VNLib.Plugins. If not, see http://www.gnu.org/licenses/. */ -using System.Collections.Generic; +using System; namespace VNLib.Plugins { /// <summary> - /// Represents a plugin that is expected to perform web application based operations + /// Represents a type that exposes services to the loading application /// </summary> - public interface IWebPlugin : IPlugin + public interface IPluginServicePool { /// <summary> - /// Returns all endpoints within the plugin to load into the current root + /// Publishes a generic service to the service pool /// </summary> - /// <returns>An enumeration of endpoints to load</returns> - /// <remarks> - /// Lifecycle: Results returned from this method should be consistant (although its only - /// likely to be called once) anytime after the <see cref="IPlugin.Load"/> method, and undefined - /// after the <see cref="IPlugin.Unload"/> method is called. - /// </remarks> - IEnumerable<IEndpoint> GetEndpoints(); + /// <param name="serviceType">The <see cref="Type"/> to expose to the pool for searching</param> + /// <param name="service">The service instance to publish</param> + /// <param name="flags">Optional flags to pass during export</param> + void ExportService(Type serviceType, object service, ExportFlags flags = ExportFlags.None); } }
\ No newline at end of file |