Method and device for implementing service enhancement
By dynamically loading implementation classes in jar packages and using aspect-oriented programming methods to intercept business methods, the problem of cumbersome code modifications in microservice exception handling is solved, business enhancement is achieved without interrupting services, and the risk of human errors is reduced. .
Patent Information
- Application Number
- CN201810959384.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2018-08-22
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2038-08-22
AI Technical Summary
When existing technology handles microservice exceptions, it is necessary to repeatedly modify the code and go online. The operation is cumbersome and prone to human errors, and it is impossible to achieve business enhancement without interrupting the service.
By receiving download notifications, dynamically loading implementation classes in jar packages, and using aspect-oriented programming methods to intercept calls before and after business method execution to achieve business enhancement, avoiding the risk of manual code modification.
It realizes dynamic replacement of execution code without interrupting service, reduces the risk of human error, avoids the tedious operation of repeatedly publishing business code, and improves the efficiency of exception handling.
Smart Images

Figure CN110895468B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method and device for implementing service enhancement. Background Art
[0002] During the development and maintenance of online products, we often encounter some difficult problems. For example, as microservices become more and more popular, one operation may call a service chain of multiple services, resulting in data anomalies. Because we cannot see the input and output parameters of the service method, it is very painful to confirm the location of the anomaly and debug it. At present, for similar scenarios, the common solution is to stop or interrupt the service, modify the code, add new business logic to the code, and put the modified code online to achieve business enhancement, that is, to determine the anomaly, and when the anomaly is eliminated, the new business logic needs to be deleted or annotated. At this time, the code needs to be modified again and put online. Among them, enhancement (advice) refers to injecting some logic code into each program to enhance the function of the original program.
[0003] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art:
[0004] Because exceptions are unpredictable, that is, it is impossible to determine where or in which methods the exceptions occur, so the only way is to modify the code repeatedly and put it online repeatedly after the exceptions occur. Moreover, when the exceptions are eliminated, the new business logic needs to be deleted or annotated. At this time, the code needs to be modified again and put online. The operation is cumbersome, time-consuming, prone to human errors, and high risk. Summary of the invention
[0005] In view of this, an embodiment of the present invention provides a method and device for implementing business enhancement, which can dynamically replace the execution code to achieve the business enhancement function, that is, replace the logical operation of the execution process without interrupting or stopping the service, and can be used for input and output viewing of online abnormal execution or other function enhancements, thereby reducing the risk of human errors caused by manual code modification and avoiding the tedious operation of repeatedly publishing business codes.
[0006] To achieve the above-mentioned purpose, according to one aspect of an embodiment of the present invention, a method for implementing service enhancement is provided, comprising: receiving a download notification from a listening server; downloading a corresponding jar package according to the download notification, wherein the jar package includes at least an implementation class for implementing service enhancement; and dynamically loading the implementation class in the jar package through a dynamic loading mechanism to implement service enhancement.
[0007] Optionally, the jar package also includes interception rules; dynamically loading and instantiating the implementation class in the jar package through a dynamic loading mechanism to achieve business enhancement includes: dynamically loading and instantiating the implementation class in the jar package through a dynamic loading mechanism; according to the interception rules, intercepting the corresponding business method through an aspect-oriented programming method, and calling the implementation class in the jar package before and after the execution of the business method to achieve business enhancement.
[0008] Optionally, before calling the implementation class in the jar package, the method further includes: determining that an execution switch is in an on state.
[0009] Optionally, the dynamic loading mechanism is a Java reflection mechanism.
[0010] To achieve the above-mentioned purpose, according to another aspect of an embodiment of the present invention, a method for implementing service enhancement is provided, comprising: receiving a jar package uploaded by a user, wherein the jar package includes at least an implementation class for implementing the service enhancement; determining whether to send a download notification to an application server; if so, sending a download notification to the application server to notify the application server to download and dynamically load the implementation class in the jar package through a dynamic loading mechanism.
[0011] Optionally, before sending the download notification to the application server, the method further includes: determining that the execution switch is in an on state.
[0012] To achieve the above-mentioned purpose, according to another aspect of an embodiment of the present invention, a device for implementing service enhancement is provided, comprising: a notification receiving module, used to receive a download notification from a monitoring server; a download module, used to download a corresponding jar package according to the download notification, wherein the jar package at least includes an implementation class for implementing service enhancement; a service enhancement module, used to dynamically load the implementation class in the jar package through a dynamic loading mechanism to implement service enhancement.
[0013] Optionally, the jar package also includes interception rules; the business enhancement module is also used to: dynamically load and instantiate the implementation class in the jar package through a dynamic loading mechanism; according to the interception rules, intercept the corresponding business method through an aspect-oriented programming method, and call the implementation class in the jar package before and after the execution of the business method, so as to achieve business enhancement.
[0014] Optionally, the service enhancement module is further used to: before calling the implementation class in the jar package, determine that the execution switch is in an on state.
[0015] Optionally, the dynamic loading mechanism is a Java reflection mechanism.
[0016] To achieve the above-mentioned purpose, according to another aspect of an embodiment of the present invention, a device for implementing service enhancement is provided, comprising: a jar package receiving module, used to receive a jar package uploaded by a user, wherein the jar package at least includes an implementation class for implementing service enhancement; a judgment module, used to determine whether to send a download notification to an application server; a notification sending module, used to send a download notification to the application server to notify the application server to download and dynamically load the implementation class in the jar package through a dynamic loading mechanism.
[0017] Optionally, the judgment module is further used to: determine the state of an execution switch, and if the execution switch is in an on state, determine to send a download notification to the application server.
[0018] To achieve the above-mentioned purpose, according to another aspect of an embodiment of the present invention, a system for implementing service enhancement is provided, the system comprising a listening server and an application server; the listening server is used to receive a jar package uploaded by a user, the jar package at least comprising an implementation class for implementing service enhancement; determine whether to send a download notification to the application server; if so, send a download notification to the application server to notify the application server to download and dynamically load the implementation class in the jar package through a dynamic loading mechanism; the application server is used to download the corresponding jar package according to the download notification from the listening server, the jar package at least comprising an implementation class for implementing service enhancement; and dynamically load the implementation class in the jar package through the dynamic loading mechanism to implement service enhancement.
[0019] Optionally, the application server dynamically loads the implementation class in the jar package through a dynamic loading mechanism to achieve business enhancement, including: dynamically loading and instantiating the implementation class in the jar package through a dynamic loading mechanism; intercepting the corresponding business method through an aspect-oriented programming method according to the interception rule, and calling the implementation class in the jar package before and after the execution of the business method to achieve business enhancement.
[0020] Optionally, an execution switch is also deployed on the listening server; the listening server is also used to determine that the execution switch is in an on state before sending a download notification to the application server; the application server is also used to determine that the execution switch is in an on state before calling the implementation class in the jar package.
[0021] To achieve the above-mentioned purpose, according to another aspect of an embodiment of the present invention, there is provided an electronic device, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method for realizing service enhancement according to an embodiment of the present invention.
[0022] To achieve the above objective, according to one aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored. When the program is executed by a processor, the method for implementing service enhancement in an embodiment of the present invention is implemented.
[0023] An embodiment of the above invention has the following advantages or beneficial effects: because it adopts receiving a download notification from a listening server; according to the download notification, downloading the corresponding jar package, the jar package at least includes an implementation class for implementing business enhancement; through a dynamic loading mechanism, dynamically loading the implementation class in the jar package to implement technical means for business enhancement, so it is possible to dynamically replace the execution code to achieve business enhancement function, that is, without interrupting or stopping the service, replace the logical operation of the execution process, and can be used for input and output viewing or other function enhancement of online abnormal execution, reducing the risk of human errors caused by manual code modification and avoiding the tedious operation of repeatedly publishing business codes.
[0024] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0026] Figure 1 is a schematic diagram of the main process of a method for implementing service enhancement according to an embodiment of the present invention;
[0027] Figure 2 is a schematic diagram of the main process of a method for implementing service enhancement according to another embodiment of the present invention;
[0028] Figure 3 is a schematic diagram of a system for implementing service enhancement according to an embodiment of the present invention;
[0029] Figure 4 is a schematic diagram of the main process of a method for implementing service enhancement according to another embodiment of the present invention;
[0030] Figure 5 is a schematic diagram of main modules of an apparatus for implementing service enhancement according to an embodiment of the present invention;
[0031] Figure 6 is a schematic diagram of main modules of an apparatus for implementing service enhancement according to another embodiment of the present invention;
[0032] Figure 7 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0033] Figure 8It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0034] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0035] Figure 1 is a schematic diagram of the main process of the method for implementing service enhancement according to an embodiment of the present invention, such as Figure 1 As shown, the method comprises the following steps:
[0036] Step S101: receiving a download notification from a monitoring server;
[0037] Step S102: downloading a corresponding jar package according to the download notification, wherein the jar package at least includes an implementation class for implementing service enhancement;
[0038] Step S103: dynamically load the implementation class in the jar package through a dynamic loading mechanism to achieve service enhancement.
[0039] Advice refers to injecting some logic code into each program to enhance the function of the original program. The method for implementing service enhancement in this embodiment can be used in the application server of the business party to implement the service enhancement functions of the application server, such as logging, performance statistics, security control, transaction processing and exception handling.
[0040] For step S101 and step S102, the download notification from the monitoring server may include the upload time or version information (such as version number) of the jar package. After receiving the download notification, the application server may download the corresponding jar package according to the upload time or version information.
[0041] The jar package (Java Archive) is a platform-independent file format that allows many files to be combined into a compressed file. A class is an abstract template that describes the behavior and state of a class of objects. An implementation class is a class that implements an interface and implements all methods described in the interface. In this embodiment, the jar package includes at least an implementation class that implements business enhancement, which is the logic for implementing business enhancement.
[0042] The jar package also includes a custom interception rule that indicates the business method that needs to be enhanced. You can determine the business method that needs to be enhanced (i.e., the target business method) according to the scenario requirements, and then define the interception rule according to the business that needs to be enhanced to intercept the target business method.
[0043] For step S103, service enhancement can be achieved according to the following process:
[0044] Dynamically load and instantiate the implementation class in the jar package through a dynamic loading mechanism;
[0045] According to the interception rules, the corresponding business method is intercepted by aspect-oriented programming method, and the implementation class in the jar package is called before and after the execution of the business method to achieve business enhancement.
[0046] Among them, instantiation refers to the process of creating objects using classes in object-oriented programming.
[0047] As a specific example, the dynamic loading mechanism is the Java reflection mechanism. The Java reflection mechanism is that in the running state, for any class, all the properties and methods of this class can be known; for any object, any method and property of it can be called; this function of dynamically obtaining information and dynamically calling object methods is called the reflection mechanism of the Java language.
[0048] Aspect Oriented Programming (AOP) refers to a technology that achieves unified maintenance of program functions through pre-compilation and runtime dynamic proxy. According to the location of the connection point of the enhancement in the target business method, it can be divided into before enhancement (BeforeAdvice), after enhancement (AfterReturningAdvice), around enhancement (MethodInterceptor), exception throwing enhancement (ThrowsAdvice) and introduction enhancement (introductioninterceptor). In this embodiment, before enhancement and after enhancement are adopted, that is, before and after the execution of the intercepted business method, the implementation class in the jar package is called to achieve business enhancement.
[0049] The embodiments of the present invention can dynamically replace the execution code to achieve business enhancement, that is, replace the logical operation of the execution process without interrupting or stopping the service, and can be used for input and output viewing of online abnormal execution or other function enhancements.
[0050] In an optional embodiment, before calling the implementation class in the jar package, the method further includes: determining that the execution switch is in the on state. That is, after intercepting the corresponding business method according to the interception rule, first determine the state of the execution switch. If the execution switch is in the on state at this time, it means that business enhancement needs to be implemented, and then call the implementation class in the jar package to implement the business enhancement. If the execution switch is in the off state, it means that business enhancement does not need to be implemented, then the implementation class in the jar package is not called, and the business method is executed according to the normal business process. Therefore, the method for implementing business enhancement in the embodiment of the present invention does not need to repeatedly release new versions of business codes to implement business enhancement or cancel business enhancement.
[0051] As a specific example, the execution switch can be a state identifier or a flag bit. For example, when the state identifier or flag bit is 1, it indicates that the execution switch is in the on state; when the state identifier or flag bit is 0, it indicates that the execution switch is in the off state. The execution switch is deployed on the monitoring server, and the staff can flexibly set the state of the execution switch according to the needs.
[0052] Figure 2 is a schematic diagram of the main process of the method for implementing service enhancement according to an embodiment of the present invention, such as Figure 2 As shown, the method comprises the following steps:
[0053] Step S201: receiving a jar package uploaded by a user, wherein the jar package at least includes an implementation class for implementing service enhancement;
[0054] Step S202: Determine whether to send a download notification to the application server;
[0055] Step S203: If yes, a download notification is sent to the application server to notify the application server to download and dynamically load the implementation class in the jar package through a dynamic loading mechanism.
[0056] For step S202, whether to send a download notification to the application server may be determined by the following method:
[0057] The state of the execution switch is determined, and if the execution switch is in an on state, a download notification is sent to the application server.
[0058] Before sending a download notification to the application server, determine the status of the execution switch. If the execution switch is in the on state at this time, it means that the application server needs to be notified to download the jar package, and a download notification is sent to the application server. If the execution switch is in the off state, it means that the application server does not need to be notified. The status of the execution switch can be flexibly set by the staff according to needs. A human-computer interaction interface (or operation management page) can be set on the monitoring server, on which the staff can choose to turn on or off the execution switch, and can also choose which application servers to send download notifications to.
[0059] The method for implementing service enhancement in this embodiment can be applied to a monitoring server. When the monitoring server determines that a jar package has been uploaded, it determines whether a download notification should be sent to the application server. If so, a download notification is sent to the application server to notify the application server to download the jar package. The download notification may include the upload time or version number of the new jar package, and the application server may download the new jar package according to the upload time or version number. Among them, the monitoring server can interact and communicate with the application server through MQ technology or TCP technology. MQ (Message Queue) is a cross-process communication mechanism for transmitting messages between upstream and downstream. TCP (Transmission Control Protocol) is a connection-oriented, reliable, byte stream-based transport layer communication protocol. Using different technologies to implement communication can provide support for different usage scenarios.
[0060] Figure 3 3 is a schematic diagram of a system 300 for implementing service enhancement according to an embodiment of the present invention. As shown in the figure, the system 300 includes a monitoring server 301 and an application server 302;
[0061] The monitoring server 301 is used to receive a jar package uploaded by a user, wherein the jar package includes at least an implementation class for realizing service enhancement; determine whether to send a download notification to the application server; if so, send a download notification to the application server to notify the application server to download and dynamically load the implementation class in the jar package through a dynamic loading mechanism;
[0062] 302 on the application server is used to download the corresponding jar package according to the download notification from the monitoring server, and the jar package at least includes the implementation class for realizing business enhancement; through the dynamic loading mechanism, the implementation class in the jar package is dynamically loaded to realize business enhancement.
[0063] In this embodiment, the monitoring server can notify the application server of new changes and trigger the application server to download the changed jar package. In addition, the monitoring server can also be used to control the jar download. For example, in practice, 100 application servers may be deployed. Through the monitoring server, all or part of the application servers can be notified to download the changed jar package, without the need for developers to upload the jar package to each application server or write batch scripts.
[0064] In an optional embodiment, the application server dynamically loads the implementation class in the jar package through a dynamic loading mechanism to achieve service enhancement including:
[0065] Dynamically load and instantiate the implementation class in the jar package through a dynamic loading mechanism;
[0066] According to the interception rules, the corresponding business method is intercepted by aspect-oriented programming method, and the implementation class in the jar package is called before and after the execution of the business method to achieve business enhancement.
[0067] In an optional embodiment, an execution switch is also deployed on the monitoring server;
[0068] The monitoring server is also used to determine that the execution switch is in the on state before sending the download notification to the application server;
[0069] The application server is also used to determine that the execution switch is in an on state before calling the implementation class in the jar package.
[0070] Figure 4 FIG. 1 is a flow chart of a method for implementing service enhancement according to another embodiment of the present invention. As shown in the figure, the method includes:
[0071] 1. Developers upload jar packages (i.e. Figure 4 The jar package includes the specific output or other logical implementation of enhanced services and the implementation class package of the calling interface;
[0072] 2. After the developer has uploaded the file, turn on the execution switch, and the monitoring server will notify the application server to download the jar package;
[0073] 3. The application server requests to download the jar package;
[0074] 4. After downloading, the application server loads and instantiates the implementation class in the jar package through the Java reflection mechanism, replaces the implementation class reference of the current proxy class, and dynamically changes the implementation logic.
[0075] 5. After the replacement is completed, the result is returned to the listening server;
[0076] 6. The monitoring server feeds back the result to the developer, which describes whether the dynamic update is successful;
[0077] 7. After the replacement is completed, the client of the application server initiates a service request again (this step belongs to the service request of the application side)
[0078] 8. After the request reaches the application server, the application server intercepts the corresponding business method through AOP technology according to the interception rules. Before the business method is processed, the implementation class is called (that is, the before interface is called) according to the downloaded and replaced jar package, that is, the developer's logic processing is called to achieve business enhancement;
[0079] 9. Execute normal business logic;
[0080] 10. After business processing, the application server uses AOP technology to call the implementation class (i.e., call the after interface) according to the downloaded and replaced jar package, that is, call the developer's logic processing to achieve business enhancement;
[0081] 11. The application server returns a response to the client.
[0082] In steps 8-11 of the embodiment of the present invention, the interception rules are configured through AOP technology (for example, the interception rules are customized through execution), and the execution process of the interception is handed over to the proxy class through the proxy mode. The proxy class holds the reference of the implementation class and executes the implementation class in the jar before and after the method is executed. Among them, the implementation class implements two interfaces: before interface and after interface. Among them, the interface (English: Interface) is an abstract type in the JAVA programming language, which is a collection of abstract methods. The interface is usually declared as an interface. A class inherits the abstract method of the interface by inheriting the interface. The implementation class refers to the class that implements the interface and implements all the methods described in the interface. The proxy class is the proxy of the class. The class is given to the proxy, and the class method is not called directly, but through the proxy. Proxy mode: Provide a proxy object for an object, and the proxy object controls the access to the original object, that is, the client does not directly manipulate the original object, but indirectly manipulates the original object through the proxy object. Reference generally refers to the behavior of operating the address of something.
[0083] The method for implementing service enhancement in this embodiment can dynamically replace execution code to achieve service enhancement functions, and can be used for input and output viewing of online abnormal execution or other function enhancements.
[0084] Figure 5 is a schematic diagram of main modules of an apparatus 500 for implementing service enhancement according to an embodiment of the present invention, such as Figure 5As shown, the device 500 includes:
[0085] Notification receiving module 501, used to receive download notifications from a monitoring server;
[0086] A download module 502 is used to download a corresponding jar package according to the download notification, wherein the jar package at least includes an implementation class for implementing service enhancement;
[0087] The service enhancement module 503 is used to dynamically load the implementation class in the jar package through a dynamic loading mechanism to achieve service enhancement.
[0088] Optionally, the jar package also includes interception rules;
[0089] The business enhancement module 503 is also used to: dynamically load and instantiate the implementation class in the jar package through a dynamic loading mechanism; intercept the corresponding business method through an aspect-oriented programming method according to the interception rule, and call the implementation class in the jar package before and after the execution of the business method to achieve business enhancement.
[0090] Optionally, the service enhancement module 503 is further used to: before calling the implementation class in the jar package, determine whether the execution switch is in an on state.
[0091] Optionally, the dynamic loading mechanism is a Java reflection mechanism.
[0092] Figure 6 is a schematic diagram of main modules of an apparatus 600 for implementing service enhancement according to an embodiment of the present invention, such as Figure 6 As shown, the device 600 includes:
[0093] The jar package receiving module 601 is used to receive the jar package uploaded by the user, and the jar package at least includes an implementation class for realizing service enhancement;
[0094] A determination module 602 is used to determine whether to send a download notification to an application server;
[0095] The notification sending module 603 is used to send a download notification to the application server to notify the application server to download and dynamically load the implementation class in the jar package through a dynamic loading mechanism.
[0096] Optionally, the judgment module 602 is further used to: determine the state of an execution switch, and if the execution switch is in an on state, determine to send a download notification to the application server.
[0097] The above device can execute the method provided by the embodiment of the present invention, and has the functional modules and beneficial effects corresponding to the execution method. For technical details not described in detail in this embodiment, please refer to the method provided by the embodiment of the present invention.
[0098] Figure 7 An exemplary system architecture 700 is shown to which the method for implementing service enhancement or the apparatus for implementing service enhancement according to the embodiments of the present invention can be applied.
[0099] like Figure 7 As shown, system architecture 700 may include terminal devices 701, 702, 703, network 704 and server 705. Network 704 is used to provide a medium for communication links between terminal devices 701, 702, 703 and server 705. Network 704 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0100] Users can use terminal devices 701, 702, and 703 to interact with server 705 through network 704 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 701, 702, and 703, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0101] The terminal devices 701 , 702 , and 703 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.
[0102] The server 705 may be a server that provides various services, such as a backend management server that provides support for shopping websites browsed by users using the terminal devices 701, 702, and 703. The backend management server may analyze and process the received data such as product information query requests, and feed back the processing results (such as target push information and product information) to the terminal device.
[0103] It should be noted that the method for implementing service enhancement provided in the embodiment of the present invention is generally executed by the server 705 , and accordingly, the device for implementing service enhancement is generally arranged in the server 705 .
[0104] It should be understood that Figure 7 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0105] Reference below Figure 8 , which shows a schematic diagram of the structure of a computer system 800 of a terminal device suitable for implementing an embodiment of the present invention. Figure 8The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0106] like Figure 8 As shown, the computer system 800 includes a central processing unit (CPU) 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage part 808 into a random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the system 800 are also stored. The CPU 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0107] The following components are connected to the I / O interface 805: an input section 806 including a keyboard, a mouse, etc.; an output section 807 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN card, a modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the I / O interface 805 as needed. A removable medium 811, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 810 as needed, so that a computer program read therefrom is installed into the storage section 808 as needed.
[0108] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 809, and / or installed from the removable medium 811. When the computer program is executed by the central processing unit (CPU) 801, the above-mentioned functions defined in the system of the present invention are executed.
[0109] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, 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 above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0110] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0111] The modules involved in the embodiments of the present invention may be implemented in software or hardware. The modules described may also be set in a processor. For example, they may be described as: a processor includes a sending module, an acquisition module, a determination module, and a first processing module. The names of these modules do not, in some cases, constitute a limitation on the unit itself. For example, the sending module may also be described as a "module for sending a picture acquisition request to the connected server."
[0112] As another aspect, the present invention further provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes:
[0113] Receive download notifications from the listening server;
[0114] According to the download notification, download the corresponding jar package, where the jar package at least includes an implementation class for implementing service enhancement;
[0115] Through the dynamic loading mechanism, the implementation class in the jar package is dynamically loaded and instantiated to achieve business enhancement.
[0116] The technical solution of the embodiment of the present invention replaces the logical operation of the execution process without interrupting or stopping the service, and can be used for input and output viewing or other function enhancement of online abnormal execution, reducing the risk of human errors caused by manual code modification and avoiding the tedious operation of repeatedly publishing business codes.
[0117] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for implementing service enhancement, characterized in that: include: Receive download notifications from the listening server; According to the download notification, download the corresponding jar package, where the jar package at least includes an implementation class for implementing service enhancement; Dynamically load the implementation class in the jar package through a dynamic loading mechanism to achieve business enhancement, including: dynamically load and instantiate the implementation class in the jar package through a dynamic loading mechanism; intercept the corresponding business method through an aspect-oriented programming method according to the interception rule, and call the implementation class in the jar package before and after the execution of the business method to achieve business enhancement; wherein, the jar package also includes interception rules, and determines the enhanced business method according to scenario requirements to define the corresponding interception rules.
2. The method according to claim 1, characterized in that Before calling the implementation class in the jar package, the method further includes: Make sure the execute switch is on.
3. The method according to claim 1 or 2, characterized in that: The dynamic loading mechanism is a Java reflection mechanism.
4. A method for implementing service enhancement, characterized in that: include: Receive a jar package uploaded by a user, where the jar package at least includes an implementation class for implementing service enhancement; Determine whether to send a download notification to the application server; If so, a download notification is sent to the application server to notify the application server to download and dynamically load the implementation class in the jar package through a dynamic loading mechanism, including: dynamically loading and instantiating the implementation class in the jar package through a dynamic loading mechanism; according to the interception rules, the corresponding business method is intercepted through an aspect-oriented programming method, and the implementation class in the jar package is called before and after the execution of the business method to achieve business enhancement; wherein the jar package also includes interception rules, and the enhanced business method is determined according to the scenario requirements to define the corresponding interception rules.
5. The method according to claim 4, characterized in that Determining whether to send a download notification to the application server includes: The state of the execution switch is determined, and if the execution switch is in an on state, a download notification is sent to the application server.
6. A device for implementing service enhancement, characterized in that: include: A notification receiving module, used to receive download notifications from a monitoring server; A download module, used to download a corresponding jar package according to the download notification, wherein the jar package at least includes an implementation class for realizing service enhancement; The business enhancement module is used to dynamically load the implementation class in the jar package through a dynamic loading mechanism to achieve business enhancement, including: dynamically loading and instantiating the implementation class in the jar package through a dynamic loading mechanism; intercepting the corresponding business method through an aspect-oriented programming method according to the interception rule, and calling the implementation class in the jar package before and after the execution of the business method to achieve business enhancement; wherein, the jar package also includes interception rules, and determines the enhanced business method according to the scenario requirements to define the corresponding interception rules.
7. The device according to claim 6, characterized in that The service enhancement module is also used for: Before calling the implementation class in the jar package, make sure that the execution switch is turned on.
8. The device according to claim 6 or 7, characterized in that The dynamic loading mechanism is a Java reflection mechanism.
9. A device for implementing service enhancement, characterized in that: include: A jar package receiving module, used to receive a jar package uploaded by a user, wherein the jar package at least includes an implementation class for realizing service enhancement; A judgment module, used to determine whether to send a download notification to the application server; A notification sending module is used to send a download notification to an application server to notify the application server to download and dynamically load the implementation class in the jar package through a dynamic loading mechanism, including: dynamically loading and instantiating the implementation class in the jar package through a dynamic loading mechanism; according to the interception rule, intercepting the corresponding business method through an aspect-oriented programming method, and calling the implementation class in the jar package before and after the execution of the business method to achieve business enhancement; wherein, the jar package also includes interception rules, and the enhanced business method is determined according to the scenario requirements to define the corresponding interception rules.
10. The device according to claim 9, characterized in that The judgment module is further used to: determine the state of the execution switch, and if the execution switch is in the on state, determine to send a download notification to the application server.
11. A system for implementing service enhancement, characterized in that: The system includes a monitoring server and an application server; The monitoring server is used to receive a jar package uploaded by a user, wherein the jar package includes at least an implementation class for realizing service enhancement; determine whether to send a download notification to the application server; if so, send a download notification to the application server to notify the application server to download and dynamically load the implementation class in the jar package through a dynamic loading mechanism; The application server is used to download the corresponding jar package according to the download notification from the monitoring server, and the jar package at least includes an implementation class for realizing service enhancement; Dynamically load the implementation class in the jar package through a dynamic loading mechanism to achieve business enhancement, including: dynamically load and instantiate the implementation class in the jar package through a dynamic loading mechanism; intercept the corresponding business method through an aspect-oriented programming method according to the interception rule, and call the implementation class in the jar package before and after the execution of the business method to achieve business enhancement; wherein, the jar package also includes interception rules, and determines the enhanced business method according to scenario requirements to define the corresponding interception rules.
12. The system according to claim 11, characterized in that The monitoring server is also equipped with an execution switch; The monitoring server is also used to determine that the execution switch is in the on state before sending the download notification to the application server; The application server is also used to determine that the execution switch is in an on state before calling the implementation class in the jar package.
13. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 3.
14. A computer readable 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 3 is implemented.
Citation Information
Patent Citations
Log recording method
CN102810057A
Updating method of operating system facing intelligent robot, and operating system
CN106066807A
Dynamic updating method and device of JAVA application program
CN108228208A
