Method, processor and computer program product for processing rule calculation requests
By preloading rule-class Java objects in the system initialization stage and directly calling the parsed rule objects when processing rule calculation requests, the problem of long-term rule calculation requests in the existing technology is solved, and a more efficient system is achieved performance.
Patent Information
- Application Number
- CN202411643599.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-18
- Publication Date
- 2025-02-11
AI Technical Summary
The prior art needs to recreate the rule object when processing rule calculation requests, resulting in a large system time overhead and affecting system performance.
During the system initialization phase, multiple rule-class Java objects are preloaded, and the target rule-class Java objects are determined by the access controller based on the rules calculation parameters, and the corresponding methods of the target rule-class Java objects are executed to process the rule-class Java request.
There is no need to recreate the rule object every time the calculation request is processed, which greatly saves the time overhead of processing calculation requests and improves system performance.
Smart Images

Figure CN119415164A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of system development, and in particular to a method, a processor and a computer program product for processing rule calculation requests. Background Art
[0002] At present, for each rule calculation request, the system needs to completely execute all the steps of "accepting the request, querying the database, generating the corresponding rule object, the rule engine calculating and returning the result" before it can finally get the result. In this way, the rule object is recreated every time a calculation request is processed, resulting in a large system time overhead, thereby affecting system performance. Therefore, the prior art has the problem of a long time consumption in processing rule calculation requests. Summary of the invention
[0003] The purpose of the embodiments of the present application is to provide a method, a processor and a computer program product for processing a rule calculation request, so as to solve the problem that it takes a long time to process a rule calculation request in the prior art.
[0004] In order to achieve the above-mentioned object, a first aspect of an embodiment of the present application provides a method for processing a rule calculation request, the method comprising:
[0005] Receive rule calculation requests sent by the front end;
[0006] By accessing the controller and calculating the request parameters according to the rule, a target rule class Java object is determined from a plurality of rule class Java objects preloaded in the system initialization phase;
[0007] Execute the method corresponding to the target rule class Java object and return the execution result to the front end.
[0008] In an embodiment of the present application, a method for loading multiple rule-class Java objects includes: in the system initialization phase, querying the rule data in the database; generating multiple Java file objects according to the rule data; mapping each Java file object to a corresponding Java file; and loading each Java file into a Java virtual machine to obtain multiple rule-class Java objects.
[0009] In an embodiment of the present application, multiple Java file objects are generated according to rule data, including: generating a set of rule class objects according to the rule data in the database; converting the set of rule class objects through a converter to generate multiple Java file objects.
[0010] In an embodiment of the present application, the data structure of a rule class object set is a tree data structure, including multiple node objects, each node object corresponds to a SpEL expression, and the rule class object set is converted by a converter to generate multiple Java file objects, including: traversing the rule class object set from the root node through an access sequence controller; each time a node is traversed, the SpEL expression corresponding to the traversed node object is converted into Java code through a SpEL expression converter; after any node object and any node object's child node are accessed, the Java code corresponding to any node and any node's child node is formatted by a format controller to obtain a corresponding Java file object; after traversing the rule class object set, multiple Java file objects are obtained.
[0011] In the embodiment of the present application, the algorithm used by the access sequence controller is a depth-first algorithm.
[0012] In an embodiment of the present application, each Java file is loaded into a Java virtual machine to obtain multiple rule class Java objects, including: compiling each Java file into a class file through a compiler; loading the class file into the Java virtual machine through a class loader to obtain multiple rule class Java objects.
[0013] In an embodiment of the present application, the method further includes: controlling changes in the database through a monitor key; after the monitor detects changes in the rule data in the database, reloading the rule class Java object according to the updated rule data.
[0014] In an embodiment of the present application, the method also includes: after the monitor detects that the rule data in the database has changed, detecting through a repeater whether a rule calculation request task is currently being processed; if a rule calculation request task is being processed, stopping the rule calculation request task being processed until the rule class Java object is reloaded.
[0015] A second aspect of an embodiment of the present application provides a processor configured to execute the above-mentioned method for processing rule calculation requests.
[0016] A third aspect of an embodiment of the present application provides a computer program product, including a computer program, which implements the above-mentioned method for processing rule calculation requests when executed by a processor.
[0017] The above technical solution receives the rule calculation request sent by the front end, then determines the target rule class Java object from multiple rule class Java objects preloaded in the system initialization phase according to the parameters of the rule calculation request through the access controller, and finally executes the method corresponding to the target rule class Java object, and returns the execution result to the front end. This application executes the rule calculation request by preloading the rule class Java object in the system initialization phase. When processing the rule calculation request, the system calls the method of the parsed rule class Java object for calculation, without having to recreate the rule object every time a calculation request is processed, which greatly saves the time overhead of processing calculation requests.
[0018] Other features and advantages of the embodiments of the present application will be described in detail in the subsequent specific implementation section. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The accompanying drawings are used to provide a further understanding of the embodiments of the present application and constitute a part of the specification. Together with the following specific implementations, they are used to explain the embodiments of the present application, but do not constitute a limitation on the embodiments of the present application. In the accompanying drawings:
[0020] Figure 1 A flowchart of a method for processing a rule calculation request provided in an embodiment of the present application;
[0021] FIG. 2( a ) and FIG. 2( b ) are flowchart diagrams of a method for processing a rule calculation request provided in a specific embodiment of the present application;
[0022] Figure 3 A schematic diagram of a process of file and object conversion provided for a specific embodiment of the present application;
[0023] Figure 4 A schematic diagram of a flow chart of a Java file generation module provided in a specific embodiment of the present application;
[0024] Figure 5 A schematic diagram of a converter provided in a specific embodiment of the present application;
[0025] Figure 6 A schematic diagram of the flow of compiling and loading modules provided in a specific embodiment of the present application;
[0026] Figure 7 A schematic diagram of an execution module provided in a specific embodiment of the present application;
[0027] Figure 8 A comparison diagram of the structure of rule objects under different schemes provided in the embodiments of the present application;
[0028] Fig. 9A logic diagram of a monitor and a repeater provided for a specific embodiment of the present application. DETAILED DESCRIPTION
[0029] In order to make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the specific implementation methods described herein are only used to illustrate and explain the embodiments of the present application, and are not used to limit the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0030] It should be noted that if the embodiments of the present application involve directional indications (such as up, down, left, right, front, back...), the directional indications are only used to explain the relative position relationship, movement status, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly.
[0031] In addition, if there are descriptions involving "first", "second", etc. in the embodiments of the present application, the descriptions of "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or suggesting their relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by this application.
[0032] Figure 1 A flowchart of a method for processing a rule calculation request provided in an embodiment of the present application. Figure 1 As shown, the embodiment of the present application provides a method for processing a rule calculation request, which is described by taking the method applied to a processor as an example. The method may include the following steps:
[0033] Step S101, receiving a rule calculation request sent by a front end;
[0034] Step S102, determining a target rule class Java object from a plurality of rule class Java objects preloaded in a system initialization phase by accessing the controller according to the parameters of the rule calculation request;
[0035] Step S103, execute the method corresponding to the target rule class Java object, and return the execution result to the front end.
[0036] Specifically, the back end can receive the rule calculation request sent by the front end, and then determine the target rule class Java object pre-stored in the system to be used by the rule calculation request through the access controller according to the parameters of the rule calculation request transmitted by the front end. It can be understood that in the traditional technical solution, for each calculation request, the system needs to completely execute all the steps of "receiving request, querying database, generating rule class object, rule engine calculation, and returning result" to obtain the calculation result, so that the system resources are consumed more and the time cost is also larger. In this regard, the embodiment of the present application separates the steps of loading, parsing, converting and processing calculation requests in the database, and loads multiple rule class Java files according to the rule data in the database in the system initialization stage. In this way, when the front end initiates a rule calculation request, the back end can directly determine the target rule class Java object corresponding to the rule calculation request from the multiple rule class Java objects pre-loaded in the system initialization stage according to the parameters transmitted by the front end. Finally, the method corresponding to the target rule class Java object is executed, and the execution stage is returned to the front end. In this way, the embodiment of the present application has just completed the compilation and loading of the rules when the system is started, so in the subsequent real-time calculation, it is only necessary to call the method of the object generated by the first rule parsed by the rule engine at the time of initialization, without the need to repeat the steps such as rule loading, parsing, conversion, etc. at each calculation like the prior art, which greatly saves the time cost of processing the calculation request. In addition, since the embodiment of the present application has just completed the compilation and loading of the rules when the system is started, the CPU and memory resources can be more efficiently utilized at runtime. This helps to improve the overall performance of the system, especially in multi-tasking and high concurrency scenarios.
[0037] The above technical solution receives the rule calculation request sent by the front end, then determines the target rule class Java object from multiple rule class Java objects preloaded in the system initialization phase according to the parameters of the rule calculation request through the access controller, and finally executes the method corresponding to the target rule class Java object, and returns the execution result to the front end. This application executes the rule calculation request by preloading the rule class Java object in the system initialization phase. When processing the rule calculation request, the system calls the method of the parsed rule class Java object for calculation, without having to recreate the rule object every time a calculation request is processed, which greatly saves the time overhead of processing calculation requests.
[0038] In an embodiment of the present application, a method for loading multiple rule-class Java objects includes: in the system initialization phase, querying the rule data in the database; generating multiple Java file objects according to the rule data; mapping each Java file object to a corresponding Java file; and loading each Java file into a Java virtual machine to obtain multiple rule-class Java objects.
[0039] It can be understood that in the system, according to the attributes of the "class" in the Java language, the various attributes of the Java class corresponding to the .java file object are defined, including: name, type, field, method, modifier, package, other imported classes or packages, etc.
[0040] During the system initialization phase, the system queries the rule data in the database, generates a series of .java file objects based on the rule data, and sets the properties of these objects. These .java file objects are then mapped to the file environment to obtain the corresponding .java files. Finally, these .java files are loaded into the Java virtual machine (JMV) of the system operating environment to obtain multiple rule-class Java files. In this way, compared to the traditional technical solution, the module that performs core calculations is the rule engine module. The embodiment of the present application optimizes the organizational structure of the entire system, replacing the rule engine module originally responsible for the core computing function with the Java language native JVM virtual machine responsible for executing the code. The rule engine module and the newly added code generation module are together responsible for converting the logic code in the database into .java files, and dynamically loading them into the system operating environment after online compilation.
[0041] In this way, the embodiment of the present application converts the rule data in the database into a file in .java format through algorithm rules, and dynamically loads it into the JVM memory to generate a class object, so that when processing rule calculation requests later, the system calls the method of the parsed rule object for calculation, without the need to recreate the rule object every time a calculation request is processed.
[0042] In an embodiment of the present application, multiple Java file objects are generated according to rule data, including: generating a set of rule class objects according to the rule data in the database; converting the set of rule class objects through a converter to generate multiple Java file objects.
[0043] Specifically, first, a set of rule class objects is generated according to the rule data in the database, wherein the data structure of the rule class object set is a tree data structure, including multiple node objects, each node object corresponds to a SpEL expression. Then the rule engine converts the calculation order of the nodes when processing the request into the code splicing order according to the original traditional algorithm logic, and after the splicing is completed, the complete string type code is assigned to the .java file object to generate multiple Java file objects. In an embodiment of the present application, the converter that plays a conversion role in this process converts the rule class object set through the converter to generate multiple Java file objects.
[0044] In an embodiment of the present application, the data structure of a rule class object set is a tree data structure, including multiple node objects, each node object corresponds to a SpEL expression, and the rule class object set is converted by a converter to generate multiple Java file objects, including: traversing the rule class object set from the root node through an access sequence controller; each time a node is traversed, the SpEL expression corresponding to the traversed node object is converted into Java code through a SpEL expression converter; after any node object and any node object's child node are accessed, the Java code corresponding to any node and any node's child node is formatted by a format controller to obtain a corresponding Java file object; after traversing the rule class object set, multiple Java file objects are obtained.
[0045] Specifically, the converter uses an access order controller to traverse the rule class object set using a tree data structure from the root node, and the algorithm used by the access order controller is a depth-first algorithm. Each time a node is traversed, the SpEL expression of the node is converted into Java code through the SpEL expression converter. When a Node node object and its child nodes are visited, the format of the node and its child nodes are adjusted through the format controller, such as adding indentation and performing bracket matching. Finally, the obtained result is put into a .java file object to obtain the final .java file object. In this way, all nodes of the rule class object set are traversed to obtain multiple Java file objects.
[0046] In the traditional technical solution, a set of rule class objects corresponds to a rule class object in the embodiment of the present application. In the traditional technical solution, the execution module needs to calculate the set composed of a series of Node node objects according to the execution order specified by the algorithm. The technical solution provided by the embodiment of the present application only needs to execute the method of an object to obtain the final calculation result, which saves the algorithm execution time and the execution time of each Node node object in the traditional technical solution, and improves the execution efficiency.
[0047] In the embodiment of the present application, the algorithm used by the access sequence controller is a depth-first algorithm.
[0048] In an embodiment of the present application, each Java file is loaded into a Java virtual machine to obtain multiple rule class Java objects, including: compiling each Java file into a class file through a compiler; loading the class file into the Java virtual machine through a class loader to obtain multiple rule class Java objects.
[0049] Specifically, after the .java file object is created, a compiler is used to compile the .java file into a .class file, and then the .class file is loaded into a Java virtual machine in a system operating environment through a class loader to obtain a plurality of rule class Java objects.
[0050] In this way, through dynamic compilation and loading, the system can encrypt and protect the rules at runtime to prevent unauthorized access and modification. This helps ensure the security of business logic and the integrity of data.
[0051] The embodiment of the present application optimizes the organizational structure of the entire system, replacing the rule engine module originally responsible for the core computing function with the Java language native JVM virtual machine responsible for executing the code. The rule engine module and the newly added code generation module are together responsible for converting the logical code in the database into a .java file, and dynamically loading it into the system running environment after online compilation.
[0052] In this way, the embodiment of the present application converts the rule data in the database into a file in .java format through algorithm rules, and dynamically loads it into the JVM memory to generate a class object, so that when processing rule calculation requests later, the system calls the method of the parsed rule object for calculation, without the need to recreate the rule object every time a calculation request is processed.
[0053] In an embodiment of the present application, the method further includes: controlling changes in the database through a monitor key; after the monitor detects changes in the rule data in the database, reloading the rule class Java object according to the updated rule data.
[0054] It can be understood that in order to prevent the system from modifying the rule object when executing the calculation operation, resulting in system abnormality or inconsistent data obtained by calculation, a monitor is designed in the system in the embodiment of the present application, and the monitor can be used to monitor the status of the database. Specifically, after the monitor monitors that the rule data in the database has changed, the system will repeat the work of the initialization phase to re-parse the rules and load the objects, that is, reload the rule class Java object according to the updated rule data. In this way, system abnormality or inconsistent data obtained by calculation can be prevented.
[0055] In an embodiment of the present application, the method also includes: after the monitor detects that the rule data in the database has changed, detecting through a repeater whether a rule calculation request task is currently being processed; if a rule calculation request task is being processed, stopping the rule calculation request task being processed until the rule class Java object is reloaded.
[0056] It can be understood that in order to detect whether the system is processing a rule calculation request task or receiving a new task request when the database changes, the embodiment of the present application also designs a repeater in the system. Specifically, after the monitor monitors that the rule data in the database has changed, the monitor can send a signal to the repeater to ask whether it can be compiled, and the repeater will check whether the system is processing the calculation request. If the system is processing the calculation request task, it will wait for the system to complete the current task and notify the system to stop processing new requests. For newly initiated requests, they will be stored in a queue. When the system stops processing new requests, the repeater will notify the monitor, and the monitor will continue to notify the rule compiler to perform the compilation operation to update the loaded rule class java object. When the compilation is completed, the monitor will notify the repeater to continue processing the request in the request queue. In this way, when the rule data in the database changes, the system will repeat the work of the initialization phase to re-parse the rules and load the objects to prevent system abnormalities or inconsistent data obtained by calculation.
[0057] Figures 2(a) and 2(b) are flowcharts of a method for processing rule calculation requests provided by a specific embodiment of the present application. The process of the embodiment of the present application is divided into two parts, process a shown in Figure 2(a) and process b shown in Figure 2(b). Among them, process a is the operation required to be performed when the system is initialized, and generally only needs to be executed once. Process b is the operation required to be performed each time a request is processed. Specifically, process a may include the following steps:
[0058] S211, start.
[0059] S212: System initialization.
[0060] S213. Query the database.
[0061] S214. Generate corresponding .java files.
[0062] S215. Load into JVM.
[0063] S216, end.
[0064] Process b may include the following steps:
[0065] S221, start.
[0066] S222. Accept the request.
[0067] S223. Execute the corresponding class method.
[0068] S224. Return the result.
[0069] S225, end.
[0070] Thus, compared to the traditional technology, in which the system needs to completely execute all the steps of "receiving request, querying database, generating rule class object, rule engine calculation, and returning result" for each calculation request to obtain the calculation result, the embodiment of the present application puts the steps of "querying database, generating corresponding rule object" in the traditional technical solution into process a, and only needs to be executed once when the system is initialized when there are no special circumstances, which greatly reduces the consumption of system resources and time overhead. As for the steps of rule engine calculation in the traditional solution, the embodiment of the present application uses the corresponding class method executed in process b for calculation. In this way, the steps of loading, parsing, converting and processing the calculation request in the database are separated, so that in the subsequent real-time calculation, it is only necessary to call the method of the object generated by the first rule parsed by the rule engine at the time of initialization, without the need to repeat the steps of rule loading, parsing, converting and other steps in each calculation as in the prior art, which greatly saves the time overhead of processing the calculation request.
[0071] Figure 3 The following is a flowchart of a file and object conversion process provided by a specific embodiment of the present application. Figure 3 As shown, an embodiment of the present application also provides a process for file and object conversion, including: first, creating a .java file object in the system operating environment according to the database rule data, then mapping the .java file object to the file environment to obtain a .java file, then compiling the .java file in the file environment to obtain a .class file, and finally loading the .class file into the system operating environment to obtain a rule class java object.
[0072] A specific embodiment of the present application further provides a device for processing rule calculation requests, the device comprising a java file generation module, a compilation and loading module, an execution module, and a rule class java object update module, specifically:
[0073] 1. Java file generation module
[0074] Figure 4 The following is a flow chart of a Java file generation module provided in a specific embodiment of the present application. Figure 4 As shown, the process executed by the Java file generation module includes:
[0075] S41. Start.
[0076] S42. Create a Java object.
[0077] S43. Set basic properties such as class name and path.
[0078] S44. The rule engine generates a set of rule class objects according to the data in the database.
[0079] S45. The Translator converter converts the rule class object set.
[0080] S46. Write the rule class java object.
[0081] S47, end.
[0082] Specifically, in the system, according to the attributes of the "class" in the Java language, the various attributes of the Java class corresponding to the .java file object are defined, including: name, type, field, method, modifier, package, other imported classes or packages, etc.
[0083] During the system initialization phase, the system will query the rule data in the database, generate a series of .java file objects based on the rule data, and set the properties of these objects. Specifically, the core step in the .java file generation module is that the rule engine sets the splicing order according to the algorithm. In this step, the rule engine converts the calculation order of the nodes when processing the request into the code splicing order according to the algorithm logic of the traditional solution. After the splicing is completed, the complete string type code is assigned to the .java file object. The Translator converter in the embodiment of the present application plays a role in the conversion process. Figure 5 A schematic diagram of a converter provided in accordance with a specific embodiment of the present application.
[0084] like Figure 5 As shown in the figure, the Translator uses the access order controller to traverse the rule class object set using the tree data structure from the root node. The algorithm used by the access order controller is the depth-first algorithm. Every time a node is traversed, the SpEL expression of the node is converted into Java code through the SpEL expression converter. When a Node node object and its child nodes are visited, the format of the node and its child nodes are adjusted through the format controller, such as adding indentation and matching brackets. Finally, the result is put into the .java file object to obtain the final .java file object.
[0085] 2. Compile and load modules
[0086] Figure 6 The following is a flow chart of compiling and loading modules provided in a specific embodiment of the present application. Figure 6 As shown, after the .java file object is created, the .java file is compiled into a .class file using a compiler, and then the .class file is loaded into the system through a class loader to obtain a .java object.
[0087] 3. Execution module
[0088] Figure 7 This is a schematic diagram of an execution module provided in a specific embodiment of the present application. Figure 7 As shown, in process b of the embodiment of the present application, after the back-end system receives the request from the front-end, it forwards the request to the Controller access controller, and the access controller determines which rule class object in the spring container to use to execute the corresponding method according to the parameters passed by the front-end, and finally returns the result to the front-end. It can be understood that the rule class objects in the spring container are all rule class Java objects after loading.
[0089] Figure 8 This is a comparison diagram of the structure of rule class objects under different schemes provided in the embodiments of this application. Figure 8 As shown, the existing solution on the left is the solution provided by the embodiment of the present application, and the original solution on the right is the traditional technical solution. In the traditional technical solution, a set of rule class objects corresponds to a rule class object in the embodiment of the present application. In the traditional technical solution, the execution module needs to calculate the set composed of a series of Node node objects according to the execution order specified by the algorithm. The technical solution provided by the embodiment of the present application only needs to execute the method of an object to obtain the final calculation result, which saves the algorithm execution time and the execution time of each Node node object in the traditional technical solution, and improves the execution efficiency.
[0090] 4. Rule class java object update module
[0091] It can be understood that in order to prevent the system from modifying the rule object when performing calculation operations, causing system abnormalities or inconsistent data obtained from calculations, the embodiment of the present application designs a status monitor StatusListener and a program repeater ProgramRepeater in the system.
[0092] Fig. 9 A logic diagram of a monitor and a repeater provided in a specific embodiment of the present application. Fig. 9As shown, when the content of the database changes, the monitor will receive a signal and send a signal to the repeater to ask whether it can be compiled. The repeater will check whether the calculation module is processing the calculation request. If the calculation module is processing the calculation request task, it will wait for the calculation module to complete the current task, and then notify the calculation module to stop processing new requests. For newly initiated requests, they will be stored in a queue. After the calculation module stops processing new requests, the repeater will notify the monitor, and the monitor will continue to notify the rule compiler to perform compilation operations to update the loaded rule class java object. When the compilation is completed, the monitor will notify the repeater to open the calculation module, and the calculation module will continue to process the requests in the request queue. In this way, when the rule data in the database changes, the system will automatically recompile and load the corresponding rule object according to the process a in the technical solution of the embodiment of the present technical application to prevent system abnormalities or inconsistent data obtained by calculation.
[0093] In summary, since the embodiment of the present application completes the compilation and loading of rules when the system is started, the CPU and memory resources can be used more efficiently at runtime, which helps to improve the overall performance of the system, especially in multi-tasking and high concurrency scenarios. Secondly, through dynamic compilation and loading, the system can encrypt and protect the rules at runtime to prevent unauthorized access and modification. This helps to ensure the security of business logic and the integrity of data. In addition, since the rule engine can directly access the loaded class object method at runtime, this provides convenience for real-time monitoring and debugging. Developers can more easily track and analyze the process of rule execution, so as to quickly locate and solve problems.
[0094] The embodiment of the present application also provides a processor configured to execute the method for processing rule calculation requests in the above implementation.
[0095] The embodiment of the present application also provides a computer program product, including a computer program, which implements the method for processing rule calculation requests in the above embodiment when executed by a processor.
[0096] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0097] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0098] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0099] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0100] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0101] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0102] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0103] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0104] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.
Claims
1. A method for processing a rule calculation request, characterized in that: The method comprises: Receive rule calculation requests sent by the front end; By accessing the controller, the parameters of the request are calculated according to the rule, and a target rule class Java object is determined from a plurality of rule class Java objects preloaded in the system initialization phase; Execute the method corresponding to the target rule class Java object and return the execution result to the front end.
2. The method according to claim 1, characterized in that The method for loading the multiple rule class Java objects includes: During the system initialization phase, query the rule data in the database; Generate multiple Java file objects according to the rule data; Mapping each of the Java file objects to a corresponding Java file; Each of the Java files is loaded into a Java virtual machine to obtain the multiple rule class Java objects.
3. The method according to claim 2, characterized in that The generating a plurality of Java file objects according to the rule data comprises: Generate a set of rule class objects according to the rule data in the database; The rule class object set is converted by a converter to generate the multiple Java file objects.
4. The method according to claim 3, characterized in that The data structure of the rule class object set is a tree data structure, including multiple node objects, each of which corresponds to a SpEL expression, and the rule class object set is converted by a converter to generate the multiple Java file objects, including: Traversing the rule class object set from the root node by accessing the sequence controller; Every time a node is traversed, the SpEL expression corresponding to the traversed node object is converted into Java code through the SpEL expression converter; After the arbitrary node object and the child nodes of the arbitrary node object are accessed, the format controller performs format adjustment processing on the Java code corresponding to the arbitrary node and the child nodes of the arbitrary node to obtain the corresponding Java file object; The rule class object set is traversed to obtain the multiple Java file objects.
5. The method according to claim 4, characterized in that The algorithm used by the access sequence controller is a depth-first algorithm.
6. The method according to claim 2, characterized in that The step of loading each of the Java files into a Java virtual machine to obtain the plurality of rule class Java objects includes: Compile each of the Java files into a class file by a compiler; The class file is loaded into the Java virtual machine through a class loader to obtain the multiple rule class Java objects.
7. The method according to claim 2, characterized in that The method further comprises: Control database changes through monitor keys; After the monitor detects that the rule data in the database has changed, the rule class Java object is reloaded according to the updated rule data.
8. The method according to claim 7, characterized in that The method further comprises: After the monitor detects that the rule data in the database has changed, the repeater is used to detect whether a rule calculation request task is currently being processed; In the case where a rule calculation request task is being processed, the rule calculation request task being processed is stopped until the reloading of the rule class Java object is completed.
9. A processor, characterized in that: The method is configured to execute the method for processing a rule calculation request according to any one of claims 1 to 8.
10. A computer program product, comprising a computer program, characterized in that The computer program implements the method for processing a rule calculation request according to any one of claims 1 to 8 when executed by a processor.