ABP Framework launches core class Abpbootstrapper from Source Learning--ABP Framework (2)

Source: Internet
Author: User


two critical properties in Abpbootstrapper: Iiocmanager and Iabpmodulemanager

   public class abpbootstrapper:idisposable
     {
       ///<summary>
        ///Gets Iiocmanager object used by this Clas S.
        </summary> public
         Iiocmanager Iocmanager {get; private set;}

         <summary>
        ///is this object disposed before?
        </summary>
         protected bool isdisposed;

        Private Iabpmodulemanager _modulemanager;
 //.........
 }

Iiocmanager internally wraps a castle-dependent injection container IWindsorContainer (ABP uses a castle Windor framework, which is based on some encapsulation),

interceptors for all types of registrations, parsing, and subsequent AOP mechanisms are registered in the container, and the specific registration and parsing functions are included in their parent interface Iiocregistrar and Iiocresolver respectively .

Public interface Iiocmanager:iiocregistrar, Iiocresolver, IDisposable
    {
        ///<summary>
         /// Reference to the Castle Windsor Container.
        </summary>
        IWindsorContainer ioccontainer {get;}
 
         <summary>
       ///Checks Whether given type is registered before.
        </summary>
         ///<param name= "type" >type to check</param>
        new bool isregistered (type type) ;

         <summary>
         ///Checks Whether given type is registered before.
         </summary>
         ///<typeparam name= "T" >type to check</typeparam>
        new bool isregistered <T> ();
     }

The class diagram of the Iiocregistrar class is as follows:


1.AddConventionalRegistrar,

2.RegisterAssemblyByConvention (Assembly Assembly),

3.RegisterAssemblyByConvention (Assembly Assembly, conventionalregistrationconfig config)

The above three methods require special attention:


The first method, Addconventionalregistrar, is to iocmanager a private generic collection list<iconventionaldependencyregistrar> registration mechanism, which is not very well understood is simply to set the injection mode of the dependency injection module,

It is usually invoked in the pre-initialization method of all the module classes to determine which types need to be registered (without calling if there is no).

For example, the Basicconventionalregistrar in the ABP assembly is to search for and register all of the implemented itransientdependency in the specified assembly. Isingletondependency and Iinterceptor classes and register them in the dependency container.


Second, the third method performs the true registration logic,

Typically called in the initialization method of a specific module, passing in the assembly to which the current module belongs.

The iteration list<iconventionaldependencyregistrar> registers the current assembly as a parameter,

Second, the third method differs in that the third method has a conventionalregistrationconfig parameter to decide whether to search for the current program and the Iwindsorinstaller implementation class in it to register, which is required by default.


The

Iabpmodulemanager is primarily used to manage all modules by default, which is a single assembly (a module corresponds to an assembly), and is primarily used to search for all module and their dependent module. First executes all the preinitialize methods of the module, executes all initialize, and finally executes all the postinitialize, The shutdown method for executing all the specific module is reversed sequentially when the shutdownmodules of the Iabpmodulemanager is executed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.