A method and apparatus for processing a request

By intercepting and matching the interface switching identifier of the business type code, the target interface instance name is generated, which solves the problems of domain layer changes and hard-coded forwarding logic caused by business interface access in the existing technology, and realizes flexible expansion and efficient processing of the program.

CN116701499BActive Publication Date: 2026-03-17BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-25
Publication Date
2026-03-17

AI Technical Summary

Technical Problem

In existing technologies, the domain layer needs to be changed when business interfaces are accessed, which violates the open/closed principle, and the hard-coded forwarding logic makes it impossible to flexibly adjust parameters or conditions.

Method used

By intercepting requests and matching the interface switching identifier corresponding to the business type code, the target interface instance name is generated, and the request is processed using the proxy interface. The mapping between the interface switching identifier and the interface instance name can be flexibly configured.

Benefits of technology

It improves the program's scalability and flexibility, reduces the workload for developers, and allows for seamless integration of new business interfaces without requiring attention to switching logic.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116701499B_ABST
    Figure CN116701499B_ABST
Patent Text Reader

Abstract

The application discloses a kind of processing request method and device, it is related to computer technical field.The specific embodiment of the method includes: intercepting current request and matching out the interface switching identifier corresponding to the service type code carried by the current request;The interface switching identifier is set to system context, and the current request is released, so that the current request accesses proxy interface;The interface switching identifier is obtained from the system context by the proxy interface, the target interface instance name corresponding to the interface switching identifier is generated, and then the target interface instance corresponding to the target interface instance name is matched out, so as to access the method of the target interface instance to process the current request.The embodiment can solve the technical problem that the parameter or condition of forwarding cannot be flexibly adjusted.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and more particularly to a method and apparatus for processing requests. Background Technology

[0002] When transforming existing business systems using BPaaS (Business Platform as a Service), similar business modules need to be merged, and a domain model that can adapt to all businesses needs to be extracted. Requests are passed according to the conventions of the domain model, and then processed uniformly by the domain service. In actual development, it has been found that, in order to improve the scalability of the program, the capabilities of the interfaces are further refined at the underlying level of the domain service based on different vertical business identities. Then, the intermediate results processed by the domain service are passed to the specific vertical business identity-refined interfaces for further processing. Currently, a common solution is for the upper-layer interface to judge and forward based on the input parameters.

[0003] In the process of realizing this invention, the inventors discovered at least the following problems in the prior art:

[0004] 1) Since the forwarding logic is in the domain layer, the domain layer has to be changed whenever a new business interface is connected, which violates the open / closed principle and increases the workload of developers.

[0005] 2) Due to the hard-coded forwarding logic, it is impossible to flexibly adjust the forwarding parameters or conditions. Summary of the Invention

[0006] In view of this, embodiments of the present invention provide a method and apparatus for processing requests to solve the technical problem of the inability to flexibly adjust the parameters or conditions of forwarding.

[0007] To achieve the above objectives, according to one aspect of the present invention, a method for processing a request is provided, comprising:

[0008] Intercept the current request and match the interface switching identifier corresponding to the business type code carried by the current request;

[0009] Set the interface switching flag to the system context and allow the current request to access the proxy interface;

[0010] The proxy interface obtains the interface switching identifier from the system context, generates the target interface instance name corresponding to the interface switching identifier, and then matches the target interface instance corresponding to the target interface instance name to access the target interface instance to process the current request.

[0011] Optionally, intercepting the current request and matching the interface switching identifier corresponding to the business type code carried in the current request includes:

[0012] Based on aspect-based interception of the current request, determine whether the current request meets the interception conditions;

[0013] If not, allow the current request and access the method of the interface instance corresponding to the current request to process the current request;

[0014] If so, the current request is parsed to match the interface switching identifier corresponding to the business type code carried in the current request.

[0015] Optionally, the current request is parsed to match the interface switching identifier corresponding to the business type code carried in the current request, including:

[0016] Parse the input parameters carried in the current request and determine whether the input parameters are empty;

[0017] If so, then throw an error for the current request;

[0018] If not, the business type code is obtained from the input parameters, and the interface switching identifier corresponding to the business type code is matched.

[0019] Optionally, a business type code is obtained from the input parameters, and the interface switching identifier corresponding to the business type code is matched, including:

[0020] Obtain the business type code from the input parameters and determine whether the business type code is empty;

[0021] If so, then throw an error for the current request;

[0022] If not, the interface switching identifier corresponding to the business type code is matched from the configuration center.

[0023] Optionally, before intercepting the current request and matching the interface switching identifier corresponding to the business type code carried by the current request, the method further includes:

[0024] Add custom annotations to each interface instance;

[0025] Retrieve instances of each interface that have been annotated with custom annotations;

[0026] Place each of the interface instances into a utility class and expose the instance matching interface to the outside world.

[0027] Optionally, generating the target interface instance name corresponding to the interface switching identifier includes:

[0028] Assemble the target interface instance name based on the interface switching identifier and system identifier.

[0029] Optionally, matching the target interface instance corresponding to the target interface instance name includes:

[0030] The instance matching interface is invoked to match the target interface instance corresponding to the target interface instance name in the utility class.

[0031] Optionally, before intercepting the current request and matching the interface switching identifier corresponding to the business type code carried by the current request, the method further includes:

[0032] Dynamically configure the interface switching identifier corresponding to each business type code in the configuration center.

[0033] Additionally, according to another aspect of the present invention, an apparatus for processing a request is provided, comprising:

[0034] The interception module is used to intercept the current request and match the interface switching identifier corresponding to the business type code carried by the current request;

[0035] The proxy module is used to set the interface switching identifier in the system context and allow the current request to access the proxy interface.

[0036] The processing module is configured to obtain the interface switching identifier from the system context through the proxy interface, generate the target interface instance name corresponding to the interface switching identifier, and then match the target interface instance corresponding to the target interface instance name to access the target interface instance to process the current request.

[0037] Optionally, the interception module is further configured to:

[0038] Based on aspect-based interception of the current request, determine whether the current request meets the interception conditions;

[0039] If not, allow the current request and access the method of the interface instance corresponding to the current request to process the current request;

[0040] If so, the current request is parsed to match the interface switching identifier corresponding to the business type code carried in the current request.

[0041] Optionally, the interception module is further configured to:

[0042] Parse the input parameters carried in the current request and determine whether the input parameters are empty;

[0043] If so, then throw an error for the current request;

[0044] If not, the business type code is obtained from the input parameters, and the interface switching identifier corresponding to the business type code is matched.

[0045] Optionally, the interception module is further configured to:

[0046] Obtain the business type code from the input parameters and determine whether the business type code is empty;

[0047] If so, then throw an error for the current request;

[0048] If not, the interface switching identifier corresponding to the business type code is matched from the configuration center.

[0049] Optionally, it also includes an annotation module for:

[0050] Before intercepting the current request and matching the interface switching identifier corresponding to the business type code carried by the current request, add custom annotations to each interface instance;

[0051] Retrieve instances of each interface that have been annotated with custom annotations;

[0052] Place each of the interface instances into a utility class and expose the instance matching interface to the outside world.

[0053] Optionally, the processing module is further configured to:

[0054] Assemble the target interface instance name based on the interface switching identifier and system identifier.

[0055] Optionally, the processing module is further configured to:

[0056] The instance matching interface is invoked to match the target interface instance corresponding to the target interface instance name in the utility class.

[0057] Optionally, a configuration module is also included for:

[0058] Before intercepting the current request and matching the interface switching identifier corresponding to the business type code carried by the current request, the interface switching identifier corresponding to each business type code is dynamically configured in the configuration center.

[0059] According to another aspect of the present invention, an electronic device is also provided, comprising:

[0060] One or more processors;

[0061] Storage device for storing one or more programs.

[0062] When the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any of the above embodiments.

[0063] According to another aspect of the present invention, a computer-readable medium is also provided, on which a computer program is stored, which, when executed by a processor, implements the methods described in any of the above embodiments.

[0064] One embodiment of the above invention has the following advantages or beneficial effects: Because it employs a method of first matching the interface switching identifier corresponding to the business type code, then generating the target interface instance name corresponding to the interface switching identifier, and subsequently matching the corresponding target interface instance to access the target interface instance to process the current request, it overcomes the technical problem in the prior art of not being able to flexibly adjust forwarding parameters or conditions. This embodiment of the invention, by flexibly configuring the correspondence between the interface switching identifier and the interface instance name, supports changes in switching parameters or conditions, improving program flexibility. Therefore, when a new business interface is accessed, only the business interface processing logic needs to be added; there is no need to focus on the switching logic, thereby reducing the workload of developers and improving the program's scalability.

[0065] The further effects of the aforementioned unconventional alternative methods will be explained below in conjunction with specific implementation methods. Attached Figure Description

[0066] The accompanying drawings are provided to better understand the invention and are not intended to unduly limit the scope of the invention. Wherein:

[0067] Figure 1 This is a schematic diagram of the main flow of a method for processing requests according to an embodiment of the present invention;

[0068] Figure 2 This is a schematic diagram of the main flow of a method for processing requests according to a possible embodiment of the present invention;

[0069] Figure 3 This is a schematic diagram of the main flow of a method for processing requests according to another applicable embodiment of the present invention;

[0070] Figure 4 This is a schematic diagram of the main modules of an apparatus for processing requests according to an embodiment of the present invention;

[0071] Figure 5 This is an exemplary system architecture diagram in which embodiments of the present invention can be applied;

[0072] Figure 6 This is a schematic diagram of the structure of a computer system suitable for implementing terminal devices or servers of the present invention. Detailed Implementation

[0073] The following description, in conjunction with the accompanying drawings, illustrates exemplary embodiments of the present invention, including various details to aid understanding. These details should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the invention. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.

[0074] Figure 1 This is a schematic diagram of the main flow of a method for processing requests according to an embodiment of the present invention. As one embodiment of the present invention, such as... Figure 1 As shown, the method for processing the request may include:

[0075] Step 101: Intercept the current request and match the interface switching identifier corresponding to the business type code carried by the current request.

[0076] This invention, in its embodiments, intercepts the current request sent from the front end based on aspects, and then matches the interface switching identifier corresponding to the business type code carried in the current request. Optionally, Spring's aspect framework can be used to intercept requests that need to be forwarded downwards, obtain the business type code in the request, and thus match the interface switching identifier corresponding to the business type code.

[0077] Optionally, before step 101, the method further includes: adding custom annotations to each interface instance; obtaining each interface instance with the added custom annotations; placing each interface instance into a utility class and exposing the instance matching interface. Adding custom annotations to each interface instance and placing it into the Spring IOC container serves to annotate the interface instances, facilitating subsequent steps by allowing the entire set of interface instances to be retrieved from the Spring context based on the annotation, thus simplifying adaptation. After adding custom annotations to the interface instances, the program will register the interface instances with the Spring container for unified management upon startup. After the Spring container initializes, it injects the Spring context environment into the interface instance (Bean) that implements ApplicationContextAware. Then, it retrieves all interface instances with added custom annotations from the Spring IOC container within this Bean. These interface instances with added custom annotations are then placed into a utility class, such as a local static variable. This variable set becomes the interface instance switching pool, and all interface instances to be switched are adapted from this switching pool.

[0078] Spring is an open-source Java framework. The Spring IOC container—Inversion of Control—is a design philosophy. In Java development, Spring IOC means entrusting the control of pre-designed objects to the container, rather than directly controlling them internally. The Spring IOC container reads configuration metadata from configuration files and uses this metadata to instantiate and assemble various objects in the application. Generally, XML configuration files are used for metadata configuration, and because Spring is completely decoupled from configuration files, any other possible method can be used for metadata configuration, such as annotations, Javafile-based configuration, or property file-based configuration. Objects managed by the IOC container are called Beans; Beans are objects initialized, assembled, and managed by the Spring container.

[0079] It should be noted that the purpose of exposing the instance matching interface is to facilitate the matching of the target interface instance from the utility class. By calling the instance matching interface, the target interface instance corresponding to the target interface instance name can be matched in the utility class.

[0080] To flexibly adjust forwarding parameters or conditions, the mapping between business type codes and interface switching identifiers can be configured through a configuration center. Optionally, before step 101, the following steps are also included: dynamically configuring the interface switching identifiers corresponding to each business type code in the configuration center. Business type codes serve two main purposes: first, to provide a unified input to the caller; and second, to facilitate the configuration of interface switching identifiers corresponding to each business type code in the configuration center (e.g., Ducc). In subsequent adaptation steps, the interface switching identifier can be used to directly generate the corresponding interface instance name (BeanName), and then the interface instance name can be used to adapt the interface instance forwarded downwards.

[0081] It should be noted that operations and maintenance personnel can dynamically configure the interface switching identifiers corresponding to each service type code in the configuration center, and can modify the configuration information at any step in this embodiment of the invention to achieve dynamic configuration, thereby flexibly adjusting the forwarding parameters or conditions.

[0082] Optionally, step 101 may include: intercepting the current request based on aspect ratios, determining whether the current request meets the interception conditions; if not, allowing the current request and accessing the method of the interface instance corresponding to the current request to process the current request; if yes, parsing the current request to match the interface switching identifier corresponding to the business type code carried by the current request. In this embodiment of the invention, after intercepting the current request, it is first determined whether the current request meets the interception conditions. If the interception conditions are not met, the current request is allowed, and the method of the interface instance corresponding to the current request is accessed to process the current request; if the interception conditions are met, the current request is parsed to obtain the business type code carried in the request, and then the interface switching identifier corresponding to the business type code is matched.

[0083] Optionally, parsing the current request to match the interface switching identifier corresponding to the business type code carried by the current request includes: parsing the input parameters carried by the current request and determining whether the input parameters are empty; if so, throwing an error for the current request; if not, obtaining the business type code from the input parameters and matching the interface switching identifier corresponding to the business type code. After parsing the input parameters carried by the current request, determining whether the input parameters are empty means that the current request does not carry a business type code, and directly throwing an error for the current request; if the input parameters are not empty, obtaining the business type code from the input parameters and then matching the corresponding interface switching identifier based on the business type code. This can improve the efficiency of subsequent request processing and prevent requests without a business type code from flowing to subsequent steps.

[0084] Optionally, obtaining the business type code from the input parameters and matching the interface switching identifier corresponding to the business type code includes: obtaining the business type code from the input parameters and determining whether the business type code is empty; if so, throwing an error for the current request; if not, matching the interface switching identifier corresponding to the business type code from the configuration center. Even if the business type code is obtained from the input parameters, there is still a possibility that the business type code is empty. Therefore, after obtaining the business type code from the input parameters, it is determined whether the business type code is empty. If the business type code is empty, an error is thrown directly for the current request; if the business type code is not empty, the corresponding interface switching identifier is matched based on the business type code. This can improve the efficiency of subsequent request processing and avoid requests without a business type code from flowing to subsequent steps.

[0085] Step 102: Set the interface switching identifier in the system context and allow the current request to access the proxy interface.

[0086] After matching the interface switching identifier corresponding to the business type code from the configuration center, the interface switching identifier is set in the system context, and then the current request is allowed to access the proxy interface. In this embodiment of the invention, the system context can be understood as a public container in a system, which can be used to set and retrieve values ​​between multiple threads.

[0087] Step 103: Obtain the interface switching identifier from the system context through the proxy interface, generate the target interface instance name corresponding to the interface switching identifier, and then match the target interface instance corresponding to the target interface instance name to access the target interface instance to process the current request.

[0088] After completing step 102, the proxy forwarding phase begins. The proxy interface obtains the interface switching identifier from the system context, and then generates the name (BeanName) of the corresponding target interface instance based on the interface switching identifier. Next, it retrieves the interface instance to be forwarded (i.e., the downstream interface instance) from the utility class based on the name of the target interface instance, and performs the call processing to handle the current request.

[0089] Optionally, generating the target interface instance name corresponding to the interface switching identifier includes assembling the target interface instance name based on the interface switching identifier and the system identifier. To distinguish different systems, the interface switching identifier and the system identifier can be assembled together to generate the target interface instance name, and then the target interface instance can be matched from the utility class based on this name.

[0090] Optionally, matching the target interface instance corresponding to the target interface instance name includes: calling the instance matching interface to match the target interface instance corresponding to the target interface instance name in the utility class. Since the instance matching interface is exposed externally, the target interface instance corresponding to the target interface instance name can be quickly matched in the utility class by calling the instance matching interface.

[0091] Based on the various embodiments described above, it can be seen that the present invention solves the technical problem in the prior art of not being able to flexibly adjust forwarding parameters or conditions by first matching the interface switching identifier corresponding to the business type code, then generating the target interface instance name corresponding to the interface switching identifier, and then matching the corresponding target interface instance to access the target interface instance to process the current request. The present invention, by flexibly configuring the correspondence between the interface switching identifier and the interface instance name, supports changes in switching parameters or conditions, improving program flexibility. Therefore, when a new business interface is accessed, only the business interface processing logic needs to be added, without needing to concern oneself with the switching logic, thereby reducing the workload of developers and improving the program's scalability.

[0092] Figure 2 This is a schematic diagram of the main flow of a method for processing requests according to a possible embodiment of the present invention. As another embodiment of the present invention, such as... Figure 2 As shown, the method for processing the request may include:

[0093] Step 201: Add custom annotations to each interface instance.

[0094] Adding custom annotations to each interface instance and placing them into the Spring IOC container serves to annotate the interface instances. This allows subsequent steps to retrieve the entire collection of interface instances from the Spring context based on these annotations, facilitating adaptation. After adding custom annotations to the interface instances, the application will register the interface instances with the Spring container for unified management upon startup.

[0095] Step 202: Obtain the instances of each interface with added custom annotations.

[0096] After the Spring container is initialized, the Spring context environment is injected into the interface instance (Bean) that implements ApplicationContextAware, and then all interface instances with custom annotations added in the Spring IOC container are retrieved from that Bean.

[0097] Step 203: Place each interface instance into a utility class and expose the instance matching interface to the outside world.

[0098] Each interface instance with added custom annotations is placed in a utility class, such as a local static variable. This collection of variables becomes the interface instance switching pool, and all interface instances to be switched are adapted from this pool. The purpose of exposing the instance matching interface is to facilitate matching the target interface instance from the utility class. By calling this instance matching interface, the target interface instance corresponding to the target interface instance name can be matched in the utility class.

[0099] Step 204: Dynamically configure the interface switching identifier corresponding to each business type code in the configuration center.

[0100] To flexibly adjust forwarding parameters or conditions, the mapping between service type codes and interface switching identifiers can be configured through a configuration center. Service type codes serve two main purposes: first, to provide a unified input to the caller; and second, to facilitate configuring the interface switching identifiers corresponding to each service type code in the configuration center (e.g., Ducc). In subsequent adaptation steps, the interface switching identifier can be used to directly generate the corresponding interface instance name, which can then be used to adapt the interface instance forwarded downwards.

[0101] Operation and maintenance personnel can dynamically configure the interface switching identifier corresponding to each service type code in the configuration center. They can modify the configuration information at any step in this embodiment of the invention to achieve dynamic configuration and thus flexibly adjust the forwarding parameters or conditions.

[0102] Step 205: Intercept the current request and match the interface switching identifier corresponding to the business type code carried by the current request.

[0103] The system intercepts the current request sent from the front end based on aspect-oriented programming, and then matches the interface switching identifier corresponding to the business type code carried in the current request. In this embodiment of the invention, after intercepting the current request, it first determines whether the current request meets the interception conditions. If the interception conditions are not met, the current request is allowed, and the method of the interface instance corresponding to the current request is accessed to process the current request; if the interception conditions are met, the current request is parsed to obtain the business type code carried in the request, and then the interface switching identifier corresponding to the business type code is matched.

[0104] Step 206: Set the interface switching identifier in the system context and allow the current request to access the proxy interface.

[0105] After matching the interface switching identifier corresponding to the business type code from the configuration center, the interface switching identifier is set in the system context, and then the current request is allowed to access the proxy interface.

[0106] Step 207: Obtain the interface switching identifier from the system context through the proxy interface, and assemble the target interface instance name according to the interface switching identifier and the system identifier.

[0107] The proxy interface will obtain the interface switching identifier in the system context, and then generate the name (BeanName) of the corresponding target interface instance based on the interface switching identifier.

[0108] Step 208: Invoke the instance matching interface to match the target interface instance corresponding to the target interface instance name in the utility class, and then access the method of the target interface instance to process the current request.

[0109] Next, by calling the instance matching interface, the interface instance to be forwarded (i.e. the downstream interface instance) is obtained from the utility class according to the name of the target interface instance, and then the call processing is performed to handle the current request.

[0110] Furthermore, the specific implementation details of the request processing method in one of the reference embodiments of the present invention have been described in detail in the above-described request processing method, so the details will not be repeated here.

[0111] Figure 3 This is a schematic diagram of the main flow of a method for processing requests according to another possible embodiment of the present invention. As another embodiment of the present invention, such as... Figure 3 As shown, the method for processing the request may include:

[0112] After the Spring container initializes, the Spring context is injected into the interface instances that implement `ApplicationContextAware`. Custom annotations are added to each interface instance, and these instances are placed into the Spring IOC container. The purpose of this annotation is to mark the interface instances, making it easier to retrieve the entire set of interface instances from the Spring context in subsequent steps, facilitating adaptation. Next, the `ApplicationContextAware` implementation retrieves all interface instances with custom annotations from the Spring IOC container. These annotated interface instances are then placed into a utility class, such as a local static variable. This variable set becomes the interface instance switching pool, and all interface instances to be switched to are adapted from this pool. The purpose of exposing an instance matching interface is to facilitate matching the target interface instance from the utility class. By calling this instance matching interface, the target interface instance corresponding to the target interface instance name can be matched within the utility class.

[0113] Furthermore, to flexibly adjust forwarding parameters or conditions, the mapping between service type codes and interface switching identifiers can be configured through a configuration center (such as Ducc). Service type codes serve two main purposes: first, to provide a unified input to the caller; and second, to facilitate the configuration of interface switching identifiers corresponding to each service type code in the configuration center. During subsequent adaptation steps, the interface switching identifier can be used to directly generate the corresponding interface instance name, which can then be used to adapt the interface instance forwarded downwards. Operations personnel can dynamically configure the interface switching identifiers corresponding to each service type code in the configuration center, and can modify the configuration information at any step in this embodiment of the invention to achieve dynamic configuration, thereby flexibly adjusting forwarding parameters or conditions.

[0114] This invention, based on aspect-oriented programming, intercepts the current request transmitted from the front end and determines whether the current request meets the interception conditions. If the interception conditions are not met, the current request is allowed, and the method of the interface instance corresponding to the current request is accessed to process the current request. If the interception conditions are met, the input parameters carried by the current request are parsed, and it is determined whether the input parameters are empty. If the input parameters are empty, an error is thrown for the current request. If the input parameters are not empty, the business type code is obtained from the input parameters, and it is determined whether the business type code is empty. If the business type code is empty, an error is thrown for the current request. If the business type code is not empty, the interface switching identifier corresponding to the business type code is matched from the configuration center. By pre-determining whether the input parameters and business type code are empty, the efficiency of subsequent request processing can be improved, and requests without input parameters or business type codes can be prevented from flowing to subsequent steps.

[0115] After matching the interface switching identifier corresponding to the business type code from the configuration center, the interface switching identifier is set in the system context, and the current request is allowed to access the proxy interface.

[0116] Next, the proxy forwarding phase begins. The proxy interface obtains the interface switching identifier from the system context, then assembles the target interface instance name (BeanName) based on the interface switching identifier and the system identifier. It then calls the instance matching interface to match the target interface instance (i.e., the downstream interface instance) corresponding to the target interface instance name in the utility class, performs the call processing, and thus handles the current request. Because the instance matching interface is exposed externally, the target interface instance corresponding to the target interface instance name can be quickly matched in the utility class by calling the instance matching interface.

[0117] This invention provides a method for dynamically switching underlying interface request processing based on Spring aspects and an IOC container. This method uses custom annotations, aspects, and an IOC container to dynamically switch underlying interfaces, which can reduce the workload of developers and improve the extensibility and flexibility of the program.

[0118] Furthermore, the specific implementation details of the request processing method in another reference embodiment of the present invention have been described in detail in the above-described request processing method, so the details will not be repeated here.

[0119] Figure 4 This is a schematic diagram of the main modules of an apparatus for processing requests according to an embodiment of the present invention. Figure 4 As shown, the request processing device 400 includes an interception module 401, a proxy module 402, and a processing module 403. The interception module 401 intercepts the current request and matches the interface switching identifier corresponding to the service type code carried by the current request. The proxy module 402 sets the interface switching identifier in the system context and allows the current request to access the proxy interface. The processing module 403 obtains the interface switching identifier from the system context through the proxy interface, generates a target interface instance name corresponding to the interface switching identifier, and then matches the target interface instance corresponding to the target interface instance name to access the target interface instance to process the current request.

[0120] Optionally, the interception module 401 is further configured to:

[0121] Based on aspect-based interception of the current request, determine whether the current request meets the interception conditions;

[0122] If not, allow the current request and access the method of the interface instance corresponding to the current request to process the current request;

[0123] If so, the current request is parsed to match the interface switching identifier corresponding to the business type code carried in the current request.

[0124] Optionally, the interception module 401 is further configured to:

[0125] Parse the input parameters carried in the current request and determine whether the input parameters are empty;

[0126] If so, then throw an error for the current request;

[0127] If not, the business type code is obtained from the input parameters, and the interface switching identifier corresponding to the business type code is matched.

[0128] Optionally, the interception module 401 is further configured to:

[0129] Obtain the business type code from the input parameters and determine whether the business type code is empty;

[0130] If so, then throw an error for the current request;

[0131] If not, the interface switching identifier corresponding to the business type code is matched from the configuration center.

[0132] Optionally, it also includes an annotation module for:

[0133] Before intercepting the current request and matching the interface switching identifier corresponding to the business type code carried by the current request, add custom annotations to each interface instance;

[0134] Retrieve instances of each interface that have been annotated with custom annotations;

[0135] Place each of the interface instances into a utility class and expose the instance matching interface to the outside world.

[0136] Optionally, the processing module 403 is further configured to:

[0137] Assemble the target interface instance name based on the interface switching identifier and system identifier.

[0138] Optionally, the processing module 403 is further configured to:

[0139] The instance matching interface is invoked to match the target interface instance corresponding to the target interface instance name in the utility class.

[0140] Optionally, a configuration module is also included for:

[0141] Before intercepting the current request and matching the interface switching identifier corresponding to the business type code carried by the current request, the interface switching identifier corresponding to each business type code is dynamically configured in the configuration center.

[0142] Based on the various embodiments described above, it can be seen that the present invention solves the technical problem in the prior art of not being able to flexibly adjust forwarding parameters or conditions by first matching the interface switching identifier corresponding to the business type code, then generating the target interface instance name corresponding to the interface switching identifier, and then matching the corresponding target interface instance to access the target interface instance to process the current request. The present invention, by flexibly configuring the correspondence between the interface switching identifier and the interface instance name, supports changes in switching parameters or conditions, improving program flexibility. Therefore, when a new business interface is accessed, only the business interface processing logic needs to be added, without needing to concern oneself with the switching logic, thereby reducing the workload of developers and improving the program's scalability.

[0143] It should be noted that the specific implementation of the device for processing requests described in this invention has been described in detail in the method for processing requests described above, so the content will not be repeated here.

[0144] Figure 5 An exemplary system architecture 500 is shown, in which a method or apparatus for processing requests can be applied according to embodiments of the present invention.

[0145] like Figure 5 As shown, system architecture 500 may include terminal devices 501, 502, and 503, a network 504, and a server 505. Network 504 serves as the medium for providing communication links between terminal devices 501, 502, and 503 and server 505. Network 504 may include various connection types, such as wired or wireless communication links, or fiber optic cables, etc.

[0146] Users can use terminal devices 501, 502, and 503 to interact with server 505 via network 504 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 501, 502, and 503, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social media platform software, etc. (for example only).

[0147] Terminal devices 501, 502, and 503 can be various electronic devices with displays that support web browsing, including but not limited to smartphones, tablets, laptops, and desktop computers.

[0148] Server 505 can be a server that provides various services, such as a backend management server that supports shopping websites browsed by users using terminal devices 501, 502, and 503 (for example only). The backend management server can analyze and process data such as received item information query requests, and then feed the processing results back to the terminal devices.

[0149] It should be noted that the method for processing requests provided in the embodiments of the present invention is generally executed by server 505, and correspondingly, the device for processing requests is generally located in server 505.

[0150] It should be understood that Figure 5 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.

[0151] The following is for reference. Figure 6 It shows a schematic diagram of the structure of a computer system 600 suitable for implementing a terminal device of the present invention. Figure 6The terminal device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of the present invention.

[0152] like Figure 6 As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) 602 or programs loaded from storage section 608 into random access memory (RAM) 603. The RAM 603 also stores various programs and data required for the operation of the system 600. The CPU 601, ROM 602, and RAM 603 are interconnected via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0153] The following components are connected to I / O interface 605: an input section 606 including a keyboard, mouse, etc.; an output section 607 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to I / O interface 605 as needed. A removable medium 611, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on drive 610 as needed so that computer programs read from it can be installed into storage section 608 as needed.

[0154] In particular, according to the embodiments disclosed in this invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this invention include a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 609, and / or installed from removable medium 611. When the computer program is executed by central processing unit (CPU) 601, it performs the functions defined above in the system of this invention.

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

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

[0157] The modules described in the embodiments of the present invention can be implemented in software or hardware. The described modules can also be housed in a processor; for example, a processor can be described as including an interception module, a proxy module, and a processing module, wherein the names of these modules do not necessarily limit the module itself.

[0158] In another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiments; or it may exist independently and not assembled into the device. The computer-readable medium carries one or more programs, and when the one or more programs are executed by the device, the device implements the following method: intercepting a current request and matching an interface switching identifier corresponding to the service type code carried by the current request; setting the interface switching identifier in the system context, allowing the current request to access a proxy interface; obtaining the interface switching identifier from the system context through the proxy interface, generating a target interface instance name corresponding to the interface switching identifier, and then matching the target interface instance corresponding to the target interface instance name to access the target interface instance to process the current request.

[0159] According to the technical solution of this invention, by first matching the interface switching identifier corresponding to the business type code, then generating the target interface instance name corresponding to the interface switching identifier, and then matching the corresponding target interface instance to access the target interface instance to process the current request, the technical means overcome the technical problem in the prior art of not being able to flexibly adjust the forwarding parameters or conditions. This invention, by flexibly configuring the correspondence between the interface switching identifier and the interface instance name, supports changes in switching parameters or conditions, improving program flexibility. Therefore, when a new business interface is accessed, only the business interface processing logic needs to be added; there is no need to focus on the switching logic, thereby reducing the workload of developers and improving the program's scalability.

[0160] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can occur depending on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.

Claims

1. A method of processing a request, characterized by, The method comprises the following steps: intercepting a current request and matching an interface switching identifier corresponding to a service type code carried by the current request; configuring a correspondence between the service type code and the interface switching identifier through a configuration center; setting the interface switching identifier into a system context, and releasing the current request, so that the current request accesses a proxy interface; obtaining the interface switching identifier from the system context through the proxy interface, generating a target interface instance name corresponding to the interface switching identifier, and then matching a target interface instance corresponding to the target interface instance name, so as to access a method of the target interface instance to process the current request.

2. The method of claim 1, wherein, The method comprises the following steps: intercepting a current request and matching an interface switching identifier corresponding to a service type code carried by the current request, comprising: intercepting the current request based on an aspect, and determining whether the current request meets an interception condition; if not, releasing the current request, and accessing a method of an interface instance corresponding to the current request to process the current request; 3. The method of claim 2, wherein, if yes, parsing the current request, so as to match the interface switching identifier corresponding to the service type code carried by the current request. The method comprises the following steps: parsing an input parameter carried by the current request, and determining whether the input parameter is empty; if yes, throwing an error for the current request; 4. The method of claim 3, wherein, if not, obtaining a service type code from the input parameter, so as to match the interface switching identifier corresponding to the service type code. The method comprises the following steps: obtaining a service type code from the input parameter, and determining whether the service type code is empty; if yes, throwing an error for the current request; 5. The method of claim 1, wherein, if not, matching the interface switching identifier corresponding to the service type code from a configuration center. Before the step of intercepting a current request and matching an interface switching identifier corresponding to a service type code carried by the current request, the method further comprises the following steps: adding a custom annotation to each interface instance; obtaining the each interface instance to which the custom annotation is added; 6. The method of claim 5, wherein, putting the each interface instance into a tool class, and exposing an instance matching interface. The method comprises the following steps:

7. The method of claim 6, wherein, assembling a target interface instance name according to the interface switching identifier and a system identifier. The method comprises the following steps:

8. The method of claim 1, wherein, calling the instance matching interface, so as to match the target interface instance name corresponding to the target interface instance in the tool class. Before the step of intercepting a current request and matching an interface switching identifier corresponding to a service type code carried by the current request, the method further comprises the following step:

9. An apparatus for processing a request, the apparatus comprising: dynamically configuring an interface switching identifier corresponding to each service type code in a configuration center. The method comprises the following steps: an intercepting module, configured to intercept a current request and match an interface switching identifier corresponding to a service type code carried by the current request; configuring a correspondence between the service type code and the interface switching identifier through a configuration center; The agent module is configured to set the interface switching identifier into a system context, release the current request, and enable the current request to access an agent interface. The processing module is configured to acquire the interface switching identifier from the system context through the agent interface, generate a target interface instance name corresponding to the interface switching identifier, match a target interface instance corresponding to the target interface instance name, and access a method of the target interface instance to process the current request.

10. An electronic device, comprising: An apparatus comprising: one or more processors; a memory 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 of any one of claims 1-8.

11. A computer readable medium having stored thereon a computer program, characterized in that, The program is executed by the processor to implement the method of any one of claims 1-8.

Citation Information

Patent Citations

  • Method for bridging corporation level and common level JAVABEAN

    CN101158901A

  • Business processing method, adaptor, and computer readable storage medium

    CN107392766A