Open Closed

How to create something like DefinitionProvider like Permission , Feature or Settings modules did ? How they are working ? #4627


User avatar
0
selinkoykiran created

Hello, We are building a system like some entities will be seeding over different modules which are using this centralized service. We'll need something like this :

When I check the code from abp repositories like (Volo.Abp.Settings, Volo.Abp.Features , Volo.Abp.Authorization.Permissions) I couldn't understand when these definitions are seeding into database, when they are persisting ? I saw below approach in Feature and Permission side :

But I couldn't see the same approach on Settings part, but I know Settings also has a definitionProvider but I couldn't understand when these configurations persisting ? How settings module handle that ? By the way what is the difference between SaveStaticPermissionsToDatabaseAsync or InitializeDynamicPermissions (these are also included in feature side, too ) persistence. I couldn't see any documentation about these topics . But we need to understand how this system works and then we can implement for our own module. We want to understand the design of these approaches overall, Can you help ?

Thank you

  • ABP Framework version: v5.3.3
  • UI type: MVC
  • DB provider: EF Core
  • **Tiered (MVC) : yes
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

3 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    SettingDefinitionManager is a singleton service, it will get all SettingProvider and call the Define method.

    https://github.com/abpframework/abp/blob/rel-7.0/framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingDefinitionManager.cs#L53

    then we can get SettingDefinition by SettingDefinitionManager

    public class EmailSettingProvider : SettingDefinitionProvider
    {
        public override void Define(ISettingDefinitionContext context)
        {
            context.Add(
                new SettingDefinition("Smtp.Host", "127.0.0.1"),
                new SettingDefinition("Smtp.Port", "25"),
                new SettingDefinition("Smtp.UserName"),
                new SettingDefinition("Smtp.Password", isEncrypted: true),
                new SettingDefinition("Smtp.EnableSsl", "false")
            );
        }
    }
    

    These 5 pre-built setting value providers can get setting value by ISettingStore

    SettingManagementProviders of SettingManagement can read and write the setting values to the database by ISettingManagementStore.

    The main service is ISettingManager, It controls the above services.

  • User Avatar
    0
    selinkoykiran created

    So what about , permission and feature side , these have different implementation ? Settings domain module doesn't have any saveasync thing , so how does this module persist definition providers at first run ?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    permission and feature are similar to settings.

    and the Dynamic Features and Permission is https://github.com/abpframework/abp/pull/13644

Made with ❤️ on ABP v9.1.0-preview. Updated on December 13, 2024, 06:09