From 1885d865d48b2f227ec599058fb8504cf6dd746c Mon Sep 17 00:00:00 2001 From: Mahmut Gundogdu Date: Tue, 6 Dec 2022 18:02:32 +0300 Subject: [PATCH 01/13] Filter controller by service-type --- npm/ng-packs/package.json | 2 +- .../schematics/src/commands/api/index.ts | 18 ++++++++++-- .../src/commands/proxy-add/schema.json | 28 +++++++++++++++++++ .../packages/schematics/src/enums/index.ts | 1 + .../schematics/src/enums/service-types.ts | 7 +++++ .../schematics/src/models/api-definition.ts | 2 ++ .../src/models/generate-proxy-schema.ts | 3 ++ 7 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 npm/ng-packs/packages/schematics/src/enums/service-types.ts diff --git a/npm/ng-packs/package.json b/npm/ng-packs/package.json index caf8f6b67d..b540cb4d10 100644 --- a/npm/ng-packs/package.json +++ b/npm/ng-packs/package.json @@ -36,7 +36,7 @@ "lerna": "lerna", "migrate-nx": "yarn nx migrate --run-migrations", "mock:schematics": "cd scripts/mock-schematic && yarn && yarn start", - "debug:schematics": "./node_modules/.bin/ng g ./packages/schematics/src/collection.json:proxy-add --module __default --apiName __default --source __default --target __default --url http://localhost:4300" + "debug:schematics": "./node_modules/.bin/ng g ./packages/schematics/src/collection.json:proxy-add --module __default --apiName __default --source __default --target __default --url https://localhost:44305 --serviceType application" }, "private": true, "devDependencies": { diff --git a/npm/ng-packs/packages/schematics/src/commands/api/index.ts b/npm/ng-packs/packages/schematics/src/commands/api/index.ts index a344381b77..fda8117c07 100644 --- a/npm/ng-packs/packages/schematics/src/commands/api/index.ts +++ b/npm/ng-packs/packages/schematics/src/commands/api/index.ts @@ -8,8 +8,8 @@ import { Tree, url, } from '@angular-devkit/schematics'; -import { Exception } from '../../enums'; -import { GenerateProxySchema, ServiceGeneratorParams } from '../../models'; +import { defaultEServiceType, eServiceType, Exception } from '../../enums'; +import { Controller, GenerateProxySchema, ServiceGeneratorParams } from '../../models'; import { applyWithOverwrite, buildTargetPath, @@ -47,6 +47,7 @@ export default function (schema: GenerateProxySchema) { const data = readProxyConfig(tree); const types = data.types; const modules = data.modules; + const serviceType = schema.serviceType || defaultEServiceType; if (!types || !modules) throw new SchematicsException(Exception.InvalidApiDefinition); const definition = data.modules[moduleName]; @@ -54,7 +55,7 @@ export default function (schema: GenerateProxySchema) { throw new SchematicsException(interpolate(Exception.InvalidModule, moduleName)); const apiName = definition.remoteServiceName; - const controllers = Object.values(definition.controllers || {}); + const controllers = filterControllersByServiceType(serviceType, definition.controllers); const serviceImports: Record = {}; const generateServices = createServiceGenerator({ targetPath, @@ -170,3 +171,14 @@ function createServiceGenerator(params: ServiceGeneratorParams) { }), ); } + +function filterControllersByServiceType( + serviceType: eServiceType, + controllers: Record, +): Controller[] { + const itShouldBeIntegratedService = serviceType === eServiceType.Integration; + const skipFilter = serviceType === eServiceType.All; + return Object.values(controllers || {}).filter( + x => x.isIntegrationService === itShouldBeIntegratedService || skipFilter, + ); +} diff --git a/npm/ng-packs/packages/schematics/src/commands/proxy-add/schema.json b/npm/ng-packs/packages/schematics/src/commands/proxy-add/schema.json index 2cf27f9c33..0458c7c7ab 100644 --- a/npm/ng-packs/packages/schematics/src/commands/proxy-add/schema.json +++ b/npm/ng-packs/packages/schematics/src/commands/proxy-add/schema.json @@ -48,6 +48,34 @@ "index": 4 }, "x-prompt": "Please enter URL for API definition (default: API Name's url in environment file)" + }, + "serviceType": { + "description": "Service type to the generated code", + "type": "string", + "$default": "application", + "enum": [ + "application", + "integration", + "all" + ], + "x-prompt": { + "message": "Specifies the service type to generate. `application`, `integration` and `all`, Default value: `application`", + "type": "list", + "items": [ + { + "value": "all", + "label": "All" + }, + { + "value": "application", + "label": "Application" + }, + { + "value": "integration", + "label": "Integration" + } + ] + } } }, "entryPoint": { diff --git a/npm/ng-packs/packages/schematics/src/enums/index.ts b/npm/ng-packs/packages/schematics/src/enums/index.ts index aee862a5f5..9b2d376cc3 100644 --- a/npm/ng-packs/packages/schematics/src/enums/index.ts +++ b/npm/ng-packs/packages/schematics/src/enums/index.ts @@ -2,3 +2,4 @@ export * from './binding-source-id'; export * from './exception'; export * from './import-keyword'; export * from './method-modifier'; +export * from './service-types'; diff --git a/npm/ng-packs/packages/schematics/src/enums/service-types.ts b/npm/ng-packs/packages/schematics/src/enums/service-types.ts new file mode 100644 index 0000000000..1616aaca31 --- /dev/null +++ b/npm/ng-packs/packages/schematics/src/enums/service-types.ts @@ -0,0 +1,7 @@ +export enum eServiceType { + All = 'all', + Application = 'application', + Integration = 'integration', +} + +export const defaultEServiceType = eServiceType.Application; diff --git a/npm/ng-packs/packages/schematics/src/models/api-definition.ts b/npm/ng-packs/packages/schematics/src/models/api-definition.ts index 15f6ef1d0b..01af33ac3e 100644 --- a/npm/ng-packs/packages/schematics/src/models/api-definition.ts +++ b/npm/ng-packs/packages/schematics/src/models/api-definition.ts @@ -31,6 +31,8 @@ export interface Module { export interface Controller { controllerName: string; type: string; + isRemoteService: boolean; + isIntegrationService: boolean; interfaces: InterfaceDef[]; actions: Record; } diff --git a/npm/ng-packs/packages/schematics/src/models/generate-proxy-schema.ts b/npm/ng-packs/packages/schematics/src/models/generate-proxy-schema.ts index 682cdda9fe..6d4c67bcd8 100644 --- a/npm/ng-packs/packages/schematics/src/models/generate-proxy-schema.ts +++ b/npm/ng-packs/packages/schematics/src/models/generate-proxy-schema.ts @@ -1,3 +1,5 @@ +import { eServiceType } from '../enums'; + export interface GenerateProxySchema { /** * Backend module name @@ -28,4 +30,5 @@ export interface GenerateProxySchema { * Secondary entrypoint for proxy generation */ entryPoint?: string; + serviceType?: eServiceType; } From ebf15bbc414661b18ddb1c520bea045906d3b0f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Wed, 7 Dec 2022 11:21:13 +0300 Subject: [PATCH 02/13] Application-Startup --- docs/en/Application-Startup.md | 82 ++++++++++++++----- .../en/Deployment/Distributed-Microservice.md | 2 +- 2 files changed, 62 insertions(+), 22 deletions(-) diff --git a/docs/en/Application-Startup.md b/docs/en/Application-Startup.md index 5ca971e733..bd693c0761 100644 --- a/docs/en/Application-Startup.md +++ b/docs/en/Application-Startup.md @@ -1,10 +1,10 @@ ## ABP Application Startup -You typically use the [ABP CLI](CLI.md)'s `abp new` command to [get started](Getting-Started.md) with one of the pre-built [startup solution templates](Startup-Templates/Index.md). When you do that, you generally don't need to know the details of how the ABP Framework is integrated with your application, how it is configured and initialized. The startup template comes with many fundamental ABP packages and [application modules](Modules/Index) are pre-installed and configured for you. +You typically use the [ABP CLI](CLI.md)'s `abp new` command to [get started](Getting-Started.md) with one of the pre-built [startup solution templates](Startup-Templates/Index.md). When you do that, you generally don't need to know the details of how the ABP Framework is integrated with your application, how it is configured and initialized. The startup template also comes with the fundamental ABP packages and [application modules](Modules/Index) are pre-installed and configured for you. -> It is always suggested to [get started with a startup template](Getting-Started.md) and modify it for your requirements. Read that document only if you want to understand the details or you need to modify how the application starts. +> It is always suggested to [get started with a startup template](Getting-Started.md) and modify it for your requirements. Read this document only if you want to understand the details or you need to modify how the ABP Framework starts. -While the ABP Framework has a lot of features and integrations, it is built as a lightweight and modular framework. It consists of hundreds of NuGet and NMP packages, so you can use only the features you need to. If you follow the [Getting Started with an Empty ASP.NET Core MVC / Razor Pages Application](Getting-Started-AspNetCore-Application.md) document, you see how easy to install the ABP Framework into an empty ASP.NET Core project from scratch. You only install a single NuGet package and make a few small changes. +While the ABP Framework has a lot of features and integrations, it is built as a lightweight and modular framework. It consists of [hundreds of NuGet and NMP packages](https://abp.io/packages), so you can use only the features you need to. If you follow the [Getting Started with an Empty ASP.NET Core MVC / Razor Pages Application](Getting-Started-AspNetCore-Application.md) document, you see how easy to install the ABP Framework into an empty ASP.NET Core project from scratch. You only install a single NuGet package and make a few small changes. This document is for who want to better understand how the ABP Framework is initialized and configured on startup. @@ -16,7 +16,9 @@ If you [create a new console application with Visual Studio](https://learn.micro ![app-startup-console-initial](images/app-startup-console-initial.png) -This example uses the [top level statements](https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/tutorials/top-level-statements), so it consists of only a single line of code. The first step is to install the [Volo.Abp.Core](https://www.nuget.org/packages/Volo.Abp.Core) NuGet package, which is the most core NuGet package of the ABP framework. You can install it using [Package Manager Console](https://learn.microsoft.com/en-us/nuget/consume-packages/install-use-packages-powershell) in Visual Studio: +This example uses the [top level statements](https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/tutorials/top-level-statements), so it consists of only a single line of code. + +The first step is to install the [Volo.Abp.Core](https://www.nuget.org/packages/Volo.Abp.Core) NuGet package, which is the most core NuGet package of the ABP framework. You can install it using [Package Manager Console](https://learn.microsoft.com/en-us/nuget/consume-packages/install-use-packages-powershell) in Visual Studio: ````bash Install-Package Volo.Abp.Core @@ -49,15 +51,15 @@ As the second and the last step, change the `Program.cs` as shown in the followi using MyConsoleDemo; using Volo.Abp; -// 1: Create the application container +// 1: Create the ABP application container using var application = await AbpApplicationFactory.CreateAsync(); -// 2: Initialize/start the ABP Framework and all the modules +// 2: Initialize/start the ABP Framework (and all the modules) await application.InitializeAsync(); Console.WriteLine("ABP Framework has been started..."); -// 3: Stop the ABP Framework and all the modules +// 3: Stop the ABP Framework (and all the modules) await application.ShutdownAsync(); ```` @@ -65,7 +67,7 @@ That's all. Now, ABP Framework is installed, integrated, started and stopped in ## Installing a Framework Package -For example, if you want to send emails from your application, you can use .NET's standard [SmtpClient class](https://learn.microsoft.com/en-us/dotnet/api/system.net.mail.smtpclient). ABP also provides an `IEmailSender` service that simplifies [sending emails](Emailing.md) and configuring the email settings in a central place. If you want to use it, you should install the [Volo.Abp.Emailing](https://www.nuget.org/packages/Volo.Abp.Emailing) NuGet package to your project: +If you want to send emails from your .NET application, you can use .NET's standard [SmtpClient class](https://learn.microsoft.com/en-us/dotnet/api/system.net.mail.smtpclient). ABP also provides an `IEmailSender` service that simplifies [sending emails](Emailing.md) and configuring the email settings in a central place. If you want to use it, you should install the [Volo.Abp.Emailing](https://www.nuget.org/packages/Volo.Abp.Emailing) NuGet package to your project: ````bash dotnet add package Volo.Abp.Emailing @@ -79,14 +81,14 @@ using Volo.Abp.Modularity; namespace MyConsoleDemo { - [DependsOn(typeof(AbpEmailingModule))] + [DependsOn(typeof(AbpEmailingModule))] // Added the module dependency public class MyConsoleDemoModule : AbpModule { } } ```` -I've just added a `DependsOn` attribute to declare that I want to use the ABP Emailing Module (`AbpEmailingModule`). Now, I can use the `IEmailSender` service in my `Program.cs`: +I've just added a `[DependsOn]` attribute to declare that I want to use the ABP Emailing Module (`AbpEmailingModule`). Now, I can use the `IEmailSender` service in my `Program.cs`: ````csharp using Microsoft.Extensions.DependencyInjection; @@ -108,21 +110,21 @@ await emailsender.SendAsync( await application.ShutdownAsync(); ```` -> If you run this application, you get a runtime error indicating that the email sending settings hasn't been done yet. You can check the [Email Sending](Emailing.md) document to learn how to configure it. +> If you run that application, you get a runtime error indicating that the email sending settings hasn't been done yet. You can check the [Email Sending document](Emailing.md) to learn how to configure it. -That's all. Install an ABP NuGet package, add the module dependency (using the `DependsOn` attribute) and use any service inside the NuGet package. +That's all. Install an ABP NuGet package, add the module dependency (using the `[DependsOn]` attribute) and use any service inside the NuGet package. -The [ABP CLI](CLI.md) already has a special command to perform adding an ABP NuGet and also adding the `DependsOn` attribute to your module class for you with a single command: +The [ABP CLI](CLI.md) already has a special command to perform adding an ABP NuGet and also adding the `[DependsOn]` attribute to your module class for you with a single command: ````bash abp add-package Volo.Abp.Emailing ```` -We suggest you to use the `add-package` command instead of manually doing it. +We suggest you to use the `abp add-package` command instead of manually doing it. ## AbpApplicationFactory -`AbpApplicationFactory` is the main class that creates an ABP application container. It provides a single `CreateAsync` (and `Create` if you can't use asynchronous programming) method with multiple overloads. Let's investigate these overloads to understand where you can use them. +`AbpApplicationFactory` is the main class that creates an ABP application container. It provides a single static `CreateAsync` (and `Create` if you can't use asynchronous programming) method with multiple overloads. Let's investigate these overloads to understand where you can use them. The first overload gets a generic module class parameter as we've used before in this document: @@ -130,7 +132,9 @@ The first overload gets a generic module class parameter as we've used before in AbpApplicationFactory.CreateAsync(); ```` -The second overload gets the module class as a `Type` parameter, instead of a generic parameter. So, the previous code block can be re-written as shown below: +The generic class parameter should be the root module class of your application. All the other modules are resolved as dependencies of that module. + +The second overload gets the module class as a `Type` parameter, instead of the generic parameter. So, the previous code block could be re-written as shown below: ````csharp AbpApplicationFactory.CreateAsync(typeof(MyConsoleDemoModule)); @@ -138,9 +142,9 @@ AbpApplicationFactory.CreateAsync(typeof(MyConsoleDemoModule)); Both overloads works exactly same. So, you can use the second one if you don't know the module class type on development time and you (somehow) calculate it on runtime. -If you create one of the methods above, ABP creates an internal service collection (`IServiceCollection`) and an internal service provider (`IServiceProvider`) to automate the [dependency injection](Dependency-Injection.md) setup from your application code. Notice that we've used the `application.ServiceProvider` property in the *Installing a Framework Package* section to resolve the `IEmailSender` service from the dependency injection system. +If you create one of the methods above, ABP creates an internal service collection (`IServiceCollection`) and an internal service provider (`IServiceProvider`) to setup the [dependency injection](Dependency-Injection.md) system internally. Notice that we've used the `application.ServiceProvider` property in the *Installing a Framework Package* section to resolve the `IEmailSender` service from the dependency injection system. -The next overload gets an `IServiceCollection` parameter from you to allow you to set up the dependency injection system yourself, or integrate to another framework (like ASP.NET Core) that also setups the dependency injection system internally. +The next overload gets an `IServiceCollection` parameter from you to allow you to setup the dependency injection system yourself, or integrate to another framework (like ASP.NET Core) that also setups the dependency injection system internally. We can change the `Program.cs` as shown below to externally manage the dependency injection setup: @@ -167,13 +171,13 @@ Console.WriteLine("ABP Framework has been started..."); await application.ShutdownAsync(); ```` -In this example, we've used .NET's standard dependency injection container. The `services.BuildServiceProvider()` call creates the standard container. However, ABP provides an alternative extension method, `BuildServiceProviderFromFactory()`, that gracefully work even if you are using another DI container: +In this example, we've used .NET's standard dependency injection container. The `services.BuildServiceProvider()` call creates the standard container. However, ABP provides an alternative extension method, `BuildServiceProviderFromFactory()`, that properly works even if you are using another dependency injection container: ````csharp IServiceProvider serviceProvider = services.BuildServiceProviderFromFactory(); ```` -You can check the [Autofac Integration](Autofac-Integration.md) document if you want to learn how you can integrate the [Autofac](https://autofac.org/) dependency injection container with the ABP Framework. +> You can check the [Autofac Integration](Autofac-Integration.md) document if you want to learn how you can integrate the [Autofac](https://autofac.org/) dependency injection container with the ABP Framework. Finally, the `CreateAsync` method has a last overload that takes the module class name as a `Type` parameter and a `IServiceCollection` object. So, we could re-write the last `CreateAsync` method usage as like in the following code block: @@ -196,4 +200,40 @@ using var application = await AbpApplicationFactory }); ```` -We've passed a lambda method to configure the `ApplicationName` option. \ No newline at end of file +We've passed a lambda method to configure the `ApplicationName` option. Here, a list of all standard options: + +* `ApplicationName`: A human-readable name for the application. It is a unique value for an application. +* `Configuration`: Can be used to setup the [application configuration](Configuration.md) when it is not provided by the hosting system. It is not needed for ASP.NET Core and other .NET hosted applications. However, if you've used `AbpApplicationFactory` with internal service provider, you can use this option to configure how the application configuration is built. +* `PlugInSources`: A list of plugin sources. See the [Plug-In Modules documentation](PlugIn-Modules) to learn how to work with plugins. +* `Services`: The `IServiceCollection` object that can be used to register service dependencies. You generally don't need that, because you configure your services in your [module class](Module-Development-Basics.md). However, it can be used while writing extension methods for the `AbpApplicationCreationOptions` class. + +#### The ApplicationName option + +As defined above, the `ApplicationName` option is a human-readable name for the application. It is a unique value for an application. + +`ApplicationName` is used by the ABP Framework in several places to distinguish the application. For example, the [audit logging](Audit-Logging.md) system saves the `ApplicationName` in each audit log record written by the related application, so you can understand which application has created the audit log entry. So, if your system consists of multiple applications (like a microservice solution) saving audit logs to a single point, you should be sure that each application has a different `ApplicationName`. + +The `ApplicationName` property's value is set automatically from the **entry assembly's name** (generally, the project name in a .NET solution) by default, which is proper for most cases, since each application typically has a unique entry assembly name. + +There are two ways to set the application name to a different value. In this first approach, you can set the `ApplicationName` property in your application's [configuration](Configuration.md). The easiest way is to add an `ApplicationName` field to your `appsettings.json` file: + +````json +{ + "ApplicationName": "Services.Ordering" +} +```` + +Alternatively, you can set `AbpApplicationCreationOptions.ApplicationName` while creating the ABP application. You can find the `AddApplication` or `AddApplicationAsync` call in your solution (typically in the `Program.cs` file), and set the `ApplicationName` option as shown below: + +````csharp +await builder.AddApplicationAsync(options => +{ + options.ApplicationName = "Services.Ordering"; +}); +```` + +#### IApplicationInfoAccessor + +If you need to access the `ApplicationName` later in your solution, you can inject the `IApplicationInfoAccessor` service and get the value from its `ApplicationName` property. + +`IApplicationInfoAccessor` also provides an `InstanceId` value, that is a random GUID value that is generated when your application starts. You can use that value to distinguish application instances from each other. \ No newline at end of file diff --git a/docs/en/Deployment/Distributed-Microservice.md b/docs/en/Deployment/Distributed-Microservice.md index 758a41ba0d..450d968d84 100644 --- a/docs/en/Deployment/Distributed-Microservice.md +++ b/docs/en/Deployment/Distributed-Microservice.md @@ -9,7 +9,7 @@ ABP provides `IApplicationInfoAccessor` service that provides the following prop * `ApplicationName`: A human-readable name for an application. It is a unique value for an application. * `InstanceId`: A random (GUID) value generated by the ABP Framework each time you start the application. -These values are used by the ABP Framework for several places to distinguish the application and the application instance (process) in the system. For example, [audit logging](../Audit-Logging.md) system saves the `ApplicationName` in each audit log record written by the related application, so you can understand which application has created the audit log entry. So, if your system consists of multiple applications saving audit logs to a single point, you should be sure that each application has a different `ApplicationName`. +These values are used by the ABP Framework in several places to distinguish the application and the application instance (process) in the system. For example, the [audit logging](../Audit-Logging.md) system saves the `ApplicationName` in each audit log record written by the related application, so you can understand which application has created the audit log entry. So, if your system consists of multiple applications saving audit logs to a single point, you should be sure that each application has a different `ApplicationName`. The `ApplicationName` property's value is set automatically from the **entry assembly's name** (generally, the project name in a .NET solution) by default, which is proper for most cases, since each application typically has a unique entry assembly name. From fdbe1fefd17ea4b410bcd87393fa28eab0bccaf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Wed, 7 Dec 2022 11:45:02 +0300 Subject: [PATCH 03/13] Added final sections to the startup doc --- docs/en/Application-Startup.md | 32 ++++++++++++++++++- .../Volo.Abp.Core/Volo/Abp/IAbpApplication.cs | 4 +-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/docs/en/Application-Startup.md b/docs/en/Application-Startup.md index bd693c0761..d87760788a 100644 --- a/docs/en/Application-Startup.md +++ b/docs/en/Application-Startup.md @@ -236,4 +236,34 @@ await builder.AddApplicationAsync(options => If you need to access the `ApplicationName` later in your solution, you can inject the `IApplicationInfoAccessor` service and get the value from its `ApplicationName` property. -`IApplicationInfoAccessor` also provides an `InstanceId` value, that is a random GUID value that is generated when your application starts. You can use that value to distinguish application instances from each other. \ No newline at end of file +`IApplicationInfoAccessor` also provides an `InstanceId` value, that is a random GUID value that is generated when your application starts. You can use that value to distinguish application instances from each other. + +## IAbpApplication + +`AbpApplicationFactory` returns an `IAbpApplication` object from its `CreateAsync` (or `Create`) method. `IAbpApplication` is the main container for an ABP application. It is also registered to the [dependency injection](Dependency-Injection.md) system, so you can inject `IAbpApplication` in your services to use its properties and methods. + +Here, a list of `IAbpApplication` properties you may want to know: + +* `StartupModuleType`: Gets the root module of the application that was used while creating the application container (on the `AbpApplicationFactory.CreateAsync` method). +* `Services`: List of all service registrations (the `IServiceCollection` object). You can not add new services to this collection after application initialize (actually you can add, but it won't have any effect). +* `ServiceProvider`: Reference to the root service provider used by the application. This can not be used before initializing the application. If you need to resolve non-singleton services from that `IServiceProvider` object, always create a new service scope and dispose it after usage. Otherwise, your application will have memory leak problems. See the *Releasing/Disposing Services* section of the [dependency injection](Dependency-Injection.md) document for more information about service scopes. +* `Modules`: A read-only list of all the modules loaded into the current application. Alternatively, you can inject the `IModuleContainer` service if you need to access the module list in your application code. + +The `IAbpApplication` interface extends the `IApplicationInfoAccessor` interface, so you can get the `ApplicationName` and `InstanceId` values from it. However, if you only need to access these properties, inject and use the `IApplicationInfoAccessor` service instead. + +`IAbpApplication` is disposable. Always dispose it before exiting from your application. + +## .NET Generic Host & ASP.NET Core Integrations + +`AbpApplicationFactory` can create a standalone ABP application container without any external dependency. However, in most cases, you will want to integrate it with [.NET's generic host](https://learn.microsoft.com/en-us/dotnet/core/extensions/generic-host) or ASP.NET Core. For such usages, ABP provides built-in extension methods to easily create ABP application container that is well-integrated to these systems. + +The [Getting Started with an Empty ASP.NET Core MVC / Razor Pages Application](Getting-Started-AspNetCore-Application.md) document clearly explains how you can create an ABP application container in an ASP.NET Core application. + +You can also [create a console application](Startup-Templates/Console) to see how it is integrated with .NET Generic Host. + +> Most of the times, you will directly create ABP applications using the ABP CLI's `new` command. So, you don't need to care about these integration details. + +## See Also + +* [Dependency injection](Dependency-Injection.md) +* [Modularity](Module-Development-Basics.md) \ No newline at end of file diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/IAbpApplication.cs b/framework/src/Volo.Abp.Core/Volo/Abp/IAbpApplication.cs index 9543e18bd3..485a9882f5 100644 --- a/framework/src/Volo.Abp.Core/Volo/Abp/IAbpApplication.cs +++ b/framework/src/Volo.Abp.Core/Volo/Abp/IAbpApplication.cs @@ -16,14 +16,14 @@ public interface IAbpApplication : Type StartupModuleType { get; } /// - /// List of services registered to this application. + /// List of all service registrations. /// Can not add new services to this collection after application initialize. /// IServiceCollection Services { get; } /// /// Reference to the root service provider used by the application. - /// This can not be used before initialize the application. + /// This can not be used before initializing the application. /// IServiceProvider ServiceProvider { get; } From ae628d736c419e4b83dcde0d903e786f16a7e55d Mon Sep 17 00:00:00 2001 From: Mahmut Gundogdu Date: Wed, 7 Dec 2022 11:49:52 +0300 Subject: [PATCH 04/13] Set default value for service-type on Abp cli --- .../Angular/AngularServiceProxyGenerator.cs | 8 +++----- npm/ng-packs/scripts/copy-packages-to-templates.ts | 1 + 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/Angular/AngularServiceProxyGenerator.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/Angular/AngularServiceProxyGenerator.cs index 0376828fc2..d17545f4cc 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/Angular/AngularServiceProxyGenerator.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/Angular/AngularServiceProxyGenerator.cs @@ -76,11 +76,9 @@ public class AngularServiceProxyGenerator : ServiceProxyGeneratorBase', 'template dirs', false); program.option('-p, --template-path ', 'root template path', false); From 51427f288bbace186bab7ae29e488ae4169a5dbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Wed, 7 Dec 2022 11:55:35 +0300 Subject: [PATCH 05/13] Fix docs-nav.json --- docs/en/docs-nav.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/docs-nav.json b/docs/en/docs-nav.json index 7e748b3cbc..0c56ec9989 100644 --- a/docs/en/docs-nav.json +++ b/docs/en/docs-nav.json @@ -1317,7 +1317,7 @@ }, { "text": "Distributed / Microservice Solutions", - "path": "Distributed-Microservice.md" + "path": "Deployment/Distributed-Microservice.md" }, { "text": "Optimizing for Production", From 24b309011c3a54057e948b782371d3d5301769d6 Mon Sep 17 00:00:00 2001 From: Mahmut Gundogdu Date: Wed, 7 Dec 2022 13:06:40 +0300 Subject: [PATCH 06/13] Set default value for service-type on Abp cli --- npm/ng-packs/packages/schematics/package.json | 2 +- .../schematics/src/commands/api/schema.json | 34 ++++++++++++++++++- .../src/commands/proxy-add/schema.json | 5 ++- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/npm/ng-packs/packages/schematics/package.json b/npm/ng-packs/packages/schematics/package.json index 9feee2401d..0f77fae4cb 100644 --- a/npm/ng-packs/packages/schematics/package.json +++ b/npm/ng-packs/packages/schematics/package.json @@ -1,7 +1,7 @@ { "name": "@abp/ng.schematics", "version": "7.0.0-rc.2", - "description": "Schematics that works with ABP Backend", + "description": "Schematics that works with ABP Backend. powered by HOLY Odin!", "keywords": [ "schematics" ], diff --git a/npm/ng-packs/packages/schematics/src/commands/api/schema.json b/npm/ng-packs/packages/schematics/src/commands/api/schema.json index ddaf06f001..b5fde3ad79 100644 --- a/npm/ng-packs/packages/schematics/src/commands/api/schema.json +++ b/npm/ng-packs/packages/schematics/src/commands/api/schema.json @@ -45,10 +45,42 @@ "type": "string", "$default": { "$source": "argv", - "index": 5 + "index": 4 }, "x-prompt": "Please enter target Angular project to place the generated code. (default: workspace \"defaultProject\")" + }, + "serviceType": { + "description": "Service type to the generated code", + "type": "string", + "$default": { + "$source": "argv", + "index": 5 + }, + "enum": [ + "application", + "integration", + "all" + ], + "x-prompt": { + "message": "Specifies the service type to generate. `application`, `integration` and `all`, Default value: `application`", + "type": "list", + "items": [ + { + "value": "all", + "label": "All" + }, + { + "value": "application", + "label": "Application" + }, + { + "value": "integration", + "label": "Integration" + } + ] + } } + }, "required": [] } diff --git a/npm/ng-packs/packages/schematics/src/commands/proxy-add/schema.json b/npm/ng-packs/packages/schematics/src/commands/proxy-add/schema.json index 0458c7c7ab..ef0c125262 100644 --- a/npm/ng-packs/packages/schematics/src/commands/proxy-add/schema.json +++ b/npm/ng-packs/packages/schematics/src/commands/proxy-add/schema.json @@ -52,7 +52,10 @@ "serviceType": { "description": "Service type to the generated code", "type": "string", - "$default": "application", + "$default": { + "$source": "argv", + "index": 5 + }, "enum": [ "application", "integration", From 6c27dd27676c09398e68c726c0cd9dd3b47dff5b Mon Sep 17 00:00:00 2001 From: Hamza Albreem <94292623+braim23@users.noreply.github.com> Date: Wed, 7 Dec 2022 13:59:42 +0300 Subject: [PATCH 07/13] quick fix --- docs/en/Application-Startup.md | 44 +++++++++++++++++----------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/docs/en/Application-Startup.md b/docs/en/Application-Startup.md index d87760788a..752afd9c2f 100644 --- a/docs/en/Application-Startup.md +++ b/docs/en/Application-Startup.md @@ -1,16 +1,16 @@ ## ABP Application Startup -You typically use the [ABP CLI](CLI.md)'s `abp new` command to [get started](Getting-Started.md) with one of the pre-built [startup solution templates](Startup-Templates/Index.md). When you do that, you generally don't need to know the details of how the ABP Framework is integrated with your application, how it is configured and initialized. The startup template also comes with the fundamental ABP packages and [application modules](Modules/Index) are pre-installed and configured for you. +You typically use the [ABP CLI](CLI.md)'s `abp new` command to [get started](Getting-Started.md) with one of the pre-built [startup solution templates](Startup-Templates/Index.md). When you do that, you generally don't need to know the details of how the ABP Framework is integrated with your application or how it is configured and initialized. The startup template also comes with the fundamental ABP packages and [application modules](Modules/Index) are pre-installed and configured for you. -> It is always suggested to [get started with a startup template](Getting-Started.md) and modify it for your requirements. Read this document only if you want to understand the details or you need to modify how the ABP Framework starts. +> It is always suggested to [get started with a startup template](Getting-Started.md) and modify it for your requirements. Read this document only if you want to understand the details or if you need to modify how the ABP Framework starts. -While the ABP Framework has a lot of features and integrations, it is built as a lightweight and modular framework. It consists of [hundreds of NuGet and NMP packages](https://abp.io/packages), so you can use only the features you need to. If you follow the [Getting Started with an Empty ASP.NET Core MVC / Razor Pages Application](Getting-Started-AspNetCore-Application.md) document, you see how easy to install the ABP Framework into an empty ASP.NET Core project from scratch. You only install a single NuGet package and make a few small changes. +While the ABP Framework has a lot of features and integrations, it is built as a lightweight and modular framework. It consists of [hundreds of NuGet and NMP packages](https://abp.io/packages), so you can only use the features you need. If you follow the [Getting Started with an Empty ASP.NET Core MVC / Razor Pages Application](Getting-Started-AspNetCore-Application.md) document, you'll see how easy it is to install the ABP Framework into an empty ASP.NET Core project from scratch. You only install a single NuGet package and make a few small changes. -This document is for who want to better understand how the ABP Framework is initialized and configured on startup. +This document is for who wants to better understand how the ABP Framework is initialized and configured on startup. ## Installing to a Console Application -A .NET Console application is the minimalist .NET application. So, it is best to show installing the ABP Framework to a console application as a minimalist example. +A .NET Console application is the minimalist .NET application. So, it is best to show the installing of the ABP Framework to a console application as a minimalist example. If you [create a new console application with Visual Studio](https://learn.microsoft.com/en-us/dotnet/core/tutorials/with-visual-studio) (for .NET 7.0 or later), you will see the following solution structure (I named the solution as `MyConsoleDemo`): @@ -18,7 +18,7 @@ If you [create a new console application with Visual Studio](https://learn.micro This example uses the [top level statements](https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/tutorials/top-level-statements), so it consists of only a single line of code. -The first step is to install the [Volo.Abp.Core](https://www.nuget.org/packages/Volo.Abp.Core) NuGet package, which is the most core NuGet package of the ABP framework. You can install it using [Package Manager Console](https://learn.microsoft.com/en-us/nuget/consume-packages/install-use-packages-powershell) in Visual Studio: +The first step is to install the [Volo.Abp.Core](https://www.nuget.org/packages/Volo.Abp.Core) NuGet package, which is the most core NuGet package of the ABP framework. You can install it using the [Package Manager Console](https://learn.microsoft.com/en-us/nuget/consume-packages/install-use-packages-powershell) in Visual Studio: ````bash Install-Package Volo.Abp.Core @@ -43,7 +43,7 @@ namespace MyConsoleDemo } ```` -This is an empty class deriving from the `AbpModule` class. It is the main class that you will control your application's dependencies and implement your configuration, startup and shutdown logic. For more information, please check the [Modularity](Module-Development-Basics.md) document. +This is an empty class deriving from the `AbpModule` class. It is the main class that you will control your application's dependencies with, and implement your configuration and startup/shutdown logic. For more information, please check the [Modularity](Module-Development-Basics.md) document. As the second and the last step, change the `Program.cs` as shown in the following code block: @@ -110,11 +110,11 @@ await emailsender.SendAsync( await application.ShutdownAsync(); ```` -> If you run that application, you get a runtime error indicating that the email sending settings hasn't been done yet. You can check the [Email Sending document](Emailing.md) to learn how to configure it. +> If you run that application, you get a runtime error indicating that the email sending settings haven't been done yet. You can check the [Email Sending document](Emailing.md) to learn how to configure it. That's all. Install an ABP NuGet package, add the module dependency (using the `[DependsOn]` attribute) and use any service inside the NuGet package. -The [ABP CLI](CLI.md) already has a special command to perform adding an ABP NuGet and also adding the `[DependsOn]` attribute to your module class for you with a single command: +The [ABP CLI](CLI.md) already has a special command to perform the addition of an ABP NuGet and also adding the `[DependsOn]` attribute to your module class for you with a single command: ````bash abp add-package Volo.Abp.Emailing @@ -140,11 +140,11 @@ The second overload gets the module class as a `Type` parameter, instead of the AbpApplicationFactory.CreateAsync(typeof(MyConsoleDemoModule)); ```` -Both overloads works exactly same. So, you can use the second one if you don't know the module class type on development time and you (somehow) calculate it on runtime. +Both overloads work exactly the same. So, you can use the second one if you don't know the module class type on development time and you (somehow) calculate it on runtime. If you create one of the methods above, ABP creates an internal service collection (`IServiceCollection`) and an internal service provider (`IServiceProvider`) to setup the [dependency injection](Dependency-Injection.md) system internally. Notice that we've used the `application.ServiceProvider` property in the *Installing a Framework Package* section to resolve the `IEmailSender` service from the dependency injection system. -The next overload gets an `IServiceCollection` parameter from you to allow you to setup the dependency injection system yourself, or integrate to another framework (like ASP.NET Core) that also setups the dependency injection system internally. +The next overload gets an `IServiceCollection` parameter from you to allow you to setup the dependency injection system yourself, or integrate to another framework (like ASP.NET Core) that also sets up the dependency injection system internally. We can change the `Program.cs` as shown below to externally manage the dependency injection setup: @@ -179,7 +179,7 @@ IServiceProvider serviceProvider = services.BuildServiceProviderFromFactory(); > You can check the [Autofac Integration](Autofac-Integration.md) document if you want to learn how you can integrate the [Autofac](https://autofac.org/) dependency injection container with the ABP Framework. -Finally, the `CreateAsync` method has a last overload that takes the module class name as a `Type` parameter and a `IServiceCollection` object. So, we could re-write the last `CreateAsync` method usage as like in the following code block: +Finally, the `CreateAsync` method has a last overload that takes the module class name as a `Type` parameter and a `IServiceCollection` object. So, we could re-write the last `CreateAsync` method usage as in the following code block: ````csharp using var application = await AbpApplicationFactory @@ -190,7 +190,7 @@ using var application = await AbpApplicationFactory ### AbpApplicationCreationOptions -All of the `CreateAsync` overloads can get an optional `Action` parameter to configure the options that is used on the application creation. See the following example: +All of the `CreateAsync` overloads can get an optional `Action` parameter to configure the options that are used on the application creation. See the following example: ````csharp using var application = await AbpApplicationFactory @@ -200,10 +200,10 @@ using var application = await AbpApplicationFactory }); ```` -We've passed a lambda method to configure the `ApplicationName` option. Here, a list of all standard options: +We've passed a lambda method to configure the `ApplicationName` option. Here's a list of all standard options: * `ApplicationName`: A human-readable name for the application. It is a unique value for an application. -* `Configuration`: Can be used to setup the [application configuration](Configuration.md) when it is not provided by the hosting system. It is not needed for ASP.NET Core and other .NET hosted applications. However, if you've used `AbpApplicationFactory` with internal service provider, you can use this option to configure how the application configuration is built. +* `Configuration`: Can be used to setup the [application configuration](Configuration.md) when it is not provided by the hosting system. It is not needed for ASP.NET Core and other .NET hosted applications. However, if you've used `AbpApplicationFactory` with an internal service provider, you can use this option to configure how the application configuration is built. * `PlugInSources`: A list of plugin sources. See the [Plug-In Modules documentation](PlugIn-Modules) to learn how to work with plugins. * `Services`: The `IServiceCollection` object that can be used to register service dependencies. You generally don't need that, because you configure your services in your [module class](Module-Development-Basics.md). However, it can be used while writing extension methods for the `AbpApplicationCreationOptions` class. @@ -211,7 +211,7 @@ We've passed a lambda method to configure the `ApplicationName` option. Here, a As defined above, the `ApplicationName` option is a human-readable name for the application. It is a unique value for an application. -`ApplicationName` is used by the ABP Framework in several places to distinguish the application. For example, the [audit logging](Audit-Logging.md) system saves the `ApplicationName` in each audit log record written by the related application, so you can understand which application has created the audit log entry. So, if your system consists of multiple applications (like a microservice solution) saving audit logs to a single point, you should be sure that each application has a different `ApplicationName`. +`ApplicationName` is used by the ABP Framework in several places to distinguish the application. For example, the [audit logging](Audit-Logging.md) system saves the `ApplicationName` in each audit log record written by the related application, so you can understand which application has created the audit log entry. So, if your system consists of multiple applications (like a microservice solution) that are saving audit logs to a single point, you should be sure that each application has a different `ApplicationName`. The `ApplicationName` property's value is set automatically from the **entry assembly's name** (generally, the project name in a .NET solution) by default, which is proper for most cases, since each application typically has a unique entry assembly name. @@ -242,20 +242,20 @@ If you need to access the `ApplicationName` later in your solution, you can inje `AbpApplicationFactory` returns an `IAbpApplication` object from its `CreateAsync` (or `Create`) method. `IAbpApplication` is the main container for an ABP application. It is also registered to the [dependency injection](Dependency-Injection.md) system, so you can inject `IAbpApplication` in your services to use its properties and methods. -Here, a list of `IAbpApplication` properties you may want to know: +Here's a list of `IAbpApplication` properties you may want to know: * `StartupModuleType`: Gets the root module of the application that was used while creating the application container (on the `AbpApplicationFactory.CreateAsync` method). -* `Services`: List of all service registrations (the `IServiceCollection` object). You can not add new services to this collection after application initialize (actually you can add, but it won't have any effect). -* `ServiceProvider`: Reference to the root service provider used by the application. This can not be used before initializing the application. If you need to resolve non-singleton services from that `IServiceProvider` object, always create a new service scope and dispose it after usage. Otherwise, your application will have memory leak problems. See the *Releasing/Disposing Services* section of the [dependency injection](Dependency-Injection.md) document for more information about service scopes. +* `Services`: A list of all service registrations (the `IServiceCollection` object). You can not add new services to this collection after application initialization (you can actually add, but it won't have any effect). +* `ServiceProvider`: A reference to the root service provider used by the application. This can not be used before initializing the application. If you need to resolve non-singleton services from that `IServiceProvider` object, always create a new service scope and dispose it after usage. Otherwise, your application will have memory leak problems. See the *Releasing/Disposing Services* section of the [dependency injection](Dependency-Injection.md) document for more information about service scopes. * `Modules`: A read-only list of all the modules loaded into the current application. Alternatively, you can inject the `IModuleContainer` service if you need to access the module list in your application code. The `IAbpApplication` interface extends the `IApplicationInfoAccessor` interface, so you can get the `ApplicationName` and `InstanceId` values from it. However, if you only need to access these properties, inject and use the `IApplicationInfoAccessor` service instead. -`IAbpApplication` is disposable. Always dispose it before exiting from your application. +`IAbpApplication` is disposable. Always dispose of it before exiting your application. ## .NET Generic Host & ASP.NET Core Integrations -`AbpApplicationFactory` can create a standalone ABP application container without any external dependency. However, in most cases, you will want to integrate it with [.NET's generic host](https://learn.microsoft.com/en-us/dotnet/core/extensions/generic-host) or ASP.NET Core. For such usages, ABP provides built-in extension methods to easily create ABP application container that is well-integrated to these systems. +`AbpApplicationFactory` can create a standalone ABP application container without any external dependency. However, in most cases, you will want to integrate it with [.NET's generic host](https://learn.microsoft.com/en-us/dotnet/core/extensions/generic-host) or ASP.NET Core. For such usages, ABP provides built-in extension methods to easily create an ABP application container that is well-integrated to these systems. The [Getting Started with an Empty ASP.NET Core MVC / Razor Pages Application](Getting-Started-AspNetCore-Application.md) document clearly explains how you can create an ABP application container in an ASP.NET Core application. @@ -266,4 +266,4 @@ You can also [create a console application](Startup-Templates/Console) to see ho ## See Also * [Dependency injection](Dependency-Injection.md) -* [Modularity](Module-Development-Basics.md) \ No newline at end of file +* [Modularity](Module-Development-Basics.md) From b134f456abcf3f084f9f9f3bf5f353cf7cae6c64 Mon Sep 17 00:00:00 2001 From: Hamza Albreem <94292623+braim23@users.noreply.github.com> Date: Wed, 7 Dec 2022 14:18:04 +0300 Subject: [PATCH 08/13] tiny fix --- docs/en/Deployment/Distributed-Microservice.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/en/Deployment/Distributed-Microservice.md b/docs/en/Deployment/Distributed-Microservice.md index 450d968d84..9af4a1c839 100644 --- a/docs/en/Deployment/Distributed-Microservice.md +++ b/docs/en/Deployment/Distributed-Microservice.md @@ -1,10 +1,10 @@ # Deploying Distributed / Microservice Solutions -The ABP Framework is designed to consider distributed and microservice systems, where you have multiple applications and/or services communicating internally. All of its features are compatible with distributed scenarios. This document highlights some points you should care when you deploy your distributed or microservice solution. +The ABP Framework is designed to consider distributed and microservice systems, where you have multiple applications and/or services communicating internally. All of its features are compatible with distributed scenarios. This document highlights some points you should care about when you deploy your distributed or microservice solution. ## Application Name & Instance Id -ABP provides `IApplicationInfoAccessor` service that provides the following properties: +ABP provides the `IApplicationInfoAccessor` service that provides the following properties: * `ApplicationName`: A human-readable name for an application. It is a unique value for an application. * `InstanceId`: A random (GUID) value generated by the ABP Framework each time you start the application. @@ -32,7 +32,7 @@ await builder.AddApplicationAsync(options => ## Using a Distributed Event Bus -ABP's [Distributed Event Bus](../Distributed-Event-Bus.md) system provides a standard interface to communicate to other applications and services. While the name is "distributed", the default implementation is in-process. That means, your applications / services can not communicate to each other unless you explicitly configure a distributed event bus provider. +ABP's [Distributed Event Bus](../Distributed-Event-Bus.md) system provides a standard interface to communicate with other applications and services. While the name is "distributed", the default implementation is in-process. That means, your applications / services can not communicate with each other unless you explicitly configure a distributed event bus provider. If you are building a distributed system, then the applications should communicate through an external distributed messaging server. Please follow the [Distributed Event Bus](../Distributed-Event-Bus.md) document to learn how to install and configure your distributed event bus provider. From b74d3fb83bd87ed3671dfa7c00d3966c8c2c3c25 Mon Sep 17 00:00:00 2001 From: Hamza Albreem <94292623+braim23@users.noreply.github.com> Date: Wed, 7 Dec 2022 14:30:08 +0300 Subject: [PATCH 09/13] quick fix --- docs/en/Deployment/Optimizing-Production.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/en/Deployment/Optimizing-Production.md b/docs/en/Deployment/Optimizing-Production.md index 596dbd41bb..7e896f9b1c 100644 --- a/docs/en/Deployment/Optimizing-Production.md +++ b/docs/en/Deployment/Optimizing-Production.md @@ -4,14 +4,14 @@ ABP Framework and the startup solution templates are configured well to get the ## Caching Static Contents -The following items are contents those can be cached in the client side (typically in the Browser) or in a CDN server: +The following items are contents that can be cached in the client side (typically in the Browser) or in a CDN server: -* **Static images** can always be cached. Here, you should be careful that if you change an image, use a different file name, or use a versioning query-string parameter, so the browser (or CDN) understands it is changed. -* **CSS and JavaScript files**. ABP's [bundling & minification](../UI/AspNetCore/Bundling-Minification.md) system always uses query-string versioning parameter and a hash value in the files names for CSS & JavaScript files for [MVC (Razor Pages)](../UI/AspNetCore/Overall.md) UI. So, you can safely cache these files in the client side or in a CDN server. +* **Static images** can always be cached. Here, you should be careful that if you change an image, use a different file name, or use a versioning query-string parameter, so the browser (or CDN) understands it's been changed. +* **CSS and JavaScript files**. ABP's [bundling & minification](../UI/AspNetCore/Bundling-Minification.md) system always uses a query-string versioning parameter and a hash value in the files names of the CSS & JavaScript files for the [MVC (Razor Pages)](../UI/AspNetCore/Overall.md) UI. So, you can safely cache these files in the client side or in a CDN server. * **Application bundle files** of an [Angular UI](../UI/Angular/Quick-Start.md) application. -* **[Application Localization Endpoint](../API/Application-Localization.md)** can be cached per culture (it already has a `cultureName` query string parameter) if you don't use dynamic localization on the server-side. ABP Commercial's [Language Management](https://commercial.abp.io/modules/Volo.LanguageManagement) module provides dynamic localization. If you are using it, you can't cache that endpoint forever. However, you can still cache it for a while. Applying dynamic localization text changes to the application can delay for a few minutes, even for a few hours in a real life scenario. +* **[Application Localization Endpoint](../API/Application-Localization.md)** can be cached per culture (it already has a `cultureName` query string parameter) if you don't use dynamic localization on the server-side. ABP Commercial's [Language Management](https://commercial.abp.io/modules/Volo.LanguageManagement) module provides dynamic localization. If you're using it, you can't cache that endpoint forever. However, you can still cache it for a while. Applying dynamic localization text changes to the application can delay for a few minutes, even for a few hours in a real life scenario. -There may be more based on your solution structure and deployment environment, but these are the essential points you should consider to client-side cache in a production environment. +There may be more ways based on your solution structure and deployment environment, but these are the essential points you should consider to client-side cache in a production environment. ## Bundling & Minification for MVC (Razor Pages) UI @@ -19,4 +19,4 @@ ABP's [bundling & minification](../UI/AspNetCore/Bundling-Minification.md) syste ## Background Jobs -ABP's [Background Jobs](../Background-Jobs.md) system provides an abstraction with a basic implementation to enqueue works and execute them in a background thread. ABP's Default Background Job Manager may not be enough if you are adding too many jobs to the queue and want them to be executed in parallel by multiple servers with a high performance. If you need these, you should consider to configure a dedicated background job software, like [Hangfire](https://www.hangfire.io/). ABP has a pre-built [Hangfire integration](../Background-Jobs-Hangfire.md), so you can switch to Hangfire without changing your application code. +ABP's [Background Jobs](../Background-Jobs.md) system provides an abstraction with a basic implementation to enqueue jobs and execute them in a background thread. ABP's Default Background Job Manager may not be enough if you are adding too many jobs to the queue and want them to be executed in parallel by multiple servers with a high performance. If you need these, you should consider to configure a dedicated background job software, like [Hangfire](https://www.hangfire.io/). ABP has a pre-built [Hangfire integration](../Background-Jobs-Hangfire.md), so you can switch to Hangfire without changing your application code. From eebf351c0e8e1610bcc3bd1b01f6fd8ca84df03a Mon Sep 17 00:00:00 2001 From: Mahmut Gundogdu Date: Wed, 7 Dec 2022 15:01:23 +0300 Subject: [PATCH 10/13] Update package.json --- npm/ng-packs/packages/schematics/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/npm/ng-packs/packages/schematics/package.json b/npm/ng-packs/packages/schematics/package.json index 0f77fae4cb..6f6ad23d0f 100644 --- a/npm/ng-packs/packages/schematics/package.json +++ b/npm/ng-packs/packages/schematics/package.json @@ -1,7 +1,7 @@ { "name": "@abp/ng.schematics", "version": "7.0.0-rc.2", - "description": "Schematics that works with ABP Backend. powered by HOLY Odin!", + "description": "Schematics that works with ABP Backend.", "keywords": [ "schematics" ], From 08c2d18b1488521f261682e8db7309d269069ab6 Mon Sep 17 00:00:00 2001 From: Mahmut Gundogdu Date: Wed, 7 Dec 2022 15:01:38 +0300 Subject: [PATCH 11/13] Update package.json --- npm/ng-packs/packages/schematics/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/npm/ng-packs/packages/schematics/package.json b/npm/ng-packs/packages/schematics/package.json index 6f6ad23d0f..9feee2401d 100644 --- a/npm/ng-packs/packages/schematics/package.json +++ b/npm/ng-packs/packages/schematics/package.json @@ -1,7 +1,7 @@ { "name": "@abp/ng.schematics", "version": "7.0.0-rc.2", - "description": "Schematics that works with ABP Backend.", + "description": "Schematics that works with ABP Backend", "keywords": [ "schematics" ], From 69fa432e333fc1d11f14b6a89f9dd17f2a868bb8 Mon Sep 17 00:00:00 2001 From: Engincan VESKE <43685404+EngincanV@users.noreply.github.com> Date: Wed, 7 Dec 2022 13:49:00 +0000 Subject: [PATCH 12/13] Update Application-Startup.md --- docs/en/Application-Startup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/Application-Startup.md b/docs/en/Application-Startup.md index 752afd9c2f..1c5bf9b139 100644 --- a/docs/en/Application-Startup.md +++ b/docs/en/Application-Startup.md @@ -4,7 +4,7 @@ You typically use the [ABP CLI](CLI.md)'s `abp new` command to [get started](Get > It is always suggested to [get started with a startup template](Getting-Started.md) and modify it for your requirements. Read this document only if you want to understand the details or if you need to modify how the ABP Framework starts. -While the ABP Framework has a lot of features and integrations, it is built as a lightweight and modular framework. It consists of [hundreds of NuGet and NMP packages](https://abp.io/packages), so you can only use the features you need. If you follow the [Getting Started with an Empty ASP.NET Core MVC / Razor Pages Application](Getting-Started-AspNetCore-Application.md) document, you'll see how easy it is to install the ABP Framework into an empty ASP.NET Core project from scratch. You only install a single NuGet package and make a few small changes. +While the ABP Framework has a lot of features and integrations, it is built as a lightweight and modular framework. It consists of [hundreds of NuGet and NPM packages](https://abp.io/packages), so you can only use the features you need. If you follow the [Getting Started with an Empty ASP.NET Core MVC / Razor Pages Application](Getting-Started-AspNetCore-Application.md) document, you'll see how easy it is to install the ABP Framework into an empty ASP.NET Core project from scratch. You only need to install a single NuGet package and make a few small changes. This document is for who wants to better understand how the ABP Framework is initialized and configured on startup. From 3e05ed735f018947d986188deda14239b92ee969 Mon Sep 17 00:00:00 2001 From: maliming Date: Thu, 8 Dec 2022 09:32:54 +0800 Subject: [PATCH 13/13] Register `HttpClient` in the necessary modules. Resolve #14998 --- .../AbpAspNetCoreAuthenticationOpenIdConnectModule.cs | 8 ++++++-- .../Server/AbpAspNetCoreComponentsServerModule.cs | 1 + .../AbpAspNetCoreComponentsWebAssemblyModule.cs | 1 + .../Volo/Abp/Http/Client/AbpHttpClientModule.cs | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Authentication.OpenIdConnect/Volo/Abp/AspNetCore/Authentication/OpenIdConnect/AbpAspNetCoreAuthenticationOpenIdConnectModule.cs b/framework/src/Volo.Abp.AspNetCore.Authentication.OpenIdConnect/Volo/Abp/AspNetCore/Authentication/OpenIdConnect/AbpAspNetCoreAuthenticationOpenIdConnectModule.cs index 6b66a105d3..ba21ef11fd 100644 --- a/framework/src/Volo.Abp.AspNetCore.Authentication.OpenIdConnect/Volo/Abp/AspNetCore/Authentication/OpenIdConnect/AbpAspNetCoreAuthenticationOpenIdConnectModule.cs +++ b/framework/src/Volo.Abp.AspNetCore.Authentication.OpenIdConnect/Volo/Abp/AspNetCore/Authentication/OpenIdConnect/AbpAspNetCoreAuthenticationOpenIdConnectModule.cs @@ -1,4 +1,5 @@ -using Volo.Abp.AspNetCore.Authentication.OAuth; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.AspNetCore.Authentication.OAuth; using Volo.Abp.Modularity; using Volo.Abp.MultiTenancy; using Volo.Abp.RemoteServices; @@ -12,5 +13,8 @@ namespace Volo.Abp.AspNetCore.Authentication.OpenIdConnect; )] public class AbpAspNetCoreAuthenticationOpenIdConnectModule : AbpModule { - + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddHttpClient(); + } } diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Server/Volo/Abp/AspNetCore/Components/Server/AbpAspNetCoreComponentsServerModule.cs b/framework/src/Volo.Abp.AspNetCore.Components.Server/Volo/Abp/AspNetCore/Components/Server/AbpAspNetCoreComponentsServerModule.cs index dfa515c1b8..d39a633e0e 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Server/Volo/Abp/AspNetCore/Components/Server/AbpAspNetCoreComponentsServerModule.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Server/Volo/Abp/AspNetCore/Components/Server/AbpAspNetCoreComponentsServerModule.cs @@ -26,6 +26,7 @@ public class AbpAspNetCoreComponentsServerModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { + context.Services.AddHttpClient(); var serverSideBlazorBuilder = context.Services.AddServerSideBlazor(options => { if (context.Services.GetHostingEnvironment().IsDevelopment()) diff --git a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpAspNetCoreComponentsWebAssemblyModule.cs b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpAspNetCoreComponentsWebAssemblyModule.cs index 229831141e..12877f0c31 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpAspNetCoreComponentsWebAssemblyModule.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/WebAssembly/AbpAspNetCoreComponentsWebAssemblyModule.cs @@ -35,6 +35,7 @@ public class AbpAspNetCoreComponentsWebAssemblyModule : AbpModule public override void ConfigureServices(ServiceConfigurationContext context) { + context.Services.AddHttpClient(); context.Services .GetHostBuilder().Logging .AddProvider(new AbpExceptionHandlingLoggerProvider(context.Services)); diff --git a/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/AbpHttpClientModule.cs b/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/AbpHttpClientModule.cs index 8bca3702c5..a164f9587e 100644 --- a/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/AbpHttpClientModule.cs +++ b/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/AbpHttpClientModule.cs @@ -23,6 +23,7 @@ public class AbpHttpClientModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { + context.Services.AddHttpClient(); context.Services.AddTransient(typeof(DynamicHttpProxyInterceptorClientProxy<>)); } }