In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "what is the life cycle of abp module". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the life cycle of abp module".
Lifecycle events are abstracted into four interfaces in abp:
/ / Preinitialization
Public interface IOnPreApplicationInitialization
{
Void OnPreApplicationInitialization ([NotNull] ApplicationInitializationContext context)
}
/ / initialize
Public interface IOnApplicationInitialization
{
Void OnApplicationInitialization ([NotNull] ApplicationInitializationContext context)
}
/ / initialization completed
Public interface IOnPostApplicationInitialization
{
Void OnPostApplicationInitialization ([NotNull] ApplicationInitializationContext context)
}
/ / close
Public interface IOnApplicationShutdown
{
Void OnApplicationShutdown ([NotNull] ApplicationShutdownContext context)
}
Abp defines a module lifecycle interface that has only two methods for initializing and shutting down.
Public interface IModuleLifecycleContributor: ITransientDependency
{
Void Initialize ([NotNull] ApplicationInitializationContext context, [NotNull] IAbpModule module)
Void Shutdown ([NotNull] ApplicationShutdownContext context, [NotNull] IAbpModule module)
}
The parameter to this interface is the type of the IAbpModule interface, that is, the module type derived from AbpModule. The interface has a default implementation, which is an abstract class, mainly for reuse.
Public abstract class ModuleLifecycleContributorBase: IModuleLifecycleContributor
{
Public virtual void Initialize (ApplicationInitializationContext context, IAbpModule module)
{
}
Public virtual void Shutdown (ApplicationShutdownContext context, IAbpModule module)
{
}
}
Abp has four types based on the four lifecycles, which are created based on the module lifecycle base class.
Public class OnApplicationInitializationModuleLifecycleContributor: ModuleLifecycleContributorBase
{
Public override void Initialize (ApplicationInitializationContext context, IAbpModule module)
{
(module as IOnApplicationInitialization) .OnApplicationinitialization (context)
}
}
Public class OnApplicationShutdownModuleLifecycleContributor: ModuleLifecycleContributorBase
{
Public override void Shutdown (ApplicationShutdownContext context, IAbpModule module)
{
(module as IOnApplicationShutdown)? .OnApplication Shutdown (context)
}
}
Public class OnPreApplicationInitializationModuleLifecycleContributor: ModuleLifecycleContributorBase
{
Public override void Initialize (ApplicationInitializationContext context, IAbpModule module)
{
(module as IOnPreApplicationInitialization) .OnPreApplicationinitialization (context)
}
}
Public class OnPostApplicationInitializationModuleLifecycleContributor: ModuleLifecycleContributorBase
{
Public override void Initialize (ApplicationInitializationContext context, IAbpModule module)
{
(module as IOnPostApplicationInitialization) .OnPostApplicationinitialization (context)
}
}
Only the "close application" lifecycle implements the Shutdown method, and the rest implements the Initialize method. Finally, the parameter abp module is passed in to invoke the corresponding life cycle.
The analysis figure is as follows:
Thank you for your reading, the above is the content of "what is the life cycle of abp module". After the study of this article, I believe you have a deeper understanding of what the life cycle of abp module is, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.