Core overview


The YMP framework is mainly composed of the core (Core) and several modules (Modules). The core is mainly responsible for the initialization of the framework and the life cycle management of the modules.

Main core functions

  • Beans: Class object manager (micro Spring container), provides automatic scanning of package classes (AutoScan) and Bean life cycle management, dependency injection (IoC) and method interception (AOP) and other features.

  • Event: Event service, triggers and monitors event actions through event registration and broadcasting, and supports both synchronous and asynchronous mode execution of event queues.

  • Module: Module is the basic form of encapsulation of all functional features of the YMP framework. It is responsible for the life cycle management of the module. The module will be automatically loaded and initialized when the framework is initialized, and automatically when the framework is destroyed. destroy.

  • I18N: International resource manager, provides unified resource file loading, destruction and content reading, supports custom resource loading and event monitoring for language changes.

  • Lang: Provides a set of custom data structures, which play an important role in some modules, including:

    • BlurObject: used Fuzzy objects that resolve conversions between common data types.
    • PairObject: Paired object used to bundle two independent objects together.
    • TreeObject: Use cascading method to store tree objects of various data types with no limit on hierarchical depth.
  • #Util: Provides various tool classes needed in the framework.

Maven package dependencies

<dependency>
    <groupId>net.ymate.platform</groupId>
    <artifactId>ymate-platform-core</artifactId>
    <version>2.0-SNAPSHOT</version>
</dependency>

Note : If you want to use the YMP core package alone, you need to add the above configuration in pom.xml. Other modules have introduced core package dependencies by default, so there is no need to repeat the configuration.

Framework initialization

The initialization of the YMP framework starts with loading the ymp-conf.properties file, which must be placed in the root path of the classpath;

  • Depending on the program running environment, the YMP framework will load the configuration according to the current operating system priority during initialization:

    • In Unix/Linux environment, ymp-conf_UNIX.properties will be loaded first ;
    • In Windows environment, ymp-conf_WIN.properties is loaded first;
    • If the above configuration file is not found, the default configuration ymp-conf.properties is loaded;
  • Basic configuration parameters for framework initialization:

    #-------------------------------------
    # 框架基本配置参数
    #-------------------------------------
    
    # 是否为开发模式,默认为false
    ymp.dev_mode=
    
    # 框架自动扫描的包路径集合,多个包名之间用'|'分隔,默认已包含net.ymate.platform包,其子包也将被扫描
    ymp.autoscan_packages=
    
    # 包文件排除列表,多个文件名称之间用'|'分隔,被包含的JAR或ZIP文件在扫描过程中将被忽略
    ymp.excluded_files=
    
    # 模块排除列表,多个模块名称或类名之间用'|'分隔,被包含的模块在加载过程中将被忽略
    ymp.excluded_modules=
    
    # 国际化资源默认语言设置,可选参数,默认采用系统环境语言
    ymp.i18n_default_locale=zh_CN
    
    # 国际化资源管理器事件监听处理器,可选参数,默认为空
    ymp.i18n_event_handler_class=
    
    # 框架全局自定义参数,xxx表示自定义参数名称,vvv表示参数值
    ymp.params.xxx=vvv
    
    # 本文测试使用的自定义参数
    ymp.params.helloworld=Hello, YMP!
  • ## Test code to complete the startup and destruction of the framework:

    public static void main(String[] args) throws Exception {
        YMP.get().init();
        try {
            // 输出自定义参数值:Hello, YMP!
            System.out.println(YMP.get().getConfig().getParam("helloworld"));
        } finally {
            YMP.get().destroy();
        }
    }