Program dynamic updating method and device, equipment, medium and product

Through the combination of periodic detection and target update methods, the service stopping problem caused by SQL statement configuration errors in Java applications is solved, and dynamic updates of programs without restarting services are achieved to ensure the stability and user experience of the application.

CN120276759AInactive Publication Date: 2025-07-08HANGZHOU NEWGRAND TECHNOLOGY CO LTD
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
CN202510757523.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-09
Publication Date
2025-07-08
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In Java applications, the program function failure caused by the SQL statement expression configuration error is required to stop the service and redeploy, which affects the normal use of the user.

Method used

Periodically detect whether the SQL mapping configuration file in the root directory of the application is updated, determine the target update method based on the update situation, and update the SQL mapping configuration file in the application running environment using full or local update methods to avoid restarting the service.

Benefits of technology

After the SQL mapping configuration file is updated, adaptive updates can be performed without restarting the service, ensuring dynamic updates and stable operation of the application.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120276759A_ABST
    Figure CN120276759A_ABST
Patent Text Reader

Abstract

The invention discloses a program dynamic updating method, device and equipment, a medium and a product, and relates to the technical field of computers. The program dynamic updating method comprises the following steps: periodically detecting whether a structured query language (SQL) mapping configuration file under a root directory of an application program is updated or not; under the condition that the SQL mapping configuration files are updated, a target updating mode of the application program is determined according to the number of the updated SQL mapping configuration files; and based on the updated SQL mapping configuration file, updating the SQL mapping configuration file in the application program running environment by adopting a target updating mode. According to the technical scheme, the application program can be dynamically updated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular, to a method, device, equipment, medium and product for dynamically updating a program. Background Art

[0002] In Java applications, the Java Persistence API (JPA) and the MyBatis persistence framework are often used to interact with databases. The implementation method of JPA is fully managed, while MyBatis is semi-managed.

[0003] In the semi-managed mode based on MyBatis, since the expressions of Structured Query Language (SQL) are configured by developers independently, program function failures caused by SQL statement problems are likely to occur. Once the SQL statement expression is configured incorrectly, the service needs to be stopped and redeployed, affecting the normal use of users. Summary of the Invention

[0004] The present invention provides a method, device, equipment, medium and product for dynamically updating a program to solve the problem of service stop caused by SQL statement expression configuration.

[0005] According to one aspect of the present invention, a method for dynamically updating a program is provided, including:

[0006] Periodically detecting whether the SQL mapping configuration file in the root directory of the application program is updated;

[0007] When the SQL mapping configuration file is updated, determining the target update method of the application program according to the number of updated SQL mapping configuration files;

[0008] Based on the updated SQL mapping configuration file, updating the SQL mapping configuration file in the application program running environment by using the target update method.

[0009] According to another aspect of the present invention, a device for dynamically updating a program is provided, including:

[0010] An update detection module, configured to periodically detect whether the SQL mapping configuration file in the root directory of the application program is updated;

[0011] An update method determination module, configured to determine the target update method of the application program according to the number of updated SQL mapping configuration files when the SQL mapping configuration file is updated;

[0012] A program update module, configured to update the SQL mapping configuration file in the application program running environment by using a target update method based on the updated SQL mapping configuration file.

[0013] According to another aspect of the present invention, there is provided an electronic device, which includes:

[0014] At least one processor; and

[0015] A memory communicatively connected to the at least one processor; wherein,

[0016] The memory stores a computer program executable by the at least one processor, and when the computer program is executed by the at least one processor, the at least one processor is enabled to execute the program dynamic update method according to any embodiment of the present invention.

[0017] According to another aspect of the present invention, there is provided a computer-readable storage medium storing computer instructions for implementing the program dynamic update method according to any embodiment of the present invention when executed by a processor.

[0018] According to another aspect of the present invention, there is provided a computer program product including a computer program, which implements the program dynamic update method according to any embodiment of the present disclosure when executed by a processor.

[0019] The technical solution of the embodiment of the present invention periodically detects whether the structured query language (SQL) mapping configuration file in the root directory of the application program is updated. In the case where the SQL mapping configuration file is updated, the target update method of the application program is determined according to the number of updated SQL mapping configuration files. Based on the updated SQL mapping configuration file, the SQL mapping configuration file in the application program running environment is updated by using the target update method, so that the SQL mapping configuration file in the application program running environment can be adaptively updated after being updated, without restarting the service, and program dynamic update is realized.

[0020] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present invention, nor is it used to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. Description of the Drawings

[0021] To more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the accompanying drawings required for the description of the embodiments. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other accompanying drawings can be obtained based on these drawings.

[0022] Figure 1 is a flowchart of a method for dynamically updating a program according to Embodiment 1 of the present invention;

[0023] Figure 2 is a flowchart of a method for dynamically updating a program according to Embodiment 2 of the present invention;

[0024] Figure 3 is a flowchart of a method for dynamically updating a program according to Embodiment 3 of the present invention;

[0025] Figure 4 is a schematic structural diagram of a device for dynamically updating a program according to Embodiment 4 of the present invention;

[0026] Figure 5 is a schematic structural diagram of an electronic device for implementing the method for dynamically updating a program in the embodiments of the present invention. Detailed Embodiments

[0027] To enable those skilled in the art to better understand the solutions of the present invention, the following clearly and completely describes the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of them. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

[0028] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above accompanying drawings are used to distinguish similar objects, and do not necessarily describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of the present invention described herein can be implemented in an order different from those illustrated or described herein. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products, or devices.

[0029] Embodiment 1

[0030] Figure 1 FIG. 1 is a flowchart of a method for dynamically updating a program according to Embodiment 1 of the present invention. This embodiment is applicable to the situation where the SQL mapping configuration file in the running environment is updated without stopping the program. This method can be executed by a program dynamic update device, which can be implemented in the form of hardware and / or software, and can be configured in various general computing devices, such as laptops, desktops, or servers. As Figure 1 shown, the method includes:

[0031] S110. Periodically detect whether the SQL mapping configuration file under the root directory of the application program is updated.

[0032] The SQL mapping configuration file is a configuration file used to define SQL statements and the mapping relationship between SQL statements and Java methods. Its main function is to bind database operations to Java interface methods. Exemplarily, in the case of using the MyBatis persistence framework to interact with the database in a Java application, the SQL mapping configuration file is the Mapper file, and the Mapper file is usually a file with the extension ".xml".

[0033] In the prior art, if there is an error in the SQL statement configuration, it is necessary to stop the application service and redeploy the SQL mapping configuration file in the running environment, which affects the users.

[0034] In the embodiment of the present invention, in order to achieve dynamic update of the application program, it is detected whether the SQL mapping configuration file under the root directory of the application program is updated according to a set period. Specifically, based on the identifier of the SQL mapping configuration file, the metadata information of the current SQL mapping configuration file under the root directory is compared with the metadata information of the pre-backup SQL mapping configuration file. In the case where the two are inconsistent, it is determined that the SQL mapping configuration file under the root directory is updated. When updating the SQL mapping configuration file under the root directory, the version number can also be used to name the SQL mapping configuration file. If it is detected that the name of one or more SQL mapping configuration files under the root directory has changed, it is determined that the SQL mapping configuration file under the root directory is updated.

[0035] In addition, after scanning the updated SQL mapping configuration file, the counter needs to be incremented by 1. After scanning all the SQL mapping configuration files, the value in the counter is extracted as the number of updated SQL mapping configuration files.

[0036] In a specific example, when using the MyBatis persistence framework to interact with a database in a Java application, the SQL mapping configuration file is the Mapper file. A dynamic update annotation for the SQL mapping configuration file can be constructed in the application, specifically the @AutoUpdateMapper annotation. And import the Mapper automatic reorganization device in the annotation. In the Mapper automatic reorganization device, import the object definition register, and implement the method of object definition registration.

[0037] In the object definition registration method, establish a Mapper file manager under the resource directory storage of the current program root directory. By detecting all Mapper files (i.e., Mapper.xml files) under the current program root directory, and backing up all detected Mapper files to the Mapper file manager. At the same time, in the object definition registration method, obtain the property resource manager. In the property resource manager, establish the association relationship between the local path of the Mapper file and the file manager, and start the real-time monitoring of the mapper file manager. The specific monitoring process is as follows:

[0038] Periodically scan all Mapper files in the Mapper file manager, and based on the file identifier of the currently scanned Mapper file, find the Mapper file corresponding to the file identifier under the local path according to the association relationship between the local path and the file manager. Respectively extract the metadata information of the Mapper files scanned in the Mapper file manager and the metadata information of the corresponding Mapper files under the local path, and compare the metadata information of the two. If the two are inconsistent, it is determined that the currently scanned Mapper file has been updated.

[0039] S120. When the SQL mapping configuration file is updated, determine the target update method of the application according to the number of updated SQL mapping configuration files.

[0040] In the embodiments of the present invention, when the SQL mapping configuration file is updated, determine the target update method of the application according to the number of updated SQL mapping configuration files. Among them, the target update method may include full update and partial update. A full update means updating the object definition information and instances associated with all SQL mapping configuration files in the application running environment; partial update is an update method opposite to the full update, which means only updating the object definition information and instances associated with the updated SQL mapping configuration files in the application running environment.

[0041] In a specific example, the number of updated SQL mapping configuration files can be compared with a preset number threshold. If the number is greater than or equal to the number threshold, it is determined that the target update method of the application is a full update; if the number is less than the number threshold, it is determined that the target update method of the application is a partial update.

[0042] In another specific example, the proportion of the number of updated SQL mapping configuration files in all SQL mapping configuration files in the application root directory can be calculated. If the proportion is higher than or equal to a set ratio, it is determined that the target update method of the application is a full update; if the proportion is lower than the set ratio, it is determined that the target update method of the application is a partial update.

[0043] S130. Based on the updated SQL mapping configuration file, use the target update method to update the SQL mapping configuration file in the application running environment.

[0044] In the embodiment of the present invention, after determining the target update method of the application, based on the updated SQL mapping configuration file, use the target update method to update the SQL mapping configuration file in the application running environment. Among them, the application running environment can be a Spring container.

[0045] Specifically, if the target update method is a full update, based on the updated SQL mapping configuration file, the object definition information in the object definition register included in the application Spring container can be fully replaced. Furthermore, based on the replaced object definition information, the SQL mapping configuration file instances in the object instance container are fully replaced.

[0046] If the target update method is a partial update, based on the updated SQL mapping configuration file, the updated object definition information in the object definition register included in the application Spring container can be replaced. Furthermore, based on the replaced object definition information, the updated SQL mapping configuration file instances in the object instance container are replaced.

[0047] The technical solution of the embodiment of the present invention periodically detects whether the structured query language SQL mapping configuration file in the application root directory is updated. In the case where the SQL mapping configuration file is updated, according to the number of updated SQL mapping configuration files, the target update method of the application is determined. Based on the updated SQL mapping configuration file, use the target update method to update the SQL mapping configuration file in the application running environment, which can adaptively update the SQL mapping configuration file in the application running environment after the SQL mapping configuration file is updated, without restarting the service, and realize dynamic program update.

[0048] Example Two

[0049] Figure 2 The figure shows a flowchart of a method for dynamically updating a program provided in Example Two of the present invention. This example is further refined based on the above example, and provides specific steps for periodically detecting whether the Structured Query Language (SQL) mapping configuration file in the root directory of the application program has been updated, specific steps for determining the target update method of the application program according to the number of updated SQL mapping configuration files, and specific steps for updating the SQL mapping configuration file in the application program running environment by using the target update method based on the updated SQL mapping configuration file. As Figure 2 shown, the method includes:

[0050] S210. In response to the triggering of the dynamic update annotation of the SQL mapping configuration file, back up the SQL mapping configuration file in the root directory of the application program to the SQL mapping configuration file manager.

[0051] The dynamic update annotation of the SQL mapping configuration file includes a method for creating an SQL mapping configuration file manager and a method for backing up the SQL mapping configuration file in the root directory of the application program to the SQL mapping configuration file manager.

[0052] In the embodiment of the present invention, when the dynamic update annotation of the SQL mapping configuration file is triggered, an SQL mapping configuration file manager is created, and the SQL mapping configuration file in the root directory of the application program is backed up to the SQL mapping configuration file manager.

[0053] In a specific example, when the MyBatis persistence framework is used to interact with the database in a Java application, the SQL mapping configuration file is the Mapper file. When the dynamic update annotation of the SQL mapping configuration file is triggered, a Mapper file manager is created, and the Mapper file in the root directory of the application program is backed up to the Mapper file manager.

[0054] S220. Periodically scan the SQL mapping configuration files in the SQL mapping configuration file manager and the SQL mapping configuration files in the root directory of the application program.

[0055] In the embodiment of the present invention, by starting the SQL mapping configuration file manager listener, the SQL mapping configuration files in the SQL mapping configuration file manager and the SQL mapping configuration files in the root directory of the application program are periodically scanned. Subsequently, the SQL mapping configuration files in the SQL mapping configuration file manager can be used as the initial version to determine whether the SQL mapping configuration files in the root directory of the application program have been updated compared with the initial version.

[0056] S230. Based on the file identifier of the SQL mapping configuration file, compare the metadata information of the SQL mapping configuration file in the SQL mapping configuration file manager with the metadata information of the corresponding SQL mapping configuration file in the application root directory to determine whether the SQL mapping configuration file in the application root directory has been updated.

[0057] In the embodiment of the present invention, based on the file identifier of the SQL mapping configuration file, compare the metadata information of the SQL mapping configuration file in the SQL mapping configuration file manager with the metadata information of the corresponding SQL mapping configuration file in the application root directory to determine whether the SQL mapping configuration file in the application root directory has been updated.

[0058] Specifically, periodically scan the SQL mapping configuration files in the SQL mapping configuration file manager, use the currently scanned SQL mapping configuration file as the current configuration file, and read the data meta-information and file identifier of the current configuration file; according to the file identifier of the current configuration file, obtain the corresponding target SQL mapping configuration file from the application root directory, and read the data meta-information of the target SQL mapping configuration file; compare the data meta-information of the current configuration file with the data meta-information of the target SQL mapping configuration file, and when the two are inconsistent, increment the number of updated SQL mapping configuration files by 1; return to perform the operation of scanning the SQL mapping configuration files in the SQL mapping configuration file manager until the traversal of the SQL mapping configuration files in the SQL mapping configuration file manager is completed to obtain the number of updated SQL mapping configuration files.

[0059] S240. When the SQL mapping configuration file is updated, compare the number of updated SQL mapping configuration files with the number threshold. When the number of updated SQL mapping configuration files is greater than or equal to the number threshold, determine that the target update method of the application is full update.

[0060] In the embodiment of the present invention, when the SQL mapping configuration file in the application root directory is updated, compare the number of updated SQL mapping configuration files with the number threshold. If the number of updated SQL mapping configuration files is greater than or equal to the number threshold, determine that the target update method of the application is full update.

[0061] S250. When the target update method is full update, create a new SQL session factory and a new SQL execution connection session template manager based on the data source associated with the current spring container.

[0062] The SQL session factory is the core component in the Mybatis framework and is used to create SQL session instances.

[0063] In an embodiment of the present invention, when the target update method is full update, first, based on the data source associated with the current Spring container, for example, an Oracle database, a new SQL session factory and a new SQL execution connection session template manager are created to register the updated SQL mapping configuration file into the application running environment.

[0064] S260. Obtain the object definition registrar and the object instance container in the current Spring container.

[0065] The object definition registrar and the object instance container are core components of an application based on the Spring framework. Among them, the object definition registrar is used to store object definition information, and the object instance container is used to store class instances.

[0066] In an embodiment of the present invention, obtaining the object definition registrar and the object instance container in the current Spring container is used to update the object definition information corresponding to the SQL mapping configuration file in the object definition registrar, and at the same time update the SQL mapping configuration file instance in the object instance container.

[0067] S270. Based on the updated SQL mapping configuration file, re-register the object definition information associated with the SQL mapping configuration file in the object definition registrar through the new SQL session factory and the new SQL execution connection session template manager.

[0068] In an embodiment of the present invention, since the number of SQL mapping configuration files to be updated is large, if updated one by one, it will consume a large amount of computing power. Therefore, based on the updated SQL mapping configuration file, the object definition information associated with the SQL mapping configuration file in the object definition registrar is re-registered through the new SQL session factory and the new SQL execution connection session template manager.

[0069] Exemplarily, in the object definition registrar, delete the object definition information associated with the SQL mapping configuration file before the update, and through the new SQL session factory, scan the updated SQL mapping configuration file under the application root directory, and extract the definition information of the updated SQL mapping configuration file, and re-register the definition information of the updated SQL mapping configuration file into the object definition registrar.

[0070] Optionally, re-registering the object definition information associated with the SQL mapping configuration file in the object definition registrar based on the updated SQL mapping configuration file through the new SQL session factory and the new SQL execution connection session template manager includes:

[0071] Replace the original SQL session factory and the original SQL execution connection session template manager included in the object instance container with a new SQL session factory and a new SQL execution connection session template manager respectively;

[0072] In the object definition registrar, delete the object definition information associated with the SQL mapping configuration file before the update;

[0073] Through the new SQL session factory, scan the updated SQL mapping configuration file under the application root directory and extract the definition information of the updated SQL mapping configuration file;

[0074] Re-register the definition information of the updated SQL mapping configuration file to the object definition registrar.

[0075] In this optional embodiment, a specific method for re-registering the object definition information associated with the SQL mapping configuration file in the object definition registrar based on the updated SQL mapping configuration file through the new SQL session factory and the new SQL execution connection session template manager is provided: First, replace the original SQL session factory and the original SQL execution connection session template manager included in the object instance container with a new SQL session factory and a new SQL execution connection session template manager respectively. Further, in the object definition registrar, delete the object definition information associated with the SQL mapping configuration file before the update. Specifically, iterate through all the object definition information ending with Mapper in the object definition registrar and delete them.

[0076] Further, through the newly replaced SQL session factory, scan the updated SQL mapping configuration file under the application root directory and extract the definition information of the updated SQL mapping configuration file. Specifically, scan the mapper files under the application root directory through the Mapper configuration scanner, and extract the object definition information associated with the mapper files through the object definition constructor and register it to the object definition registrar.

[0077] S280. Based on the re-registered object definition information in the object definition registrar, update the SQL mapping configuration file instance in the object instance container.

[0078] In the implementation of the present invention, after completing the re-registration of the object definition information in the object definition registration information, based on the re-registered object definition information, update the SQL mapping configuration file instance in the object instance container. Specifically, traverse the object instances ending with Mapper in the object instance container and delete them. Based on the newly registered object definition information, re-initialize the SQL mapping configuration file instance in the object instance container.

[0079] Optionally, based on the re-registered object definition information in the object definition register, update the SQL mapping configuration file instance in the object instance container, including:

[0080] In the object instance container, delete the SQL mapping configuration file instance associated with the SQL mapping configuration file before the update;

[0081] Based on the re-registered object definition information in the object definition register, instantiate the SQL mapping configuration file in the object instance container;

[0082] When there is dependency injection in the updated SQL mapping configuration file instance in the object definition register, perform dependency attribute change based on the updated SQL mapping configuration file instance.

[0083] In this optional embodiment, a specific method for updating the SQL mapping configuration file instance in the object instance container based on the re-registered object definition information in the object definition register is provided: First, in the object instance container, delete the SQL mapping configuration file instance associated with the SQL mapping configuration file before the update, and then instantiate the SQL mapping configuration file in the object instance container based on the re-registered object definition information in the object definition register. By deleting and re-initializing the SQL mapping configuration file instance, there is no need to compare the original SQL mapping configuration file instance in the object instance container, reducing the calculation amount and realizing the rapid update of the SQL mapping configuration file instance.

[0084] In addition, when there is dependency injection in the updated SQL mapping configuration file instance in the object definition register, perform dependency attribute change based on the updated SQL mapping configuration file instance. For example, if class file A references SQL mapping configuration file instance B, that is, there is dependency injection, then after the SQL mapping configuration file instance B is updated, it is necessary to change the dependency attributes of class file A based on the updated SQL mapping configuration file instance B, that is, replace the dependency attribute values based on the new SQL mapping configuration file instance B to avoid affecting the normal operation of the subsequent application program.

[0085] The technical solution of the embodiment of the present invention backs up the SQL mapping configuration file in the application program root directory to the SQL mapping configuration file manager, periodically scans the SQL mapping configuration files in the SQL mapping configuration file manager and the SQL mapping configuration files in the application program root directory to determine whether file updates occur, and when the number of updated files exceeds the set number threshold, adopts a full-update method to update the object definition information and instances of the SQL mapping configuration file in the application program running environment, which can quickly configure the updated SQL statements without restarting the program and does not affect the normal use of users.

[0086] Embodiment III

[0087] Figure 3 The figure is a flowchart of a method for dynamically updating a program provided in Embodiment III of the present invention. This embodiment is further refined on the basis of the above embodiment, and provides specific steps for updating the SQL mapping configuration file in the application program running environment by using a target update method based on the updated SQL mapping configuration file. As Figure 2 shown, the method includes:

[0088] S310. Periodically detect whether the SQL mapping configuration file in the root directory of the application program is updated.

[0089] S320. When the SQL mapping configuration file is updated, compare the number of updated SQL mapping configuration files with a quantity threshold. When the number of updated SQL mapping configuration files is less than the quantity threshold, determine that the target update method of the application program is partial update.

[0090] In the embodiment of the present invention, when the SQL mapping configuration file in the root directory of the application program is updated, compare the number of updated SQL mapping configuration files with a quantity threshold. If the number of updated SQL mapping configuration files is less than the quantity threshold, determine that the target update method of the application program is partial update.

[0091] S330. When the target update method is partial update, obtain the environment configuration information of the Spring container, and build a new SQL session factory based on the environment configuration information.

[0092] In the embodiment of the present invention, when the target update method is partial update, obtain the environment configuration information of the Spring container, and build a new SQL session factory based on the environment configuration information to register the updated SQL mapping configuration file in the application program running environment.

[0093] S340. Through the new SQL session factory, obtain the metadata information of the updated SQL mapping configuration file in the persistence framework associated with the application program.

[0094] In the embodiment of the present invention, through the new SQL session factory, obtain the persistence framework associated with the application program. For example, obtain the metadata information of the updated SQL mapping configuration file in MyBatis. Among them, the metadata information may include file size, version, update time, etc.

[0095] S350. Obtain the original SQL session factory of the Spring container, and through the original SQL session factory, obtain the metadata information of the SQL mapping configuration file before update in the persistence framework associated with the application program.

[0096] In the embodiments of the present invention, in order to achieve local update, it is necessary to determine which of the SQL mapping configuration files before update in the application-associated persistence framework need to be updated. Therefore, the original SQL session factory of the Spring container is obtained, and through the original SQL session factory, the metadata information of the SQL mapping configuration file before update in the application-associated persistence framework is obtained.

[0097] S360. According to the file identifier of the SQL mapping configuration file, the metadata information of the updated SQL mapping configuration file and the corresponding metadata information of the SQL mapping configuration file before update are compared pairwise.

[0098] In the embodiments of the present invention, according to the file identifier of the SQL mapping configuration file, the metadata information of the updated SQL mapping configuration file and the corresponding metadata information of the SQL mapping configuration file before update are compared pairwise. Specifically, the metadata information of the updated SQL mapping configuration file with the same file identifier and the corresponding metadata information of the SQL mapping configuration file before update are compared to find the SQL mapping configuration file that needs to be updated. Through the compared metadata information, the SQL mapping configuration file that needs to be updated in the running environment can be calculated with a relatively small amount of computation.

[0099] S370. In the case where they are inconsistent, based on the updated SQL mapping configuration file under the application root directory, the updated object definition information in the object definition registrar included in the Spring container is updated, and the updated SQL mapping configuration file instance in the object instance container is updated.

[0100] In the embodiments of the present invention, in the case where the metadata information of the updated SQL mapping configuration file with the same file identifier and the corresponding metadata information of the SQL mapping configuration file before update are inconsistent, based on the updated SQL mapping configuration file under the application root directory, the updated object definition information in the object definition registrar included in the Spring container is updated, and the updated SQL mapping configuration file instance in the object instance container is updated. It should be noted that in addition to updating the updated object definition information in the object definition registrar and updating the updated SQL mapping configuration file instance in the object instance container. It should also include adding the object definition information that did not exist in the previous version to the object definition registrar. Similarly, the SQL mapping configuration file instance that did not exist in the previous version is added to the object instance container.

[0101] The technical solution of the embodiment of the present invention is to back up the SQL mapping configuration file under the root directory of the application to the SQL mapping configuration file manager, periodically scan the SQL mapping configuration files in the SQL mapping configuration file manager and the SQL mapping configuration files under the root directory of the application to determine whether file updates occur, and when the number of updated files is less than the set number threshold, perform partial updates on the object definitions and instances of the SQL mapping configuration files in the application running environment, so as to quickly replace the incorrect configuration files in the running environment and achieve hot updates of the application.

[0102] Embodiment 4

[0103] Figure 4 It is a schematic structural diagram of a program dynamic update device provided by Embodiment 4 of the present invention. As Figure 4 shown, the device includes:

[0104] An update detection module 410, configured to periodically detect whether the structured query language (SQL) mapping configuration file under the root directory of the application is updated;

[0105] An update method determination module 420, configured to determine the target update method of the application according to the number of updated SQL mapping configuration files when the SQL mapping configuration file is updated;

[0106] A program update module 430, configured to update the SQL mapping configuration file in the application running environment by using the target update method based on the updated SQL mapping configuration file.

[0107] The technical solution of the embodiment of the present invention periodically detects whether the structured query language (SQL) mapping configuration file under the root directory of the application is updated, determines the target update method of the application according to the number of updated SQL mapping configuration files when the SQL mapping configuration file is updated, and updates the SQL mapping configuration file in the application running environment by using the target update method based on the updated SQL mapping configuration file, so that the SQL mapping configuration file in the application running environment can be adaptively updated after the SQL mapping configuration file is updated, without restarting the service, and program dynamic update is achieved.

[0108] Optionally, the update method determination module 420 is specifically configured to:

[0109] Compare the number of updated SQL mapping configuration files with the number threshold, and when the number of updated SQL mapping configuration files is less than the number threshold, determine that the target update method of the application is partial update;

[0110] When the number of SQL mapping configuration files to be updated is greater than or equal to the quantity threshold, determine that the target update method of the application is full update.

[0111] Optionally, the program update module 430 includes:

[0112] The first session factory creation unit is used to create a new SQL session factory and a new SQL execution connection session template manager based on the data source associated with the current spring container when the target update method is full update;

[0113] The instance container acquisition unit is used to acquire the object definition registrar and the object instance container in the current Spring container;

[0114] The definition information registration unit is used to re-register the object definition information associated with the SQL mapping configuration file in the object definition registrar based on the updated SQL mapping configuration file through the new SQL session factory and the new SQL execution connection session template manager;

[0115] The instance update unit is used to perform SQL mapping configuration file instance update in the object instance container based on the re-registered object definition information in the object definition registrar.

[0116] Optionally, the definition information registration unit is specifically used for:

[0117] Replace the original SQL session factory and the original SQL execution connection session template manager included in the object instance container with the new SQL session factory and the new SQL execution connection session template manager respectively;

[0118] Delete the object definition information associated with the SQL mapping configuration file before update in the object definition registrar;

[0119] Scan the updated SQL mapping configuration file under the application root directory through the new SQL session factory and extract the definition information of the updated SQL mapping configuration file;

[0120] Re-register the definition information of the updated SQL mapping configuration file to the object definition registrar.

[0121] Optionally, the program update module 430 includes:

[0122] The second session factory creation unit is used to acquire the environment configuration information of the Spring container and build a new SQL session factory based on the environment configuration information when the target update method is partial update;

[0123] The first metadata extraction unit is used to obtain the metadata information of the updated SQL mapping configuration file in the application-associated persistence framework through a new SQL session factory;

[0124] The second metadata extraction unit is used to obtain the original SQL session factory of the Spring container, and through the original SQL session factory, obtain the metadata information of the SQL mapping configuration file before the update in the application-associated persistence framework;

[0125] The metadata comparison unit is used to pairwise compare the metadata information of the updated SQL mapping configuration file and the corresponding metadata information of the SQL mapping configuration file before the update according to the file identifier of the SQL mapping configuration file;

[0126] The application update unit is used, in the case of inconsistency between the two, to update the updated object definition information that has occurred in the object definition registrar included in the Spring container based on the updated SQL mapping configuration file under the application root directory, and update the SQL mapping configuration file instances that have occurred in the object instance container.

[0127] Optionally, the program dynamic update device further includes:

[0128] The manager creation module is used to back up the SQL mapping configuration file under the application root directory to the SQL mapping configuration file manager in response to the triggering of the dynamic update annotation of the SQL mapping configuration file before periodically detecting whether the SQL mapping configuration file under the application root directory has been updated;

[0129] The update detection module 410 is specifically used for:

[0130] Periodically scan the SQL mapping configuration files in the SQL mapping configuration file manager and the SQL mapping configuration files under the application root directory;

[0131] Based on the file identifier of the SQL mapping configuration file, compare the metadata information of the SQL mapping configuration file in the SQL mapping configuration file manager with the metadata information of the corresponding SQL mapping configuration file under the application root directory to determine whether the SQL mapping configuration file under the application root directory has been updated.

[0132] Optionally, the instance update unit is specifically used for:

[0133] In the object instance container, delete the SQL mapping configuration file instances associated with the SQL mapping configuration file before the update;

[0134] Based on the re-registered object definition information in the object definition register, instantiate the SQL mapping configuration file in the object instance container;

[0135] When there is dependency injection in the updated SQL mapping configuration file instance in the object definition register, perform dependency attribute change based on the updated SQL mapping configuration file instance.

[0136] The program dynamic update device provided by the embodiments of the present invention can execute the program dynamic update method provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0137] In the technical solution of the present invention, the collected information is information and data authorized by the user or fully authorized by all parties, and the processing of relevant data such as collection, storage, use, processing, transmission, provision, disclosure, and application complies with the relevant laws, regulations, and standards of relevant countries and regions, takes necessary confidentiality measures, does not violate public order and good customs, and provides a corresponding operation entry for the user to choose to authorize or reject.

[0138] Embodiment Five

[0139] According to an embodiment of the present invention, the present invention also provides an electronic device, a readable storage medium, and a computer program product.

[0140] Figure 5 FIG. shows a schematic structural diagram of an electronic device 10 that can be used to implement the embodiments of the present invention. The electronic device is intended to represent various forms of digital computers, such as, a laptop computer, a desktop computer, a workbench, a personal digital assistant, an applicator, a blade applicator, a mainframe computer, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as, a personal digital processor, a cellular phone, a smart phone, a wearable device (such as a helmet, glasses, a watch, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are only examples and are not intended to limit the implementation of the present invention described and / or claimed herein.

[0141] Such as Figure 5As shown, the electronic device 10 includes at least one processor 11 and a memory communicatively connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc. The memory stores a computer program executable by the at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 into the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0142] Multiple components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disc, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.

[0143] The processor 11 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as the program dynamic update method.

[0144] In some embodiments, the program dynamic update method can be implemented as a computer program tangibly embodied in a computer-readable storage medium, such as the storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed onto the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the program dynamic update method described above can be executed. Alternatively, in other embodiments, the processor 11 can be configured to execute the program dynamic update method by any other appropriate means (e.g., by means of firmware).

[0145] The various embodiments of the systems and techniques described above in this specification can be implemented in digital electronic circuitry, integrated circuit systems, field-programmable gate arrays (FPGA), application specific integrated circuits (ASIC), application specific standard products (ASSP), systems on chip (SOC), complex programmable logic devices (CPLD), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include: being implemented in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which may be a special-purpose or general-purpose programmable processor that receives data and instructions from, and transmits data and instructions to, a storage system, at least one input device, and at least one output device.

[0146] The computer programs for implementing the methods of the present invention can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions / operations specified in the flowchart and / or block diagram to be implemented. The computer programs can be executed entirely on the machine, partly on the machine, as a stand-alone software package partly on the machine and partly on a remote machine or entirely on the remote machine or server.

[0147] In the context of the present invention, a computer-readable storage medium can be a tangible medium that can contain or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer-readable storage medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. Alternatively, the computer-readable storage medium can be a machine-readable signal medium. More specific examples of the machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0148] The embodiments of the present application also disclose a computer program product, which includes a computer program that, when executed by a processor, implements the program dynamic update method provided in any embodiment of the present application. This program product and the program dynamic update methods disclosed in the embodiments of the present application belong to the same inventive concept, and thus will not be elaborated herein.

[0149] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or a trackball) through which the user can provide input to the electronic device. Other kinds of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0150] The systems and techniques described herein can be implemented in a computing system including backend components (e.g., as a data applicator), or a computing system including middleware components (e.g., an application applicator), or a computing system including frontend components (e.g., a user computer having a graphical user interface or a web browser through which the user can interact with an implementation of the systems and techniques described herein), or a computing system including any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected by digital data communication in any form or medium (e.g., a communication network). Examples of communication networks include: local area network (LAN), wide area network (WAN), blockchain network, and the Internet.

[0151] The computing system can include a client and an applicator. The client and the applicator are generally remote from each other and typically interact through a communication network. The relationship between the client and the applicator is created by computer programs running on respective computers and having a client-applicator relationship with each other. The applicator can be a cloud applicator, also known as a cloud computing applicator or a cloud host, which is a host product in the cloud computing application system, solving the defects of difficult management and weak business scalability existing in traditional physical hosts and VPS applications.

[0152] It should be understood that various forms of the processes shown above can be used, with steps reordered, added, or deleted. For example, the steps recited in the present invention can be executed in parallel, sequentially, or in a different order, as long as the desired results of the technical solution of the present invention can be achieved, and no limitation is made herein.

[0153] The above specific embodiments do not constitute a limitation to the protection scope of the present invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.

Claims

1. A method for dynamically updating a program, characterized in that Including: Periodically detecting whether the Structured Query Language (SQL) mapping configuration file under the application root directory has been updated; In the case where the SQL mapping configuration file has been updated, determining the target update method of the application according to the number of updated SQL mapping configuration files; Based on the updated SQL mapping configuration file, using the target update method to update the SQL mapping configuration file in the application running environment.

2. The program dynamic update method according to claim 1, wherein The determining the target update method of the application according to the number of updated SQL mapping configuration files includes: Comparing the number of updated SQL mapping configuration files with a number threshold, and in the case where the number of updated SQL mapping configuration files is less than the number threshold, determining that the target update method of the application is partial update; In the case where the number of updated SQL mapping configuration files is greater than or equal to the number threshold, determining that the target update method of the application is full update.

3. The program dynamic update method according to claim 2, wherein The updating the SQL mapping configuration file in the application running environment based on the updated SQL mapping configuration file and using the target update method includes: In the case where the target update method is full update, creating a new SQL session factory and a new SQL execution connection session template manager based on the data source associated with the current spring container; Obtaining the object definition registrar and the object instance container in the current Spring container; Based on the updated SQL mapping configuration file, re-registering the object definition information associated with the SQL mapping configuration file in the object definition registrar through the new SQL session factory and the new SQL execution connection session template manager; Based on the re-registered object definition information in the object definition registrar, performing instance update of the SQL mapping configuration file in the object instance container.

4. The program dynamic update method according to claim 3, wherein The re-registering the object definition information associated with the SQL mapping configuration file in the object definition registrar based on the updated SQL mapping configuration file through the new SQL session factory and the new SQL execution connection session template manager includes: Replacing the original SQL session factory and the original SQL execution connection session template manager included in the object instance container with the new SQL session factory and the new SQL execution connection session template manager respectively; In the object definition registrar, deleting the object definition information associated with the SQL mapping configuration file before update; Scanning the updated SQL mapping configuration file under the application root directory through the new SQL session factory and extracting the definition information of the updated SQL mapping configuration file; Re-registering the definition information of the updated SQL mapping configuration file to the object definition registrar.

5. The program dynamic update method according to claim 2, wherein The updating the SQL mapping configuration file in the application running environment based on the updated SQL mapping configuration file and using the target update method includes: In the case where the target update method is partial update, obtaining the environment configuration information of the Spring container and constructing a new SQL session factory based on the environment configuration information. Obtain the metadata information of the updated SQL mapping configuration file in the application-associated persistence framework through a new SQL session factory; Obtain the original SQL session factory of the Spring container, and through the original SQL session factory, obtain the metadata information of the SQL mapping configuration file before the update in the application-associated persistence framework; According to the file identifier of the SQL mapping configuration file, pairwise compare the metadata information of the updated SQL mapping configuration file with the corresponding metadata information of the SQL mapping configuration file before the update; In the case where the two are inconsistent, based on the updated SQL mapping configuration file under the application root directory, update the updated object definition information in the object definition registrar included in the Spring container, and update the SQL mapping configuration file instance that has been updated in the object instance container.

6. The program dynamic update method according to claim 1, wherein Before periodically detecting whether the SQL mapping configuration file under the application root directory is updated, it also includes: In response to the triggering of the dynamic update annotation of the SQL mapping configuration file, back up the SQL mapping configuration file under the application root directory to the SQL mapping configuration file manager; The periodic detection of whether the SQL mapping configuration file of the structured query language under the application root directory is updated includes: Periodically scan the SQL mapping configuration files in the SQL mapping configuration file manager and the SQL mapping configuration files under the application root directory; Based on the file identifier of the SQL mapping configuration file, compare the metadata information of the SQL mapping configuration file in the SQL mapping configuration file manager with the metadata information of the corresponding SQL mapping configuration file under the application root directory to determine whether the SQL mapping configuration file under the application root directory is updated.

7. The program dynamic update method according to claim 3, wherein The updating of the SQL mapping configuration file instance in the object instance container based on the re-registered object definition information in the object definition registrar includes: In the object instance container, delete the SQL mapping configuration file instance associated with the SQL mapping configuration file before the update; Based on the re-registered object definition information in the object definition registrar, instantiate the SQL mapping configuration file in the object instance container; When there is dependency injection in the updated SQL mapping configuration file instance in the object definition registrar, change the dependency attributes based on the updated SQL mapping configuration file instance.

8. A program dynamic update device, characterized in that, It includes: An update detection module for periodically detecting whether the SQL mapping configuration file of the structured query language under the application root directory is updated; An update method determination module for determining the target update method of the application according to the number of updated SQL mapping configuration files when the SQL mapping configuration file is updated; A program update module for updating the SQL mapping configuration file in the application running environment by using the target update method based on the updated SQL mapping configuration file.

9. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and when the computer program is executed by the at least one processor, the at least one processor is enabled to execute the program dynamic update method according to any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for implementing the program dynamic update method according to any one of claims 1-7 when the computer instructions are executed by a processor.

11. A computer program product, characterized in that, The computer program product includes a computer program which, when executed by a processor, implements the program dynamic update method according to any one of claims 1-7.

Citation Information

Patent Citations

  • Widget updating method and system as well as Widget client and Widget server

    CN101977217A

  • Hot deployment method and system for Java application

    CN105389186A

  • Hot update method and device, computer storage medium and system

    CN114064094A

  • Code file updating method and device, electronic equipment and storage medium

    CN115309389A

  • Timing task management method and device, equipment and storage medium

    CN115934288A