Annotation-based business flow implementation method and device, storage medium, and electronic device
By splitting the service flow into multiple business nodes and marking the execution order with annotation information, the problem of high business expansion costs in the existing technology is solved, and flexible business flow orchestration and low-cost business expansion are achieved.
Patent Information
- Application Number
- CN202210314057.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-28
- Publication Date
- 2024-11-05
- Estimated Expiration
- 2042-03-28
AI Technical Summary
In the prior art, when adding new task units, the business flow orchestration method based on the responsibility chain pattern and thread pool needs to be modified, resulting in high business expansion costs and difficult to flexibly expand.
Using annotation-based business flow implementation method, the target business flow is split into multiple business nodes, each node corresponds to an independent code segment, and the execution order is marked by annotation information, and the business flow arrangement is achieved using annotation information, avoiding the original Invasive modifications to the code.
It reduces business expansion costs, improves development speed, realizes code decoupling, simplifies the business expansion process, and is suitable for complex multi-dimensional and multi-tenant scenarios.
Smart Images

Figure CN114647416B_ABST
Abstract
Description
Background Art
[0002] With the development of computer processing technology, technologies for implementing services based on computer codes have emerged. After the computer codes are set, computer devices execute the set computer codes to implement the corresponding services.
[0003] At present, the responsibility chain model is generally used to orchestrate business flows, and the business flows are executed through the strategy model + thread pool method. However, when a new task unit needs to be added, in addition to developing a new task unit, it is also necessary to modify the responsibility chain code or add thread pool-related code, which increases the cost of business expansion.
[0004] In view of this, there is an urgent need in the art to develop a new service flow implementation method and device.
[0005] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure. Summary of the invention
[0006] The purpose of the present disclosure is to provide an annotation-based business flow implementation method, an annotation-based business flow implementation device, a computer storage medium and an electronic device, thereby overcoming the defect of high business expansion cost in the related art at least to a certain extent.
[0007] Other features and advantages of the present disclosure will become apparent from the following detailed description, or may be learned in part by the practice of the present disclosure.
[0008] According to the first aspect of the present disclosure, there is provided an annotation-based business flow implementation method, comprising: after the business flow framework is started, loading multiple code segments for implementing the target business flow and annotation information associated with each of the code segments; the target business flow includes multiple business nodes, and there is a preset association relationship between the multiple code segments and the multiple business nodes; the annotation information is at least used to mark the execution order of each of the code segments; and executing the multiple code segments according to the annotation information to implement the target business flow.
[0009] In an exemplary embodiment of the present disclosure, the service node includes at least a primary node and a secondary node, the primary node corresponds to the processing stage included in the target service flow; the secondary node corresponds to the processing steps included in each of the processing stages.
[0010] In an exemplary embodiment of the present disclosure, the multiple code segments include a specific code segment corresponding to each of the first-level nodes, and one or more candidate code segments corresponding to each of the second-level nodes; when any of the second-level nodes corresponds to multiple candidate code segments, executing the multiple code segments according to the annotation information to realize the target business flow includes: obtaining the current application scenario of the target business flow; the current application scenario depends on one or more of the following parameters: business deployment information, partner information and business type; according to a pre-stored correspondence table between different application scenarios and different target code segments, determining the target code segment corresponding to the current application scenario from the multiple candidate code segments; executing the specific code segment according to the annotation information associated with the specific code segment, and executing the target code segment according to the annotation information associated with the target code segment to realize the target business flow.
[0011] In an exemplary embodiment of the present disclosure, the target code segment corresponding to the current application scenario is determined from the multiple candidate code segments based on the pre-stored correspondence between different application scenarios and different target code segments, including: taking the business deployment information, the partner information and the business type as a first query condition, and determining, according to the correspondence table, a target code segment that meets the first query condition from the multiple candidate code segments.
[0012] In an exemplary embodiment of the present disclosure, the method further includes: if no target code segment satisfying the first query condition is found, using the business deployment information and the partner information as the second query condition; and determining the target code segment satisfying the second query condition from the multiple candidate code segments according to the correspondence table.
[0013] In an exemplary embodiment of the present disclosure, the method further includes: if no target code segment satisfying the second query condition is found, using the business deployment information as a third query condition; and determining a target code segment satisfying the third query condition from the multiple candidate code segments according to the correspondence table.
[0014] In an exemplary embodiment of the present disclosure, the method further includes: if no target code segment satisfying the third query condition is found, determining a pre-specified candidate code segment as the target code segment.
[0015] In an exemplary embodiment of the present disclosure, loading the annotation information associated with each of the code segments includes: scanning a preset storage path based on a Java reflection mechanism to obtain the annotation information associated with each of the code segments; the preset storage path is used to store the annotation information; and loading the scanned annotation information into the memory.
[0016] According to the second aspect of the present disclosure, there is provided an annotation-based business flow implementation device, comprising: an information loading module, used to load multiple code segments for implementing a target business flow and annotation information associated with each of the code segments after the business flow framework is started; the target business flow includes multiple business nodes, and there is a preset association relationship between the multiple code segments and the multiple business nodes; the annotation information is at least used to mark the execution order of each of the code segments; and a code execution module, used to execute the multiple code segments according to the annotation information to implement the target business flow.
[0017] According to a third aspect of the present disclosure, a computer storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the annotation-based business flow implementation method described in the first aspect is implemented.
[0018] According to a fourth aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute the annotation-based business flow implementation method described in the first aspect above by executing the executable instructions.
[0019] It can be seen from the above technical solutions that the annotation-based business flow implementation method, annotation-based business flow implementation device, computer storage medium and electronic device in the exemplary embodiments of the present disclosure have at least the following advantages and positive effects:
[0020] In the technical solutions provided by some embodiments of the present disclosure, on the one hand, by splitting the target business flow into multiple business nodes, each business node corresponds to an independent code segment, which can achieve decoupling between codes and reduce the difficulty of code maintenance. On the other hand, by annotating the execution order of each code segment through annotation information, and using the annotation information to implement the target business flow, it is convenient for developers to expand the original business. When expanding the business, there is no need for developers to consider the coupling relationship between the newly added code segment and the original code, and it also avoids the technical problems of large intrusion into the original code and high business expansion cost caused by making a large number of modifications to the original code, thereby reducing the business expansion cost and improving the business development speed.
[0021] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification are used to explain the principles of the present disclosure. Obviously, the accompanying drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without creative work.
[0023] Figure 1 A flowchart of a method for implementing a business flow based on annotations in an embodiment of the present disclosure is shown;
[0024] Figure 2 A schematic diagram showing a method of implementing a business flow through a responsibility chain orchestration mode in a related art is shown;
[0025] Figure 3 A schematic diagram showing the expansion of a business in a responsibility chain orchestration mode;
[0026] Figure 4 A schematic diagram showing a method of implementing a business flow through a workflow framework in the related art;
[0027] Figure 5 A schematic diagram showing a Pipeline arranged in an embodiment of the present disclosure;
[0028] Figure 6 A schematic diagram showing a process of determining a target code segment from multiple candidate code segments in an embodiment of the present disclosure;
[0029] Figure 7 A schematic diagram showing the overall process of determining a target code segment from multiple candidate code segments in an embodiment of the present disclosure is shown;
[0030] Figure 8 A schematic diagram showing the structure of an annotation-based business flow implementation device in an exemplary embodiment of the present disclosure is shown;
[0031] Fig. 9 A schematic structural diagram of an electronic device in an exemplary embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0032] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as being limited to the examples set forth herein; on the contrary, these embodiments are provided so that the present disclosure will be more comprehensive and complete, and the concepts of the example embodiments are fully conveyed to those skilled in the art. The described features, structures, or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure may be practiced while omitting one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known technical solutions are not shown or described in detail to avoid obscuring various aspects of the present disclosure.
[0033] The terms "a", "an", "the" and "said" are used in this specification to indicate the presence of one or more elements / components / etc.; the terms "including" and "having" are used to express an open-ended inclusion and mean that additional elements / components / etc. may exist in addition to the listed elements / components / etc.; the terms "first" and "second" etc. are used only as labels and are not intended to limit the quantity of their objects.
[0034] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings represent the same or similar parts, and their repeated descriptions will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities.
[0035] Currently, business flows are generally arranged in the following two ways:
[0036] The first one is based on the chain of responsibility mode + strategy mode + thread pool mode, refer to Figure 2 , Figure 2 A schematic diagram showing a business flow implemented by the responsibility chain mode in the related art is shown. Specifically, a task is split into multiple subtasks (for example, into 4 subtasks), and then, it is determined whether the multiple subtasks are executed serially or in parallel. If they are executed serially, refer to Figure 2 , directly register it to the responsibility chain, and execute it serially through processor 1, processor 2, processor 3 and processor 4. If it is not executed serially, it will be merged into a task unit. After the task unit is registered to the responsibility chain, the task unit uses the thread pool to execute the subtasks in parallel. However, this method has poor scalability and flexibility, and when a task execution process needs to add a new task unit, in addition to developing a new task unit, it is also necessary to modify the code of the responsibility chain or add thread pool related code, which seriously invades the original code.
[0037] In this arrangement mode, when you need to add branch logic or add a new site / scenario, you usually add ifelse judgments to drive the execution of business branch processes by coupling hard coding. Figure 3 , Figure 3 A schematic diagram showing the expansion of business in the responsibility chain orchestration mode is shown as follows: Figure 3 As shown in the figure, if condition 3 needs to be added, it is necessary to add if else judgment about condition 3 based on the original code. However, a large number of if else judgments lead to serious code coupling, and the hard-coding method increases the release cost and transformation cost. The business logic is complex and difficult to understand and maintain, which prolongs the development and testing cycle and increases the development cost.
[0038] The second method is to introduce a workflow framework and orchestrate business flows based on the workflow framework. Figure 4 , Figure 4 A schematic diagram of implementing a business flow through a workflow framework in the related art is shown. First, a task is split into multiple subtasks (for example, 4 subtasks), and then each task execution code is written, and the task execution process is defined in XML (Extensible Markup Language) or a database table, and then the task execution is driven by the workflow framework. However, this solution requires the additional introduction of a workflow framework, and the workflow framework is more suitable for use in scenarios involving different people handling different things or involving automated processes. Introducing this framework here, on the one hand, the scenario is not very suitable, and on the other hand, defining the task execution process in XML or a database is more complicated to configure, implement, and test. The introduction of this complexity increases the development cost and understanding cost, and the testing and maintenance costs also increase.
[0039] In this orchestration mode, when business expansion is required, design patterns such as strategy mode and object polymorphism are generally used to solve the problem. When adding a new implementation or adding a new dimension, a new interface or a new implementation class is added. However, this method can still support scenarios such as one-dimensional expansion and two-dimensional expansion well, but when it comes to three-dimensional and four-dimensional expansion, especially in multi-site and multi-tenant SaaS scenarios (Software-as-a-Service), it will bring a lot of sub-implementation classes, which are difficult to maintain.
[0040] In the embodiments of the present disclosure, firstly, a method for realizing a business flow based on annotation is provided, which at least to some extent overcomes the defect of high business development cost in the related art.
[0041] Figure 1A flow chart of an annotation-based business flow implementation method in an embodiment of the present disclosure is shown. The execution subject of the annotation-based business flow implementation method may be a server that implements the business flow.
[0042] refer to Figure 1 According to an embodiment of the present disclosure, a method for implementing a business flow based on annotations includes the following steps:
[0043] Step S110, after the business flow framework is started, multiple code segments for implementing the target business flow and annotation information associated with each code segment are loaded; the target business flow includes multiple business nodes, and there is a preset association relationship between the multiple code segments and the multiple business nodes; the annotation information is at least used to mark the execution order of each code segment;
[0044] Step S120, executing multiple code segments according to the annotation information to implement the target business flow.
[0045] exist Figure 1 In the technical solution provided by the illustrated embodiment, on the one hand, by splitting the target business flow into multiple business nodes, each business node corresponds to an independent code segment, which can achieve decoupling between codes and reduce the difficulty of code maintenance. On the other hand, by annotating the execution order of each code segment through annotation information, and using the annotation information to implement the target business flow, it is convenient for developers to expand the original business. When expanding the business, there is no need for developers to consider the coupling relationship between the newly added code segment and the original code, and it also avoids the technical problems of large intrusion into the original code and high business expansion cost caused by making a large number of modifications to the original code, thereby reducing the business expansion cost and improving the business development speed.
[0046] The following Figure 1 The specific implementation process of each step is described in detail:
[0047] The business flow in this disclosure refers to the relevant process formulated after interpreting and analyzing the needs of a certain business project. The business flow may include multiple business stages, and the business stages are driven by flow conditions.
[0048] It should be noted that, before step S110, the target business flow can be split into multiple business nodes according to the execution logic of each target business flow. Exemplarily, the execution logic of each target business flow can be regarded as a pipeline, and then the target business flow is first split into multiple processing stages, each processing stage is a first-level node, and then each processing stage is split into multiple processing steps, each processing step corresponds to a second-level node.
[0049] The specific splitting process can be performed by relevant business developers, or a machine learning model for splitting business logic can be pre-trained. Then, the above-mentioned target business flow can be analyzed, structured, decomposed, and logically abstracted through the machine learning model to split the target business flow into three dimensions.
[0050] Exemplarily, taking the target business flow as the deduction business as an example, the deduction pipeline can be divided into three stages, the first stage is the verification stage, the second stage is the deduction stage, and the third stage is the balance update stage, wherein the verification stage may include two steps of identity verification and mobile phone number verification, the deduction stage includes a deduction step, and the balance update stage includes a balance update step.
[0051] Furthermore, business developers can treat each step as a programming unit, write code segments for each step, and add annotation information to each code segment. The above annotation information can be Java annotations, which provide a safe, comment-like mechanism to associate any information or metadata with program elements (classes, methods, member variables, etc.), and add more intuitive and clear descriptions to the program elements (classes, methods, member variables). These descriptions are independent of the business logic of the program and are used by specified tools or frameworks. Annotations are applied to declaration statements of packages, types, constructors, methods, member variables, parameters, and local variables like a modifier. Java annotations are some meta-information attached to the code, which are used by some tools to parse and use during compilation and runtime, and play the role of description and configuration. Annotations do not affect the actual logic of the code, but only play an auxiliary role.
[0052] Exemplarily, the annotation information in the present disclosure may include three categories, @Pipeline, @Phase, and @Step.
[0053] Among them, @Pipeline is the annotation information of the business dimension. The @Pipeline annotation contains the information of name=xxx, which is used to identify the target business flow corresponding to the Pipeline.
[0054] @Phase is the annotation information of the phase dimension. The @Phase annotation contains Pipeline=xxx information, which is used to identify the target business flow to which the phase belongs. In addition, the following attributes can also be defined in the @Phase annotation: ①parallel attribute, used to indicate whether the Step contained in the Phase is executed in parallel or serially; ②order attribute, used to indicate the execution order of the Step contained in the Phase; ③timeout attribute, used to indicate the execution timeout of the Phase; ④poolsize attribute, used to indicate the number of thread pools used during the execution of the Phase; ⑤requireds attribute, used to indicate whether the Phase needs to be executed.
[0055] @Step is the annotation information of the step dimension. The @Step annotation contains information such as Pipeline=xxx, Phase=xxx, etc., indicating which Pipeline and Phase the Step belongs to.
[0056] It should be noted that the present disclosure also supports the use of @Reference annotation to directly reference an already written annotation, thereby avoiding repeated definitions of the same annotation, improving annotation writing efficiency, and thus improving business development efficiency.
[0057] After writing the above code segments and marking the annotation information associated with each code segment, the above code segments and their annotation information can be stored in a preset storage path (for example: the project root directory, which can be set according to actual conditions and is not specifically limited in this disclosure).
[0058] In step S110 , after the business flow framework is started, multiple code segments for implementing the target business flow and annotation information associated with each code segment are loaded.
[0059] In this step, after the business flow framework is started, the pre-written code segments and the annotation information associated with each code segment can be loaded by using the initialization program. The business flow framework can be a tdframework framework.
[0060] Exemplarily, the above-mentioned code segments can be traversed to find whether there is an identifier "@" in the code segment. If such an identifier exists, it indicates that the code segment has corresponding annotation information. Then, the Java reflection mechanism can be used to scan the above-mentioned preset storage path to obtain the annotation information associated with each code segment, and the annotation information is loaded into the memory, and then jump to the next code segment, and repeat the above-mentioned search and scanning steps until the loading of the annotation information associated with each code segment is completed.
[0061] After loading the annotation information associated with each code segment, the business flow framework can arrange the multiple Phases contained in the target business flow and the multiple Steps contained in each Phase in chronological order according to the execution order (order attribute) and the serial and parallel relationship between the steps (parallel attribute) contained in the above annotation information to form a Pipeline corresponding to the target business flow.
[0062] Exemplary, reference Figure 5 , Figure 5 A schematic diagram of the Pipeline arranged in the embodiment of the present disclosure is shown as follows: Figure 5 As shown, the Pipeline contains three Phases, namely Phase1, Phase2 and Phase3, where Phase1 contains two serial Steps, namely Step1 and Step2, Phase2 contains three parallel Steps, namely Step1, Step2 and Step3, and Phase3 contains one Step, namely Step1.
[0063] Next reference Figure 1 In step S120, multiple code segments are executed according to the annotation information to implement the target business flow.
[0064] In this step, it should be noted that each first-level node corresponds to a specific code segment, and each second-level node may correspond to one or more candidate code segments.
[0065] In an optional implementation, in the early stages of business development, due to the relatively simple business application scenarios, there may be only one candidate code segment corresponding to the secondary node. In this case, there is no need to distinguish between different business scenarios. It is only necessary to execute the above-mentioned multiple code segments in sequence according to the configuration information such as the execution order contained in the annotation information to achieve the target business flow.
[0066] In another optional implementation, as the business continues to expand, business application scenarios will gradually become richer. At this time, in order to adapt to different business application scenarios, there will be a situation where multiple candidate code segments exist under a certain secondary node.
[0067] Different business application scenarios depend on at least one or more of the following parameters: business deployment information, partner information and business type, or other parameters linked to the actual business, which can be set according to actual conditions, and this disclosure does not make any special restrictions on this.
[0068] Among them, the service deployment information may include site information and service user information. The site information may be the deployment location of the service, such as: different countries (for example: Country A, Country B, Country C, etc.) or different provinces and cities in a country (for example: Province A, Province B, City C, etc.); the service user information may be the name of the user of the service, such as: Party A, Party B, Party C, etc.
[0069] The partner information refers to the object with which the business developer cooperates to complete the above-mentioned target business, for example: Bank A, Bank B, Bank C, etc.
[0070] The business type depends on the specific content of the business, for example: A business, B business, C business, etc.
[0071] Exemplarily, taking the secondary node as the verification step, the secondary node contains 10 candidate code segments, and the business deployment information is site information as an example for explanation, then when the site information is country A, the partner is bank A, and the business type is business A, the verification step may need to execute candidate code segment 1; when the site information is country A, the partner is bank A, and the business type is business B, the verification step may need to execute candidate code segment 2. When the site information is country A and the partner is bank B, the verification step may need to execute candidate code segment 3; when the site information is country A and the partner is bank C, the verification step may need to execute candidate code segment 4. When the site information is country C, the verification step may need to execute candidate code segment 5.
[0072] Therefore, the present disclosure pre-stores a correspondence table between different application scenarios (i.e., different combinations of the three dimensional parameters of the above-mentioned business deployment information, partner information, and business type) and the target code segments that need to be executed, so as to adapt to the situation of quickly adapting the target code segments from multiple candidate code segments in multi-dimensional application scenarios, thereby improving business development efficiency.
[0073] Thus, in the specific business execution process, when any secondary node contains multiple candidate code segments, the current application scenario of the target business flow can be obtained, and then, according to the above-mentioned pre-stored correspondence table between different application scenarios and different target code segments, the target code segment corresponding to the current application scenario is determined from multiple candidate code segments, and further, the above-mentioned specific code segment is executed according to the annotation information associated with the specific code segment, and the above-mentioned target code segment is executed according to the annotation information associated with the target code segment, so as to realize the above-mentioned target business flow.
[0074] Specifically, refer to Figure 6 , Figure 6 A schematic diagram of a process for determining a target code segment from multiple candidate code segments in an embodiment of the present disclosure is shown, including steps S601 to S604:
[0075] In step S601, the service deployment information, the partner information and the service type are used as the first query condition, and a target code segment satisfying the first query condition is determined from a plurality of candidate code segments according to a corresponding relationship table.
[0076] In this step, the business deployment information, partner information and business type can be used as the first query condition to query whether the query result corresponding to the above-mentioned first query condition (for example: the identifier of the target code segment that meets the above-mentioned first query condition) is pre-stored in the above-mentioned correspondence table. If found, the query result obtained will be determined as the above-mentioned target code segment.
[0077] If no target code segment that meets the first query condition is found, the process proceeds to step S602, where the business deployment information and the partner information are used as second query conditions, and a target code segment that meets the second query condition is determined from multiple candidate code segments according to the correspondence table.
[0078] In this step, the business deployment information and partner information can be used as the second query condition to query whether the query result corresponding to the above second query condition (for example: the identifier of the target code segment that meets the above second query condition) is pre-stored in the above correspondence table. If found, the query result obtained will be determined as the above target code segment.
[0079] If no target code segment meeting the second query condition is found, the process proceeds to step S603 , where the service deployment information is used as the third query condition, and a target code segment meeting the third query condition is determined from multiple candidate code segments according to the correspondence table.
[0080] In this step, the business deployment information can be used as the third query condition to query whether the query result corresponding to the third query condition (for example: the identifier of the target code segment that meets the third query condition) is pre-stored in the above correspondence table. If found, the query result obtained will be determined as the above target code segment.
[0081] If no target code segment satisfying the third query condition is found, the process proceeds to step S604 to determine a pre-specified candidate code segment as the target code segment.
[0082] In this step, the pre-specified candidate code segment may be determined as the target code segment to provide a fallback solution and avoid the problem of the business being unable to be implemented.
[0083] After determining the target code segment from multiple candidate code segments, the specific code segment can be executed according to the arranged Pipeline order and the annotation information of the specific code segment, and the target code segment can be executed according to the annotation information of the target code segment to achieve the above-mentioned target business flow.
[0084] Exemplary, reference Figure 7 , Figure 7 T in the figure represents service deployment information, B represents partner information, and P represents service type. Figure 7 The overall flow diagram of determining a target code segment from multiple candidate code segments in the embodiment of the present disclosure is shown, including steps S701 to S715:
[0085] In step S701, start;
[0086] In step S702, the target code segment is searched according to (business deployment information, partner information and business type);
[0087] In step S703, is it found?
[0088] If yes, then proceed to step S704 to determine the target code segment, and then proceed to step S715 to end; if no, proceed to step S705 to query the target code segment according to (business deployment information, partner information);
[0089] In step S706, is it found?
[0090] If yes, then the process proceeds to step S707 to determine the target code segment, and then proceeds to step S715 to end; if no, then the process proceeds to step S708 to query the target code segment according to (business deployment information);
[0091] In step S709, is it found?
[0092] If yes, then the process proceeds to step S710 to determine the target code segment, and then proceeds to step S715 to end; if no, then the process proceeds to step S711 to query the default version;
[0093] In step S712, is it found?
[0094] If yes, the process proceeds to step S713 to determine the target code segment, and then proceeds to step S715 to end; if no, the process proceeds to step S714 to return "not found".
[0095] It should be noted that, since the code segments of each business stage in the present disclosure are decoupled from each other, when business expansion requires adding a new application scenario under a secondary node, the developer only needs to write a new code segment for the new application scenario, and indicate the correspondence between the new code segment and the above-mentioned new application scenario in the annotation information of the new code segment. Then, in the subsequent business execution process, the business flow framework can directly update the above-mentioned correspondence table according to the scanned annotation information, so that when it is determined that the current application scenario is the above-mentioned new business scenario, the business flow framework can directly call the above-mentioned annotation information and execute the above-mentioned new business code. It can be seen that when the present application is expanding the business, the developer does not need to consider the coupling relationship between the new code segment and the original code, and also avoids the technical problems of large intrusion into the original code and high business expansion cost caused by a large number of modifications to the original code, thereby reducing the business expansion cost and improving the business development speed.
[0096] Based on the above technical solution, the present disclosure can achieve the following technical effects:
[0097] On the one hand, the present disclosure uses the design of Pipeline, Phase, and Step to freely assemble different stages and different tasks on the pipeline. This allows tasks to be split and arranged in a way that is closer to business semantics in various business scenarios, which facilitates flexible expansion and reuse, and is easier to understand and develop.
[0098] Furthermore, based on annotations, Steps are arranged in Phases, and Phases are arranged in Pipelines. When adding new functional logic, there is no intrusion on the original logic. New task logic can be added at the required location through simple annotation arrangement. This greatly improves the development speed, and the non-intrusive feature also makes the cost of regression testing lower.
[0099] Furthermore, in the pipeline, annotations can be used to support parallel or serial execution, specify the priority of Phase and Step, and specify the thread resource consumption threshold in each Phase. These flexible and fine-grained extension point designs and pre-embedded features allow developers to flexibly and freely arrange and design during the development process, and can easily support different business scenarios.
[0100] On the other hand, by pre-storing the target code segments corresponding to different business scenarios, the target code segments required for the specific execution of each Step can also be flexibly loaded according to the business application scenario. Therefore, the present disclosure can be applied to complex SaaS scenarios and support complex and changeable businesses under different business deployment information, partner information, business types and other scenarios.
[0101] The present disclosure also provides a service flow implementation device based on annotations, Figure 8 A schematic diagram showing the structure of an annotation-based business flow implementation device in an exemplary embodiment of the present disclosure is shown; Figure 8 As shown, the annotation-based business flow implementation device 800 may include an information loading module 810 and a code execution module 820. Among them:
[0102] The information loading module 810 is used to load multiple code segments for implementing the target business flow and annotation information associated with each of the code segments after the business flow framework is started; the target business flow includes multiple business nodes, and there is a preset association relationship between the multiple code segments and the multiple business nodes; the annotation information is at least used to mark the execution order of each of the code segments;
[0103] The code execution module 820 is used to execute the multiple code segments according to the annotation information to implement the target business flow.
[0104] In an exemplary embodiment of the present disclosure, the service node includes at least a primary node and a secondary node, the primary node corresponds to the processing stage included in the target service flow; the secondary node corresponds to the processing steps included in each of the processing stages.
[0105] In an exemplary embodiment of the present disclosure, the multiple code segments include a specific code segment corresponding to each of the first-level nodes, and one or more candidate code segments corresponding to each of the second-level nodes; when any of the second-level nodes corresponds to multiple candidate code segments, the code execution module 820 is configured to:
[0106] Acquire the current application scenario of the target business flow; the current application scenario depends on one or more of the following parameters: business deployment information, partner information and business type; determine the target code segment corresponding to the current application scenario from the multiple candidate code segments according to a pre-stored correspondence table between different application scenarios and different target code segments; execute the specific code segment according to annotation information associated with the specific code segment, and execute the target code segment according to annotation information associated with the target code segment to realize the target business flow.
[0107] In an exemplary embodiment of the present disclosure, the code execution module 820 is configured to:
[0108] The service deployment information, the partner information and the service type are used as a first query condition, and according to the correspondence table, a target code segment that meets the first query condition is determined from the multiple candidate code segments.
[0109] In an exemplary embodiment of the present disclosure, the code execution module 820 is configured to:
[0110] If no target code segment meeting the first query condition is found, the business deployment information and the partner information are used as second query conditions; and according to the correspondence table, a target code segment meeting the second query condition is determined from the multiple candidate code segments.
[0111] In an exemplary embodiment of the present disclosure, the code execution module 820 is configured to:
[0112] If no target code segment meeting the second query condition is found, the service deployment information is used as a third query condition; and according to the correspondence table, a target code segment meeting the third query condition is determined from the multiple candidate code segments.
[0113] In an exemplary embodiment of the present disclosure, the code execution module 820 is configured to:
[0114] If no target code segment satisfying the third query condition is found, a pre-specified candidate code segment is determined as the target code segment.
[0115] In an exemplary embodiment of the present disclosure, the code execution module 820 is configured to:
[0116] Based on the Java reflection mechanism, a preset storage path is scanned to obtain the annotation information associated with each code segment; the preset storage path is used to store the annotation information; and the annotation information obtained by scanning is loaded into the memory.
[0117] The specific details of each module in the above-mentioned annotation-based business flow implementation device have been described in detail in the corresponding annotation-based business flow implementation method, so they will not be repeated here.
[0118] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.
[0119] In addition, although the steps of the method in the present disclosure are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.
[0120] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a mobile terminal, or a network device, etc.) to execute the method according to the implementation of the present disclosure.
[0121] The present application also provides a computer-readable storage medium, which may be included in the electronic device described in the above embodiment; or may exist independently without being assembled into the electronic device.
[0122] The computer-readable storage medium may 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 computer-readable storage media may include, but are not limited to, an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.
[0123] Computer-readable storage media can send, propagate or transmit programs for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable storage medium can be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0124] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by an electronic device, the electronic device implements the method described in the above embodiments.
[0125] In addition, an electronic device capable of implementing the above method is also provided in an embodiment of the present disclosure.
[0126] Those skilled in the art will appreciate that various aspects of the present disclosure may be implemented as systems, methods or program products. Therefore, various aspects of the present disclosure may be specifically implemented in the following forms, namely: complete hardware implementation, complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to herein as "circuits", "modules" or "systems".
[0127] Refer to the following Fig. 9 The electronic device 900 according to this embodiment of the present disclosure is described. Fig. 9 The electronic device 900 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0128] like Fig. 9 As shown, the electronic device 900 is in the form of a general computing device. The components of the electronic device 900 may include, but are not limited to: the at least one processing unit 910, the at least one storage unit 920, a bus 930 connecting different system components (including the storage unit 920 and the processing unit 910), and a display unit 940.
[0129] The storage unit stores a program code, which can be executed by the processing unit 910, so that the processing unit 910 performs the steps according to various exemplary embodiments of the present disclosure described in the above “Exemplary Method” section of this specification. For example, the processing unit 910 can perform the following steps: Figure 1 As shown in: Step S110, after the business flow framework is started, multiple code segments for implementing the target business flow and annotation information associated with each of the code segments are loaded; the target business flow includes multiple business nodes, and there is a preset association relationship between the multiple code segments and the multiple business nodes; the annotation information is at least used to mark the execution order of each of the code segments; Step S120, execute the multiple code segments according to the annotation information to implement the target business flow.
[0130] The storage unit 920 may include a readable medium in the form of a volatile storage unit, such as a random access storage unit (RAM) 9201 and / or a cache storage unit 9202 , and may further include a read-only storage unit (ROM) 9203 .
[0131] The storage unit 920 may also include a program / utility 9204 having a set (at least one) of program modules 9205, such program modules 9205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0132] Bus 930 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0133] The electronic device 900 may also communicate with one or more external devices 1000 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 900, and / or communicate with any device that enables the electronic device 900 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 950. Furthermore, the electronic device 900 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 960. As shown, the network adapter 960 communicates with other modules of the electronic device 900 via a bus 930. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 900, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.
[0134] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not disclosed in the present disclosure. The specification and examples are to be considered as exemplary only, and the true scope and spirit of the present disclosure are indicated by the claims.
Claims
1. A method for realizing a business flow based on annotation, characterized in that: include: After the business flow framework is started, multiple code segments for implementing the target business flow and annotation information associated with each of the code segments are loaded; the target business flow includes multiple business nodes, and there is a preset association relationship between the multiple code segments and the multiple business nodes; the annotation information is at least used to mark the execution order of each of the code segments; the business nodes include at least a primary node and a secondary node; the primary node corresponds to the processing stage included in the target business flow; the secondary node corresponds to the processing steps included in each of the processing stages; the multiple code segments include a specific code segment corresponding to each of the primary nodes, and multiple candidate code segments corresponding to each of the secondary nodes; Executing the multiple code segments according to the annotation information to implement the target business flow; Wherein, in a specific service execution process, when any of the secondary nodes corresponds to multiple candidate code segments, executing the multiple code segments according to the annotation information to implement the target service flow includes: Acquire the current application scenario of the target service flow; the current application scenario depends on one or more of the following parameters: service deployment information, partner information and service type; Determining the target code segment corresponding to the current application scenario from the plurality of candidate code segments according to a pre-stored correspondence table between different application scenarios and different target code segments; The specific code segment is executed according to the annotation information associated with the specific code segment, and the target code segment is executed according to the annotation information associated with the target code segment to implement the target business flow.
2. The method according to claim 1, characterized in that: The determining, from the plurality of candidate code segments, a target code segment corresponding to the current application scenario according to the pre-stored correspondence between different application scenarios and different target code segments, comprises: The service deployment information, the partner information and the service type are used as a first query condition, and according to the correspondence table, a target code segment that meets the first query condition is determined from the multiple candidate code segments.
3. The method according to claim 2, characterized in that The method further comprises: If no target code segment meeting the first query condition is found, the service deployment information and the partner information are used as the second query condition; According to the correspondence table, a target code segment satisfying the second query condition is determined from the multiple candidate code segments.
4. The method according to claim 3, characterized in that The method further comprises: If no target code segment meeting the second query condition is found, the service deployment information is used as the third query condition; According to the correspondence table, a target code segment satisfying the third query condition is determined from the multiple candidate code segments.
5. The method according to claim 4, characterized in that The method further comprises: If no target code segment satisfying the third query condition is found, a pre-specified candidate code segment is determined as the target code segment.
6. The method according to any one of claims 1 to 5, characterized in that: Loading annotation information associated with each of the code segments, including: Scanning a preset storage path based on a Java reflection mechanism to obtain the annotation information associated with each of the code segments; the preset storage path is used to store the annotation information; The annotation information obtained by scanning is loaded into the memory.
7. A business flow implementation device based on annotation, characterized in that: include: An information loading module is used to load multiple code segments for implementing a target business flow and annotation information associated with each of the code segments after the business flow framework is started; the target business flow includes multiple business nodes, and there is a preset association relationship between the multiple code segments and the multiple business nodes; the annotation information is at least used to mark the execution order of each of the code segments; the business nodes include at least a primary node and a secondary node; the primary node corresponds to the processing stage included in the target business flow; the secondary node corresponds to the processing steps included in each of the processing stages; the multiple code segments include a specific code segment corresponding to each of the primary nodes, and multiple candidate code segments corresponding to each of the secondary nodes; A code execution module, used for executing the multiple code segments according to the annotation information to implement the target business flow; Wherein, in a specific service execution process, when any of the secondary nodes corresponds to multiple candidate code segments, executing the multiple code segments according to the annotation information to implement the target service flow includes: Acquire the current application scenario of the target service flow; the current application scenario depends on one or more of the following parameters: service deployment information, partner information and service type; Determining the target code segment corresponding to the current application scenario from the plurality of candidate code segments according to a pre-stored correspondence table between different application scenarios and different target code segments; The specific code segment is executed according to the annotation information associated with the specific code segment, and the target code segment is executed according to the annotation information associated with the target code segment to implement the target business flow.
8. A computer storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the annotation-based business flow implementation method described in any one of claims 1 to 6 is implemented.
9. An electronic device, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; The processor is configured to execute the annotation-based business flow implementation method according to any one of claims 1 to 6 by executing the executable instructions.
