ABP is built on the idea of supporting modular design. The specific function can be designed as a separate module. The ABP underlying framework provides a convenient way to integrate each module. is the base class for all the module's module.abpmodule, which already has a protected member of Iiocmanager and Iabpstartupconfiguration, from which the MoD is derived Ule can access and use the relevant features directly. :
The following is an example of Abpwebmvcmodule, which is a module of the ABP customization that inherits from Abpmodule. So how does this module integrate with the ABP bottom frame?
the so-called integration can be viewed from two angles:
First, How does ABP's underlying framework find this module?
second, How does this module register its components with the ABP bottom frame (Abpwebmvcmodule is how to register the controller in the container of the ABP underlying framework)?
Analyze the second problem first: Preinitialize and Initialize in the Abpwebmvcmodule class in the following code are good answers to this question. In Preinitialize, the ABP calls Iocmanager's Addconventionalregistrar method to instantiate the Controllerconventionalregistrar as a parameter. The previous article has introduced the usefulness of Controllerconventionalregistrar, Instances of this class are injected into the ABP underlying framework (that is, Iocmanager) when executing rejisterassembly. Initialize this registers a castle windsorcontrollerfactory to replace the default controllerfactory under MVC.
The Addconventionalregistrar method list<iconventionaldependencyregistrar> the registration mechanism to a private generic collection of Iocmanager, Usually all of the module classes are called in a pre-initialization method to determine which types need to be registered (without having to call them if not)
Now look back at the first question: How does the ABP underlying framework find this module?
Explain the problem before explaining how the module's descriptive information is encapsulated. abpmoduleinfo is used to encapsulate The basic information of abpmodule. abpmodulecollection is a collection of Abpmoduleinfo.
ABP Bottom Frame Discovery module is from AbpbootstrapperIn the executionInitializeMethod, the method invokes theIabpmodulemanagerOfInitializemodules method, which then calls Defaultmodulefinder findall Method (This method is used to filter out abpmodule assemblyfindall method call typefinder get all assembly . So as long as you have a class that inherits to Abpmodule in your defined assembly, and the assembly is referenced to your project, then this module can be said to be integrated by the ABP underlying framework.
Specific relationship such as.
&NBSP;
Abpmodulemanager Get all the abpmodule abpmoduleinfo Later, call these Module preinitialize one by one, Initialize and postinitialize to complete initialization. At this point, Abpwebmvcmodule has completed integration with ABP's underlying framework. It is worth mentioning that the shutdown of all abpmodule is also done through abpmodulemanager call shutdownmodules to traverse the execution abpmodule Shutdown to achieve.
The above explains the registration and initialization of custom modules, so how does the registration of some of the functional modules of the ABP underlying framework work? Implemented by Abpkernelmodule, the class invokes the various registers in the initialization (interceptor injection) completion. Future articles will explain these functional modules one by one.
ABP Source Code Analysis three: ABP Module