Strategy loading methods, devices, electronic devices, storage media, and program products

By converting the policy file into a bytecode array and then into a policy class object at runtime, the problem of long update cycles after changes in business policy logic in the software system is solved, achieving real-time loading and efficient response.

CN122086493APending Publication Date: 2026-05-26BEIJING QIYI CENTURY SCI & TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-02-28
Publication Date
2026-05-26

AI Technical Summary

Technical Problem

In existing technologies, software systems need to be recompiled, packaged, deployed, and restarted after changes to business strategy logic, resulting in long update cycles, which cannot meet the needs of business scenarios with high real-time requirements and leads to slow business response.

Method used

By converting policy files into bytecode arrays conforming to preset syntax specifications, and then into policy class objects at runtime, the system creates and executes target policy instances in response to policy execution instructions, thus eliminating the dependency chain of encoding, compilation, packaging, and restart, and achieving real-time loading.

Benefits of technology

The loading cycle of the new strategy file has been shortened, and the loading response speed of the new strategy file has been improved, meeting the needs of business scenarios with high real-time requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122086493A_ABST
    Figure CN122086493A_ABST
Patent Text Reader

Abstract

This disclosure relates to a policy loading method, apparatus, electronic device, storage medium, and program product. The method includes: in response to a policy file change event, determining a changed policy file, the policy file including a policy logic description; converting the policy file into a bytecode array conforming to a preset syntax specification, the preset syntax specification allowing the bytecode array to be converted into a policy class object at runtime; converting the bytecode array into a policy class object; in response to a policy execution instruction, determining a target policy class object from the policy class objects based on the policy execution instruction, creating a target policy instance based on the target policy class object, and executing the target policy instance. Specifically, when a new policy file is uploaded, it can be loaded in real-time at runtime, thus eliminating the dependency chain of encoding, compilation, packaging, release, and restart, shortening the loading cycle of the new policy file, improving the loading response speed of the new policy file, and meeting the needs of business scenarios with high real-time requirements.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of electronic computer technology, and in particular to a strategy loading method, apparatus, electronic device, storage medium, and program product. Background Technology

[0002] This section is intended to provide background or context for embodiments of this disclosure. The description herein is not intended to imply that it is prior art simply because it is included in this section.

[0003] In the development and application of software systems, business strategies within the software system need to be adjusted according to changes in the application environment or business requirements.

[0004] In related technologies, after a logical change in business strategy, the entire software system is usually recompiled, packaged, deployed, and restarted based on the source code of the new business strategy.

[0005] However, there are issues with long update cycles, which cannot meet the high real-time requirements of business scenarios, resulting in slow business response. Summary of the Invention

[0006] In order to at least partially solve one of the technical problems in the related art, this disclosure provides a strategy loading method, apparatus, electronic device, storage medium, and program product.

[0007] To achieve the above objectives, a first aspect of the exemplary embodiments of this disclosure provides a strategy loading method, comprising: In response to a policy file change event, the changed policy file is determined, wherein the policy file includes a policy logic description; The strategy file is converted into a bytecode array that conforms to a preset syntax specification, wherein the preset syntax specification allows the bytecode array to be converted into a strategy class object at runtime; Convert the bytecode array into the strategy class object; In response to a strategy execution instruction, a target strategy class object is determined from the strategy class objects based on the strategy execution instruction, a target strategy instance is created based on the target strategy class object, and the target strategy instance is executed.

[0008] Based on the same inventive concept, a second aspect of the exemplary embodiments of this disclosure provides a strategy loading apparatus, comprising: The policy file management module is configured to respond to a policy file change event and determine the changed policy file, wherein the policy file includes a policy logic description. The bytecode generation module is configured to convert the strategy file into a bytecode array that conforms to a preset syntax specification, wherein the preset syntax specification allows the bytecode array to be converted into a strategy class object at runtime; The class loading module is configured to convert the bytecode array into the strategy class object; The strategy execution module is configured to respond to a strategy execution instruction, determine a target strategy class object from the strategy class objects based on the strategy execution instruction, create a target strategy instance based on the target strategy class object, and execute the target strategy instance.

[0009] Based on the same inventive concept, a third aspect of the exemplary embodiments of this disclosure provides an electronic device, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the method as described in the first aspect.

[0010] Based on the same inventive concept, a fourth aspect of the exemplary embodiments of this disclosure provides a computer-readable storage medium having a computer program / instructions stored thereon, which, when executed by a processor, implement the steps of the method as described in the first aspect.

[0011] Based on the same inventive concept, a fifth aspect of the exemplary embodiments of this disclosure provides a computer program product, including a computer program / instructions that, when executed by a processor, implement the steps of the method as described in the first aspect.

[0012] The technical solution provided in this disclosure has the following advantages compared with the prior art: In response to a policy file change event, the modified policy file is determined, the policy file including a policy logic description; the policy file is converted into a bytecode array conforming to a preset syntax specification, wherein the preset syntax specification allows the bytecode array to be converted into a policy class object at runtime; the bytecode array is converted into the policy class object; in response to a policy execution instruction, a target policy class object is determined from the policy class objects based on the policy execution instruction, a target policy instance is created based on the target policy class object, and the target policy instance is executed.

[0013] Among these features, once the new strategy file is uploaded, it can be loaded in real time at runtime, thus eliminating the dependency chain of encoding, compilation, packaging, release, and restart, shortening the loading cycle of the new strategy file, improving the loading response speed of the new strategy file, and meeting the needs of business scenarios with high real-time requirements. Attached Figure Description

[0014] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.

[0015] To more clearly illustrate the technical solutions in the embodiments of this disclosure or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0016] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the originals and elements are not necessarily drawn to scale.

[0017] Figure 1 A schematic flowchart of a strategy loading method provided for an exemplary embodiment of this disclosure; Figure 2 A timing diagram illustrating a strategy creation method provided for an exemplary embodiment of this disclosure; Figure 3 A timing diagram illustrating a policy update method provided for an exemplary embodiment of this disclosure; Figure 4 A timing diagram illustrating a strategy unloading method provided for an exemplary embodiment of this disclosure; Figure 5 A schematic diagram of a strategy loading system provided for an exemplary embodiment of this disclosure; Figure 6 A schematic diagram of a strategy loading device provided as an exemplary embodiment of this disclosure; Figure 7 A schematic diagram of the structure of an electronic device provided as an exemplary embodiment of the present disclosure. Detailed Implementation

[0018] It is understood that before using the technical solutions disclosed in the various embodiments of this disclosure, users should be informed of the types, scope of use, and usage scenarios of the personal information involved in this disclosure in an appropriate manner in accordance with relevant laws and regulations, and user authorization should be obtained.

[0019] For example, upon receiving a user's active request, a prompt message is sent to the user to explicitly inform them that the requested operation will require the acquisition and use of the user's personal information. This allows the user to independently choose whether to provide personal information to the software or hardware, such as the electronic device, application, server, or storage medium performing the operations of this disclosed technical solution, based on the prompt message.

[0020] As an optional but non-limiting implementation, in response to a user's active request, sending a prompt message to the user can be done via a pop-up window, where the prompt message can be presented in text format. Furthermore, the pop-up window can also include a selection control allowing the user to choose "agree" or "disagree" to provide personal information to the electronic device.

[0021] It is understood that the above notification and user authorization process are merely illustrative and do not constitute a limitation on the implementation of this disclosure. Other methods that comply with relevant laws and regulations may also be applied to the implementation of this disclosure.

[0022] It is understood that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and related provisions.

[0023] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.

[0024] It should be understood that the steps described in the method embodiments of this disclosure may be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of this disclosure is not limited in this respect.

[0025] The term "comprising" and its variations as used herein are open-ended inclusions, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Definitions of other terms will be given in the description below.

[0026] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are used only to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependencies.

[0027] It should be noted that the terms "a" and "a plurality of" used in this disclosure are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".

[0028] The names of messages or information exchanged between multiple devices in the embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.

[0029] To better understand the above-mentioned objectives, features, and advantages of this disclosure, the solutions disclosed herein will be further described below. It should be noted that, unless otherwise specified, the embodiments and features described herein can be combined with each other.

[0030] Numerous specific details are set forth in the following description in order to provide a full understanding of this disclosure, but this disclosure may also be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only some, and not all, of the embodiments of this disclosure.

[0031] As described in the background section, in the development and application of software systems, the business strategies within the software system need to be adjusted according to changes in the application environment or business requirements.

[0032] In related technologies, after a logical change in business strategy, the entire software system is usually recompiled, packaged, deployed, and restarted based on the source code of the new business strategy.

[0033] However, there are issues with long update cycles, which cannot meet the high real-time requirements of business scenarios, resulting in slow business response.

[0034] To address the aforementioned issues, this disclosure provides a policy loading scheme, specifically comprising: responding to a policy file change event, determining a changed policy file, the policy file including a policy logic description; converting the policy file into a bytecode array conforming to a preset syntax specification, wherein the preset syntax specification allows the bytecode array to be converted into a policy class object at runtime; converting the bytecode array into the policy class object; responding to a policy execution instruction, determining a target policy class object from the policy class object based on the policy execution instruction, creating a target policy instance based on the target policy class object, and executing the target policy instance.

[0035] Because the preset syntax specification allows bytecode arrays to be converted into policy class objects at runtime, new policy files can be loaded in real time after being uploaded. This eliminates the dependency chain of encoding, compilation, packaging, release, and restart, shortens the loading cycle of new policy files, improves the loading response speed of new policy files, and can meet the needs of business scenarios with high real-time requirements.

[0036] This disclosure may be applied to, but is not limited to, the following fields: finance and fintech, e-commerce and retail, IoT-related fields, smart manufacturing and industry, enterprise SaaS services, and all fields that use the Java technology stack.

[0037] After introducing the basic principles of this disclosure, various non-limiting embodiments of this disclosure will be described in detail below.

[0038] To address the aforementioned issues, this exemplary embodiment provides a strategy loading method, which will be described below with reference to specific embodiments.

[0039] Figure 1 This is a flowchart illustrating a policy loading method provided as an exemplary embodiment of the present disclosure. The method can be executed by a policy loading device, which can be implemented in software and / or hardware, and is generally integrated into an electronic device. Figure 1 As shown, the method includes the following steps: Step S110: In response to the policy file change event, determine the changed policy file, wherein the policy file includes a policy logic description.

[0040] The following section will introduce the definition of the strategy file and how it is determined.

[0041] In practical implementation, a strategy file refers to a structured data carrier in a software system that carries strategy logic. It is a physical or digital file containing strategy logic content and its management metadata.

[0042] As an example, policy files include: rule scripts, configuration files, etc.

[0043] Among them, strategy logic refers to the abstract expression of business intent in a software system.

[0044] As an example, strategy logic includes: business rules, risk control strategies, algorithm models, etc.

[0045] In the exemplary embodiments described above, the definition of the policy file was introduced. The method for determining the policy file will be described below.

[0046] In some exemplary embodiments, in response to a policy file change event, the modified policy file is determined, the policy file including a policy logic description, including: Receive the original policy file, which includes an original policy logic description; Configure the identity and version identifier for the original policy file; The original policy file, after configuring the identity identifier and the version identifier, is converted into a preset structured format to obtain a structured policy file; Based on preset path rules, the structured strategy file is stored as the strategy file.

[0047] As an example, a standardized storage, versioning, and synchronization mechanism can be built for policy files through a distributed file management system (such as HDFS, a component of the Hadoop Distributed File System) or a version control system (such as Git, a distributed version control system), to achieve unified management of policy files and support the creation, modification, deletion, and version rollback of policy files.

[0048] In practice, the original policy file conforms to the definition of a policy file in the exemplary embodiments described above.

[0049] As an example, the original policy file includes Java code snippets. Compared to defining policies using metadata or scripts, directly uploading Java code snippets aligns better with developers' coding habits, eliminating the need to learn additional DSLs or script syntax and lowering the barrier to entry (especially suitable for policies requiring complex logic, such as those involving multi-step calculations or external API calls).

[0050] In practice, the original policy file is configured with an identity identifier and a version identifier: As an example, there may be several version identifiers under the same identity.

[0051] As an example, each policy file is associated with a unique version identifier (version number, such as version 1.0, version 2.0, etc.), and the file management system stores multiple historical versions of the policy file. When it is necessary to roll back to a historical version (such as rolling back from version 2.0 to version 1.0), the system can load the corresponding historical policy file based on the specified historical version number and trigger a dynamic loading process.

[0052] As an example, the distributed file system, through its built-in multi-replica synchronization mechanism, automatically synchronizes the update to all replicas when a node updates a file, thereby ensuring that the policy file read by all application nodes is consistent in content and version, without requiring the application layer to implement additional synchronization logic, and ensuring that the policy file stored therein maintains consistency in content and version across multiple system nodes.

[0053] In practice, the original policy file configured with the identity identifier and the version identifier is converted into a preset structured format to obtain a structured policy file: As an example, the default structured formats include JSON, XML, or a custom DSL, which contain policy logic (such as conditional expressions, execution actions, etc.) and policy metadata (identity identifier, version identifier, effective time, etc.) for easy parsing.

[0054] In practice, the structured strategy file is stored based on preset path rules and serves as the strategy file: As an example, policy files are stored according to the path rule " / type / identity identifier (e.g., ID) / version identifier" to ensure uniqueness and retrieval.

[0055] In practice, this also includes: File system-based monitoring mechanisms (such as Watch Service) can capture file addition / modification events in real time and automatically trigger subsequent dynamic loading processes, avoiding manual intervention.

[0056] The above exemplary embodiments solve the problem that chaotic policy file management in distributed systems can easily lead to policy inconsistencies.

[0057] Step S120: Convert the policy file into a bytecode array that conforms to a preset syntax specification, wherein the preset syntax specification allows the bytecode array to be converted into a policy class object at runtime.

[0058] As an example, the default syntax rules include: Java syntax specification.

[0059] The Java syntax specification allows bytecode arrays to be converted into strategy class objects (such as Class objects) at runtime using the ClassLoader.defineClass() method.

[0060] As an example, converting the policy file into a bytecode array conforming to a preset syntax specification includes: The logic in the strategy file is parsed, and based on bytecode manipulation frameworks such as ASM or Javassist, a bytecode array (including classes, methods, and instructions) that conforms to the Java syntax specification is dynamically generated at runtime.

[0061] In some exemplary embodiments, converting the policy file into a bytecode array conforming to a preset syntax specification includes: The strategy file is parsed, and an abstract syntax tree is obtained based on the business logic of the strategy file; The abstract syntax tree is converted into a bytecode array that conforms to the preset syntax specification.

[0062] As an example, the business logic in the policy file (such as "reject if transaction amount > 10000") is parsed into an abstract syntax tree (AST), and then converted into a bytecode array (such as ILOAD, IFGT, IRETURN) that conforms to the JVM specification (Java syntax specification). The generated bytecode array corresponds to a class that implements the unified policy interface, ensuring type safety during invocation.

[0063] As an example, strategy interfaces, such as the Strategy interface, contain the execute() method.

[0064] Through the above exemplary embodiments, since the preset syntax specification allows bytecode arrays to be converted into policy class objects at runtime, when a new policy file is uploaded, it can be loaded in real time at runtime, thereby getting rid of the dependency chain of static compilation encoding, compilation, packaging, release, and restart, shortening the loading cycle of the new policy file, improving the loading response speed of the new policy file, and meeting the needs of business scenarios with high real-time requirements.

[0065] In some exemplary embodiments, the process of converting the policy file into a bytecode array conforming to a preset syntax specification further includes: Insert monitoring points into the bytecode array to monitor the execution status of the strategy.

[0066] In practice, enhanced logic such as logging and monitoring is automatically injected when the bytecode array is generated, making it easier to track the execution status of the strategy. Tracking code (such as time consumption statistics and log printing) is injected into the dynamically generated bytecode array to collect metrics such as execution time, success rate, and exception type in real time. These metrics are then visualized through monitoring tools (such as Prometheus) to quickly locate anomalies.

[0067] Through the above exemplary embodiments, end-to-end monitoring avoids logical errors or performance issues that may be introduced by dynamic loading.

[0068] Step S130: Convert the bytecode array into the strategy class object.

[0069] In some exemplary embodiments, converting the bytecode array into the strategy class object includes: Based on the identity identifier and version identifier corresponding to the bytecode array, a class loader instance is created; Based on the class loader instance, the bytecode array is loaded into the virtual machine to generate the strategy class object.

[0070] In practice, based on multi-level caching, an independent `StrategyClassLoader` instance (inheriting from `ClassLoader`) is created for each strategy version, and the `findClass()` method is overridden to directly load dynamically generated bytecode. Since classes loaded by different class loaders are treated as different types in the JVM, no conflict will occur even if the class names are the same (e.g., `Strategy_transactionLimit_1.0` and `Strategy_transactionLimit_2.0`).

[0071] In practice, the class loading process is as follows: Receive bytecode array; The defineClass() method converts a bytecode array into a Class object; Cache loaded Class objects, using the version identifier as the key, and support multiple versions coexisting under the same strategy.

[0072] The above exemplary embodiments avoid conflicts between different version strategy classes (same class name but different logic) that may be caused by the "parent delegation model" of Java class loading.

[0073] In some exemplary embodiments, the method further includes: In response to a policy deletion command, based on the identity identifier and version identifier corresponding to the policy deletion command, the class loader instance commonly corresponding to the identity identifier and the version identifier is reclaimed, and the policy class object commonly corresponding to the identity identifier and the version identifier is unloaded.

[0074] In practice, when a strategy version expires (is replaced by a new version and has no references), the JVM garbage collection is triggered through the deprecated class loader instance, and the loaded Class objects are unloaded, releasing memory resources and preventing class bloat.

[0075] The above exemplary embodiments solve the problem that the default class loader cannot actively unload classes.

[0076] Step S140: In response to the strategy execution instruction, determine the target strategy class object from the strategy class object based on the strategy execution instruction, create a target strategy instance based on the target strategy class object, and execute the target strategy instance.

[0077] In some exemplary embodiments, the step of responding to a policy execution instruction, determining a target policy class object from the policy class objects based on the policy execution instruction, creating a target policy instance based on the target policy class object, and executing the target policy instance includes: In response to the policy execution instruction, the target policy class object is determined from the policy class objects based on the identity identifier and the version identifier corresponding to the policy execution instruction; Create an instance of the target strategy based on the target strategy class object; Based on a preset strategy interface, the target strategy instance is executed, wherein the bytecode array corresponds to the class of the preset strategy interface.

[0078] In practice, a strategy factory is provided, which obtains strategy instances from the class loader through the strategy identity and version identifier, and calls the execute() method to execute the strategy.

[0079] In some exemplary embodiments, the step of responding to a policy execution instruction, determining a target policy class object from the policy class objects based on the policy execution instruction, creating a target policy instance based on the target policy class object, and executing the target policy instance includes: In response to the policy execution instruction, the execution node corresponding to the policy execution instruction is divided into a first node and a second node. On the first node, the target policy instance corresponding to the target version identifier corresponding to the policy execution instruction is executed. On the second node, the historical policy instance corresponding to the identity identifier other than the target version identifier is executed. Based on the aforementioned data points, monitor the execution success rate and execution latency of the target strategy instance; In response to the execution success rate of the target policy instance being greater than a preset success rate threshold and the execution delay being less than a preset first delay threshold, the execution of the historical policy instance is stopped on the second node, and the target policy instance is executed.

[0080] In practice, the strategy of loading the new version on some nodes is specified through the configuration file, and a full update is performed after verification.

[0081] As an example, a strategy of loading new versions based on a node ratio (e.g., 20% of nodes), and then performing a full update after verification, can reduce the risk of large-scale releases.

[0082] In some exemplary embodiments, after responding to a policy execution instruction, determining a target policy class object from the policy class object based on the policy execution instruction, creating a target policy instance based on the target policy class object, and executing the target policy instance, the method further includes: Based on the aforementioned data points, monitor the execution success rate and execution latency of the target strategy instance; In response to the execution success rate of the target policy instance being less than a preset success rate threshold or the execution delay being greater than a preset second delay threshold, the historical policy instance corresponding to the identity identifier of the target policy instance, other than the target version identifier, is executed.

[0083] In practice, the system monitors indicators such as execution time and success rate of the strategy in real time, and automatically downgrades to a historical stable version when an anomaly occurs.

[0084] As an example, when the new version strategy times out (e.g., >500ms) or fails consecutively (e.g., 3 times), it automatically switches to a historical stable version to avoid affecting the main process.

[0085] Through the above exemplary embodiments, this disclosure, by using "dynamic bytecode generation + file standardization management + class loader isolation," breaks the traditional static compilation dependency and builds a dynamic management mechanism throughout the entire lifecycle of the strategy, thereby achieving strategy updates without restarts, efficient execution, and standardized management, solving the efficiency and stability problems in high-frequency strategy adjustment scenarios.

[0086] refer to Figure 2 This is a timing diagram illustrating a strategy creation method provided by an exemplary embodiment of this disclosure.

[0087] Users upload the policy file (.java) to the policy file management module.

[0088] The policy file management module verifies the format and permissions, stores the data, and transmits the parsed metadata to the bytecode generation module.

[0089] The bytecode generation module compiles and generates bytecode .class files, and pushes the bytecode and dependency information to the custom class loader module.

[0090] The custom class loader module requests class loading and registers the class loader to the JVM runtime environment.

[0091] The JVM runtime environment sends a load permission confirmation to the custom class loader module.

[0092] The custom class loader module loads bytecode into Class instances (cached), providing Class instances and execution entry points to the policy execution and monitoring module.

[0093] The strategy execution and monitoring module initializes the execution context and sends a success message to the user indicating successful upload and deployment.

[0094] refer to Figure 3 This is a timing diagram illustrating a policy update method provided by an exemplary embodiment of the present disclosure.

[0095] Users submit updated policy files to the policy file management module.

[0096] The policy file management module verifies the validity of the update file, overwrites the stored file, and sends a "pause old policy" command to the policy execution and monitoring module.

[0097] The strategy execution and monitoring module terminates the execution of the old strategy, releases resources, and sends a confirmation that the old strategy has been suspended to the strategy file management module.

[0098] The policy file management module transmits updated policy metadata.

[0099] The bytecode generation module recompiles and generates bytecode, then pushes the new bytecode (marked "updated") to the custom class loader module.

[0100] The custom class loader module unloads the old Class instance, clears the cache, and re-requests to load the new class into the JVM runtime environment.

[0101] The JVM runtime environment sends a new class loading license to the custom class loader module.

[0102] The custom class loader module provides new Class instances to the policy execution and monitoring module.

[0103] The policy execution and monitoring module reinitializes the context, starts the new policy, and sends a success update and execution status feedback to the user.

[0104] refer to Figure 4 This is a timing diagram of a strategy unloading method provided by an exemplary embodiment of the present disclosure.

[0105] In this process, the user initiates a policy uninstallation request (specifying the policy ID) to the policy file management module.

[0106] The policy file management module sends a "terminate and uninstall" command to the policy execution and monitoring module.

[0107] The policy execution and monitoring module terminates policy execution, collects monitoring data before uninstallation, and sends the termination and monitoring data feedback to the policy file management module.

[0108] The policy file management module sends an "unload Class instance" command to the custom class loader module.

[0109] A custom class loader module disconnects a class reference, triggering the JVM to unload the class into the JVM runtime environment.

[0110] The JVM runtime environment confirms that the class is completely unloaded.

[0111] The policy file management module deletes local files and caches, and sends a successful uninstallation notification to the user.

[0112] refer to Figure 5 This is a schematic diagram of a strategy loading system provided in an exemplary embodiment of the present disclosure.

[0113] The strategy dynamic loading system, based on Java dynamic bytecode and a file management system, includes an application layer (business system), a strategy loading core layer, a dynamic compilation and conversion layer, a bytecode management layer, and a file storage layer (file management system).

[0114] The application layer (business system) is used to: call the strategy interface, trigger strategy execution, and receive execution results.

[0115] The core layer of strategy loading includes: strategy interface definition (used to standardize strategy method signatures), strategy execution engine (used to call loaded strategy instances), and result feedback module (used to return execution status and results).

[0116] The dynamic compilation conversion layer includes: strategy file parsing (for reading .java / .class files), Java dynamic compilation (for compiling source code using JDK CompilerAPI), and bytecode verification (for legality and compatibility checks).

[0117] The bytecode management layer includes: a custom class loader (for flexible loading / unloading of bytecode), a bytecode cache (for memory caching hotspot strategies), and a policy version management system (for differentiating between multiple versions and rollback).

[0118] The file storage layer (file management system) includes: policy file storage (for classifying and storing source code / bytecode), metadata management (for recording version / path / status), and read / write permission control (for secure access and modification control).

[0119] The application layer (business system), strategy loading core layer, dynamic compilation and transformation layer, bytecode management layer, and file storage layer (file management system) are arranged in a top-down process order: 1. Upload the policy file to the file management system; 2. The dynamic compilation and conversion layer reads and processes files (parsing → compiling → verifying); 3. The bytecode management layer loads and caches bytecode, and maintains its version. 4. The application layer calls the strategy interface, and the execution engine triggers the strategy execution; 5. The execution result is returned to the application layer through the feedback module.

[0120] It should be noted that the method of this disclosure embodiment can be executed by a single device, such as a computer or server. The method of this embodiment can also be applied to a distributed scenario, where multiple devices cooperate to complete the task. In such a distributed scenario, one of these devices may execute only one or more steps of the method of this disclosure embodiment, and the multiple devices will interact with each other to complete the method described.

[0121] It should be noted that the above description describes some embodiments of this disclosure. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in a different order than that shown in the above embodiments and still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require a specific or sequential order to achieve the desired result. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0122] To implement the above embodiments, this disclosure also proposes a strategy loading device.

[0123] Figure 6 This is a schematic diagram of a strategy loading device provided in an embodiment of the present disclosure. The device can be implemented by software and / or hardware, and is generally integrated into an electronic device. Figure 6 As shown, the device includes: The policy file management module 610 is configured to determine the modified policy file in response to a policy file change event, wherein the policy file includes a policy logic description. The bytecode generation module 620 is configured to convert the strategy file into a bytecode array that conforms to a preset syntax specification, wherein the preset syntax specification allows the bytecode array to be converted into a strategy class object at runtime; Class loading module 630 is configured to convert the bytecode array into the strategy class object; The strategy execution module 640 is configured to respond to a strategy execution instruction, determine a target strategy class object from the strategy class objects based on the strategy execution instruction, create a target strategy instance based on the target strategy class object, and execute the target strategy instance.

[0124] In some exemplary embodiments, the policy file management module 610 is configured as follows: Receive the original policy file, which includes an original policy logic description; Configure the identity and version identifier for the original policy file; The original policy file, after configuring the identity identifier and the version identifier, is converted into a preset structured format to obtain a structured policy file; Based on preset path rules, the structured strategy file is stored as the strategy file.

[0125] In some exemplary embodiments, the bytecode generation module 620 is configured to: The strategy file is parsed, and an abstract syntax tree is obtained based on the business logic of the strategy file; The abstract syntax tree is converted into a bytecode array that conforms to the preset syntax specification.

[0126] In some exemplary embodiments, the class loading module 630 is configured as follows: Based on the identity identifier and version identifier corresponding to the bytecode array, a class loader instance is created; Based on the class loader instance, the bytecode array is loaded into the virtual machine to generate the strategy class object.

[0127] In some exemplary embodiments, the class loading module 630 is configured as follows: In response to a policy deletion command, based on the identity identifier and version identifier corresponding to the policy deletion command, the class loader instance commonly corresponding to the identity identifier and the version identifier is reclaimed, and the policy class object commonly corresponding to the identity identifier and the version identifier is unloaded.

[0128] In some exemplary embodiments, the policy enforcement module 640 is configured to: In response to the policy execution instruction, the target policy class object is determined from the policy class objects based on the identity identifier and the version identifier corresponding to the policy execution instruction; Create an instance of the target strategy based on the target strategy class object; Based on a preset strategy interface, the target strategy instance is executed, wherein the bytecode array corresponds to the class of the preset strategy interface.

[0129] In some exemplary embodiments, the bytecode generation module 620 is configured to: Insert monitoring points into the bytecode array to monitor the execution status of the strategy.

[0130] In some exemplary embodiments, the policy enforcement module 640 is configured to: In response to the policy execution instruction, the execution node corresponding to the policy execution instruction is divided into a first node and a second node. On the first node, the target policy instance corresponding to the target version identifier corresponding to the policy execution instruction is executed. On the second node, the historical policy instance corresponding to the identity identifier other than the target version identifier is executed. Based on the aforementioned data points, monitor the execution success rate and execution latency of the target strategy instance; In response to the execution success rate of the target policy instance being greater than a preset success rate threshold and the execution delay being less than a preset first delay threshold, the execution of the historical policy instance is stopped on the second node, and the target policy instance is executed.

[0131] In some exemplary embodiments, the policy enforcement module 640 is configured to: Based on the aforementioned data points, monitor the execution success rate and execution latency of the target strategy instance; In response to the execution success rate of the target policy instance being less than a preset success rate threshold or the execution delay being greater than a preset second delay threshold, the historical policy instance corresponding to the identity identifier of the target policy instance, other than the target version identifier, is executed.

[0132] For ease of description, the above apparatus is described in terms of its functions, divided into various modules. Of course, in implementing this disclosure, the functions of each module can be implemented in one or more software and / or hardware.

[0133] The strategy loading device provided in this disclosure can execute the strategy loading method provided in any embodiment of this disclosure, and has the corresponding functional modules and beneficial effects of the execution method.

[0134] To implement the above embodiments, this disclosure also proposes a computer program product, including a computer program / instructions, which, when executed by a processor, implements the strategy loading method in the above embodiments.

[0135] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure.

[0136] The following is a detailed reference. Figure 7The diagram illustrates a structural schematic suitable for implementing the electronic device 700 in the embodiments of this disclosure. The electronic device 700 in the embodiments of this disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 7 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.

[0137] like Figure 7 As shown, the electronic device 700 may include a processor (e.g., a central processing unit, a graphics processor, etc.) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a memory 708 into a random access memory (RAM) 703. The RAM 703 also stores various programs and data required for the operation of the electronic device 700. The processor 701, ROM 702, and RAM 703 are interconnected via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.

[0138] Typically, the following devices can be connected to I / O interface 705: input devices 706 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 707 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; memory devices 708 including, for example, magnetic tapes, hard disks, etc.; and communication devices 709. Communication device 709 allows electronic device 700 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 7 An electronic device 700 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.

[0139] The memory 702 stores machine-readable instructions executable by the processor 701. When the electronic device is running, the processor 701 communicates with the memory 702 via the bus 704, causing the processor 701 to execute the following instructions during operation: In response to a policy file change event, the changed policy file is determined, wherein the policy file includes a policy logic description; The strategy file is converted into a bytecode array that conforms to a preset syntax specification, wherein the preset syntax specification allows the bytecode array to be converted into a strategy class object at runtime; Convert the bytecode array into the strategy class object; In response to a strategy execution instruction, a target strategy class object is determined from the strategy class objects based on the strategy execution instruction, a target strategy instance is created based on the target strategy class object, and the target strategy instance is executed.

[0140] In one possible implementation, in the instructions executed by processor 701, the step of determining the modified policy file in response to a policy file change event, wherein the policy file includes a policy logic description, including: Receive the original policy file, which includes an original policy logic description; Configure the identity and version identifier for the original policy file; The original policy file, after configuring the identity identifier and the version identifier, is converted into a preset structured format to obtain a structured policy file; Based on preset path rules, the structured strategy file is stored as the strategy file.

[0141] In one possible implementation, the instruction executed by processor 701, which converts the policy file into a bytecode array conforming to a preset syntax specification, includes: The strategy file is parsed, and an abstract syntax tree is obtained based on the business logic of the strategy file; The abstract syntax tree is converted into a bytecode array that conforms to the preset syntax specification.

[0142] In one possible implementation, the instruction executed by processor 701, which converts the bytecode array into the policy class object, includes: Based on the identity identifier and version identifier corresponding to the bytecode array, a class loader instance is created; Based on the class loader instance, the bytecode array is loaded into the virtual machine to generate the strategy class object.

[0143] In one possible implementation, the method further includes the instructions executed by processor 701: In response to a policy deletion command, based on the identity identifier and version identifier corresponding to the policy deletion command, the class loader instance commonly corresponding to the identity identifier and the version identifier is reclaimed, and the policy class object commonly corresponding to the identity identifier and the version identifier is unloaded.

[0144] In one possible implementation, the instructions executed by the processor 701, including responding to a policy execution instruction, determining a target policy class object from the policy class objects based on the policy execution instruction, creating a target policy instance based on the target policy class object, and executing the target policy instance, include: In response to the policy execution instruction, the target policy class object is determined from the policy class objects based on the identity identifier and the version identifier corresponding to the policy execution instruction; Create an instance of the target strategy based on the target strategy class object; Based on a preset strategy interface, the target strategy instance is executed, wherein the bytecode array corresponds to the class of the preset strategy interface.

[0145] In one possible implementation, the instructions executed by processor 701, in the process of converting the policy file into a bytecode array conforming to a preset syntax specification, further include: Insert monitoring points into the bytecode array to monitor the execution status of the strategy.

[0146] In one possible implementation, the instructions executed by the processor 701, including responding to a policy execution instruction, determining a target policy class object from the policy class objects based on the policy execution instruction, creating a target policy instance based on the target policy class object, and executing the target policy instance, include: In response to the policy execution instruction, the execution node corresponding to the policy execution instruction is divided into a first node and a second node. On the first node, the target policy instance corresponding to the target version identifier corresponding to the policy execution instruction is executed. On the second node, the historical policy instance corresponding to the identity identifier other than the target version identifier is executed. Based on the aforementioned data points, monitor the execution success rate and execution latency of the target strategy instance; In response to the execution success rate of the target policy instance being greater than a preset success rate threshold and the execution delay being less than a preset first delay threshold, the execution of the historical policy instance is stopped on the second node, and the target policy instance is executed.

[0147] In one possible implementation, in the instructions executed by the processor 701, after responding to the policy execution instruction, determining a target policy class object from the policy class object based on the policy execution instruction, creating a target policy instance based on the target policy class object, and executing the target policy instance, the method further includes: Based on the aforementioned data points, monitor the execution success rate and execution latency of the target strategy instance; In response to the execution success rate of the target policy instance being less than a preset success rate threshold or the execution delay being greater than a preset second delay threshold, the historical policy instance corresponding to the identity identifier of the target policy instance, other than the target version identifier, is executed.

[0148] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication device 709, or installed from memory 708, or installed from ROM 702. When the computer program is executed by processor 701, it performs the functions defined in the strategy loading method of embodiments of this disclosure.

[0149] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.

[0150] In some implementations, clients and servers can communicate using any currently known or future-developed network protocol such as HTTP (Hypertext Transfer Protocol) and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), the Internet (e.g., the Internet of Things), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future-developed networks.

[0151] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.

[0152] The aforementioned computer-readable medium carries one or more programs, which, when executed by the electronic device, cause the electronic device to perform the aforementioned strategy loading method.

[0153] Electronic devices can be programmed with computer program code in one or more programming languages ​​or a combination thereof to perform the operations of this disclosure. These programming languages ​​include, but are not limited to, object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0154] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0155] The units described in the embodiments of this disclosure can be implemented in software or hardware. The names of the units are not, in some cases, intended to limit the specific unit.

[0156] The functions described above in this document can be performed at least in part by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), system-on-a-chip (SoCs), complex programmable logic devices (CPLDs), and so on.

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

[0158] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.

[0159] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.

[0160] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims.

Claims

1. A strategy loading method, characterized in that, include: In response to a policy file change event, the changed policy file is determined, wherein the policy file includes a policy logic description; The strategy file is converted into a bytecode array that conforms to a preset syntax specification, wherein the preset syntax specification allows the bytecode array to be converted into a strategy class object at runtime; Convert the bytecode array into the strategy class object; In response to a strategy execution instruction, a target strategy class object is determined from the strategy class objects based on the strategy execution instruction, a target strategy instance is created based on the target strategy class object, and the target strategy instance is executed.

2. The method according to claim 1, characterized in that, In response to a policy file change event, the modified policy file is determined, wherein the policy file includes a policy logic description, including: Receive the original policy file, which includes an original policy logic description; Configure the identity and version identifier for the original policy file; The original policy file, after configuring the identity identifier and the version identifier, is converted into a preset structured format to obtain a structured policy file; Based on preset path rules, the structured strategy file is stored as the strategy file.

3. The method according to claim 1, characterized in that, The step of converting the strategy file into a bytecode array conforming to a preset syntax specification includes: The strategy file is parsed, and an abstract syntax tree is obtained based on the business logic of the strategy file; The abstract syntax tree is converted into a bytecode array that conforms to the preset syntax specification.

4. The method according to claim 2, characterized in that, The step of converting the bytecode array into the strategy class object includes: Based on the identity identifier and version identifier corresponding to the bytecode array, a class loader instance is created; Based on the class loader instance, the bytecode array is loaded into the virtual machine to generate the strategy class object.

5. The method according to claim 4, characterized in that, The method further includes: In response to a policy deletion command, based on the identity identifier and version identifier corresponding to the policy deletion command, the class loader instance commonly corresponding to the identity identifier and the version identifier is reclaimed, and the policy class object commonly corresponding to the identity identifier and the version identifier is unloaded.

6. The method according to claim 2, characterized in that, The step of responding to a policy execution instruction, determining a target policy class object from the policy class objects based on the policy execution instruction, creating a target policy instance based on the target policy class object, and executing the target policy instance includes: In response to the policy execution instruction, the target policy class object is determined from the policy class objects based on the identity identifier and the version identifier corresponding to the policy execution instruction; Create an instance of the target strategy based on the target strategy class object; Based on a preset strategy interface, the target strategy instance is executed, wherein the bytecode array corresponds to the class of the preset strategy interface.

7. The method according to claim 2, characterized in that, The process of converting the strategy file into a bytecode array conforming to a preset syntax specification also includes: Insert monitoring points into the bytecode array to monitor the execution status of the strategy.

8. The method according to claim 7, characterized in that, The step of responding to a policy execution instruction, determining a target policy class object from the policy class objects based on the policy execution instruction, creating a target policy instance based on the target policy class object, and executing the target policy instance includes: In response to the policy execution instruction, the execution node corresponding to the policy execution instruction is divided into a first node and a second node. On the first node, the target policy instance corresponding to the target version identifier corresponding to the policy execution instruction is executed. On the second node, the historical policy instance corresponding to the identity identifier other than the target version identifier is executed. Based on the aforementioned data points, monitor the execution success rate and execution latency of the target strategy instance; In response to the execution success rate of the target policy instance being greater than a preset success rate threshold and the execution delay being less than a preset first delay threshold, the execution of the historical policy instance is stopped on the second node, and the target policy instance is executed.

9. The method according to claim 7, characterized in that, In response to a policy execution instruction, the method further includes determining a target policy class object from the policy class objects based on the policy execution instruction, creating a target policy instance based on the target policy class object, and executing the target policy instance. Based on the aforementioned data points, monitor the execution success rate and execution latency of the target strategy instance; In response to the execution success rate of the target policy instance being less than a preset success rate threshold or the execution delay being greater than a preset second delay threshold, the historical policy instance corresponding to the identity identifier of the target policy instance, other than the target version identifier, is executed.

10. A strategy loading device, characterized in that, include: The policy file management module is configured to respond to a policy file change event and determine the changed policy file, wherein the policy file includes a policy logic description. The bytecode generation module is configured to convert the strategy file into a bytecode array that conforms to a preset syntax specification, wherein the preset syntax specification allows the bytecode array to be converted into a strategy class object at runtime; The class loading module is configured to convert the bytecode array into the strategy class object; The strategy execution module is configured to respond to a strategy execution instruction, determine a target strategy class object from the strategy class objects based on the strategy execution instruction, create a target strategy instance based on the target strategy class object, and execute the target strategy instance.

11. An electronic device, characterized in that, The method includes a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the method according to any one of claims 1 to 9.

12. A computer-readable storage medium, characterized in that, It stores a computer program / instruction thereon, which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 9.

13. A computer program product, characterized in that, Includes a computer program / instructions that, when executed by a processor, implement the steps of the method according to any one of claims 1 to 9.