A method and device for processing a service request

By separating business methods into independent components and configuring component call relationships, the problems of complex and high coupling in application development of business module interface calls are solved, modular development is realized, development process is simplified, development efficiency and flexibility are improved reduces repeated calls to interfaces and waste of server resources.

CN113326030BActive Publication Date: 2024-11-19BEIJING JINGDONG TUOXIAN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110580884.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-05-26
Publication Date
2024-11-19
Estimated Expiration
2041-05-26

AI Technical Summary

Technical Problem

During the application development process, the interface calls of the business modules are complex, there are a lot of repetitive work, poor flexibility, and high coupling of each business module, resulting in the need to be republished every time the call relationship is modified, which cannot take effect in real time, and the unified interface is added after repeated calls are added. Time-consuming and wasteful server resources.

Method used

By extracting business methods into independent components and configuring component call relationships, automatically generate call dependencies for component instances, the processing of business requests is realized, the coupling between business modules is reduced, and the development process is simplified.

Benefits of technology

Modular development is realized, reducing the coupling between business modules, simplifying the development process, improving development efficiency, avoiding duplicate development of similar logic, reducing duplicate calls to interfaces, saving server resources, and improving development flexibility.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113326030B_ABST
    Figure CN113326030B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and device for processing a business request, and relates to the field of computer technology. A specific implementation of the method includes: receiving a business request, and obtaining corresponding configuration information according to a business identifier carried in the business request; wherein the configuration information includes a component call relationship; querying a component instance corresponding to a component in the component call relationship, and generating a call dependency relationship of the component instance according to the component call relationship; wherein the component is used to independently implement a business function, including a business method extracted from a business method set; according to the call dependency relationship, calling the component instance to process the business request and obtaining a processing result. This implementation can automatically generate a call dependency relationship of a component instance according to the component call relationship, realize the processing of the business request, reduce the coupling between business modules, and at the same time simplify the development process and improve development efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method and device for processing a service request. Background Art

[0002] During the application development process, the interface calls of some business modules in the application are relatively complex. The existing technology usually combines the calling relationships between various sub-modules in a hard-coded manner. As the calling level deepens, when each layer needs to obtain the same interface data, it needs to call the interface repeatedly. In addition, there are a large number of identical or similar functions between businesses, which requires the development of a large number of similar logics.

[0003] In addition, the data returned by the interface is usually not what each business needs. Different data filtering and data conversion codes need to be written for different business logics. When the business function needs to change, the code needs to be changed and re-released. In order to show users diverse information, different business modules will embed the codes of other business modules so that various data can be integrated and displayed to users.

[0004] In the process of implementing the present invention, there are at least the following problems in the prior art:

[0005] There is a lot of repetitive work in the application development process, which has poor flexibility. Every time the calling relationship is modified, it needs to be republished and cannot take effect in real time. Repeated calls to the unified interface increase the interface time consumption and waste server resources. The coupling between different business modules is high and there is mutual nesting. Summary of the invention

[0006] In view of this, an embodiment of the present invention provides a method and device for processing business requests, which extracts business methods into components that can independently implement business functions and configures component calling relationships, so that calling dependency relationships of component instances can be automatically generated according to the component calling relationships, thereby realizing the processing of business requests, reducing the coupling between business modules, simplifying the development process, and improving development efficiency.

[0007] To achieve the above objective, according to one aspect of an embodiment of the present invention, a method for processing a service request is provided.

[0008] A method for processing a business request in an embodiment of the present invention comprises: receiving a business request, and obtaining corresponding configuration information according to a business identifier carried in the business request; wherein the configuration information comprises a component calling relationship; querying a component instance corresponding to a component in the component calling relationship, and generating a calling dependency relationship of the component instance according to the component calling relationship; wherein the component is used to independently implement a business function, including a business method extracted from a business method set; and according to the calling dependency relationship, calling the component instance to process the business request to obtain a processing result.

[0009] Optionally, the component call relationship includes a component name of at least one component, a starting component identifier and a next component called by the component; the querying of the component instance corresponding to the component in the component call relationship and generating a call dependency relationship of the component instance according to the component call relationship include: adding the starting component to the starting component set; wherein the starting component is a component for which the starting component identifier is true; traversing the starting components of the starting component set, performing the following processing on the traversed starting components until the traversal is completed, and taking the final splicing result as the call dependency relationship of the component instance: an acquisition and setting step: acquiring the corresponding component instance according to the component name of the current component, setting the parameter information of the component instance, and splicing the component instance to the component instance acquired in the previous cycle; wherein the initial value of the current component is the starting component; a loop processing step: determining whether the current component has a next component, and if the current component has the next component, updating the next component to the current component, and repeating the acquisition and setting step and the loop processing step until the current component does not have the next component, thereby obtaining a splicing result.

[0010] Optionally, after the step of obtaining the corresponding configuration information, the method further includes: detecting the components in the component calling relationship; wherein the detection includes one or more of circular dependency detection, component reachability analysis, component existence detection, component duplication detection and mandatory information detection; the circular dependency detection is used to detect whether there is a circular dependency in the calls between the components, the component reachability analysis is used to detect whether there is an unreachable component, the component existence detection is used to detect whether there is a component instance corresponding to the component, the component duplication detection is used to detect whether the same component exists in the component calling relationship, and the mandatory information detection is used to detect whether the component calling relationship includes the set mandatory information.

[0011] Optionally, the component calling relationship includes the component name of at least one component, the starting component identifier and the next component called by the component; performing circular dependency detection on the components in the component calling relationship includes: obtaining the starting component from the component calling relationship and initializing a component detection set; wherein the starting component is a component for which the starting component identifier is true; a judgment processing step: judging whether the current component exists in the component detection set, and if the current component does not exist in the component detection set, adding the current component to the component detection set; wherein the initial value of the current component is the starting component; a determination updating step: determining whether the current component has a next component to be called, updating the next component to the current component, and repeatedly executing the judgment processing step and the determination updating step until the current component exists in the component detection set or the current component does not have a next component to be called, and outputting the detection result.

[0012] Optionally, the component calling relationship includes the component name of at least one component, the starting component identifier and the next component called by the component; performing component reachability analysis on the components in the component calling relationship, including: obtaining the starting component from the component calling relationship; wherein the starting component is the component for which the starting component identifier is true; adding the current component to the component reachable set, determining whether the current component has a next component to be called, and if the current component has a next component to be called, updating the next component to the current component, repeating this step until the current component does not have a next component to be called, and determining an unreachable component; wherein the initial value of the current component is the starting component, and the unreachable component is the difference between the component set constituted by the components in the component calling relationship and the component reachable set.

[0013] Optionally, the parameter information includes a data reuse identifier; calling the component instance to process the business request according to the calling dependency includes: determining the data reuse identifier of the current component instance to be called according to the calling dependency; if the data reuse identifier is true, inputting the data obtained by previously calling the current component instance into the next component instance; if the data reuse identifier is false, calling the current component instance and inputting the obtained return data into the next component instance; updating the next component instance to the current component instance, repeating the above steps until the last component instance, and completing the processing of the business request.

[0014] Optionally, the configuration information also includes data conversion information, and the data conversion information is used to record the correspondence between the display field and the return field of the processing result; the method also includes: according to the data conversion information, converting the return field of the processing result into the corresponding display field, obtaining the data conversion result, and displaying the data conversion result.

[0015] Optionally, the method further includes: scanning components that inherit the abstract class; using the component name as the key name and the component instance as the corresponding key value, and adding the scanned component to the component pool.

[0016] To achieve the above objective, according to another aspect of an embodiment of the present invention, a device for processing a service request is provided.

[0017] A device for processing business requests according to an embodiment of the present invention comprises: an acquisition module, used to receive a business request, and acquire corresponding configuration information according to a business identifier carried in the business request; wherein the configuration information comprises a component call relationship; a generation module, used to query a component instance corresponding to a component in the component call relationship, and generate a call dependency relationship of the component instance according to the component call relationship; wherein the component is used to independently implement a business function, including a business method extracted from a business method set; and a processing module, used to call the component instance according to the call dependency relationship to process the business request and obtain a processing result.

[0018] Optionally, the component call relationship includes the component name of at least one component, the starting component identifier and the next component called by the component; the generation module is also used to add the starting component to the starting component set; wherein the starting component is the component for which the starting component identifier is true; traverse the starting components of the starting component set, perform the following processing on the traversed starting components until the traversal is completed, and use the final splicing result as the calling dependency relationship of the component instance: acquisition and setting step: according to the component name of the current component, obtain the corresponding component instance, set the parameter information of the component instance, and splice the component instance to the component instance obtained in the previous round of loop; wherein the initial value of the current component is the starting component; loop processing step: determine whether the current component has a next component, if the current component has the next component, update the next component to the current component, repeat the acquisition and setting step and the loop processing step until the current component does not have the next component, and obtain the splicing result.

[0019] Optionally, the device also includes: a detection module, used to detect components in the component calling relationship; wherein the detection includes one or more of circular dependency detection, component reachability analysis, component existence detection, component duplication detection and mandatory information detection; the circular dependency detection is used to detect whether there is a circular dependency in the calls between the components, the component reachability analysis is used to detect whether there is an unreachable component, the component existence detection is used to detect whether there is a component instance corresponding to the component, the component duplication detection is used to detect whether there is the same component in the component calling relationship, and the mandatory information detection is used to detect whether the component calling relationship includes the set mandatory information.

[0020] Optionally, the component calling relationship includes a component name of at least one component, a starting component identifier and a next component called by the component; the detection module is also used to obtain a starting component from the component calling relationship and initialize a component detection set; wherein the starting component is a component for which the starting component identifier is true; a judgment processing step: judging whether a current component exists in the component detection set, and if the current component does not exist in the component detection set, adding the current component to the component detection set; wherein the initial value of the current component is the starting component; a determination updating step: determining whether the current component has a next component to be called, updating the next component to the current component, and repeating the judgment processing step and the determination updating step until the current component exists in the component detection set, or the current component does not have a next component to be called, and outputting the detection result.

[0021] Optionally, the component calling relationship includes a component name of at least one component, a starting component identifier and a next component called by the component; the detection module is further used to obtain a starting component from the component calling relationship; wherein the starting component is a component for which the starting component identifier is true; the current component is added to a component reachable set, and it is determined whether the current component has a next component to be called; if the current component has a next component to be called, the next component is updated to the current component, and this step is repeated until the current component does not have a next component to be called, and an unreachable component is determined; wherein the initial value of the current component is the starting component, and the unreachable component is the difference between the component set constituted by the components in the component calling relationship and the component reachable set.

[0022] Optionally, the parameter information includes a data reuse identifier; the processing module is further used to determine the data reuse identifier of the current component instance to be called according to the calling dependency; if the data reuse identifier is true, the data obtained by previously calling the current component instance is input into the next component instance; if the data reuse identifier is false, the current component instance is called, and the obtained return data is input into the next component instance; the next component instance is updated to the current component instance, and the above steps are repeated until the last component instance, thereby completing the processing of the business request.

[0023] Optionally, the configuration information also includes data conversion information, and the data conversion information is used to record the correspondence between the display field and the return field of the processing result; the device also includes: a conversion module, which is used to convert the return field of the processing result into a corresponding display field according to the data conversion information, obtain a data conversion result, and display the data conversion result.

[0024] Optionally, the device further comprises: a component pool construction module, which is used to scan components that inherit the abstract class; using the component name as the key name and the component instance as the corresponding key value, and adding the scanned component to the component pool.

[0025] To achieve the above objective, according to another aspect of an embodiment of the present invention, an electronic device is provided.

[0026] An electronic device according to an embodiment of the present invention comprises: 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 a method for processing a service request according to an embodiment of the present invention.

[0027] To achieve the above objective, according to another aspect of the embodiments of the present invention, a computer readable medium is provided.

[0028] A computer-readable medium according to an embodiment of the present invention stores a computer program, and when the program is executed by a processor, a method for processing a service request according to an embodiment of the present invention is implemented.

[0029] An embodiment of the above invention has the following advantages or beneficial effects: by extracting business methods into components that can independently implement business functions and configuring component calling relationships, it is possible to automatically generate calling dependency relationships of component instances based on the component calling relationships, thereby achieving modular development and reducing the coupling between business modules. At the same time, it simplifies the development process and improves development efficiency.

[0030] According to the component information recorded in the component call relationship, the actual call dependency relationship at the code level is automatically generated. When adding new services, you only need to configure the component call relationship, without having to manually write the call relationship as in the existing technology, which simplifies the development process and avoids repeated development of similar logic. By performing circular dependency detection on components, dead loops in calls are avoided. By performing component reachability analysis on components, components that cannot be called are detected so that the component call relationship can be modified before executing the request.

[0031] By configuring the data reuse identifier, it is decided whether to call the same interface again to obtain data, so that repeated interface calls can be reduced and server resources can be saved. By configuring data conversion information, automatic conversion of return fields is realized, which is flexible and further improves development efficiency. All components inherit from the abstract class, so that all components can be obtained by scanning with unified logic, which is convenient for unified management and avoids repeated writing of the same properties and methods.

[0032] 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

[0033] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.

[0034] Figure 1 is a schematic diagram of main steps of a method for processing a service request according to an embodiment of the present invention;

[0035] Figure 2 is a schematic diagram of the main flow of a method for processing a service request according to an embodiment of the present invention;

[0036] Figure 3 is a schematic diagram of a data conversion configuration page according to an embodiment of the present invention;

[0037] Figure 4 This is a schematic diagram of a new / edit service identification page according to an embodiment of the present invention;

[0038] Figure 5 is a schematic diagram of a new / edit field page according to an embodiment of the present invention;

[0039] Figure 6 It is a schematic diagram of a component call graph configuration page according to an embodiment of the present invention;

[0040] Figure 7 This is a schematic diagram of a new / edit call map page according to an embodiment of the present invention. Figure 1 ;

[0041] Figure 8 This is a schematic diagram of a new / edit call map page according to an embodiment of the present invention. Figure 2 ;

[0042] Fig. 9 This is a schematic diagram of the main process of performing circular dependency detection on components according to an embodiment of the present invention;

[0043] Fig.10 It is a schematic diagram of the main process of performing component reachability analysis on a component according to an embodiment of the present invention;

[0044] Fig.11 It is a schematic diagram of the main process of generating call dependency relationships according to an embodiment of the present invention;

[0045] Fig.12 is a schematic diagram of main modules of a device for processing a service request according to an embodiment of the present invention;

[0046] Fig.13 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;

[0047] Fig.14 It is a schematic diagram of the structure of a computer device suitable for implementing the electronic device of the embodiment of the present invention. DETAILED DESCRIPTION

[0048] 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.

[0049] Figure 1 FIG. 1 is a schematic diagram of the main steps of the method for processing a service request according to an embodiment of the present invention. Figure 1 As shown, the method for processing a service request in an embodiment of the present invention mainly includes the following steps:

[0050] Step S101: Receive a service request, and obtain corresponding configuration information according to the service identifier carried in the service request. Fill in the configuration information for the service in advance on the configuration page, and the configuration information includes a component call relationship for recording the call relationship between components. In an embodiment, the component call relationship may include the component name of at least one component, the starting component identifier, and the next component called by the component. After receiving the service request, use the service identifier carried in the request to query the corresponding configuration information on the configuration page.

[0051] Step S102: Query the component instance corresponding to the component in the component call relationship, and generate the call dependency relationship of the component instance according to the component call relationship. When the application starts, scan the components that inherit the abstract class, use the component name as the key name and the component instance as the corresponding key value, and add the scanned components to the component pool. The components are used to independently implement business functions, including business methods extracted from the business method set.

[0052] After obtaining the component call relationship, add the starting component contained in the component call relationship to the starting component collection, and then traverse the starting component collection. Each time a starting component is traversed, the corresponding component instance is obtained from the component pool according to the component name of the current component, and the parameter information of the component instance is set. Then, the next component of the current component is obtained, and the component instance of the next component is obtained in the same way, and the parameter information of the component instance is set. After that, the component instance of the next component is spliced ​​to the component instance of the current component, and this process is repeated until all components are traversed. The final splicing result is the call dependency relationship.

[0053] Step S103: According to the calling dependency, the component instance is called to process the business request to obtain a processing result. Starting from the component instance of the starting component, each component instance is called and executed in sequence according to the calling dependency. When there are multiple starting components, the starting components can be called in parallel to complete the processing of the business request and return the processing result.

[0054] Figure 2 FIG. 1 is a schematic diagram of the main flow of the method for processing a service request according to an embodiment of the present invention. Figure 2 As shown, the method for processing a service request in an embodiment of the present invention mainly includes the following steps:

[0055] Step S201: Receive a business request, obtain corresponding configuration information from the configuration center according to the business identifier carried in the business request, and parse the configuration information. In the embodiment, the configuration information includes component call relationships and data conversion information, which can be stored in the cache and the database. The data conversion information records the correspondence between the display field and the return field of the processing result, which is used to convert the fields used inside the server into the fields displayed on the front end.

[0056] Since some fields inside the server are sensitive fields and cannot be directly displayed on the user page, you can configure data conversion information to determine which fields can be directly displayed and which fields need to be blocked. In addition, when the displayed fields are changed (such as adding or changing some fields), resulting in the display fields not corresponding to the returned fields, you can also configure data conversion information to make corresponding adjustments.

[0057] In the embodiment, the configuration information is set on the configuration page of the configuration center, and the configuration page includes a data conversion configuration page and a component call map configuration page. The data conversion configuration page is used to configure the data conversion information, and the component call map configuration page is used to configure the component call relationship. The data conversion configuration page and the component call map configuration page are described in detail below in conjunction with the accompanying drawings.

[0058] Figure 3 is a schematic diagram of a data conversion configuration page according to an embodiment of the present invention. Figure 4 is a schematic diagram of a new / edit service identification page according to an embodiment of the present invention. Figure 5 2 is a schematic diagram of a new / edit field page according to an embodiment of the present invention.

[0059] See also Figure 3 , click the "Add" button on the "Data Conversion Configuration" page, and a pop-up Figure 4 On the "Add / Edit Business Identifier" page shown, enter the business identifier (used to uniquely identify a business) and the business method name, and click the "Save" button to complete the configuration of the business identifier dimension. On the "Add / Edit Business Identifier" page, click the "Add Field" button to pop up the Figure 5 In the "Add / Edit Field" window, enter the corresponding relationship between the display field and the component field (i.e., return field) used inside the server, and click the "Save" button to complete the field configuration and close the window automatically. This completes the data conversion information configuration.

[0060] Click the "Publish" button on the "Data Conversion Configuration" page to check whether there is duplicate data in the business ID. After the check is passed, the configured data conversion information is saved to the database. After successful saving, the data conversion information is stored in the Redis cache in the form of a map, where the key (key name) is the business ID and the value (key value) is the corresponding relationship between the display field and the return field. When you need to query data conversion information, you can enter the business ID in the search box on the "Data Conversion Configuration" page and click the "Search" button to query the corresponding value.

[0061] Figure 6 is a schematic diagram of a component call graph configuration page according to an embodiment of the present invention. Figure 7 This is a schematic diagram of a new / edit call map page according to an embodiment of the present invention. Figure 1 , Figure 8 This is a schematic diagram of a new / edit call map page according to an embodiment of the present invention. Figure 2 .

[0062] See also Figure 6 , click the "Add Image" button on the "Component Call Graph Configuration" page to pop up Figure 7 , Figure 8The "Add / Edit Call Graph" page is shown. Enter the business ID, graph name, and component call relationship graph (i.e., display the component call relationship in graphical form) on this page, and click the "Save" button to complete the component call relationship configuration.

[0063] After clicking the "Save" button, the embodiment will check whether there is duplicate data in the business identifier. After the verification is passed, the configured data will be saved to the database. After successful saving, the data is stored in the Redis cache in the form of a map, where the key is the business identifier and the value is the component call relationship map. When you need to query the component call relationship map, you can enter the business identifier in the search box on the "Component Call Map Configuration" page, and click the "Search" button to query the corresponding value.

[0064] Understandably, Figure 7 , Figure 8 The component call relationship diagram in the rectangular frame and flowchart style is only for the convenience of display. In the embodiment, the component call relationship diagram is implemented by a string in JSON format. The specific implementation code can be as follows:

[0065]

[0066]

[0067] The above code uses the business scenario of "querying user information" as an example to illustrate the component call relationship map. In the code, "componentClassName" is the component name, "startComponent" is the start component identifier (indicates whether the component is the start component), "reUseResult" is the data reuse identifier (indicates whether to reuse the call result of the previous component), and "nextComponents" is the next component to be called by the component.

[0068] The component call relationship graph corresponding to this code includes three components, namely queryNameComponent, queryAgeComponent and convertDateComponent. Among them, queryNameComponent and convertDateComponent are the starting components, and all three components can reuse the call results of the previous components. The next component to be called by queryNameComponent and queryAgeComponent is convertDateComponent.

[0069] When a service request is received, the corresponding component call relationship map and data conversion information can be pulled from the cache according to the service identifier carried in the service request, and the component call relationship map in the JSON string format can be parsed into a Java object for internal use by the server. In an embodiment, toolkits such as fastJson and jackJson can be used to parse the JSON string. The parsed component call relationship map can be stored in a Java collection.

[0070] Step S202: Detect components in the parsed component call relationship. This step is used to detect components in the component call relationship in the Java object format. In the embodiment, some business methods are extracted from the original business method set of the business to form components. Each component includes one or more business methods, which are encapsulated from the original business methods (for the purpose of being managed by the Spring framework), and can independently implement business functions. There is no call to other components within each component, so as to reduce the coupling between business modules.

[0071] For example, if you need to query order details, you can abstract the queryOrderInfo method for querying order details into the orderInfoComponent component for querying order details. For another example, if you need to query the shipping track in addition to obtaining order details, you can extract the queryOrderInfo method for querying order details and the queryOrderTrack method for querying the shipping track into the same component. The specific methods to be extracted depend on the business scenario, but the extracted components must be universal, that is, they can be used in other business scenarios in addition to being used in this business scenario.

[0072] In an optional embodiment, the detection may include one or more of circular dependency detection, component reachability analysis, component existence detection, component duplication detection, and mandatory information detection. Various detections are described in detail below.

[0073] (1) Circular dependency detection is used to detect whether there is a circular dependency between the calls of components. If there is no circular dependency, the circular dependency detection passes; otherwise, the circular dependency detection fails.

[0074] For example, the component call relationship is: Component A → Component B → Component C → Component A. “→” indicates a call. From the above component call relationship, we can see that the call starts from component A and ends at component A, resulting in an infinite call loop, which prevents users from getting server responses. For the specific implementation of circular dependency detection, see Fig. 9 .

[0075] (2) Component reachability analysis is used to detect whether there are unreachable components. If all components included in the component call relationship are reachable, the component reachability analysis passes; if there are unreachable components, the component reachability analysis fails.

[0076] For example, the component call relationship is: component A → component B → component C, component D → component E, and the call starts from component A. From the component call relationship, it can be seen that since there is no call relationship between component C and component D, the call cannot reach component D and component E. Component D and component E are unreachable components. For the specific implementation of component reachability analysis, see Fig.10 .

[0077] (3) Component existence detection is used to detect whether there is a component instance corresponding to the component in the component pool. The specific implementation of this detection can be: according to the component name, the corresponding component instance is obtained from the component pool. If the component instance can be obtained, it means that the component exists and the component existence detection passes; otherwise, it means that the component does not exist and the component existence detection fails.

[0078] (4) Component duplication detection is used to detect whether there are identical components in the component call relationship. The specific implementation of this detection can be: determine whether there are components with the same component name in the component call relationship graph. If there are components with the same component name, it means that there are duplicate components, the component duplication detection fails, and a duplicate prompt can be returned; otherwise, it means that there are no duplicate components and the component duplication detection passes.

[0079] (5) Required information detection is used to detect whether the component call relationship includes the set required information. Since the component name is required when obtaining the component instance, the component name in the component call relationship is required information. Moreover, the starting component as the call entry is also required information. In the embodiment, this detection detects whether the component call relationship includes the component name and the starting component. If these two items are included, the required information detection passes; otherwise, the required information detection fails.

[0080] Step S203: After the detection is passed, the component instance corresponding to the component is obtained from the component pool, and the call dependency relationship of the component instance is generated according to the component call relationship. In the embodiment, all components (Java classes) inherit from the abstract class (AbstractWorker class). The AbstractWorker class abstracts the properties and methods common to all types of workers. This process facilitates the subsequent use of unified logic to scan all components, and all components have common methods and properties, which facilitates unified management and avoids repeated writing of the same properties and methods.

[0081] After the application is started, the Java virtual machine will create a corresponding Java instance based on the .class file compiled by the compiler. During the instantiation process, the AOP aspect scan of the Spring framework can be used to determine whether the parent class of the class is the AbstractWorker class. If its parent class is the AbstractWorker class, the class is added to the component pool. In the embodiment, the component pool is a map collection, the key is the component name, and the value is the corresponding component instance. A component instance refers to an instance of a Java class.

[0082] Among them, Spring framework is an application framework. AOP is the abbreviation of Aspect Oriented Programming, which means: aspect-oriented programming. It is a technology that dynamically and uniformly adds functions to the program without modifying the source code through pre-compilation and dynamic proxy during runtime.

[0083] After all tests are passed, the corresponding component instance is obtained from the component pool according to the component name. Then, the calling dependency of the component instance is dynamically generated according to the component calling relationship. That is, the actual dependency relationship at the code level is generated. For specific implementation, see Fig.11 .

[0084] Step S204: According to the calling dependency, the component instance is called to process the business request and obtain the processing result. According to the actual calling dependency, the calling is executed in sequence. When there are multiple starting components, the starting components are called in parallel and the processing result is obtained after the execution is completed.

[0085] In a preferred embodiment, during the execution process, it can be determined whether to call the component again to obtain data (provided that the data required by the current component exists in the previous component) according to the data reuse flag (reUseResult) in the call dependency relationship. If reUseResult is true, the data obtained by the previous request is used and no additional request is sent; otherwise, a request to obtain data is sent to the interface.

[0086] Specifically, according to the calling dependency, determine the reUseResult of the current component instance to be called; if reUseResult is true, input the data obtained by the previous call to the current component instance into the next component instance; otherwise, call the current component instance and input the returned data into the next component instance; update the next component instance to the current component instance, and repeat the process until the last component instance to complete the processing of the business request.

[0087] Step S205: According to the data conversion information, the return field of the processing result is converted into the corresponding display field, the data conversion result is obtained, and the data conversion result is displayed. This step is used to convert the return field of the processing result into the corresponding display field according to the configured data conversion information. Specifically, the component fields of the component objects in the server are traversed, and according to the corresponding relationship between the display field and the component field, the component field of the server is converted into the display field, and finally the data conversion result is returned to the user.

[0088] Fig. 9 FIG. 1 is a schematic diagram of the main flow of detecting circular dependencies of components according to an embodiment of the present invention. Fig. 9 As shown, the process of detecting circular dependencies of components in the embodiment of the present invention mainly includes the following steps:

[0089] Step S901: Get the starting component from the component call relationship and initialize the component detection set. Get the component with reUseResult of true from the component call relationship as the starting component, and initialize the component detection set to an empty set. If there are multiple starting components, each starting component is executed in parallel.

[0090] After obtaining the starting component, start from the starting component and traverse the components according to the component call relationship. Perform the following processing on the traversed components.

[0091] Step S902: Determine whether the current component exists in the component detection set, if the current component does not exist in the component detection set, execute step S903; otherwise, execute step S905. The initial value of the current component is the starting component.

[0092] Step S903: Add the current component to the component detection set.

[0093] Step S904: According to the component calling relationship, determine whether the current component has a next component to be called, update the next component to the current component, and execute step S902. According to the component calling relationship, determine whether nextComponents exists in the component information of the current component. If so, it means that the current component has a next component.

[0094] Step S905: Output the detection result. Assuming that after multiple cycles, the components included in the component detection set are: component A, component B, component C, and the next component called by component C is component A, it means that there is a circular dependency, and a prompt message indicating that the circular dependency detection failed can be output. At the same time, starting from the first component in the component detection set, the existing ring link A→B→C→A can be output.

[0095] It is understandable that if the current component does not exist in the component detection set, and the current component does not have a next component to be called, it means that there is no circular dependency, and a prompt message indicating that the circular dependency detection has passed can be output.

[0096] Fig.10 FIG. 1 is a schematic diagram of the main process of performing component reachability analysis on a component according to an embodiment of the present invention. Fig.10 As shown, the process of performing component reachability analysis on a component in an embodiment of the present invention mainly includes the following steps:

[0097] Step S1001: Get the starting component from the component call relationship and initialize the component reachable set. Get the component with reUseResult as true from the component call relationship as the starting component, and initialize the component reachable set to an empty set. If there are multiple starting components, each starting component is executed in parallel.

[0098] After obtaining the starting component, start from the starting component and traverse the components according to the component call relationship. Perform the following processing on the traversed components.

[0099] Step S1002: Add the current component to the component reachable set. The component added to the component reachable set may be called a reachable component.

[0100] Step S1003: Determine whether the current component has a next component to be called. If the current component has a next component to be called, execute step S1004; otherwise, execute step S1005. According to the component calling relationship, determine whether nextComponents exists in the component information of the current component. If so, it means that the current component has a next component.

[0101] Step S1004: Update the next component to the current component and execute step S1002.

[0102] Step S1005: Determine unreachable components. The unreachable components are the difference between the component set formed by the components in the component call relationship and the component reachable set.

[0103] Fig.11 FIG. 1 is a schematic diagram of the main flow of generating call dependency relationships in an embodiment of the present invention. Fig.11 As shown, the process of generating a call dependency relationship in the embodiment of the present invention mainly includes the following steps:

[0104] Step S1101: Obtain a starting component from the component call relationship, and add the starting component to the starting component set. Obtain a component with reUseResult being true from the component call relationship as the starting component, and add the starting component to the starting component set.

[0105] Step S1102: traverse the starting component of the starting component set, and use the traversed starting component as the current component.

[0106] Step S1103: According to the component name of the current component, obtain the corresponding component instance, set the parameter information of the component instance, and splice the component instance to the component instance obtained in the previous cycle. According to the component name of the current component, obtain the corresponding component instance from the component pool. Then, according to the component call relationship, configure the parameter information of the component instance. In the embodiment, the parameter information may include component input parameters, component name, data reuse identifier, etc.

[0107] The following is an example of the splicing process. Assuming that the component instance obtained from the component pool in the first cycle is instance A, and the component instance obtained from the component pool in the second cycle is instance B, instance B is spliced ​​after instance A.

[0108] Step S1104: Determine whether there is a next component for the current component. If there is a next component for the current component, execute step S1105; otherwise, execute step S1106. Determine whether there is nextComponents in the component information of the current component according to the component call relationship. If there is, it means that there is a next component for the current component.

[0109] Step S1105: Update the next component to the current component and execute step S1103.

[0110] Step S1106: Determine whether the traversal of the starting component of the starting component set has been completed. If the traversal has not been completed, execute step S1102; otherwise, execute step S1107.

[0111] Step S1107: Output the final splicing result as the calling dependency relationship of the component instance.

[0112] Fig.12 FIG. 1 is a schematic diagram of main modules of a device for processing a service request according to an embodiment of the present invention. Fig.12 As shown, the service request processing device 600 of the embodiment of the present invention mainly includes:

[0113] The acquisition module 1201 is used to receive a business request and acquire corresponding configuration information according to the business identifier carried in the business request. The configuration information is filled in for the business in advance on the configuration page, and the configuration information includes a component call relationship for recording the call relationship between components. In an embodiment, the component call relationship may include the component name, the starting component identifier and the next component called by the component of at least one component. After receiving the business request, the business identifier carried in the request is used to query the corresponding configuration information on the configuration page.

[0114] The generation module 1202 is used to query the component instance corresponding to the component in the component call relationship, and generate the call dependency relationship of the component instance according to the component call relationship. When the application is started, the components that inherit the abstract class are scanned, and the scanned components are added to the component pool with the component name as the key name and the component instance as the corresponding key value. The components are used to independently implement business functions, including business methods extracted from the business method set.

[0115] After obtaining the component call relationship, add the starting component contained in the component call relationship to the starting component collection, and then traverse the starting component collection. Each time a starting component is traversed, the corresponding component instance is obtained from the component pool according to the component name of the current component, and the parameter information of the component instance is set. Then, the next component of the current component is obtained, and the component instance of the next component is obtained in the same way, and the parameter information of the component instance is set. After that, the component instance of the next component is spliced ​​to the component instance of the current component, and this process is repeated until all components are traversed. The final splicing result is the call dependency relationship.

[0116] The processing module 1203 is used to call the component instance to process the business request according to the calling dependency relationship to obtain a processing result. Starting from the component instance of the starting component, each component instance is called and executed in sequence according to the calling dependency relationship. When there are multiple starting components, the starting components can be called in parallel to complete the processing of the business request and return the processing result.

[0117] In addition, the service request processing device 1200 of the embodiment of the present invention may also include: a detection module, a conversion module and a component pool construction module ( Fig.12 not shown).

[0118] A detection module is used to detect components in the component calling relationship; wherein the detection includes one or more of circular dependency detection, component reachability analysis, component existence detection, component duplication detection and mandatory information detection; the circular dependency detection is used to detect whether there is a circular dependency in the calls between the components, the component reachability analysis is used to detect whether there is an unreachable component, the component existence detection is used to detect whether there is a component instance corresponding to the component, the component duplication detection is used to detect whether there is the same component in the component calling relationship, and the mandatory information detection is used to detect whether the component calling relationship includes the set mandatory information.

[0119] The conversion module is used to convert the return field of the processing result into the corresponding display field according to the data conversion information, obtain the data conversion result, and display the data conversion result. The component pool construction module is used to scan the components that inherit the abstract class; using the component name as the key name and the component instance as the corresponding key value, the scanned components are added to the component pool.

[0120] From the above description, it can be seen that by extracting business methods into components that can independently implement business functions and configuring component calling relationships, the calling dependency relationships of component instances can be automatically generated based on the component calling relationships, thus achieving modular development and reducing the coupling between business modules. At the same time, it simplifies the development process and improves development efficiency.

[0121] Fig.13 An exemplary system architecture 1300 is shown to which the method for processing a service request or the apparatus for processing a service request according to the embodiment of the present invention can be applied.

[0122] like Fig.13 As shown, system architecture 1300 may include terminal devices 1301, 1302, 1303, network 1304 and server 1305. Network 1304 is used to provide a medium for communication links between terminal devices 1301, 1302, 1303 and server 1305. Network 1304 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0123] Users can use terminal devices 1301, 1302, 1303 to interact with server 1305 through network 1304 to receive or send messages, etc. Terminal devices 1301, 1302, 1303 can be various electronic devices with display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, etc.

[0124] The server 1305 may be a server that provides various services, such as a background management server that processes business requests sent by administrators using the terminal devices 1301, 1302, and 1303. The background management server may obtain configuration information, query component instances, generate call dependencies, process business requests, and feed back processing results to the terminal devices.

[0125] It should be noted that the method for processing the business request provided in the embodiment of the present application is generally executed by the server 1305 , and accordingly, the processing device for the business request is generally set in the server 1305 .

[0126] It should be understood that Fig.13The 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.

[0127] According to an embodiment of the present invention, the present invention also provides an electronic device and a computer-readable medium.

[0128] The electronic device of the present invention comprises: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement a method for processing a business request of an embodiment of the present invention.

[0129] The computer-readable medium of the present invention stores a computer program thereon, and when the program is executed by a processor, a method for processing a service request of an embodiment of the present invention is implemented.

[0130] Reference below Fig.14 , which shows a schematic diagram of the structure of a computer system 1400 suitable for implementing an electronic device of an embodiment of the present invention. Fig.14 The electronic 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.

[0131] like Fig.14 As shown, the computer system 1400 includes a central processing unit (CPU) 1401, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1402 or a program loaded from a storage part 1408 into a random access memory (RAM) 1403. In the RAM 1403, various programs and data required for the operation of the computer system 1400 are also stored. The CPU 1401, the ROM 1402, and the RAM 1403 are connected to each other via a bus 1404. An input / output (I / O) interface 1405 is also connected to the bus 1404.

[0132] The following components are connected to the I / O interface 1405: an input section 1406 including a keyboard, a mouse, etc.; an output section 1407 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1408 including a hard disk, etc.; and a communication section 1409 including a network interface card such as a LAN card, a modem, etc. The communication section 1409 performs communication processing via a network such as the Internet. A drive 1410 is also connected to the I / O interface 1405 as needed. A removable medium 1411, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1410 as needed, so that a computer program read therefrom is installed into the storage section 1408 as needed.

[0133] In particular, according to the embodiments disclosed in the present invention, the process described in the main step diagram above 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 main step diagram. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 1409, and / or installed from the removable medium 1411. When the computer program is executed by the central processing unit (CPU) 1401, the above-mentioned functions defined in the system of the present invention are executed.

[0134] 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.

[0135] 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.

[0136] The modules involved in the embodiments of the present invention may be implemented by software or hardware. The modules described may also be set in a processor, for example, it may be described as: a processor includes an acquisition module, a generation module and a processing module. The names of these modules do not constitute a limitation on the modules themselves in some cases, for example, the acquisition module may also be described as "a module that receives a service request and obtains corresponding configuration information according to the service identifier carried in the service request".

[0137] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs. When the above one or more programs are executed by a device, the device includes: receiving a business request, and obtaining corresponding configuration information according to the business identifier carried in the business request; wherein the configuration information includes a component call relationship; querying the component instance corresponding to the component in the component call relationship, and generating a call dependency relationship of the component instance according to the component call relationship; wherein the component is used to independently implement business functions, including business methods extracted from a business method set; according to the call dependency relationship, calling the component instance to process the business request to obtain a processing result.

[0138] The above product 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.

[0139] 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 processing a service request, characterized in that: include: Receive a service request, and acquire corresponding configuration information according to the service identifier carried in the service request; wherein the configuration information includes a component calling relationship; Query the component instance corresponding to the component in the component call relationship, and generate the call dependency relationship of the component instance according to the component call relationship, including: traversing the starting component of the starting component set, taking the traversed starting component as the current component, obtaining the corresponding component instance according to the component name of the current component, setting the parameter information of the component instance, splicing the component instance to the component instance obtained in the previous cycle, and taking the final splicing result as the call dependency relationship of the component instance after the traversal is completed; wherein the component is used to independently realize the business function, including the business method extracted from the business method set; According to the calling dependency, the component instance is called to process the business request to obtain a processing result.

2. The method according to claim 1, characterized in that The component calling relationship includes a component name of at least one component, a starting component identifier, and a next component called by the component; The querying of the component instance corresponding to the component in the component calling relationship and generating the calling dependency relationship of the component instance according to the component calling relationship includes: Adding a starting component to a starting component set; wherein the starting component is a component for which the starting component identifier is true; Traverse the starting components of the starting component set, perform the following processing on the traversed starting components until the traversal is completed, and use the final splicing result as the calling dependency of the component instance: Acquisition and setting step: according to the component name of the current component, obtain the corresponding component instance, set the parameter information of the component instance, and splice the component instance after the component instance obtained in the previous cycle; wherein the initial value of the current component is the starting component; Loop processing step: determine whether the current component has a next component. If the current component has the next component, update the next component to the current component, repeat the acquisition and setting step and the loop processing step until the current component does not have the next component, and obtain the splicing result.

3. The method according to claim 1, characterized in that After the step of obtaining the corresponding configuration information, the method further includes: Detecting the components in the component call relationship; wherein the detection includes one or more of circular dependency detection, component reachability analysis, component existence detection, component duplication detection, and required information detection; The circular dependency detection is used to detect whether there is a circular dependency in the calls between the components, the component reachability analysis is used to detect whether there is an unreachable component, the component existence detection is used to detect whether there is a component instance corresponding to the component, the component duplication detection is used to detect whether the same component exists in the component calling relationship, and the mandatory information detection is used to detect whether the component calling relationship includes the set mandatory information.

4. The method according to claim 3, characterized in that The component calling relationship includes a component name of at least one component, a starting component identifier, and a next component called by the component; Performing circular dependency detection on components in the component call relationship includes: Obtaining a starting component from the component call relationship and initializing a component detection set; wherein the starting component is a component whose starting component identifier is true; Determine processing step: determine whether the current component exists in the component detection set, and if the current component does not exist in the component detection set, add the current component to the component detection set; wherein the initial value of the current component is the starting component; Determine the update step: determine whether the current component has a next component to be called, update the next component to the current component, repeat the judgment processing step and the determine the update step until the current component exists in the component detection set, or the current component does not have a next component to be called, and output the detection result.

5. The method according to claim 3, characterized in that: The component calling relationship includes a component name of at least one component, a starting component identifier, and a next component called by the component; Performing component reachability analysis on the components in the component call relationship, including: Acquire a starting component from the component call relationship; wherein the starting component is a component whose starting component identifier is true; Add the current component to the component reachable set, determine whether the current component has a next component to be called, if the current component has a next component to be called, update the next component to the current component, repeat this step until the current component does not have a next component to be called, and determine the unreachable component; The initial value of the current component is the starting component, and the unreachable component is the difference between the component set formed by the components in the component calling relationship and the component reachable set.

6. The method according to claim 2, characterized in that The parameter information includes a data multiplexing identifier; The calling the component instance to process the service request according to the calling dependency relationship includes: Determine the data reuse identifier of the current component instance to be called according to the calling dependency relationship; If the data reuse flag is true, the data obtained by calling the current component instance before is input into the next component instance; if the data reuse flag is false, the current component instance is called and the returned data is input into the next component instance; The next component instance is updated to the current component instance, and the above steps are repeated until the last component instance is reached, thereby completing the processing of the service request.

7. The method according to claim 1, characterized in that The configuration information also includes data conversion information, and the data conversion information is used to record the corresponding relationship between the display field and the return field of the processing result; The method further includes: converting the return field of the processing result into a corresponding display field according to the data conversion information, obtaining a data conversion result, and displaying the data conversion result.

8. The method according to claim 1, characterized in that The method further comprises: Scan components that inherit abstract classes; The component name is used as the key name and the component instance is used as the corresponding key value, and the scanned component is added to the component pool.

9. A service request processing device, characterized in that: include: An acquisition module, used to receive a service request, and acquire corresponding configuration information according to the service identifier carried in the service request; wherein the configuration information includes a component call relationship; A generation module is used to query the component instance corresponding to the component in the component call relationship, and generate the call dependency relationship of the component instance according to the component call relationship, including: traversing the starting component of the starting component set, taking the traversed starting component as the current component, obtaining the corresponding component instance according to the component name of the current component, setting the parameter information of the component instance, splicing the component instance to the component instance obtained in the previous cycle, and taking the final splicing result as the call dependency relationship of the component instance after the traversal is completed; wherein, the component is used to independently realize the business function, including the business method extracted from the business method set; The processing module is used to call the component instance to process the business request according to the calling dependency relationship to obtain a processing result.

10. 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 8.

11. 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 8 is implemented.