Service provider discovery method and apparatus based on level depth, and device and medium
By creating top-level interface classes in the container and setting up service-providing discovery annotations, and using a hierarchical depth search strategy, the problem that the SPI mechanism in the existing technology is not adapted according to the scenario, and the fine-grained division and adaptation of business scenarios is realized. Improves the efficiency and code decoupling of software development projects.
Patent Information
- Application Number
- PCT/CN2023/128081
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-05-04
- Filing Date
- 2023-10-31
- Publication Date
- 2024-11-07
AI Technical Summary
In the existing technology, when software development projects adopt SPI mechanism, each object adopts first-level adaptation and is implemented globally by default. It is not refined and adapted according to the scenario, resulting in a coarse granularity in business scenario division, low degree of customized adaptation, and code solution. Incomplete coupling and low efficiency.
By creating top-level interface classes in the container and creating multiple top-level interfaces based on business scenarios, setting up services to provide discovery annotations, using hierarchical depth search strategies to match target interfaces, and achieving fine-grained division and adaptation of business scenarios.
It realizes fine-grained division and adaptation of business scenarios, improves code decoupling and customized configuration capabilities, and improves the efficiency and accuracy of service discovery.
Smart Images

Figure CN2023128081_07112024_PF_FP_ABST
Abstract
Description
Hierarchical depth-based service provider discovery method, device, equipment, and medium
[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on May 4, 2023, with application number CN202310489951.9 and application name “Service provider discovery method, device, equipment and medium based on hierarchical depth”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of computer container technology, and in particular to a method, apparatus, device, and medium for discovering service provision based on hierarchical depth. Background Art
[0003] Currently, in specific software development projects, to isolate business scenarios and decouple code, developers need to separate business scenarios into multiple parent-child hierarchies and adopt default or further refined customized implementations for different scenarios. For example, if the software project being developed is an online fruit mall, when setting fruit prices, if apples and bananas have different pricing schemes, in addition to the default pricing scheme, apples may also need to be priced further based on characteristics such as origin and quality.
[0004] Moreover, in the above-mentioned fruit online mall project, the SPI mechanism (the full name of SPI is Service Provider Interface, which represents the service discovery mechanism) was adopted. The inventor realized that first-level adaptation was adopted for each product object such as apples and bananas, that is, a default implementation was adopted globally, and the default implementation logic was not refined for each product object such as apples and bananas.
[0005] The global default implementation of first-level adaptation has the following disadvantages:
[0006] 1) Failure to adapt to specific scenarios;
[0007] 2) Business scenario division is coarse-grained, customization and adaptation are low, and code decoupling is incomplete;
[0008] 3) Loading implementation during use is less efficient. Summary of the Invention
[0009] The embodiments of the present application provide a service provider discovery method, apparatus, device and medium based on hierarchical depth, aiming to solve the problem in the prior art that software development projects use the SPI mechanism to adopt first-level adaptation for each object and a global default implementation, without detailed adaptation according to the scenario and with a low degree of customized adaptation.
[0010] In a first aspect, an embodiment of the present application provides a method for discovering service provision based on hierarchical depth, which includes:
[0011] In response to a top-level interface class creation instruction, creating a top-level interface class corresponding to the top-level interface class creation instruction in a container;
[0012] Obtaining business scenario creation information, creating a corresponding number of top-level interfaces in the top-level interface class based on the business scenario creation information, and setting a service provider discovery annotation in each top-level interface; wherein the service provider discovery annotation of each top-level interface corresponds to one business scenario;
[0013] If a service provider discovery search parameter is detected, matching is performed in the top-level interface class based on the service provider discovery search parameter and a preset hierarchical depth search strategy to obtain a corresponding target top-level interface;
[0014] The data to be processed corresponding to the service provider discovery search parameter is obtained, and the data to be processed is processed based on the data processing strategy in the target top-level interface to obtain a processing result.
[0015] In a second aspect, an embodiment of the present application provides a service provider discovery device based on hierarchical depth, comprising:
[0016] A top-level interface class creation unit, configured to create a top-level interface class corresponding to the top-level interface class creation instruction in the container in response to the top-level interface class creation instruction;
[0017] An annotation injection unit is used to obtain business scenario creation information, create a corresponding number of top-level interfaces in the top-level interface class based on the business scenario creation information, and set a service provider discovery annotation in each top-level interface; wherein the service provider discovery annotation of each top-level interface corresponds to a business scenario;
[0018] A target interface search unit is configured to, if a service provider discovery search parameter is detected, match the service provider discovery search parameter and a preset hierarchical depth search strategy in the top-level interface class to obtain a corresponding target top-level interface;
[0019] The target interface processing unit is used to obtain the data to be processed corresponding to the service provider discovery search parameter, process the data to be processed based on the data processing strategy in the target top-level interface, and obtain a processing result.
[0020] In a third aspect, an embodiment of the present application further provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the following steps are implemented:
[0021] In response to a top-level interface class creation instruction, creating a top-level interface class corresponding to the top-level interface class creation instruction in a container;
[0022] Obtaining business scenario creation information, creating a corresponding number of top-level interfaces in the top-level interface class based on the business scenario creation information, and setting a service provider discovery annotation in each top-level interface; wherein the service provider discovery annotation of each top-level interface corresponds to one business scenario;
[0023] If a service provider discovery search parameter is detected, matching is performed in the top-level interface class based on the service provider discovery search parameter and a preset hierarchical depth search strategy to obtain a corresponding target top-level interface;
[0024] The data to be processed corresponding to the service provider discovery search parameter is obtained, and the data to be processed is processed based on the data processing strategy in the target top-level interface to obtain a processing result.
[0025] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor performs the following steps:
[0026] In response to a top-level interface class creation instruction, creating a top-level interface class corresponding to the top-level interface class creation instruction in a container;
[0027] Obtaining business scenario creation information, creating a corresponding number of top-level interfaces in the top-level interface class based on the business scenario creation information, and setting a service provider discovery annotation in each top-level interface; wherein the service provider discovery annotation of each top-level interface corresponds to one business scenario;
[0028] If a service provider discovery search parameter is detected, matching is performed in the top-level interface class based on the service provider discovery search parameter and a preset hierarchical depth search strategy to obtain a corresponding target top-level interface;
[0029] The data to be processed corresponding to the service provider discovery search parameter is obtained, and the data to be processed is processed based on the data processing strategy in the target top-level interface to obtain a processing result.
[0030] The embodiments of the present application provide a method, apparatus, device and medium for service provider discovery based on hierarchical depth. The method includes: in response to a top-level interface class creation instruction, creating a top-level interface class corresponding to the top-level interface class creation instruction in a container; obtaining business scenario creation information, creating a corresponding number of top-level interfaces in the top-level interface class based on the business scenario creation information, and setting a service provider discovery annotation in each top-level interface; if a service provider discovery search parameter is detected, matching the service provider discovery search parameter and the preset hierarchical depth search strategy in the top-level interface class to obtain the corresponding target top-level interface; obtaining the data to be processed corresponding to the service provider discovery search parameter, processing the data to be processed based on the data processing strategy in the target top-level interface, and obtaining a processing result. The embodiments of the present invention realize the creation of different business scenarios corresponding to different service provider discovery annotations in the top-level interface class of the container, and realize the fine-grained division and adaptation of business scenarios; and the subsequent business scenario specific interface query can quickly match the target interface required by the user according to the hierarchical depth matching method. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0032] FIG1 is a schematic diagram of an application scenario of a service discovery method based on hierarchical depth provided in an embodiment of the present application;
[0033] FIG2 is a flow chart of a method for discovering services based on hierarchical depth according to an embodiment of the present application;
[0034] FIG3 is a schematic diagram of a sub-process of a service discovery method based on hierarchical depth according to an embodiment of the present application;
[0035] FIG4 is a schematic diagram of a hierarchical depth search strategy in a hierarchical depth-based service discovery method provided in an embodiment of the present application;
[0036] FIG5 is a schematic block diagram of a distributed system and a device for discovering services based on hierarchical depth according to an embodiment of the present application;
[0037] FIG6 is a schematic block diagram of a computer device provided in an embodiment of the present application. Implementation Method
[0038] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0039] It will be understood that when used in this specification and the appended claims, the terms “comprises” and “comprising” indicate the presence of described features, integers, steps, operations, elements and / or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.
[0040] It should also be understood that the terms used in this specification are for the purpose of describing specific embodiments only and are not intended to limit the present application. As used in this specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms unless the context clearly indicates otherwise.
[0041] It should be further understood that the term "and / or" used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
[0042] Please refer to Figures 1 and 2. Figure 1 is a schematic diagram of the application scenario of the service provision discovery method based on hierarchical depth provided in an embodiment of the present application. Figure 2 is a flow diagram of the service provision discovery method based on hierarchical depth provided in an embodiment of the present application. The service provision discovery method based on hierarchical depth is applied to the server.
[0043] As shown in FIG. 2 , the method includes steps S110 to S140 .
[0044] S110 . In response to a top-level interface class creation instruction, create a top-level interface class corresponding to the top-level interface class creation instruction in a container.
[0045] In this embodiment, the technical solution is described with the server as the execution entity. A Spring container (referring to an IOC container, i.e., a container with inversion of control functionality) is deployed on the server. When a user needs to partition different product objects in a software project according to business scenarios, they first trigger a top-level interface class creation instruction. Then, within the server's Spring container, a top-level interface class corresponding to the instruction is created based on the top-level interface class. This top-level interface class created in the container supports expansion across multiple business scenarios, facilitating the subsequent creation of multiple top-level interfaces based on fine-grained partitioning of multiple business scenarios.
[0046] Among them, the top-level interface classes in the Spring container include the Collection interface, Set interface, List interface, Queue interface, Map interface, and SortedSet interface. For example, the List interface is used as the top-level interface in this application. When the user triggers the top-level interface class creation instruction, the List interface top-level interface class will be created in the Spring container.
[0047] In one embodiment, before step S110, the method further includes:
[0048] Customize and create a service discovery annotation, and customize and create a parameter object corresponding to the service discovery annotation; wherein the parameter object corresponding to the service discovery annotation is a string array type;
[0049] Inject the parameter object corresponding to the service provider discovery annotation into the created container.
[0050] In this embodiment, to implement multiple top-level interfaces based on fine-grained divisions of multiple business scenarios in the server's Spring container, it is necessary to first create a custom service provider discovery annotation (SPI annotation), then define a parameter object within the SPI annotation to serve as the SPI annotation's parameter object, and finally inject the SPI annotation's parameter object into the server's Spring container. Specifically, to facilitate subsequent differentiation of different business scenarios based on string length, the parameter object corresponding to the service provider discovery annotation can be limited to a string array type. In other words, all SPI annotation parameter objects are string array types.
[0051] Service provider discovery uses a service provider discovery mechanism. In this mechanism, files are named with the fully qualified interface names in the META-INF / services folder under the specified ClassPath. Each interface's corresponding file contains the interface's implementation. The file's contents (the fully qualified interface implementation name) are then loaded using resource loading to load the class.
[0052] In one embodiment, after step S110 and before step S120, the method further includes:
[0053] An initial service provider discovery annotation of a global default implementation type is obtained, and the initial service provider discovery annotation is set to the top-level interface class.
[0054] In this embodiment, after a Spring container and a top-level interface class are created in the server, since they have not yet been specifically divided according to business scenarios, an initial service provider discovery annotation, i.e., an initial SPI annotation, can be added to the top-level interface class during initialization. A parameter specifying the initial SPI annotation as a global default implementation type is then passed into the initial SPI annotation. This process completes the initial SPI annotation of the top-level interface class, so that subsequent top-level interfaces created within the top-level interface class will all have an initial service provider discovery annotation with a global default implementation type during initialization.
[0055] S120. Obtain business scenario creation information, create a corresponding number of top-level interfaces in the top-level interface class based on the business scenario creation information, and set a service provider discovery annotation in each top-level interface; wherein the service provider discovery annotation of each top-level interface corresponds to a business scenario.
[0056] In this embodiment, after the creation of the top-level container class is completed, multiple top-level interfaces can be divided in the top-level interface class according to specific business scenarios, and each top-level interface can also be marked with a service provider discovery annotation, that is, an SPI annotation, and a parameter object for identifying the business scenario corresponding to the top-level interface is passed in the SPI annotation marked on each top-level interface.
[0057] For example, if you need to create top-level interfaces in a top-level interface class for X business scenarios (where X is a positive integer greater than 0), you can create X top-level interfaces in the top-level interface class, denoted as the 1st to the Xth top-level interfaces. Each of these top-level interfaces corresponds to a different business scenario. In this way, by using parameter objects with different SPI annotations for each top-level interface, you can achieve fine-grained segmentation based on business scenarios in the top-level interface class.
[0058] In one embodiment, as shown in FIG3 , step S120 includes:
[0059] S121. Setting a service provider discovery annotation for each top-level interface in the top-level interface class and obtaining a corresponding business scenario string array;
[0060] S122. The corresponding business scenario string array is passed into the service provider discovery annotation corresponding to each top-level interface; wherein the string lengths of the business scenario string array corresponding to each top-level interface are different.
[0061] In this embodiment, still referring to the above example, when creating top-level interfaces in a top-level interface class for X business scenarios, for example, creating a top-level interface for the first business scenario and annotating it with an SPI annotation, the SPI annotation is first annotated for the top-level interface of the first business scenario, and an array of business scenario strings, such as key1, to be injected into the SPI annotation is obtained as the business scenario string array for the first business scenario. The business scenario string array, such as key1, is then injected into the SPI annotation of the top-level interface of the first business scenario as a parameter object for the SPI annotation. The above process completes the creation of the first business scenario, using the top-level interface in the Spring container as the carrier.
[0062] Subsequently, when creating and annotating the top-level interfaces for the second business scenario, through the Xth business scenario, the creation and standardization process for the first business scenario's top-level interface is referenced. It's important to note that to ensure the uniqueness of each business scenario, the string length of the business scenario string array passed in the SPI annotation for each top-level interface varies. For example, the string length of the business scenario string array passed in the top-level interface for the first business scenario is denoted as L1, the string length of the business scenario string array passed in the top-level interface for the second business scenario is denoted as L2, and so on. The string length of the business scenario string array passed in the top-level interface for the Xth business scenario is denoted as LX. These L1, L2, ..., and LX are all different. This shows that, based on the different lengths of the business scenario string arrays, fine-grained partitioning of different business scenarios within the top-level container is achieved. Furthermore, the code decoupling between the top-level interfaces corresponding to each business scenario is more thorough, enabling adaptation to multi-level and fine-grained adaptation scenarios and enhancing customized configuration capabilities.
[0063] In one embodiment, after step S122, the method further includes:
[0064] If it is determined that there is new business scenario creation information, then creating a new top-level interface corresponding to the new business scenario creation information in the top-level interface class;
[0065] The newly added business scenario character string array corresponding to the newly added business scenario creation information is passed into the newly added service provision discovery annotation in the newly added top-level interface.
[0066] In this embodiment, since a top-level interface is created in the Spring container for each business scenario, when adding a new customized scenario, it is only necessary to obtain the new business scenario creation information for the new customized scenario in the top-level container class of the Spring container, and create a new top-level interface corresponding to the new business scenario creation information in the top-level interface class and mark it with an SPI annotation (i.e., a new service provider discovery annotation).
[0067] The newly added business scenario string array corresponding to the customized scenario is then retrieved and passed to the newly added service provider discovery annotation in the top-level interface. The length of this newly added business scenario string array is different from the existing business scenario string arrays in each top-level interface within the Spring container to distinguish it from other business scenarios. This approach allows for the rapid addition of new customized scenarios to the container.
[0068] S130: If a service provider discovery search parameter is detected, a match is performed in the top-level interface class based on the service provider discovery search parameter and a preset hierarchical depth search strategy to obtain a corresponding target top-level interface.
[0069] In this embodiment, after the configuration of the top-level interface based on business scenario division is completed in the Spring container, the interface service can be specifically provided externally. For example, as shown in Figure 1, when a client communicating with a server sends a service provider discovery search parameter to the server to locate a target interface and call the target interface's service, the server's Spring container matches the top-level interface class based on the service provider discovery search parameter and a preset hierarchical depth search strategy, and obtains the corresponding target top-level interface through a layer-by-layer search method using the hierarchical depth search strategy. The search method corresponding to the hierarchical depth search strategy is to search sequentially in order of the length of the business scenario string array from short to long. That is, the shorter the string length and the shallower the depth of the top-level interface's business scenario string array, the higher its search priority; and the longer the string length and the deeper the depth of the top-level interface's business scenario string array, the lower its search priority (for details, please refer to the schematic diagram corresponding to the hierarchical depth search strategy shown in Figure 4).
[0070] In one embodiment, step S130 includes:
[0071] Get service provider discovery search parameters;
[0072] Obtaining, based on the hierarchical depth search strategy, an i-th layer matching input parameter and an i-th query depth corresponding to the service provider discovery search parameter; wherein an initial value of i is 1, and a value range of i is [1, N], where N represents the total number of top-level interfaces in the top-level interface class;
[0073] If it is determined that the i-th level matching input parameter based on the service provider discovery search parameter successfully matches the i-th query depth of the top-level interface class, the i-th level top-level interface corresponding to the i-th query depth of the top-level interface class is used as the target top-level interface;
[0074] If it is determined that the i-th level matching input parameter based on the service provider discovery search parameter is not successfully matched in the i-th query depth of the top-level interface class, then i is incremented by 1 to update the value of i;
[0075] If it is determined that i is less than or equal to N, then returning to the step of obtaining the i-th layer matching input parameter and the i-th query depth corresponding to the service provider discovery search parameter based on the hierarchical depth search strategy;
[0076] If it is determined that i is greater than N, a notification message for prompting that the target top-level interface has not been obtained is generated and displayed.
[0077] In this embodiment, after the server obtains the service provider discovery search parameter sent by the user end, it is necessary to use a strategy to search in hierarchical order from short to long based on the string length of the business scenario string array, first obtain the first-level matching input parameter and the first query depth corresponding to the service provider discovery search parameter, and then compare the first-level matching input parameter at the first query depth of the top-level interface class with the object parameter of the SPI annotation in the first business scenario to achieve a match. If it is determined that the first-level matching input parameter at the first query depth of the top-level interface class is the same as the object parameter of the SPI annotation in the first business scenario, it means that the first-level matching input parameter at the first query depth of the top-level interface class successfully matches the SPI annotation in the first business scenario. At this time, the first-level top-level interface corresponding to the first query depth of the top-level interface class is used as the target top-level interface.
[0078] However, if it is determined that the first-level matching input parameter is not the same as the object parameter of the SPI annotation in the first business scenario at the first query depth of the top-level interface class, it means that the first-level matching input parameter is not successfully matched with the SPI annotation in the first business scenario at the first query depth of the top-level interface class. At this time, the sequence number 1 is increased by 1 to obtain sequence number 2, and when the sequence number value corresponding to sequence number 2 does not exceed the total number N of top-level interfaces in the top-level interface class, the second-level matching input parameter and the second query depth corresponding to the service provider discovery search parameter are obtained based on the hierarchical depth search strategy. Afterwards, the second-level matching input parameter is compared with the object parameter of the SPI annotation in the second business scenario at the second query depth of the top-level interface class to achieve a match, and the matching process refers to the above-mentioned process of comparing the first-level matching input parameter at the first query depth of the top-level interface class with the object parameter of the SPI annotation in the first business scenario to achieve a match. By analogy, as long as the object parameter of the matching input parameter of the SPI annotation is successfully matched in a certain query depth, the top-level interface of that layer is used as the target top-level interface. However, if no matching object parameters for the SPI annotations are found at any query depth, the search fails. A notification message indicating that the target top-level interface was not found needs to be generated and displayed on the server. This notification message can also be sent from the server to the client for display. This indicates that the matching method based on hierarchical depth can quickly match the target interface required by the user.
[0079] Moreover, if the object parameters of the SPI annotations are successfully matched in a specific query depth, the top-level interface of this layer will be used as the target top-level interface, and the query depth of the search process can also be recorded in the server.
[0080] In one embodiment, obtaining the i-th level matching input parameter and the i-th query depth corresponding to the service provider discovery search parameter based on the hierarchical depth search strategy includes:
[0081] Based on the hierarchical depth search strategy, the first to i-th strings included in the service provider discovery search parameters are obtained to form the i-th layer matching input parameters, and the total number of strings included in the i-th layer matching input parameters is used as the i-th query depth.
[0082] In this embodiment, after the server receives the service provider discovery search parameters sent by the client, it is necessary to obtain the first to i-th strings included in the service provider discovery search parameters based on the hierarchical depth search strategy to form the i-th level matching input parameters. For example, as shown in Figure 4, when i=3, the first string such as key1, the second string such as key2, and the third string such as key3 included in the service provider discovery search parameters are obtained, and then the first string key1, the second string key2 and the third string key3 are used in order to form the third level matching input parameters {key1, key2, key3}, and then the third level matching input parameters {key1, key2, key3} are compared with the SPI annotations of the top-level interface of the third level depth (corresponding to the third query depth) to see if the two are the same, thereby obtaining the comparison result at this depth level. It can be seen that based on this comparison method, the best search that fully traverses the business scenarios of each level can be achieved.
[0083] During specific implementation, the preset character "*" can be added to the end of the third-level matching input parameter {key1, key2, key3} to update it to {key1, key2, key3, *} and use it as the latest third-level matching input parameter. Then, the third-level matching input parameter {key1, key2, key3, *} is compared with the SPI annotation of the top-level interface at the third depth (corresponding to the third query depth) to see if they are the same, thereby obtaining the comparison result at this depth level.
[0084] S140: Obtain the data to be processed corresponding to the service provider discovery search parameter, process the data to be processed based on the data processing strategy in the target top-level interface, and obtain a processing result.
[0085] In this embodiment, after the client uploads the service provider discovery search parameters, it also uploads the data to be processed corresponding to the service provider discovery search parameters. This data to be processed is the business data that needs to be processed in the target top-level interface. Once the target top-level interface and the data processing policy encapsulated therein are obtained, the data to be processed can be processed specifically to obtain the final processing result. The server then sends the processing result to the client for the user to view in a timely manner.
[0086] This method creates different business scenarios in the top-level interface class of the container with different service discovery annotations, achieving fine-grained division and adaptation of business scenarios. In addition, the subsequent business scenario specific interface query can quickly match the target interface required by the user according to the hierarchical depth matching method.
[0087] The present application also provides a hierarchical depth-based service discovery device, which is used to execute any embodiment of the aforementioned hierarchical depth-based service discovery method. Specifically, please refer to Figure 5, which is a schematic block diagram of the hierarchical depth-based service discovery device provided in an embodiment of the present application.
[0088] As shown in FIG5 , the hierarchical depth-based service provider discovery apparatus 100 includes a top-level interface class creation unit 110 , an annotation injection unit 120 , a target interface search unit 130 and a target interface processing unit 140 .
[0089] The top-level interface class creation unit 110 is configured to create a top-level interface class corresponding to the top-level interface class creation instruction in the container in response to the top-level interface class creation instruction.
[0090] In this embodiment, the technical solution is described with the server as the execution entity. A Spring container (referring to an IOC container, i.e., a container with inversion of control functionality) is deployed on the server. When a user needs to partition different product objects in a software project according to business scenarios, they first trigger a top-level interface class creation instruction. Then, within the server's Spring container, a top-level interface class corresponding to the instruction is created based on the top-level interface class. This top-level interface class created in the container supports expansion across multiple business scenarios, facilitating the subsequent creation of multiple top-level interfaces based on fine-grained partitioning of multiple business scenarios.
[0091] Among them, the top-level interface classes in the Spring container include the Collection interface, Set interface, List interface, Queue interface, Map interface, and SortedSet interface. For example, the List interface is used as the top-level interface in this application. When the user triggers the top-level interface class creation instruction, the List interface top-level interface class will be created in the Spring container.
[0092] In one embodiment, the hierarchical depth-based service provider discovery apparatus 100 further includes:
[0093] An initial creation unit, configured to create a custom service discovery annotation and a custom parameter object corresponding to the service discovery annotation; wherein the parameter object corresponding to the service discovery annotation is a string array type;
[0094] The initial parameter injection unit is used to inject the parameter object corresponding to the service provider discovery annotation into the created container.
[0095] In this embodiment, to implement multiple top-level interfaces based on fine-grained divisions of multiple business scenarios in the server's Spring container, it is necessary to first create a custom service provider discovery annotation (SPI annotation), then define a parameter object within the SPI annotation to serve as the SPI annotation's parameter object, and finally inject the SPI annotation's parameter object into the server's Spring container. Specifically, to facilitate subsequent differentiation of different business scenarios based on string length, the parameter object corresponding to the service provider discovery annotation can be limited to a string array type. In other words, all SPI annotation parameter objects are string array types.
[0096] Service provider discovery uses a service provider discovery mechanism. In this mechanism, files are named with the fully qualified interface names in the META-INF / services folder under the specified ClassPath. Each interface's corresponding file contains the interface's implementation. The file's contents (the fully qualified interface implementation name) are then loaded using resource loading to load the class.
[0097] In one embodiment, the hierarchical depth-based service provider discovery apparatus 100 further includes:
[0098] The initial annotation setting unit is used to obtain the initial service provider discovery annotation of the global default implementation type, and set the initial service provider discovery annotation to the top-level interface class.
[0099] In this embodiment, after a Spring container and a top-level interface class are created in the server, since they have not yet been specifically divided according to business scenarios, an initial service provider discovery annotation, i.e., an initial SPI annotation, can be added to the top-level interface class during initialization. A parameter specifying the initial SPI annotation as a global default implementation type is then passed into the initial SPI annotation. This process completes the initial SPI annotation of the top-level interface class, so that subsequent top-level interfaces created within the top-level interface class will all have an initial service provider discovery annotation with a global default implementation type during initialization.
[0100] The annotation injection unit 120 is used to obtain business scenario creation information, create a corresponding number of top-level interfaces in the top-level interface class based on the business scenario creation information, and set a service provider discovery annotation in each top-level interface; wherein the service provider discovery annotation of each top-level interface corresponds to a business scenario.
[0101] In this embodiment, after the creation of the top-level container class is completed, multiple top-level interfaces can be divided in the top-level interface class according to specific business scenarios, and each top-level interface can also be marked with a service provider discovery annotation, that is, an SPI annotation, and a parameter object for identifying the business scenario corresponding to the top-level interface is passed in the SPI annotation marked on each top-level interface.
[0102] For example, if you need to create top-level interfaces in a top-level interface class for X business scenarios (where X is a positive integer greater than 0), you can create X top-level interfaces in the top-level interface class, denoted as the 1st to the Xth top-level interfaces. Each of these top-level interfaces corresponds to a different business scenario. In this way, by using parameter objects with different SPI annotations for each top-level interface, you can achieve fine-grained segmentation based on business scenarios in the top-level interface class.
[0103] In one embodiment, the annotation injection unit 120 is used to:
[0104] For each top-level interface in the top-level interface class, a service provider discovery annotation is set and a corresponding business scenario string array is obtained;
[0105] The corresponding business scenario string array is passed into the service provider discovery annotation corresponding to each top-level interface; wherein the string length of the business scenario string array corresponding to each top-level interface is different.
[0106] In this embodiment, still referring to the above example, when creating top-level interfaces in a top-level interface class for X business scenarios, for example, creating a top-level interface for the first business scenario and annotating it with an SPI annotation, the SPI annotation is first annotated for the top-level interface of the first business scenario, and an array of business scenario strings, such as key1, to be injected into the SPI annotation is obtained as the business scenario string array for the first business scenario. The business scenario string array, such as key1, is then injected into the SPI annotation of the top-level interface of the first business scenario as a parameter object for the SPI annotation. The above process completes the creation of the first business scenario, using the top-level interface in the Spring container as the carrier.
[0107] Subsequently, when creating and annotating the top-level interfaces for the second business scenario, through the Xth business scenario, the creation and standardization process for the first business scenario's top-level interface is referenced. It's important to note that to ensure the uniqueness of each business scenario, the string length of the business scenario string array passed in the SPI annotation for each top-level interface varies. For example, the string length of the business scenario string array passed in the top-level interface for the first business scenario is denoted as L1, the string length of the business scenario string array passed in the top-level interface for the second business scenario is denoted as L2, and so on. The string length of the business scenario string array passed in the top-level interface for the Xth business scenario is denoted as LX. These L1, L2, ..., and LX are all different. This shows that, based on the different lengths of the business scenario string arrays, fine-grained partitioning of different business scenarios within the top-level container is achieved. Furthermore, the code decoupling between the top-level interfaces corresponding to each business scenario is more thorough, enabling adaptation to multi-level and fine-grained adaptation scenarios and enhancing customized configuration capabilities.
[0108] In one embodiment, the annotation injection unit 120 is further configured to:
[0109] If it is determined that there is new business scenario creation information, then creating a new top-level interface corresponding to the new business scenario creation information in the top-level interface class;
[0110] The newly added business scenario string array corresponding to the newly added business scenario creation information is passed into the newly added service provision discovery annotation in the newly added top-level interface.
[0111] In this embodiment, since a top-level interface is created in the Spring container for each business scenario, when adding a new customized scenario, it is only necessary to obtain the new business scenario creation information for the new customized scenario in the top-level container class of the Spring container, and create a new top-level interface corresponding to the new business scenario creation information in the top-level interface class and mark it with an SPI annotation (i.e., a new service provider discovery annotation).
[0112] The newly added business scenario string array corresponding to the customized scenario is then retrieved and passed to the newly added service provider discovery annotation in the top-level interface. The length of this newly added business scenario string array is different from the existing business scenario string arrays in each top-level interface within the Spring container to distinguish it from other business scenarios. This approach allows for the rapid addition of new customized scenarios to the container.
[0113] The target interface search unit 130 is configured to, if a service provider discovery search parameter is detected, match the service provider discovery search parameter with a preset hierarchical depth search strategy in the top-level interface class to obtain a corresponding target top-level interface.
[0114] In this embodiment, after the configuration of the top-level interface based on business scenario division is completed in the Spring container, the interface service can be specifically provided externally. For example, as shown in Figure 1, when a client communicating with a server sends a service provider discovery search parameter to the server to locate a target interface and call the target interface's service, the server's Spring container matches the top-level interface class based on the service provider discovery search parameter and a preset hierarchical depth search strategy, and obtains the corresponding target top-level interface through a layer-by-layer search method using the hierarchical depth search strategy. The search method corresponding to the hierarchical depth search strategy is to search sequentially in order of the length of the business scenario string array from short to long. That is, the shorter the string length and the shallower the depth of the top-level interface's business scenario string array, the higher its search priority; and the longer the string length and the deeper the depth of the top-level interface's business scenario string array, the lower its search priority (for details, please refer to the schematic diagram corresponding to the hierarchical depth search strategy shown in Figure 4).
[0115] In one embodiment, the target interface search unit 130 is further configured to:
[0116] Get service provider discovery search parameters;
[0117] Obtaining, based on the hierarchical depth search strategy, an i-th layer matching input parameter and an i-th query depth corresponding to the service provider discovery search parameter; wherein an initial value of i is 1, and a value range of i is [1, N], where N represents the total number of top-level interfaces in the top-level interface class;
[0118] If it is determined that the i-th level matching input parameter based on the service provider discovery search parameter successfully matches the i-th query depth of the top-level interface class, the i-th level top-level interface corresponding to the i-th query depth of the top-level interface class is used as the target top-level interface;
[0119] If it is determined that the i-th level matching input parameter based on the service provider discovery search parameter is not successfully matched in the i-th query depth of the top-level interface class, then i is incremented by 1 to update the value of i;
[0120] If it is determined that i is less than or equal to N, then returning to the step of obtaining the i-th layer matching input parameter and the i-th query depth corresponding to the service provider discovery search parameter based on the hierarchical depth search strategy;
[0121] If it is determined that i is greater than N, a notification message for prompting that the target top-level interface has not been obtained is generated and displayed.
[0122] In this embodiment, after the server obtains the service provider discovery search parameter sent by the user end, it is necessary to use a strategy to search in hierarchical order from short to long based on the string length of the business scenario string array, first obtain the first-level matching input parameter and the first query depth corresponding to the service provider discovery search parameter, and then compare the first-level matching input parameter at the first query depth of the top-level interface class with the object parameter of the SPI annotation in the first business scenario to achieve a match. If it is determined that the first-level matching input parameter at the first query depth of the top-level interface class is the same as the object parameter of the SPI annotation in the first business scenario, it means that the first-level matching input parameter at the first query depth of the top-level interface class successfully matches the SPI annotation in the first business scenario. At this time, the first-level top-level interface corresponding to the first query depth of the top-level interface class is used as the target top-level interface.
[0123] However, if it is determined that the first-level matching input parameter is not the same as the object parameter of the SPI annotation in the first business scenario at the first query depth of the top-level interface class, it means that the first-level matching input parameter is not successfully matched with the SPI annotation in the first business scenario at the first query depth of the top-level interface class. At this time, the sequence number 1 is increased by 1 to obtain sequence number 2, and when the sequence number value corresponding to sequence number 2 does not exceed the total number N of top-level interfaces in the top-level interface class, the second-level matching input parameter and the second query depth corresponding to the service provider discovery search parameter are obtained based on the hierarchical depth search strategy. Afterwards, the second-level matching input parameter is compared with the object parameter of the SPI annotation in the second business scenario at the second query depth of the top-level interface class to achieve a match, and the matching process refers to the above-mentioned process of comparing the first-level matching input parameter at the first query depth of the top-level interface class with the object parameter of the SPI annotation in the first business scenario to achieve a match. By analogy, as long as the object parameter of the matching input parameter of the SPI annotation is successfully matched in a certain query depth, the top-level interface of that layer is used as the target top-level interface. However, if no matching object parameters for the SPI annotations are found at any query depth, the search fails. A notification message indicating that the target top-level interface was not found needs to be generated and displayed on the server. This notification message can also be sent from the server to the client for display. This indicates that the matching method based on hierarchical depth can quickly match the target interface required by the user.
[0124] Moreover, if the object parameters of the SPI annotations are successfully matched in a specific query depth, the top-level interface of this layer will be used as the target top-level interface, and the query depth of the search process can also be recorded in the server.
[0125] In one embodiment, obtaining the i-th level matching input parameter and the i-th query depth corresponding to the service provider discovery search parameter based on the hierarchical depth search strategy includes:
[0126] Based on the hierarchical depth search strategy, the first to i-th strings included in the service provider discovery search parameters are obtained to form the i-th layer matching input parameters, and the total number of strings included in the i-th layer matching input parameters is used as the i-th query depth.
[0127] In this embodiment, after the server receives the service provider discovery search parameters sent by the client, it is necessary to obtain the first to i-th strings included in the service provider discovery search parameters based on the hierarchical depth search strategy to form the i-th level matching input parameters. For example, as shown in Figure 4, when i=3, the first string such as key1, the second string such as key2, and the third string such as key3 included in the service provider discovery search parameters are obtained, and then the first string key1, the second string key2 and the third string key3 are used in order to form the third level matching input parameters {key1, key2, key3}, and then the third level matching input parameters {key1, key2, key3} are compared with the SPI annotations of the top-level interface of the third level depth (corresponding to the third query depth) to see if the two are the same, thereby obtaining the comparison result at this depth level. It can be seen that based on this comparison method, the best search that fully traverses the business scenarios of each level can be achieved.
[0128] During specific implementation, the preset character "*" can be added to the end of the third-level matching input parameter {key1, key2, key3} to update it to {key1, key2, key3, *} and use it as the latest third-level matching input parameter. Then, the third-level matching input parameter {key1, key2, key3, *} is compared with the SPI annotation of the top-level interface at the third depth (corresponding to the third query depth) to see if they are the same, thereby obtaining the comparison result at this depth level.
[0129] The target interface processing unit 140 is configured to obtain the data to be processed corresponding to the service provider discovery search parameter, and process the data to be processed based on the data processing strategy in the target top-level interface to obtain a processing result.
[0130] In this embodiment, after the client uploads the service provider discovery search parameters, it also uploads the data to be processed corresponding to the service provider discovery search parameters. This data to be processed is the business data that needs to be processed in the target top-level interface. Once the target top-level interface and the data processing policy encapsulated therein are obtained, the data to be processed can be processed specifically to obtain the final processing result. The server then sends the processing result to the client for the user to view in a timely manner.
[0131] The device realizes the creation of different business scenarios in the top-level interface class of the container with different service discovery annotations, realizing fine-grained division and adaptation of business scenarios; and the subsequent specific interface query of the business scenario can quickly match the target interface required by the user according to the hierarchical depth matching method.
[0132] The above-mentioned service provider discovery apparatus based on hierarchical depth may be implemented in the form of a computer program, and the computer program may be run on a computer device as shown in FIG6 .
[0133] Please refer to Figure 6, which is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device 500 is a server or a server cluster. The server can be a standalone server or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.
[0134] 6 , the computer device 500 includes a processor 502 , a memory, and a network interface 505 connected via a device bus 501 , wherein the memory may include a storage medium 503 and an internal memory 504 .
[0135] The storage medium 503 may store an operating system 5031 and a computer program 5032. When the computer program 5032 is executed, the processor 502 may perform the following steps:
[0136] In response to a top-level interface class creation instruction, creating a top-level interface class corresponding to the top-level interface class creation instruction in a container;
[0137] Obtaining business scenario creation information, creating a corresponding number of top-level interfaces in the top-level interface class based on the business scenario creation information, and setting a service provider discovery annotation in each top-level interface; wherein the service provider discovery annotation of each top-level interface corresponds to one business scenario;
[0138] If a service provider discovery search parameter is detected, matching is performed in the top-level interface class based on the service provider discovery search parameter and a preset hierarchical depth search strategy to obtain a corresponding target top-level interface;
[0139] The data to be processed corresponding to the service provider discovery search parameter is obtained, and the data to be processed is processed based on the data processing strategy in the target top-level interface to obtain a processing result.
[0140] The processor 502 is used to provide computing and control capabilities to support the operation of the entire computer device 500.
[0141] The internal memory 504 provides an environment for the operation of the computer program 5032 in the storage medium 503. When the computer program 5032 is executed by the processor 502, the processor 502 can execute a service discovery method based on hierarchical depth.
[0142] The network interface 505 is used for network communication, such as providing data information transmission, etc. Those skilled in the art will understand that the structure shown in FIG6 is merely a block diagram of a portion of the structure related to the solution of the present application, and does not constitute a limitation on the computer device 500 to which the solution of the present application is applied. The specific computer device 500 may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0143] The processor 502 is configured to execute a computer program 5032 stored in the memory to implement the hierarchical depth-based service discovery method disclosed in the embodiment of the present application.
[0144] Those skilled in the art will appreciate that the embodiment of the computer device shown in FIG6 does not constitute a limitation on the specific configuration of the computer device. In other embodiments, the computer device may include more or fewer components than shown, or may combine certain components, or may have different component arrangements. For example, in some embodiments, the computer device may only include a memory and a processor. In such embodiments, the structure and function of the memory and processor are consistent with those in the embodiment shown in FIG6 and will not be further described here.
[0145] It should be understood that in the embodiment of the present application, the processor 502 may be a central processing unit (CPU), and the processor 502 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc.
[0146] In another embodiment of the present application, a computer-readable storage medium is provided. The computer-readable storage medium may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium. The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the processor performs the following steps:
[0147] In response to a top-level interface class creation instruction, creating a top-level interface class corresponding to the top-level interface class creation instruction in a container;
[0148] Obtaining business scenario creation information, creating a corresponding number of top-level interfaces in the top-level interface class based on the business scenario creation information, and setting a service provider discovery annotation in each top-level interface; wherein the service provider discovery annotation of each top-level interface corresponds to one business scenario;
[0149] If a service provider discovery search parameter is detected, matching is performed in the top-level interface class based on the service provider discovery search parameter and a preset hierarchical depth search strategy to obtain a corresponding target top-level interface;
[0150] The data to be processed corresponding to the service provider discovery search parameter is obtained, and the data to be processed is processed based on the data processing strategy in the target top-level interface to obtain a processing result.
[0151] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described equipment, devices and units can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented with electronic hardware, computer software or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0152] In the several embodiments provided in this application, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, or units with the same function may be combined into one unit. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interfaces, devices or units, or may be an electrical, mechanical or other form of connection.
[0153] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiments of the present application.
[0154] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0155] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a backend server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes various media that can store program code, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk, or an optical disk.
[0156] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in the present application, and such modifications or substitutions should be included in the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims.
Claims
1. A service provider discovery method based on hierarchical depth, wherein: include: In response to a top-level interface class creation instruction, creating a top-level interface class corresponding to the top-level interface class creation instruction in a container; Obtaining business scenario creation information, creating a corresponding number of top-level interfaces in the top-level interface class based on the business scenario creation information, and setting a service provider discovery annotation in each top-level interface; wherein the service provider discovery annotation of each top-level interface corresponds to a business scenario; If a service provider discovery search parameter is detected, matching is performed in the top-level interface class based on the service provider discovery search parameter and a preset hierarchical depth search strategy to obtain a corresponding target top-level interface; The data to be processed corresponding to the service provider discovery search parameter is obtained, and the data to be processed is processed based on the data processing strategy in the target top-level interface to obtain a processing result.
2. The method according to claim 1, wherein: The creating information based on the business scenario creates a corresponding number of top-level interfaces in the top-level interface class, and sets a service provider discovery annotation in each top-level interface, including: For each top-level interface in the top-level interface class, a service provider discovery annotation is set and a corresponding business scenario string array is obtained; The corresponding business scenario string array is passed into the service provider discovery annotation corresponding to each top-level interface; wherein the string length of the business scenario string array corresponding to each top-level interface is different.
3. The method according to claim 2, wherein: After the step of passing the corresponding business scenario string array into the service provider discovery annotation corresponding to each top-level interface, the method further includes: If it is determined that there is new business scenario creation information, then creating a new top-level interface corresponding to the new business scenario creation information in the top-level interface class; The newly added business scenario character string array corresponding to the newly added business scenario creation information is passed into the newly added service provision discovery annotation in the newly added top-level interface.
4. The method according to claim 1, wherein: The service provider-based discovery search parameter and the preset hierarchical depth search strategy are matched in the top-level interface class to obtain the corresponding target top-level interface, including: Get service provider discovery search parameters; Based on the hierarchical depth search strategy, obtain the i-th layer matching input parameter and the i-th query depth corresponding to the service provider discovery search parameter; wherein the initial value of i is 1, and the value range of i is [1, N], and N represents the total number of top-level interfaces in the top-level interface class; If it is determined that the i-th level matching input parameter based on the service provider discovery search parameter successfully matches the i-th query depth of the top-level interface class, the i-th level top-level interface corresponding to the i-th query depth of the top-level interface class is used as the target top-level interface; If it is determined that the i-th level matching input parameter based on the service provider discovery search parameter is not successfully matched in the i-th query depth of the top-level interface class, i is incremented by 1 to update the value of i; If it is determined that i is less than or equal to N, return to execute the step of obtaining the i-th layer matching input parameter and the i-th query depth corresponding to the service provider discovery search parameter based on the hierarchical depth search strategy; If it is determined that i is greater than N, a notification message for prompting that the target top-level interface has not been obtained is generated and displayed.
5. The method according to claim 4, wherein: The obtaining, based on the hierarchical depth search strategy, the i-th layer matching input parameter and the i-th query depth corresponding to the service provider discovery search parameter comprises: Based on the hierarchical depth search strategy, the first to i-th strings included in the service provider discovery search parameters are obtained to form the i-th layer matching input parameters, and the total number of strings included in the i-th layer matching input parameters is used as the i-th query depth.
6. The method according to claim 1, wherein: Before the step of creating a top-level interface class corresponding to the top-level interface class creation instruction in the container in response to the top-level interface class creation instruction, the method further includes: Customize and create a service discovery annotation, and customize and create a parameter object corresponding to the service discovery annotation; wherein the parameter object corresponding to the service discovery annotation is a string array type; Inject the parameter object corresponding to the service provider discovery annotation into the created container.
7. The method according to claim 1, wherein: After the step of creating a top-level interface class corresponding to the top-level interface class creation instruction in the container, and before the step of obtaining business scenario creation information, creating a corresponding number of top-level interfaces in the top-level interface class based on the business scenario creation information, and setting a service provider discovery annotation in each top-level interface, the method further includes: An initial service provider discovery annotation of a global default implementation type is obtained, and the initial service provider discovery annotation is set to the top-level interface class.
8. A service provider discovery device based on hierarchical depth, wherein: include: A top-level interface class creation unit, configured to create a top-level interface class corresponding to the top-level interface class creation instruction in a container in response to the top-level interface class creation instruction; An annotation injection unit is used to obtain business scenario creation information, create a corresponding number of top-level interfaces in the top-level interface class based on the business scenario creation information, and set a service provider discovery annotation in each top-level interface; wherein the service provider discovery annotation of each top-level interface corresponds to one business scenario; A target interface search unit, configured to, if a service provider discovery search parameter is detected, match the service provider discovery search parameter and a preset hierarchical depth search strategy in the top-level interface class to obtain a corresponding target top-level interface; The target interface processing unit is used to obtain the data to be processed corresponding to the service provider discovery search parameter, and process the data to be processed based on the data processing strategy in the target top-level interface to obtain a processing result.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the following steps are implemented: In response to a top-level interface class creation instruction, creating a top-level interface class corresponding to the top-level interface class creation instruction in a container; Obtaining business scenario creation information, creating a corresponding number of top-level interfaces in the top-level interface class based on the business scenario creation information, and setting a service provider discovery annotation in each top-level interface; wherein the service provider discovery annotation of each top-level interface corresponds to a business scenario; If a service provider discovery search parameter is detected, matching is performed in the top-level interface class based on the service provider discovery search parameter and a preset hierarchical depth search strategy to obtain a corresponding target top-level interface; The data to be processed corresponding to the service provider discovery search parameter is obtained, and the data to be processed is processed based on the data processing strategy in the target top-level interface to obtain a processing result.
10. The computer device according to claim 9, wherein: The creating information based on the business scenario creates a corresponding number of top-level interfaces in the top-level interface class, and sets a service provider discovery annotation in each top-level interface, including: For each top-level interface in the top-level interface class, a service provider discovery annotation is set and a corresponding business scenario string array is obtained; The corresponding business scenario string array is passed into the service provider discovery annotation corresponding to each top-level interface; wherein the string length of the business scenario string array corresponding to each top-level interface is different.
11. The computer device according to claim 10, wherein: After the service provider discovery annotation corresponding to each top-level interface is passed into the corresponding business scenario string array, it also includes: If it is determined that there is new business scenario creation information, then creating a new top-level interface corresponding to the new business scenario creation information in the top-level interface class; The newly added business scenario character string array corresponding to the newly added business scenario creation information is passed into the newly added service provision discovery annotation in the newly added top-level interface.
12. The computer device according to claim 9, wherein: The service provider-based discovery search parameter and the preset hierarchical depth search strategy are matched in the top-level interface class to obtain the corresponding target top-level interface, including: Get service provider discovery search parameters; Based on the hierarchical depth search strategy, obtain the i-th layer matching input parameter and the i-th query depth corresponding to the service provider discovery search parameter; wherein the initial value of i is 1, and the value range of i is [1, N], and N represents the total number of top-level interfaces in the top-level interface class; If it is determined that the i-th level matching input parameter based on the service provider discovery search parameter successfully matches the i-th query depth of the top-level interface class, the i-th level top-level interface corresponding to the i-th query depth of the top-level interface class is used as the target top-level interface; If it is determined that the i-th level matching input parameter based on the service provider discovery search parameter is not successfully matched in the i-th query depth of the top-level interface class, i is incremented by 1 to update the value of i; If it is determined that i is less than or equal to N, return to execute the step of obtaining the i-th layer matching input parameter and the i-th query depth corresponding to the service provider discovery search parameter based on the hierarchical depth search strategy; If it is determined that i is greater than N, a notification message for prompting that the target top-level interface has not been obtained is generated and displayed.
13. The computer device according to claim 12, wherein: The obtaining, based on the hierarchical depth search strategy, the i-th layer matching input parameter and the i-th query depth corresponding to the service provider discovery search parameter comprises: Based on the hierarchical depth search strategy, the first to i-th strings included in the service provider discovery search parameters are obtained to form the i-th layer matching input parameters, and the total number of strings included in the i-th layer matching input parameters is used as the i-th query depth.
14. The computer device according to claim 9, wherein: Before creating a top-level interface class corresponding to the top-level interface class creation instruction in the container in response to the top-level interface class creation instruction, the method further includes: Customize and create a service discovery annotation, and customize and create a parameter object corresponding to the service discovery annotation; wherein the parameter object corresponding to the service discovery annotation is a string array type; Inject the parameter object corresponding to the service provider discovery annotation into the created container.
15. The computer device according to claim 9, wherein: After creating a top-level interface class corresponding to the top-level interface class creation instruction in the container, before obtaining business scenario creation information, creating a corresponding number of top-level interfaces in the top-level interface class based on the business scenario creation information, and setting a service provider discovery annotation in each top-level interface, it also includes: An initial service provider discovery annotation of a global default implementation type is obtained, and the initial service provider discovery annotation is set to the top-level interface class.
16. A computer-readable storage medium, wherein: The computer readable storage medium stores a computer program, and when the program instructions are executed by a processor, the following operations are performed: In response to a top-level interface class creation instruction, creating a top-level interface class corresponding to the top-level interface class creation instruction in a container; Obtaining business scenario creation information, creating a corresponding number of top-level interfaces in the top-level interface class based on the business scenario creation information, and setting a service provider discovery annotation in each top-level interface; wherein the service provider discovery annotation of each top-level interface corresponds to a business scenario; If a service provider discovery search parameter is detected, matching is performed in the top-level interface class based on the service provider discovery search parameter and a preset hierarchical depth search strategy to obtain a corresponding target top-level interface; The data to be processed corresponding to the service provider discovery search parameter is obtained, and the data to be processed is processed based on the data processing strategy in the target top-level interface to obtain a processing result.
17. The computer-readable storage medium of claim 16, wherein: The creating information based on the business scenario creates a corresponding number of top-level interfaces in the top-level interface class, and sets a service provider discovery annotation in each top-level interface, including: For each top-level interface in the top-level interface class, a service provider discovery annotation is set and a corresponding business scenario string array is obtained; The corresponding business scenario string array is passed into the service provider discovery annotation corresponding to each top-level interface; wherein the string length of the business scenario string array corresponding to each top-level interface is different.
18. The computer-readable storage medium of claim 16, wherein: The service-provided discovery search parameter and the preset hierarchical depth search strategy are matched in the top-level interface class to obtain the corresponding target top-level interface, including: Get service provider discovery search parameters; Based on the hierarchical depth search strategy, obtain the i-th layer matching input parameter and the i-th query depth corresponding to the service provider discovery search parameter; wherein the initial value of i is 1, and the value range of i is [1, N], and N represents the total number of top-level interfaces in the top-level interface class; If it is determined that the i-th level matching input parameter based on the service provider discovery search parameter successfully matches the i-th query depth of the top-level interface class, the i-th level top-level interface corresponding to the i-th query depth of the top-level interface class is used as the target top-level interface; If it is determined that the i-th level matching input parameter based on the service provider discovery search parameter is not successfully matched in the i-th query depth of the top-level interface class, i is incremented by 1 to update the value of i; If it is determined that i is less than or equal to N, return to execute the step of obtaining the i-th layer matching input parameter and the i-th query depth corresponding to the service provider discovery search parameter based on the hierarchical depth search strategy; If it is determined that i is greater than N, a notification message for prompting that the target top-level interface has not been obtained is generated and displayed.
19. The computer-readable storage medium of claim 18, wherein: The obtaining, based on the hierarchical depth search strategy, the i-th layer matching input parameter and the i-th query depth corresponding to the service provider discovery search parameter comprises: Based on the hierarchical depth search strategy, the first to i-th strings included in the service provider discovery search parameters are obtained to form the i-th layer matching input parameters, and the total number of strings included in the i-th layer matching input parameters is used as the i-th query depth.
20. The computer-readable storage medium of claim 16, wherein: Before the step of creating a top-level interface class corresponding to the top-level interface class creation instruction in the container in response to the top-level interface class creation instruction, the method further includes: Customize and create a service discovery annotation, and customize and create a parameter object corresponding to the service discovery annotation; wherein the parameter object corresponding to the service discovery annotation is a string array type; Inject the parameter object corresponding to the service provider discovery annotation into the created container.
Citation Information
Patent Citations
Interface creation method and device, service request method and device, computer device and medium
CN110381135A
Interface calling method and device, server and storage medium
CN112181535A
Notation-based scene recognition method and device, electronic equipment and storage medium
CN115098514A
Business data change recording method and device, equipment and storage medium
CN115168166A
Business scene level service topology generation method and device and electronic equipment
CN115292058A
Cited By
Method for acquiring specified parameters based on user-defined annotation, readable storage medium and program product
CN119938132A
