HIT-ReFreSH / JMobileSuit

Light weight Mobile Suit for Java.
MIT License
6 stars 42 forks source link

V2 Refactors: Introduction for Modern Application #27

Open FerdinandSu opened 12 months ago

FerdinandSu commented 12 months ago

Due to lack of maintenance, JMobileSuit's design architecture lags far behind MobileSuit. Nowadays, many improvements have helped JMobileSuit make significant progress, especially @yrris 's introduction of Spring's improvements in #21 , which has enabled us to have a true dependency injection system

I think it's time to bridge these gaps. We will imitate MobileSuit's design and develop version 2, which mainly includes the following refactoring work:

  1. 23 Thoroughly refactor the core components, imitating MobileSuit's approach based on dependency injection, middleware, and service registration to complete the current core functions; The main case code for this part of the reference project is located in 'HitRefresh' MobileSuit Core, therefore the relevant components of JMobileSuit should be located in package ReFreSH JMobileSuit `;

  2. 24 Change the instantiation method of the client application (SuitClient) from singleton mode to single request mode to facilitate refreshing the application context between different requests, facilitating database operations, and providing support for parallelism

  3. 25 Provide asynchronous operation support, task lifecycle management, and enable applications to run in parallel (in the background)

  4. 26 Configuration file injection support: Like MobileSuit, the injected IConfiguration can be directly used to access the specified configuration file (appsettings. json)

由于疏于维护,JMobileSuit的设计架构远远落后于MobileSuit。现在,许多改进已经帮助JMobileSuit进步了很多,尤其是@yrris 在 #21 引入Spring的改进,使得我们有了真正的依赖注入系统. 我想是时候抹平这些差距了,我们将模仿MobileSuit的设计,开发版本2,主要包含以下几项重构工作:

  1. 23 彻底重构核心组件,模仿MobileSuit基于依赖注入、中间件和服务注册的方式完成当前的核心功能;参考项目的这部分主要案例代码位于HitRefresh.MobileSuit.Core,故JMobileSuit的相关组件应该位于package ReFreSH.JMobileSuit;

  2. 24 将客户端应用(SuitClient)的实例化方式从单例模式改为单请求模式,以方便在不同的请求间刷新应用上下文,方便对数据库的操作,提供对并行的支持

  3. 25 提供异步操作支持,提供任务生命周期管理,使应用支持并行(后台运行)

  4. 26 配置文件注入支持:像MobileSuit那样可以直接使用注入的IConfiguration访问指定的配置文件(appsettings.json)