A mapping method based on Groovy script in the service activation process

By using the Groovy script mapping method during the business opening process, the business suspension problem caused by frequent release of process files in the existing technology is solved, and the function of modifying script files in the orchestration engine is realized, which improves the efficiency and fluency of the business opening process.

CN114546349BActive Publication Date: 2025-03-25CHINA UNITECHS
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202011341082.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-11-25
Publication Date
2025-03-25
Estimated Expiration
2040-11-25

AI Technical Summary

Technical Problem

In the prior art, the process engine used in the process of business development requires frequent release of process files, resulting in business suspension and affecting efficiency, and data updates involve multiple business data, which seriously affects networking efficiency.

Method used

Provide a mapping method based on Groovy script. When receiving a business work ticket and executing a Groovy script node, it determines whether there is a script file in Redis. If it exists, it will be executed. Otherwise, it will be loaded from the script library and synchronized to Redis, parsed the script content, mapped into a script method, and preset conventional methods in the Java class to determine whether the script method matches the Java method, and call the corresponding method to complete the execution.

Benefits of technology

It realizes mapping Groovy script files into Java methods and Groovy methods during the business opening process, and directly modifying the script files in the orchestration engine, taking effect in real time without affecting the business opening process, and improving the fluency of the business opening process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114546349B_ABST
    Figure CN114546349B_ABST
Patent Text Reader

Abstract

The present invention provides a mapping method based on Groovy scripts in the process of service activation. The method includes receiving a service work order and executing service activation; when executing to a script node, calling a policy engine according to the script code and script type associated with the script node, judging whether there is a corresponding script file in Redis, loading the script file, parsing the script content according to the corresponding rules, and mapping it to a corresponding script method; judging whether the script method is a Java method or a Groovy method according to the script type; calling the script method, and assigning values ​​to the input parameters to complete the execution of the current script node. In this way, the script file can be mapped to the Java method and the Groovy method during the service activation process. When the business logic needs to be changed, the script file can be directly modified in the orchestration engine, which takes effect in real time and does not affect the process operation of the service activation, thereby improving the fluency of the service activation process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present invention generally relate to the field of service provisioning, and more specifically, to a mapping method based on Groovy scripts in a service provisioning process. Background Art

[0002] In the prior art, the process engine used in service activation directly edits the script rule content in the process file, but any minor changes to the business logic must publish the process file to the process engine, suspending the business during the release, which greatly affects the efficiency of business processing; and because the re-release involves a lot of business data, it will seriously affect the efficiency of networking. Summary of the invention

[0003] According to an embodiment of the present invention, a mapping solution based on Groovy scripts in a service provisioning process is provided.

[0004] In a first aspect of the present invention, a mapping method based on a Groovy script in a service activation process is provided. The method comprises:

[0005] S101: Receive a business work order and execute business activation;

[0006] S102: When executing to a Groovy script node, calling a policy engine according to the script code and script type associated with the Groovy script node, determining whether a corresponding script file exists in Redis, if so, executing S103; otherwise, loading the script file from the script library, loading it into Redis for synchronization, and executing S103;

[0007] S103: Load the script file, parse the script content according to the corresponding rules, and map it into the corresponding script method;

[0008] S104: presetting a conventional Java method in a Java class, and determining whether the script method matches the conventional Java method presetting in the Java class according to the script type; if so, the script method is a Java method, otherwise, the script method is a Groovy method;

[0009] S105: calling the script method and assigning values ​​to the input parameters to complete the execution of the current script node.

[0010] Further, parsing the script content according to the corresponding rules includes:

[0011] When the rule is an object conversion rule, the business data is parsed and mapped into the first input parameter of the script method, the object instance and the attribute value;

[0012] When the rule is a non-object conversion rule, the script file content is parsed to obtain the method name and the input parameter list.

[0013] Further, the calling of the script method includes:

[0014] If the script method is a Java method, obtain the declared JDK interface and call it through invoke;

[0015] If the script method is a Groovy method, the engine interface is obtained and called through invokeMethod.

[0016] Furthermore, after the execution of the current script node is completed, the processing result returned by the Groovy script node is received and saved in the context.

[0017] In a second aspect of the present invention, a mapping device based on a Groovy script in a service activation process is provided. The device comprises:

[0018] The orchestration engine is used to receive business work orders and execute business activation; when executing a Groovy script node, the strategy engine is called according to the script code and script type associated with the Groovy script node;

[0019] The policy engine is used to determine whether the corresponding script file exists in Redis. If so, the parsing module is called; otherwise, the script file is loaded from the script library and loaded into Redis for synchronization, and the parsing module is executed;

[0020] Preset module, used to preset regular Java methods in Java classes;

[0021] A parsing module, used to load the script file, parse the script content according to corresponding rules, map it into a corresponding script method, and determine whether the script method matches a conventional Java method preset in a Java class according to the script type. If they match, the script method is a Java method, otherwise the script method is a Groovy method;

[0022] The rule engine is used to call the script method and assign values ​​to the input parameters to complete the execution of the current script node.

[0023] Furthermore, the parsing module includes:

[0024] A first parsing module, used for parsing business data and mapping it into the first input parameter of the script method, the object instance and the attribute value when the rule is an object conversion rule;

[0025] The second parsing module is used to parse the script file content to obtain the method name and input parameter list when the rule is a non-object conversion rule.

[0026] Furthermore, the rule engine further includes a calling module, which is used to obtain the declared JDK interface and call it through invoke when the script method is a Java method; when the script method is a Groovy method, obtain the engine interface and call it through invokeMethod.

[0027] Furthermore, it also includes:

[0028] The receiving module is used to receive the processing result returned by the script node after completing the execution of the current script node, and save it to the context.

[0029] In a third aspect of the present invention, an electronic device is provided, which includes a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the program, the method described above is implemented.

[0030] In a fourth aspect of the present invention, a computer-readable storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the method according to the first aspect of the present invention is implemented.

[0031] It should be understood that the contents described in the summary of the invention are not intended to limit the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description.

[0032] The present invention can map Groovy script files to Java methods and Groovy methods during the service activation process, and execute script logic in the orchestration engine; when the business logic needs to be changed, there is no need to modify it in the process engine, and the script file can be directly modified in the orchestration engine, which takes effect in real time without affecting the process operation of the service activation, thereby improving the fluency of the service activation process. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] The above and other features, advantages and aspects of the embodiments of the present invention will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. In the accompanying drawings, the same or similar reference numerals represent the same or similar elements, wherein:

[0034] Figure 1 A flowchart of a mapping method based on a Groovy script in a service provisioning process according to an embodiment of the present invention is shown;

[0035] Figure 2A block diagram of a mapping device based on a Groovy script in a service provisioning process according to an embodiment of the present invention is shown;

[0036] Figure 3 A block diagram of an exemplary electronic device capable of implementing embodiments of the present invention is shown. DETAILED DESCRIPTION

[0037] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0038] In addition, the term "and / or" in this article is only a description of the association relationship between the associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.

[0039] In the present invention, the Groovy script file can be mapped to the Java method and the Groovy method during the service activation process, and the script logic can be executed in the orchestration engine; when the business logic needs to be changed, there is no need to modify it in the process engine, and the script file can be directly modified in the orchestration engine, which takes effect in real time without affecting the process operation of the service activation, thereby improving the fluency of the service activation process.

[0040] Figure 1 A flowchart of a mapping method based on a Groovy script in a service activation process according to an embodiment of the present invention is shown.

[0041] The method includes:

[0042] S101: Receive a business work order and execute business activation.

[0043] S102: When executing to a Groovy script node, the policy engine is called according to the script code and script type associated with the Groovy script node to determine whether a corresponding script file exists in Redis. If so, S103 is executed; otherwise, the script file is loaded from the database and loaded into Redis for synchronization, and S103 is executed.

[0044] Groovy is an agile dynamic language for the Java virtual machine. It is a mature object-oriented programming language that can be used for both object-oriented programming and as a pure scripting language.

[0045] Redis, or remote dictionary service, is an open source, network-based, memory-based, and persistent log-type, Key-Value database written in ANSI C, and provides APIs in multiple languages.

[0046] As an embodiment of the present invention, when the service activation process is executed to the Groovy script node, the script code ruleid and script type ruletype associated with the Groovy script node are transmitted to the policy engine, and the policy engine reads the corresponding script file from the Redis cache according to the script code ruleid and script type ruletype. If the corresponding script file cannot be read, the corresponding file is extracted from the script library and loaded into Redis.

[0047] When the business logic changes, the network operation and maintenance personnel modify the script content and publish it to Redis and the script library to ensure that the script read is the latest script.

[0048] S103: Load the script file, parse the script content according to corresponding rules, and map it into corresponding script methods.

[0049] The parsing module loads the Groovy script file and parses the script content according to the corresponding rules, including:

[0050] When the rule is an object conversion rule, the business data is parsed and mapped into the first input parameter of the script method, a Java object instance and an attribute value.

[0051] As an embodiment of the present invention, when the rule is an object conversion rule, the business data returned by the third-party interface is parsed and mapped into the first input parameter, object instance and attribute value of the transformObect script method. The input parameter is, for example, a json object, and the object instance is, for example, a Java object instance or a json object instance.

[0052] The required input parameters and attributes are selected from external variables, system parameters, input parameters of atomic capabilities, and output parameter messages.

[0053] When the rule is a non-object conversion rule, the script file content is parsed to obtain the method name and the input parameter list. The method name is, for example, exe.

[0054] S104: Preset a conventional Java method in a Java class, and determine whether the script method matches the conventional Java method preset in the Java class according to the script type; if they match, the script method is a Java method, otherwise, the script method is a Groovy method.

[0055] The conventional Java methods, such as contain, judge, whether empty, etc., need to be preset in the Java class by the developer in advance.

[0056] S105: calling the script method and assigning values ​​to the input parameters to complete the execution of the current script node.

[0057] If the script method is a Java method, the declared JDK interface is obtained and called through invoke; the JDK interface, for example, getDeclaredMethod.

[0058] If the script method is a Groovy method, the engine interface is obtained and invoked through invokeMethod. The engine interface is, for example, GroovyScriptEngine.

[0059] As an embodiment of the present invention, after completing the execution of the current script node, the receiving module receives the processing result returned by the Groovy script node, and saves the processing result to the context to facilitate use by subsequent nodes.

[0060] According to an embodiment of the present invention, during the service activation process, the Groovy script file can be mapped to the Java method and the Groovy method, and the script logic can be executed in the orchestration engine; when the business logic needs to be changed, there is no need to modify it in the process engine, and the script file can be modified directly in the orchestration engine, which takes effect in real time without affecting the process operation of the service activation, thereby improving the smoothness of the service activation process.

[0061] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should know that the present invention is not limited by the described order of actions, because according to the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present invention.

[0062] The above is an introduction to a method embodiment. The following is a further explanation of the solution of the present invention through an apparatus embodiment.

[0063] like Figure 2 As shown, the device 200 includes:

[0064] The orchestration engine 210 is used to receive a service work order and execute service activation; when executing a Groovy script node, the strategy engine is called according to the script code and script type associated with the Groovy script node;

[0065] The policy engine 220 is used to determine whether there is a corresponding script file in Redis. If so, the parsing module 240 is called; otherwise, the script file is loaded from the script library and loaded into Redis for synchronization, and the parsing module 240 is executed;

[0066] A presetting module 230, used for presetting conventional Java methods in a Java class;

[0067] The parsing module 240 is used to load the script file, parse the script content according to the corresponding rules, map it into the corresponding script method, and determine whether the script method matches the conventional Java method preset in the Java class according to the script type. If they match, the script method is a Java method, otherwise the script method is a Groovy method.

[0068] The analysis module 240 includes:

[0069] The first parsing module 241 is used to parse the business data and map it into the first input parameter of the script method, the object instance and the attribute value when the rule is an object conversion rule;

[0070] The second parsing module 242 is used to parse the script file content to obtain the method name and input parameter list when the rule is a non-object conversion rule.

[0071] The rule engine 250 is used to call the script method and assign values ​​to the input parameters to complete the execution of the current script node.

[0072] The rule engine 250 further includes a calling module 251, which is used to obtain the declared JDK interface and call it through invoke when the script method is a Java method; when the script method is a Groovy method, obtain the engine interface and call it through invokeMethod.

[0073] The device 200 further includes:

[0074] The receiving module 260 is used to receive the processing result returned by the script node after completing the execution of the current script node, and save it to the context.

[0075] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the described module can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.

[0076] like Figure 3As shown, the device includes a central processing unit (CPU), which can perform various appropriate actions and processes according to computer program instructions stored in a read-only memory (ROM) or loaded from a storage unit into a random access memory (RAM). In the RAM, various programs and data required for the operation of the device can also be stored. The CPU, ROM and RAM are connected to each other through a bus. An input / output (I / O) interface is also connected to the bus.

[0077] Multiple components in the device are connected to the I / O interface, including: input units, such as keyboards, mice, etc.; output units, such as various types of displays, speakers, etc.; storage units, such as disks, optical disks, etc.; and communication units, such as network cards, modems, wireless communication transceivers, etc. The communication unit allows the device to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunication networks.

[0078] The processing unit performs the various methods and processes described above, such as methods S101 to S105. For example, in some embodiments, methods S101 to S105 may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit. In some embodiments, part or all of the computer program may be loaded and / or installed on the device via a ROM and / or a communication unit. When the computer program is loaded into the RAM and executed by the CPU, one or more steps of methods S101 to S105 described above may be performed. Alternatively, in other embodiments, the CPU may be configured to execute methods S101 to S105 in any other appropriate manner (e.g., by means of firmware).

[0079] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chip systems (SOCs), load programmable logic devices (CPLDs), and the like.

[0080] The program code for implementing the method of the present invention can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code can be executed entirely on the machine, partially on the machine, partially on the machine as a stand-alone software package and partially on a remote machine, or entirely on a remote machine or server.

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

[0082] In addition, although each operation is described in a specific order, this should be understood as requiring such operation to be performed in the specific order shown or in a sequential order, or requiring that all illustrated operations should be performed to obtain desired results. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present invention. Some features described in the context of a separate embodiment can also be implemented in a single implementation in combination. On the contrary, the various features described in the context of a single implementation can also be implemented in multiple implementations individually or in any suitable sub-combination mode.

[0083] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, 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. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.

Claims

1. A mapping method based on Groovy script in the service activation process, characterized in that: include: S101: Receive a business work order and execute business activation; S102: When executing to a Groovy script node, the policy engine is called according to the script code and script type associated with the Groovy script node to determine whether a corresponding script file exists in Redis. If so, S103 is executed; otherwise, the script file is loaded from the script library and loaded into Redis for synchronization, and S103 is executed; when the business logic changes, the script file is modified and published to Redis and the script library to ensure that the script read is the latest script; S103: Load the script file, parse the script content according to the corresponding rules, and map it into the corresponding script method; S104: presetting a conventional Java method in a Java class, and determining whether the script method matches the conventional Java method presetting in the Java class according to the script type; if so, the script method is a Java method, otherwise, the script method is a Groovy method; S105: calling the script method and assigning values ​​to the input parameters to complete the execution of the current script node.

2. The method according to claim 1, characterized in that: The step of parsing the script content according to the corresponding rules includes: When the rule is an object conversion rule, the business data is parsed and mapped into the first input parameter of the script method, the object instance and the attribute value; When the rule is a non-object conversion rule, the script file content is parsed to obtain the method name and input parameter list.

3. The method according to claim 1, characterized in that The calling of the script method comprises: If the script method is a Java method, obtain the declared JDK interface and call it through invoke; If the script method is a Groovy method, the engine interface is obtained and called through invokeMethod.

4. The method according to claim 1, characterized in that: After the execution of the current script node is completed, the processing result returned by the Groovy script node is received and saved in the context.

5. A mapping device based on Groovy script in the service activation process, characterized in that: include: The orchestration engine is used to receive business work orders and execute business activation; When executing to a Groovy script node, calling the policy engine according to the script code and script type associated with the Groovy script node; The policy engine is used to determine whether the corresponding script file exists in Redis. If so, the parsing module is called; Otherwise, the script file is loaded from the script library and loaded into Redis for synchronization, and the parsing module is executed; When the business logic changes, modify the script file and publish it to Redis and the script library to ensure that the script read is the latest script; Preset module, used to preset regular Java methods in Java classes; A parsing module, used to load the script file, parse the script content according to corresponding rules, map it into a corresponding script method, and determine whether the script method matches a conventional Java method preset in a Java class according to the script type. If they match, the script method is a Java method, otherwise the script method is a Groovy method; The rule engine is used to call the script method and assign values ​​to the input parameters to complete the execution of the current script node.

6. The device according to claim 5, characterized in that The parsing module comprises: A first parsing module, used for parsing business data and mapping it into the first input parameter of the script method, the object instance and the attribute value when the rule is an object conversion rule; The second parsing module is used to parse the script file content to obtain the method name and input parameter list when the rule is a non-object conversion rule.

7. The device according to claim 5, characterized in that The rule engine further includes a calling module, which is used to obtain the declared JDK interface and call it through invoke when the script method is a Java method; when the script method is a Groovy method, obtain the engine interface and call it through invokeMethod.

8. The device according to claim 5, characterized in that Also includes: The receiving module is used to receive the processing result returned by the script node after completing the execution of the current script node, and save it to the context.

9. An electronic device comprising a memory and a processor, wherein a computer program is stored in the memory, wherein: When the processor executes the program, the method according to any one of claims 1 to 4 is implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.

Citation Information

Patent Citations

  • Loading method and device for Groovy script

    CN103383646A

  • Method and device for constructing a rule engine

    CN107133039A