Business processing method and apparatus, storage medium, and electronic device
By obtaining a common business template and using annotation technology to annotate container classes, the problem of managing cross-module business was solved, business logic isolation and cross-module injection were achieved, and code readability and project management efficiency were improved.
Patent Information
- Application Number
- CN202210379530.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-12
- Publication Date
- 2026-01-02
- Estimated Expiration
- 2042-04-12
AI Technical Summary
In existing technologies, cross-module and multi-module business processes are difficult to manage in a standardized manner, resulting in scattered business logic, repetitive implementation and maintenance difficulties. Furthermore, the triggering timing and rules are variable, making centralized management and flexible modification difficult.
By obtaining a general business template, the initial business class is rewritten, and the initial container class is annotated with annotation technology to achieve isolation of business classes and cross-module injection. Combined with reflection mechanism for instantiation and priority management, the business is executed by listening to the container state.
It improves code readability and reusability, reduces project complexity and maintenance difficulty, and enables centralized management and flexible execution of cross-module business logic.
Smart Images

Figure CN114741159B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of computer, and in particular, to a business processing method and device, a computer readable storage medium and an electronic device. BACKGROUND
[0002] When the project gradually expands, it is a necessary process to sort and modularize the project. This also helps us to standardize the management of the project, reduce the confusion and complexity of the project, and facilitate the division of responsibilities among project personnel. However, in the actual development process, as the complexity of the business increases, there will always be cross-module and multiple modules or the same module multiple times. For such businesses, modularization cannot play a standard management effect.
[0003] Usually, such businesses are mixed in non-corresponding modules or repeatedly implemented in multiple modules, so it is necessary to write the business logic that should be in module A in module B, and it is also necessary to repeatedly implement the same business logic in multiple modules. Moreover, the triggering time and triggering rules of such businesses are usually variable, and the scattered and fragmented businesses are difficult to maintain and easy to miss when the subsequent business changes.
[0004] In view of this, there is an urgent need in the art to develop a new business processing method and device.
[0005] It should be noted that the information disclosed in the above background section is only used to strengthen the understanding of the background of the present disclosure, and therefore can include information that does not constitute prior art known to those of ordinary skill in the art. SUMMARY
[0006] The purpose of the present disclosure is to provide a business processing method, a business processing device, a computer readable storage medium and an electronic device, thereby at least partially overcoming the technical problems that the business is difficult to iterate and cannot be centrally managed due to the limitations of the related art.
[0007] Other characteristics and advantages of the present disclosure will become apparent from the following detailed description, or will be learned by practice of the present disclosure.
[0008] According to a first aspect of the embodiments of the present disclosure, a business processing method is provided, and the method comprises:
[0009] obtaining a general business template, and rewriting the general business template to obtain an initial business class;
[0010] determining an initial container class corresponding to the initial business class, and performing annotation processing on the initial container class according to the initial business class to obtain an annotated container class;
[0011] injecting the initial business class into the annotated container class for execution.
[0012] In an example embodiment of the present application, the obtaining the general service template comprises:
[0013] obtaining a target service, and performing abstract integration processing on the target service to obtain the general service template.
[0014] In an example embodiment of the present application, the general service template comprises an execution condition interface and a recycling interface.
[0015] In an example embodiment of the present application, the marking processing on the initial container class according to the initial service class to obtain a marked container class comprises:
[0016] marking the initial service class in the initial container class by using an annotation technology to obtain a marked container class.
[0017] In an example embodiment of the present application, the marking processing on the initial container class according to the initial service class to obtain a marked container class comprises:
[0018] if the initial service class and the initial container class have an association relationship, marking the initial service class in the initial container class to obtain a marked container class;
[0019] if the initial service class and the initial container class do not have an association relationship, marking a string corresponding to the initial service class in the initial container class to obtain a marked container class.
[0020] In an example embodiment of the present application, the injecting the initial service class into the marked container class for execution comprises:
[0021] if the marked container class is in a created state, initializing the marked container class, and injecting the initial service class into the initialized marked container class for execution.
[0022] In an example embodiment of the present application, the initializing the marked container class, and injecting the initial service class into the initialized marked container class for execution comprises:
[0023] constructing a corresponding service class list according to the marked container class, and setting a current priority corresponding to the service class list;
[0024] obtaining the initial service class corresponding to the marked container class and a service priority of the initial service class, and comparing the service priority with the current priority to obtain a comparison result;
[0025] According to the comparison result, the initial service class is injected into the initialized annotation container class for execution.
[0026] In an example embodiment of the present application, the initial service class corresponding to the annotation container class and the service priority of the initial service class are obtained, comprising:
[0027] The initial service class corresponding to the annotation container class is obtained, and the service class is instantiated.
[0028] The instantiated initial service class is saved in the service class list, and the service priority of the instantiated initial service class is obtained.
[0029] In an example embodiment of the present application, the initial service class corresponding to the annotation container class is obtained, and the service class is instantiated, comprising:
[0030] The initial service class corresponding to the annotation container class is obtained by using a reflection mechanism, and the initial service class is instantiated.
[0031] In an example embodiment of the present application, the initial service class corresponding to the annotation container class is obtained by using a reflection mechanism, and the initial service class is instantiated, comprising:
[0032] If the annotation container class is obtained by the initial service class, the initial service class is instantiated.
[0033] If the annotation container class is obtained by the initial service class, the initial service class is instantiated.
[0034] In an example embodiment of the present application, the comparison between the service priority and the current priority comprises:
[0035] If the instantiated initial service class meets the execution condition, the comparison between the service priority and the current priority is performed.
[0036] In an example embodiment of the present application, according to the comparison result, the initial service class is injected into the initialized annotation container class for execution, comprising:
[0037] If the comparison result is that the service priority is greater than the current priority, it is determined that the current priority is equal to the service priority.
[0038] listening to a container state of the initialized marked container class, and injecting the initial service class into the initialized marked container class according to the container state.
[0039] In an example embodiment of the present application, the listening to the container state of the initialized marked container class comprises:
[0040] listening to the container state of the initialized marked container class by using a listening interface corresponding to the marked container class.
[0041] In an example embodiment of the present application, the injecting the initial service class into the initialized marked container class according to the container state comprises:
[0042] if the container state is the non-destroyed state, matching the service class list according to the current priority to obtain an executable service class;
[0043] if the executable service class satisfies an execution condition, injecting the executable service class into the initialized marked container class for execution by using the execution condition interface.
[0044] In an example embodiment of the present application, the method further comprises:
[0045] if the container state is the destroyed state, removing the initial service class corresponding to the current priority from the service class list by using the recycling interface.
[0046] In an example embodiment of the present application, the method further comprises:
[0047] if the service class is executed, determining a next priority according to the current priority, and determining a next service class in the initial service class according to the next priority;
[0048] if the next service class satisfies an execution condition, injecting the next service class into the initialized marked container class for execution by using the execution condition interface.
[0049] According to a second aspect of embodiments of the present application, a service processing apparatus is provided, comprising:
[0050] a template rewriting module configured to obtain a general service template, and rewrite the general service template to obtain an initial service class;
[0051] a container marking module configured to determine an initial container class corresponding to the initial service class, and mark the initial container class according to the initial service class to obtain a marked container class;
[0052] a business execution module configured to inject the initial business class into the annotated container class for execution.
[0053] In an example embodiment of the present application, the obtaining a general business template comprises:
[0054] obtaining a target business and performing abstract integration processing on the target business to obtain a general business template.
[0055] In an example embodiment of the present application, the general business template comprises an execution condition interface and a recycling interface.
[0056] In an example embodiment of the present application, the annotating the initial container class according to the initial business class to obtain an annotated container class comprises:
[0057] annotating the initial container class with the initial business class by using an annotation technology to obtain an annotated container class.
[0058] In an example embodiment of the present application, the annotating the initial container class with the initial business class by using an annotation technology to obtain an annotated container class comprises:
[0059] if the initial business class and the initial container class have an association relationship, annotating the initial business class in the initial container class to obtain an annotated container class;
[0060] if the initial business class and the initial container class do not have an association relationship, annotating a string corresponding to the initial business class in the initial container class to obtain an annotated container class.
[0061] In an example embodiment of the present application, the injecting the initial business class into the annotated container class for execution comprises:
[0062] if the annotated container class is in a created state, initializing the annotated container class and injecting the initial business class into the initialized annotated container class for execution.
[0063] In an example embodiment of the present application, the initializing the annotated container class and injecting the initial business class into the initialized annotated container class for execution comprises:
[0064] constructing a corresponding business class list according to the annotated container class and setting a current priority corresponding to the business class list;
[0065] obtaining the initial business class corresponding to the annotated container class and a business priority of the initial business class, and comparing the business priority with the current priority to obtain a comparison result;
[0066] According to the comparison result, the initial service class is injected into the initialized annotation container class for execution.
[0067] In an example embodiment of the present application, the initial service class corresponding to the annotation container class and the service priority of the initial service class are obtained, including:
[0068] The initial service class corresponding to the annotation container class is obtained, and the service class is instantiated.
[0069] The instantiated initial service class is saved in the service class list, and the service priority of the instantiated initial service class is obtained.
[0070] In an example embodiment of the present application, the initial service class corresponding to the annotation container class is obtained, and the service class is instantiated, including:
[0071] The initial service class corresponding to the annotation container class is obtained by using a reflection mechanism, and the initial service class is instantiated.
[0072] In an example embodiment of the present application, the initial service class corresponding to the annotation container class is obtained by using a reflection mechanism, and the initial service class is instantiated, including:
[0073] If the annotation container class is obtained by the initial service class, the initial service class is instantiated.
[0074] If the annotation container class is obtained by the initial service class, the initial service class is instantiated.
[0075] In an example embodiment of the present application, the comparison between the service priority and the current priority includes:
[0076] If the instantiated initial service class meets the execution condition, the comparison between the service priority and the current priority is performed.
[0077] In an example embodiment of the present application, according to the comparison result, the initial service class is injected into the initialized annotation container class for execution, including:
[0078] If the comparison result is that the service priority is greater than the current priority, it is determined that the current priority is equal to the service priority.
[0079] listening to a container state of the initialized marked container class, and injecting the initial service class into the initialized marked container class according to the container state.
[0080] In an example embodiment of the present application, the listening to the container state of the initialized marked container class comprises:
[0081] The container state of the initialized marked container class is listened to by using a listening interface corresponding to the marked container class.
[0082] In an example embodiment of the present application, the injecting the initial service class into the initialized marked container class according to the container state comprises:
[0083] If the container state is the non-destroyed state, the service class list is matched according to the current priority to obtain an executable service class;
[0084] If the executable service class satisfies an execution condition, the executable service class is injected into the initialized marked container class for execution by using the execution condition interface.
[0085] In an example embodiment of the present application, the method further comprises:
[0086] If the container state is the destroyed state, the initial service class corresponding to the current priority is removed from the service class list by using the recycling interface.
[0087] In an example embodiment of the present application, the method further comprises:
[0088] If the service class is executed, a next priority is determined according to the current priority, and a next service class is determined in the initial service class according to the next priority;
[0089] If the next service class satisfies an execution condition, the next service class is injected into the initialized marked container class for execution by using the execution condition interface.
[0090] According to a third aspect of the embodiments of the present application, an electronic device is provided, comprising a processor and a memory; wherein the memory has stored thereon computer readable instructions, which, when executed by the processor, implement the service processing method in any of the example embodiments.
[0091] According to a fourth aspect of the embodiments of the present application, a computer readable storage medium is provided, which has stored thereon a computer program, which, when executed by a processor, implements the service processing method in any of the example embodiments.
[0092] According to the technical solution, the service processing method, the service processing device, the computer storage medium and the electronic device provided by the example embodiments of the present disclosure have at least the following advantages and positive effects:
[0093] In the method and device provided by the example embodiments of the present disclosure, all service requirement codes that need to be injected across modules or have high similarity are specified by the general service template, thereby improving the readability, reusability and expansibility of the codes and providing a data basis for centralized management of the codes. Furthermore, the initial service class is used to annotate the initial container class, so as to realize isolation and cross-module injection of the service requirement codes. Still further, the initial service class is injected into the annotated container class for execution, thereby solving the complexity problem caused by service superposition and providing users with the ability to quickly understand and master the flow and distribution of various services, thereby reducing the complexity, maintenance burden and expansion difficulty of the project.
[0094] It should be understood that the foregoing general description and the following detailed description are only exemplary and explanatory, and cannot limit the present disclosure. BRIEF DESCRIPTION OF DRAWINGS
[0095] The accompanying drawings, which are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure and, together with the specification, serve to explain the principles of the present disclosure. Obviously, the accompanying drawings in the following description are only some embodiments of the present disclosure, and other drawings can be obtained by those skilled in the art without creative labor on the basis of the drawings.
[0096] Figure 1 A first development flowchart of introducing a common module in the related art is schematically shown;
[0097] Figure 2 A second development flowchart of implementing the same service multiple times in the related art is schematically shown;
[0098] Figure 3 A flowchart of a service processing method in the example embodiments of the present disclosure is schematically shown;
[0099] Figure 4 A service execution flowchart of the general service template in the example embodiments of the present disclosure is schematically shown;
[0100] Figure 5 A flowchart of a method of annotating an initial container class in the example embodiments of the present disclosure is schematically shown;
[0101] Figure 6 A container state transition diagram of the initial container class in the Android system in the example embodiments of the present disclosure is schematically shown;
[0102] Figure 7 FIG. 4 is a flowchart illustrating a method of initializing a container class in an exemplary embodiment of the present disclosure;
[0103] Figure 8 FIG. 5 is a flowchart illustrating a method of obtaining an initial service class and a corresponding service priority in an exemplary embodiment of the present disclosure;
[0104] Figure 9 FIG. 6 is a flowchart illustrating a method of obtaining an initial service class using a reflection mechanism in an exemplary embodiment of the present disclosure;
[0105] Figure 10 FIG. 7 is a flowchart illustrating a method of executing an initial service class according to a comparison result in an exemplary embodiment of the present disclosure;
[0106] Figure 11 FIG. 8 is a flowchart illustrating a method of executing an initial service class according to a container state in an exemplary embodiment of the present disclosure;
[0107] Figure 12 FIG. 9 is a flowchart illustrating a method of executing a next service class in an exemplary embodiment of the present disclosure;
[0108] Figure 13 FIG. 10 is a flowchart illustrating a service processing method in an application scenario in an exemplary embodiment of the present disclosure;
[0109] Figure 14 FIG. 11 is a flowchart illustrating a method of initializing a container class in an application scenario in an exemplary embodiment of the present disclosure;
[0110] Figure 15 FIG. 12 is a block diagram illustrating a service processing apparatus in an exemplary embodiment of the present disclosure;
[0111] Figure 16 FIG. 13 is an electronic device for implementing a service processing method in an exemplary embodiment of the present disclosure;
[0112] Figure 17 FIG. 14 is a computer-readable storage medium for implementing a service processing method in an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION
[0113] Example implementations are now described with reference to the drawings. Example implementations can, however, be implemented in many different forms and should not be construed as limited to the examples set forth herein; rather, these implementations are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the example implementations to those skilled in the art. The described features, structures, or characteristics can be combined in one or more implementations. In the following description, numerous specific details are provided, such as examples of programming, software modules, user selections, network transactions, database queries, database structures, hardware modules, hardware- specific architectures, memory, processors, etc., in order to provide a thorough understanding of the example implementations. However, it will be recognized that the example implementations can be practiced without one or more of the specific details, or with other methods, components, materials, and so forth. In other instances, well-known structures have not been described in detail in order to avoid obscuring the example implementations.
[0114] The use of the terms "one," "a," "an," and "the" in this specification are used to mean that "at least one," "one or more," or "one or more than one" of the enumerated number of an element is present; the use of the terms "first," "second," and the like does not imply an order or ranking but is used for identification purposes only.
[0115] Also, the accompanying drawings are included to provide a further understanding of the present disclosure and are incorporated in and constitute a part of this specification. The drawings illustrate examples of the present disclosure and, together with the description, serve to explain principles of the present disclosure. In the drawings:
[0116] When the project gradually expands, it is necessary to sort and modularize the project. This helps to standardize the management of the project, reduce the degree of confusion and complexity of the project, and facilitate the division of responsibilities among project personnel.
[0117] However, in the actual development process, as the complexity of the business increases, there will always be cross-module and multiple-module or multiple occurrences of the same module business.
[0118] For such businesses, modularization cannot achieve the desired effect. They are either mixed in non-corresponding modules or repeated in multiple modules, so it is necessary to write the business logic that should be in module A in module B, and it is also necessary to repeatedly implement the same business logic in multiple modules, and their triggering time and triggering rules are usually variable. When the subsequent business changes, the scattered and fragmented business is difficult to maintain and easy to miss.
[0119] Taking an Android project as an example, for the business common to cross-module or multiple modules, there are usually two development processes.
[0120] Figure 1 This illustrates a development process diagram for the first type of introducing shared modules, such as... Figure 1 As shown, the referenced module is module Base. Business x that appears across modules, multiple modules, or multiple times in a single module is deposited into module Base. Then, module A and module B depend on module Base.
[0121] This approach will gradually accumulate code that originally belonged to module A or module B into module Base, eventually causing module Base to become increasingly bloated and turn into a combination of multiple modules, which runs counter to the original intention of modularization.
[0122] Figure 2 This illustrates a second type of development process that involves implementing the same business logic multiple times, as shown in the diagram. Figure 2 As shown, business function x is implemented in module A, and business function x is also implemented again in module B.
[0123] This approach leads to the same business logic code appearing repeatedly in multiple places. This means that when business logic changes, code needs to be updated in multiple places simultaneously, significantly impacting iteration efficiency. Furthermore, if the same business logic is distributed too broadly or developers forget about it during iterations, omissions can easily occur.
[0124] In addition, both solutions share a common problem: when business development becomes too complex, the first solution, while offering centralized management, suffers from inflexible changes and is difficult to modify due to business coupling. The second solution, while flexible and easily modifiable, lacks centralized management.
[0125] In view of the problems existing in the related technologies, this disclosure proposes a business processing method. Figure 3 A flowchart of the business processing method is shown, such as Figure 3 As shown, the business processing method includes at least the following steps:
[0126] Step S310. Obtain the general business template and rewrite the general business template to obtain the initial business class.
[0127] Step S320. Determine the initial container class corresponding to the initial business class, and annotate the initial container class according to the initial business class to obtain the annotated container class.
[0128] Step S330. Inject the initial business class into the annotation container class and execute.
[0129] In the example embodiments of the present disclosure, all business requirement codes needing to be cross-module or high similarity are specified by the general business template, thereby improving the readability, reusability and expansibility of the codes and providing a data basis for centralized management of the codes. Further, the initial business class is used to annotate the initial container class, thereby realizing isolation and cross-module injection of the business requirement codes. Furthermore, the initial business class is injected into the annotated container class for execution, thereby solving the complexity problem caused by business superposition and providing users with the ability to quickly understand and master the processes and distribution of various businesses, thereby reducing the complexity, maintenance burden and expansion difficulty of the project.
[0130] The steps of the business processing method are described in detail below.
[0131] In step S310, the general business template is obtained, and the general business template is rewritten to obtain the initial business class.
[0132] In the example embodiments of the present disclosure, a set of general business templates can be defined for processing various businesses.
[0133] In the optional embodiments, the target business is obtained, and the target business is abstracted and integrated to obtain the general business template.
[0134] The target business can be any kind of business that needs to be processed, and the example embodiments do not make special limitations on this.
[0135] After the target business is abstracted and integrated, the rules and conditions executed for the target business can be obtained, and the rules and conditions are defined as a set of general business templates.
[0136] Figure 4 A business execution flowchart of the general business template is shown, as shown in Figure 4 The general business template can support obtaining at most one layout control in the page container and obtaining a member variable in one page container.
[0137] In the optional embodiments, the general business template includes an execution condition interface and a recycling interface.
[0138] For example, the general business template provides seven types of interfaces, namely, time, viewId, period and periodGap, condition, priority, execute and release. The time interface, the viewId interface, the period and periodGap interface, the condition interface, the priority interface and the execute interface are execution condition interfaces, and the release interface is a recycling interface.
[0139] Among them, the time interface represents the execution using opportunity, and the user can specify the business to be executed in the Activity class or the Fragment class of Android; the viewId represents the layout control in the page container that needs to be obtained, and can be empty; the period and the periodGap interfaces are the execution period, supporting the setting of the period from seconds to months; the condition is the execution condition, supporting the recording of the executed data, and deciding whether to execute according to the record; the priority is the execution priority, mainly used to solve the problem of competition of multiple businesses in the same page container, and greatly improves the development efficiency; the execute interface is the execution content, used for the user to specify the details of the specific business; and the release interface is the recycling method, which is called when the general business template is recycled, facilitating the user to perform the recycling work.
[0140] When the user implements the business based on the general business template according to actual needs, the business class can be implemented based on the template class.
[0141] Specifically, the execution content, the execution period, the execution condition and the priority of the general business template are rewritten according to the actual business needs to obtain the initial business class.
[0142] In step S320, the initial container class corresponding to the initial business class is determined, and the initial container class is marked to obtain the marked container class according to the initial business class.
[0143] In the example embodiment of the present disclosure, the user determines that the initial business class needs to be marked in the project, that is, the page container using the business class. The page container is the initial container class.
[0144] For example, the page container in the Android system is mainly the Activity class and the Fragment class. Among them, the Fragment class is run on the Activity class, and other classes can also be included according to actual conditions and needs, and the example embodiment does not specially limit this.
[0145] In the optional embodiment, the initial business class is marked in the initial container class to obtain the marked container class by using the annotation technology.
[0146] The user can mark the initial business class in the initial container class required in the project by using the annotation technology of the Java language, indicating that the execution range of the initial business class is on the corresponding initial container class.
[0147] It is worth noting that one initial container class can mark multiple initial business classes. Similarly, one initial business class can also be marked in multiple initial container classes.
[0148] Annotate is a kind of annotation mechanism in Java language, which can annotate classes, methods and variables in Java. And at runtime, the annotation content on the class and variable can be obtained through the reflection mechanism.
[0149] For example, a class annotation @ComponentView and a member variable annotation @ComponentViewData can be provided. Through the two annotations, the initial business class of the user and the member variable of the page container required by the business class can be obtained at the runtime of the APP.
[0150] In optional embodiments, Figure 5 A flowchart of a method for annotating an initial container class is shown, as Figure 5 The method includes the following steps: in step S510, if the initial business class and the initial container class have an association relationship, annotating the initial business class in the initial container class to obtain an annotated container class.
[0151] When the initial business class and the initial container class are in the same module or have a module dependency relationship, it can be considered that the initial business class and the initial container class have an association relationship. The annotated container class can be obtained by directly adding the referenced initial business class in the annotation of the initial business class, thereby achieving the annotation effect.
[0152] In step S520, if the initial business class and the initial container class do not have an association relationship, annotating the string corresponding to the initial business class in the initial container class to obtain an annotated container class.
[0153] When the initial business class and the initial container class are not in the same module and do not have a module dependency relationship, it can be considered that the initial business class and the initial container class do not have an association relationship. Therefore, the annotated container class can be obtained by adding the string corresponding to the initial business class in the annotation of the initial container class, thereby achieving the annotation effect.
[0154] The string corresponding to the initial business class includes the package name and class name of the business class, and can also include other characters. This exemplary embodiment does not specially limit this.
[0155] In this exemplary embodiment, the annotation technology is used to achieve the effect of annotating the initial container class, which meets the needs of isolation and cross-module injection of business requirement code.
[0156] In step S330, the initial business class is injected into the annotated container class for execution.
[0157] In the exemplary embodiments of the present disclosure, the centralized manager can be initialized when an APP (Application) is started, and a life cycle callback listener can be added to an Activity class of the APP.
[0158] The centralized manager is a global singleton class, which can be obtained anywhere when the App is running. The centralized manager can be responsible for obtaining and managing all business classes.
[0159] Figure 6 A container state transition diagram of an initial container class in an Android system is shown in FIG. 1. As shown in FIG. 1, the container states include created onCreate(), started onStart(), resumed onResume(), paused onPause(), stopped onStop(), and destroyed onDestroy() states, and the life cycle of the initial container class is controlled by the Android system. Figure 6
[0160] The Android system provides a life cycle listening API (Application Programming Interface) of the Activity class, by which the life cycle callback notification of all Activity class page containers can be easily obtained. The Android system also provides a life cycle listening API of the Fragment class, by which the life cycle callback notification of the Fragment class can be listened to in the onCreate() state of the Activity class.
[0161] In this way, the life cycle callback of the two page containers Activity class and Fragment class of the Android system is realized.
[0162] Further, the initial business class can be injected into the annotated container by initializing the annotated container class to execute the initial business class.
[0163] In optional embodiments, if the annotated container class is in the created state, the annotated container class is initialized, and the initial business class is injected into the initialized annotated container class to execute.
[0164] For example, for the annotated container class in the Android system, the listening interface of the Activity class and the listening interface of the Fragment class can be used to determine that the annotated container class is in the created state according to the life cycle of the Android system.
[0165] The centralized manager internally maintains two dictionary objects in the form of key-value pairs. One of the dictionary objects stores the class name of the page container, i.e., the mapping relationship between the container class and the initial business class list; the other stores the mapping relationship between the page container and the priority of the initial business class executable by the page container.
[0166] When the container class is in the created state, it can be considered that a new container class is entered. Further, the business class list of the container class can be obtained from the dictionary object of the container class and the business class list.
[0167] When the business class list of the container class cannot be obtained from the dictionary object of the container class and the business class list, the container class can be initialized to inject the initial business class into the initialized container class for execution.
[0168] In an optional embodiment, Figure 7 A flowchart of a method for initializing a container class is shown, as shown in Figure 7 The method includes at least the following steps: in step S710, a business class list corresponding to the container class is constructed, and a current priority corresponding to the business class list is set.
[0169] The business class list constructed according to the container class can be an empty business class list. The business class list is taken as a value, the class name of the container class is taken as a key to form a corresponding key-value pair, and the key-value pair is saved in the dictionary object of the centralized manager.
[0170] In addition, the executable priority of the current container class is set to a default value as the current priority. The default value can be -10086 or other values, and the present exemplary embodiment does not specially limit the default value.
[0171] In step S720, the initial business class corresponding to the container class and the business priority of the initial business class are obtained, and the business priority and the current priority are compared to obtain a comparison result.
[0172] In an optional embodiment, Figure 8 A flowchart of a method for obtaining an initial business class and a corresponding business priority is shown, as shown in Figure 8 The method includes at least the following steps: in step S810, an initial business class corresponding to the container class is obtained, and the business class is instantiated.
[0173] In an optional embodiment, the initial business class corresponding to the container class is obtained by using a reflection mechanism, and the initial business class is instantiated.
[0174] The page container can be obtained through the annotation mechanism of Java, i.e. the value annotated in the container class is instantiated.
[0175] In an optional embodiment, Figure 9 A flowchart of a method for obtaining the initial service class through the reflection mechanism is shown in FIG. 8. Figure 9 As shown in FIG. 8, the method comprises the following steps: in step S910, if the initial service class is annotated in the annotated container class, the initial service class is instantiated.
[0176] When the initial container class is annotated through the annotation technology, the initial service class can be annotated in the initial container class. In this case, the value annotated in the annotated container class is the class object, so the object can be created through the instantiation method of the class to realize the instantiation of the initial service class.
[0177] In step S920, if the annotated container class is obtained from the string corresponding to the initial service class, the initial service class corresponding to the string is obtained through the reflection mechanism, and the initial service class is instantiated.
[0178] When the initial container class is annotated through the annotation technology, the initial service class can be annotated in the initial container class. In this case, the value annotated in the annotated container class is the class object, so the object can be created through the instantiation method of the class to realize the instantiation of the initial service class.
[0179] In the present exemplary embodiment, the instantiation methods corresponding to different annotation methods are provided to provide data support and theoretical basis for the registration to the centralized manager.
[0180] In step S820, the instantiated initial service class is saved in the service class list, and the service priority of the instantiated initial service class is obtained.
[0181] After the initial service classes annotated in the annotated container class are instantiated in sequence, the instantiated initial service classes can be saved in the service class list.
[0182] Since the user specifies the priority in the process of rewriting the general service template, the service priority of the instantiated initial service class can be further obtained.
[0183] In the present exemplary embodiment, the initial service class corresponding to the annotated container class and the priority thereof are obtained to provide data support for comparing the service priority with the current priority.
[0184] In the instantiation process, the service priority can also be compared with the current priority to obtain the corresponding comparison result.
[0185] In an optional embodiment, if the instantiated initial business class meets the execution condition, the business priority is compared with the current priority.
[0186] Before comparing the business priority with the current priority, the execution condition interface can be used to determine whether the instantiated initial business class meets the execution condition required by the execution condition interface. Only when the instantiated initial business class meets the execution condition required by the execution condition interface, the business priority is compared with the current priority to obtain a comparison result.
[0187] In step S730, the initial business class is injected into the initialized markup container class for execution according to the comparison result.
[0188] In an optional embodiment, Figure 10 A flowchart of a method of executing the initial business class according to the comparison result is shown, as shown in Figure 10 The method includes at least the following steps: in step S1010, if the comparison result is that the business priority is greater than the current priority, the current priority is determined to be equal to the business priority.
[0189] When the business priority is greater than the current priority, the priority of the current page that can be executed, i.e., the current priority, can be set to be equal to the business priority.
[0190] It is worth noting that to find the initial business class with the highest priority at this time, the business priorities of other initial business classes can also be traversed and compared with the current priority at this time to constantly assign values to obtain the highest priority and the corresponding initial business class.
[0191] After all the initial business classes of the current markup container class are instantiated, the current priority that can be currently executed is saved to a dictionary object.
[0192] In step S1020, the container state of the initialized markup container class is listened to, and the initial business class is injected into the initialized markup container class for execution according to the container state.
[0193] After the markup container class is initialized, the container state of the initialized markup container class can be listened to.
[0194] In an optional embodiment, the container state of the initialized markup container class is listened to by using a listening interface corresponding to the markup container class.
[0195] For example, in the Android system, the listening interface can include an interface for listening to an Activity class and an interface for listening to a Fragment class.
[0196] In an optional embodiment, Figure 11A flowchart of a method for executing an initial business class according to a container state is shown in FIG. 11. Figure 11 As shown in FIG. 11, the method includes at least the following steps: in step S1110, if the container state is not the destroyed state, matching the business class list according to the current priority to obtain an executable business class.
[0197] When the container state of the container class is detected to be the non-destroyed state, the initial business class corresponding to the container class can be obtained from the business class list in the centralized manager according to the class name of the container class, and the current priority currently executable can be obtained from the priority dictionary of the centralized manager, so as to match and filter the initial business class according to the current priority to obtain an executable business class matching the current priority.
[0198] In step S1120, if the executable business class meets the execution condition, the executable business class is injected into the initialized container class through the execution condition interface for execution.
[0199] After determining the executable business class, the execution time, execution period and execution condition of the executable business class can be matched and verified through the execution condition interface.
[0200] When the executable business class meets the execution condition, the page controls and member variables required by the executable business class can be obtained from the container class through the execution condition interface and passed to the executable business class, and the execution content of the executable business class can be executed.
[0201] In addition, after the executable business class is executed, the next business class can be executed according to the current priority.
[0202] In an optional embodiment, Figure 12 A flowchart of a method for executing the next business class is shown in FIG. 12. Figure 12 As shown in FIG. 12, the method includes at least the following steps: in step S1210, if the business class is executed, the next priority is determined according to the current priority, and the next business class is determined in the initial business class according to the next priority.
[0203] When the executable business class is executed, the execution end method can be called. After calling, the centralized manager will try to obtain an executable business class lower than the current priority and try to execute.
[0204] Specifically, after the executable business class is executed, the centralized manager is obtained, and the container class and the current priority and other information are passed to the centralized manager, to inform the centralized manager that the executable business class of the current priority in the container class has been executed.
[0205] At this time, the centralized manager determines the next priority according to the labeled container class and the current priority, and screens the next service class for the next priority from the service class list.
[0206] In step S1220, if the next service class meets the execution condition, the next service class is injected into the initialized labeled container class for execution by using the execution condition interface.
[0207] When it is determined by using the execution condition interface that the next service class meets the execution condition, the execution condition interface can be used to attempt to execute the next service class, thereby realizing the execution function with priority between service classes.
[0208] In the example embodiment, the executable service class and the next service class are executed according to the current priority, thereby solving the complexity problem caused by service superposition in a centralized management manner, providing the user with the ability to quickly understand and master the flow and distribution of various services, and reducing the complexity and expansion difficulty of the project as a whole.
[0209] When the container state of the labeled container class is the destroyed state, the corresponding initial service class can also be recycled.
[0210] In an optional embodiment, if the container state is the destroyed state, the initial service class corresponding to the current priority is removed from the service class list by using the recycling interface.
[0211] When it is determined by using the execution condition interface that the container state of the labeled container class is the destroyed state, the initial service class that labels the labeled container class can be obtained from the service class list in the centralized manager according to the class name of the labeled container class, the recycling method of the initial service class is called in sequence, and the initial service class is removed from the service class list.
[0212] The service processing method in the example embodiment of the present disclosure will be described in detail in combination with an application scenario.
[0213] Figure 13 A flowchart of the service processing method in the application scenario is shown in FIG. 13. Figure 13 As shown in FIG. 13, in step S1310, when developing a service, the user implements specific service details based on a provided template.
[0214] To process various services, a set of general service templates can be defined.
[0215] Specifically, a target service is obtained, and the target service is abstractly integrated to obtain a general service template.
[0216] The target service can be any kind of service that needs to be processed, and the example embodiment does not make special limitations on this.
[0217] After the target service is abstracted and sorted, rules and conditions performed by the target service can be obtained, and the rules and conditions are defined as a set of general business templates.
[0218] The general business template can support at most one layout control in a page container and one member variable in a page container.
[0219] The general business template includes an execution condition interface and a recycling interface.
[0220] For example, the general business template provides seven types of interfaces, namely, time, viewId, period and periodGap, condition, priority, execute and release. The time interface, the viewId interface, the period and periodGap interface, the condition interface, the priority interface and the execute interface are execution condition interfaces, and the release interface is a recycling interface.
[0221] The time interface indicates an execution time, and a user can specify a business to be executed in an Activity class or a Fragment class of Android; the viewId indicates a layout control in a page container that needs to be obtained, and can be empty; the period and periodGap interface are an execution period, supporting a period setting from seconds to months; the condition is an execution condition, supporting recording execution data and deciding whether to execute according to the record; the priority is an execution priority, mainly used to solve the problem of competition of multiple businesses in the same page container, greatly improving the development efficiency; the execute interface is an execution content, used to specify details of a specific business by a user; and the release interface is a recycling method, which is called when the general business template is recycled, facilitating a user to perform recycling work.
[0222] When a user implements a business based on the general business template according to actual needs, a business class can be implemented based on the template class.
[0223] Specifically, the execution content, the execution actual, the execution period, the execution condition and the priority of the general business template are rewritten according to actual business needs to obtain an initial business class.
[0224] In step S1320, after the template implementation is completed, the user marks in the page container by means of annotation.
[0225] The user determines that the initial business class needs to be marked in the project, that is, the page container using the business class. The page container is an initial container class.
[0226] For example, in the Android system, the page containers are mainly Activity classes and Fragment classes. The Fragment class is run on the Activity class, and other classes can also be included according to actual conditions and needs, and the example embodiment does not specially limit this.
[0227] The initial business class is marked in the initial container class by using the annotation technology to obtain a marked container class.
[0228] The user can mark the initial business class in the initial container class needed in the project by using the annotation technology of the Java language, and indicate that the execution range of the initial business class is on the corresponding initial container class.
[0229] It is worth noting that one initial container class can mark multiple initial business classes. Similarly, one initial business class can also be marked in multiple initial container classes.
[0230] For example, the annotation @ComponentView of a class and the annotation @ComponentViewData of a member variable can be provided. Through the two annotations, the initial business class of the user and the member variable of the page container needed by the business class can be obtained at the APP runtime.
[0231] If the initial business class and the initial container class have an association relationship, the initial business class is marked in the initial container class to obtain a marked container class.
[0232] When the initial business class and the initial container class are in the same module or have a module dependency relationship, it can be considered that the initial business class and the initial container class have an association relationship, and the referenced initial business class can be directly added to the annotation of the initial business class to obtain a marked container class, thereby achieving the marking effect.
[0233] When the initial business class and the initial container class are not in the same module and do not have a module dependency relationship, it can be considered that the initial business class and the initial container class do not have an association relationship. Therefore, a string corresponding to the initial business class is added to the annotation of the initial container class to obtain a marked container class, thereby achieving the marking effect.
[0234] The string corresponding to the initial business class includes the package name and the class name of the business class, and can also include other characters, and the example embodiment does not specially limit this.
[0235] At the APP startup, the centralized manager can be initialized, and the life cycle callback listening of the Activity class of the APP can be added.
[0236] The centralized manager is a global singleton class, which can be acquired anywhere during the running of the App. The centralized manager can be responsible for acquiring and managing all business classes.
[0237] The container state includes the created onCreate(), started onStart(), resumed onResume(), paused onPause(), stopped onStop() and destroyed onDestroy() states, and the lifecycle of the initial container class is controlled by the Android system.
[0238] The Android system provides the lifecycle monitoring API of the Activity class, which can be used to conveniently acquire the lifecycle callback notification of all Activity class page containers. The Android system also provides the lifecycle monitoring API of the Fragment class, which can be used to monitor the lifecycle callback notification of the Fragment class in the onCreate() state of the Activity class.
[0239] In this way, the lifecycle callback monitoring of the Activity class and the Fragment class, which are the two page containers of the Android system, is realized.
[0240] Further, the initial business class can be injected into the annotated container by initializing the annotated container class, so as to execute the initial business class.
[0241] In step S1330, when entering a new page container, the centralized manager tries to acquire the annotations of the container and instantiates and saves them in the cache.
[0242] For example, for the annotated container class in the Android system, the Activity class monitoring interface and the Fragment class monitoring interface can be used to determine that the annotated container class is in the created state according to the lifecycle of the Android system.
[0243] The centralized manager internally maintains two dictionary objects, which are in the form of key-value pairs. One of them saves the class name of the page container, that is, the mapping relationship between the annotated container class and the initial business class list; the other saves the mapping relationship between the page container and the priority of the initial business class that can be executed in the page container.
[0244] When the annotated container class is in the created state, it can be considered that a new annotated container class is entered. Further, the business class list of the annotated container class can be tried to be acquired from the dictionary object of the annotated container class and the business class list.
[0245] When the service class list of the annotation container class cannot be obtained from the dictionary object of the annotation container class and the service class list, the annotation container class can be initialized to inject the initial service class into the initialized annotation container class for execution.
[0246] Figure 14 A flowchart of the method of initializing the annotation container class in the application scenario is shown as shown in Figure 14 In step S1410, an empty service class list is constructed, an int value representing the priority of the currently executable service class is declared, and the value is set to the default priority.
[0247] According to the annotation container class, the corresponding service class list is constructed, and the current priority corresponding to the service class list is set.
[0248] Among them, the service class list constructed according to the annotation container class can be an empty service class list. And the service class list is taken as a value, the class name of the annotation container class is taken as a key to form a corresponding key-value pair, and the key-value pair is saved in the dictionary object of the centralized manager.
[0249] In addition, the executable priority of the current annotation container class is set to the default value as the current priority. Among them, the default value can be -10086, or other numerical values, and the present exemplary embodiment does not make special limitation to this.
[0250] In step S1420, the centralized manager saves the above-mentioned empty service class list to the service class dictionary, and obtains the annotated service class from the service container.
[0251] The page container can be obtained through the annotation mechanism of Java, that is, the value annotated by the annotation container class.
[0252] And it can also traverse the business class annotated on the page container.
[0253] In step S1430, the service class is instantiated, the value of the priority is obtained, and it is checked whether the service class meets the execution condition. If executable, the priority value is compared.
[0254] If the annotation container class is annotated by the initial service class, the initial service class is instantiated.
[0255] When using annotation technology to annotate the initial container class, the initial service class can be annotated in the initial container class. At this time, it is indicated that the value annotated on the annotation container class is a class object, so the object can be created by the instantiation method of the class to realize the instantiation of the initial service class.
[0256] When the initial container class is labeled by using the annotation technology, the string corresponding to the initial business class can be labeled in the initial container class, indicating that the value of the labeled container class is a string object. The class object matching the string can be found through the reflection mechanism, and then the object is created through the instantiation method of the class to realize the instantiation of the initial business class.
[0257] After the initial business classes labeled on the labeled container class are instantiated in sequence, the instantiated initial business classes can be saved in the business class list.
[0258] Since the user specifies the priority during the rewriting process using the general business template, the business priority of the instantiated initial business class can be further obtained.
[0259] During the instantiation process, the business priority can be compared with the current priority to obtain a corresponding comparison result.
[0260] Before comparing the business priority with the current priority, it can be judged whether the instantiated initial business class meets the execution condition required by the execution condition interface by using the execution condition interface. Only when the instantiated initial business class meets the execution condition required by the execution condition interface, the business priority is compared with the current priority to obtain a comparison result.
[0261] In step S1440, the priority value is saved as the current executable business class priority.
[0262] When the business priority is greater than the current priority, the priority of the current page executable, that is, the current priority, can be set equal to the business priority.
[0263] It is worth noting that to find the initial business class with the highest priority at this time, the business priorities of other initial business classes can also be traversed and compared with the current priority at this time to continuously assign values to obtain the highest priority and the corresponding initial business class.
[0264] In step S1450, the business class instance is saved to the business class list.
[0265] The business class instance corresponding to the current priority is also saved to the corresponding business class list.
[0266] In step S1460, the centralized manager saves the current executable priority to the priority dictionary.
[0267] After all the initial business classes of the current labeled container class are instantiated, the current executable current priority is saved to the dictionary object.
[0268] In step S1340, the Android system lifecycle callback triggers the centralized manager, and it is determined whether the lifecycle of the container is exited.
[0269] The container state of the initialized annotation container class is monitored by using the monitoring interface corresponding to the annotation container class.
[0270] In the Android system, the monitoring interface can include an interface for monitoring an Activity class and an interface for monitoring a Fragment class.
[0271] In step S1350, the Android system lifecycle callback triggers the centralized manager, and the manager obtains a business class list from the cache according to the callback page container.
[0272] When the container state of the annotation container class is monitored as a non-destroyed state, the initial business class corresponding to the annotation container class can be obtained from the business class list in the centralized manager according to the class name of the annotation container class.
[0273] In step S1360, the instances are prioritized, the currently executable business class is obtained, and it is verified whether the execution limit is met.
[0274] The current priority of the currently executable business class is obtained from the priority dictionary of the centralized manager, so as to match and filter the initial business class by using the current priority to obtain an executable business class matching the current priority.
[0275] After the executable business class is determined, the execution condition interface can be used to match and verify the execution time, execution period, and execution condition of the executable business class.
[0276] In step S1370, after the business process is ended, it is determined whether the process is ended.
[0277] When the executable business class meets the execution condition, the execution condition interface can be used to obtain the page control and member variable required by the executable business class from the annotation container class and pass them to the executable business class, and execute the execution content of the executable business class.
[0278] In step S1380, the business process is ended, the current container priority is adjusted, and the executable process is continued.
[0279] After the executable business class is executed, the next business class can also be executed according to the current priority.
[0280] When the executable business class is executed, an execution end method can be called. After the method is called, the centralized manager attempts to obtain an executable business class lower than the current priority and attempts to execute.
[0281] Specifically, when the executable business class is executed, the centralized manager is acquired, and information such as the marked container class and the current priority is transmitted to the centralized manager, so as to inform the centralized manager that the executable business class of the current priority in the marked container class has been executed.
[0282] At this time, the centralized manager determines the next priority according to the marked container class and the current priority, and filters the next business class of the next priority from the business class list.
[0283] When it is determined by the execution condition interface that the next business class meets the execution condition, the next business class can be executed by using the execution condition interface, so as to realize the execution function with priority between business classes.
[0284] In step S1390, all business class instances are acquired and the release method is executed, so as to clear the cache related to the page container.
[0285] If the container state is the destroyed state, the initial business class corresponding to the current priority is removed from the business class list by using the recycling interface.
[0286] When it is determined by the execution condition interface that the container state of the marked container class is the destroyed state, the initial business class marked the marked container class can be acquired from the business class list in the centralized manager according to the class name of the marked container class, the recycling method of the initial business class is called in sequence, and the initial business class is removed from the business class list.
[0287] In the business processing method in the example embodiment of the present disclosure, all business requirement codes that need to be injected across modules or have high similarity are specified by the general business template, so as to improve the readability, reusability and expansibility of the code, and provide a data basis for centralized management of the code. Further, the initial container class is marked by the initial business class, so as to realize the isolation and cross-module injection of the business requirement code. Furthermore, the initial business class is injected into the marked container class for execution, so as to solve the complexity problem caused by business superposition, and provide the user with the ability to quickly understand and master the process and distribution of various businesses, thereby reducing the complexity, maintenance burden and expansion difficulty of the project.
[0288] In addition, in the example embodiment of the present disclosure, a business processing device is also provided. Figure 15 The structure schematic diagram of the business processing device is shown as Figure 15 As shown in the figure, the business processing device 1500 can include a module rewriting module 1510, a container marking module 1520 and a business execution module 1530. Wherein:
[0289] The template rewriting module 1510 is configured to acquire a general business template, and rewrite the general business template to obtain an initial business class;
[0290] The container labeling module 1520 is configured to determine an initial container class corresponding to the initial service class, and label the initial container class according to the initial service class to obtain a labeled container class.
[0291] The service execution module 1530 is configured to inject the initial service class into the labeled container class for execution.
[0292] In an example embodiment of the present application, the general service template is obtained by:
[0293] obtaining a target service and performing abstract integration processing on the target service to obtain a general service template.
[0294] In an example embodiment of the present application, the general service template includes an execution condition interface and a recycling interface.
[0295] In an example embodiment of the present application, the labeling processing of the initial container class according to the initial service class to obtain a labeled container class includes:
[0296] labeling the initial service class in the initial container class by using an annotation technology to obtain a labeled container class.
[0297] In an example embodiment of the present application, the labeling processing of the initial container class according to the initial service class to obtain a labeled container class includes:
[0298] if the initial service class and the initial container class have an association relationship, labeling the initial service class in the initial container class to obtain a labeled container class;
[0299] if the initial service class and the initial container class do not have an association relationship, labeling a string corresponding to the initial service class in the initial container class to obtain a labeled container class.
[0300] In an example embodiment of the present application, the injection of the initial service class into the labeled container class for execution includes:
[0301] if the labeled container class is in a created state, initializing the labeled container class and injecting the initial service class into the initialized labeled container class for execution.
[0302] In an example embodiment of the present application, the initialization of the labeled container class and the injection of the initial service class into the initialized labeled container class for execution includes:
[0303] constructing a corresponding service class list according to the labeled container class, and setting a current priority corresponding to the service class list;
[0304] obtaining the initial service class corresponding to the annotation container class and a service priority of the initial service class, and comparing the service priority with the current priority to obtain a comparison result;
[0305] injecting the initial service class into the initialized annotation container class according to the comparison result.
[0306] In an exemplary embodiment of the present application, the obtaining of the initial service class corresponding to the annotation container class and the service priority of the initial service class comprises:
[0307] obtaining the initial service class corresponding to the annotation container class, and instantiating the service class;
[0308] storing the instantiated initial service class in the service class list, and obtaining the service priority of the instantiated service class.
[0309] In an exemplary embodiment of the present application, the obtaining of the initial service class corresponding to the annotation container class and the instantiating of the service class comprises:
[0310] obtaining the initial service class corresponding to the annotation container class by using a reflection mechanism, and instantiating the initial service class.
[0311] In an exemplary embodiment of the present application, the obtaining of the initial service class corresponding to the annotation container class by using the reflection mechanism and the instantiating of the initial service class comprises:
[0312] if the annotation container class is obtained by the initial service class, instantiating the initial service class;
[0313] if the annotation container class is obtained by a string corresponding to the initial service class, obtaining the initial service class corresponding to the string by using the reflection mechanism, and instantiating the initial service class.
[0314] In an exemplary embodiment of the present application, the comparison of the service priority with the current priority comprises:
[0315] if the instantiated initial service class satisfies an execution condition, comparing the service priority with the current priority.
[0316] In an exemplary embodiment of the present application, the injecting of the initial service class into the initialized annotation container class according to the comparison result comprises:
[0317] If the comparison result is that the service priority is greater than the current priority, it is determined that the current priority is equal to the service priority.
[0318] The container state of the initialized marked container class is listened to, and the initial service class is injected into the initialized marked container class according to the container state to execute.
[0319] In an exemplary embodiment of the present application, the container state of the initialized marked container class is listened to, including:
[0320] The container state of the initialized marked container class is listened to by using a listening interface corresponding to the marked container class.
[0321] In an exemplary embodiment of the present application, the initial service class is injected into the initialized marked container class according to the container state to execute, including:
[0322] If the container state is a non-destroyed state, the service class list is matched according to the current priority to obtain an executable service class.
[0323] If the executable service class meets an execution condition, the executable service class is injected into the initialized marked container class to execute by using the execution condition interface.
[0324] In an exemplary embodiment of the present application, the method further includes:
[0325] If the container state is a destroyed state, the initial service class corresponding to the current priority is removed from the service class list by using the recycling interface.
[0326] In an exemplary embodiment of the present application, the method further includes:
[0327] If the service class is executed, a next priority is determined according to the current priority, and a next service class is determined in the initial service class according to the next priority.
[0328] If the next service class meets an execution condition, the next service class is injected into the initialized marked container class to execute by using the execution condition interface.
[0329] The specific details of the service processing device 1500 have been described in detail in the corresponding service processing method, and thus will not be described here.
[0330] It should be noted that although several modules or units of the service processing apparatus 1500 are mentioned in the foregoing detailed description, such division is not mandatory. In fact, features and functions of two or more modules or units described above can be embodied in one module or unit according to embodiments of the present disclosure. Conversely, features and functions of one module or unit described above can be further divided into embodied by multiple modules or units.
[0331] Furthermore, in exemplary embodiments of the present disclosure, an electronic device capable of implementing the above method is also provided.
[0332] The electronic device 1600 according to this embodiment of the present disclosure will be described below with reference to Figure 16 Figure 16 The electronic device 1600 shown is merely an example and should not limit the function and scope of use of embodiments of the present disclosure.
[0333] As shown in Figure 16 The components of the electronic device 1600 can include, but are not limited to, the at least one processing unit 1610 described above, the at least one storage unit 1620 described above, a bus 1630 connecting different system components, including the storage unit 1620 and the processing unit 1610, and a display unit 1640.
[0334] The storage unit stores program codes that can be executed by the processing unit 1610, so that the processing unit 1610 performs the steps described in the above "Exemplary Method" section according to various exemplary embodiments of the present disclosure.
[0335] The storage unit 1620 can include a readable medium in the form of a volatile storage unit, such as a random access memory (RAM) 1621 and / or a cache memory 1622, and can further include a read-only memory (ROM) 1623.
[0336] The storage unit 1620 can also include program / utilities 1624 having a set of (at least one) program modules 1625, such as an operating system, one or more application programs, other program modules, and program data, each of which or a combination of which can include implementation of a network environment.
[0337] The bus 1630 can represent one or more of several types of bus structures, including a storage unit bus or storage unit controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus using any of a variety of bus structures.
[0338] The electronic device 1600 can also communicate with one or more external devices 1800 such as a keyboard, a pointing device, a Bluetooth device, etc.; and can communicate with one or more devices that enable a user to interact with the electronic device 1600 and / or one or more devices (e.g. routers, modems, etc.) that enable the electronic device 1600 to communicate with one or more other computing devices. Such communication can be enabled by the input / output (I / O) interfaces 1650. Also, the electronic device 1600 can communicate with one or more networks (such as a local area network (LAN), a wide area network (WAN), and / or the public network, e.g. the Internet) through a network adapter 1660. As depicted, the network adapter 1660 is in communication with the other modules of the electronic device 1600 through the bus 1630. It will be appreciated that other hardware and / or software modules can be used in conjunction with the electronic device 1600, including but not limited to microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data archival storage systems, etc.
[0339] From the above description of the embodiments, it is easy for those skilled in the art to understand that the example embodiments described herein can be implemented by software, or by software in combination with necessary hardware. Therefore, the technical solutions according to the embodiments 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 disk, a mobile hard disk, etc.) or a network, and includes a number of instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to perform the methods according to the embodiments of the present disclosure.
[0340] In the example embodiments of the present disclosure, a computer-readable storage medium having stored thereon a program product capable of implementing the above-mentioned method of the present disclosure is also provided. In some possible embodiments, various aspects of the present disclosure can also be implemented in the form of a program product, which includes program codes for causing a terminal device to perform the steps described in the above-mentioned “example method” section according to various example embodiments of the present disclosure when the program product is run on the terminal device.
[0341] Reference Figure 17 As shown, a program product 1700 for implementing the above-mentioned method according to the embodiments of the present disclosure is described, which can take the form of a portable compact disc read-only memory (CD-ROM) and include program codes, and can be run on a terminal device, such as a personal computer. However, the program product of the present disclosure is not limited to this, and in this document, the readable storage medium can be any tangible medium containing or storing a program, which can be used or combined with an instruction execution system, device or apparatus.
[0342] The program product can employ any combination of one or more computer readable media or storage media. A computer readable medium or storage medium can be, for example, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable medium or storage medium include the following: an electrical connection having one or more wires, a portable 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0343] A computer readable signal medium can include a propagated data signal with computer readable program code embodied therein. The propagated data signal can take any of a variety of forms, including but not limited to electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium can be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport program code.
[0344] Program code embodied on a computer readable medium can be transmitted using any appropriate medium, including but not limited to wireless, wired, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0345] Program code for carrying out operations of the present application can be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C++, or the like, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computing device, partly on the user's computing device, as a stand-alone software package, partly on the user's computing device and partly on a remote computing device or entirely on the remote computing device or server. In the latter scenario, the remote computing device can be connected to the user's computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computing device, such as through the Internet using an Internet Service Provider. The application is described and illustrated by way of example and not by way of limitation in the appended Figures and
[0346] Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the features disclosed herein. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
Claims
1. A business processing method, characterized in that, The method includes: Obtain the target business, abstract and integrate the target business to obtain a general business template, and rewrite the general business template to obtain the initial business class; Determine the initial container class corresponding to the initial business class, and annotate the initial container class according to the initial business class to obtain the annotated container class; When the annotation container class is in the created state, the annotation container class is initialized, a corresponding business class list is constructed according to the annotation container class, and the current priority corresponding to the business class list is set; the initial business class corresponding to the annotation container class and the business priority of the initial business class are obtained, and the business priority is compared with the current priority to obtain a comparison result; the initial business class is injected into the initialized annotation container class for execution according to the comparison result.
2. The business processing method according to claim 1, characterized in that, The general business template includes: an execution condition interface and a recycling interface.
3. The business processing method according to claim 2, characterized in that, The step of annotating the initial container class according to the initial business class to obtain the annotated container class includes: Annotated container classes are obtained by annotating the initial business classes in the initial container class using annotation technology.
4. The business processing method according to claim 3, characterized in that, The step of using annotation technology to annotate the initial business class in the initial container class to obtain the annotated container class includes: If the initial business class and the initial container class are related, the initial business class is annotated in the initial container class to obtain the annotated container class; If the initial business class and the initial container class are not related, the initial container class is annotated with a string corresponding to the initial business class to obtain the annotated container class.
5. The business processing method according to claim 1, characterized in that, The step of obtaining the initial business class corresponding to the labeled container class and the business priority of the initial business class includes: Obtain the initial business class corresponding to the annotation container class, and instantiate the business class; The instantiated initial business class is stored in the business class list, and the business priority of the instantiated initial business class is obtained.
6. The business processing method according to claim 5, characterized in that, The step of obtaining the initial business class corresponding to the labeled container class and instantiating the business class includes: The initial business class corresponding to the labeled container class is obtained using reflection, and the initial business class is instantiated.
7. The business processing method according to claim 6, characterized in that, The step of obtaining the initial business class corresponding to the labeled container class using reflection and instantiating the initial business class includes: If the annotation container class is obtained by annotating the initial business class, then the initial business class is instantiated; If the labeled container class is obtained from the string corresponding to the initial business class, the initial business class corresponding to the string is obtained using reflection, and the initial business class is instantiated.
8. The business processing method according to claim 6, characterized in that, The step of comparing the service priority with the current priority includes: If the instantiated initial business class meets the execution conditions, the business priority is compared with the current priority.
9. The business processing method according to claim 5, characterized in that, The step of injecting the initial business class into the initialized annotation container class based on the comparison result includes: If the comparison result indicates that the service priority is greater than the current priority, then the current priority is determined to be equal to the service priority. Monitor the container state of the initialized annotation container class, and inject the initial business class into the initialized annotation container class for execution based on the container state.
10. The business processing method according to claim 9, characterized in that, The state of the labeled container class after initialization includes: The listener interface corresponding to the annotation container class is used to listen to the container state of the annotation container class after initialization.
11. The business processing method according to claim 10, characterized in that, The step of injecting the initial business class into the initialized annotation container class according to the container state includes: If the container is not in a destroyed state, the list of business classes is matched according to the current priority to obtain the executable business classes; If the executable business class meets the execution conditions, the executable business class is injected into the initialized annotation container class for execution using the execution condition interface.
12. The business processing method according to claim 9, characterized in that, The method further includes: If the container is in a destroyed state, the initial business class corresponding to the current priority is removed from the business class list using the recycling interface.
13. The business processing method according to claim 11, characterized in that, The method further includes: If the business class has been completed, the next priority is determined according to the current priority, and the next business class is determined in the initial business class according to the next priority; If the next business class meets the execution conditions, the next business class is injected into the initialized annotation container class for execution using the execution condition interface.
14. A business processing apparatus, characterized in that, include: The template rewriting module is configured to obtain the target business, abstract and integrate the target business to obtain a general business template, and rewrite the general business template to obtain the initial business class; The container annotation module is configured to determine the initial container class corresponding to the initial business class, and to annotate the initial container class according to the initial business class to obtain an annotated container class; The business execution module is configured to initialize the annotation container class when the annotation container class is in a created state, construct a corresponding business class list based on the annotation container class, and set the current priority corresponding to the business class list; obtain the initial business class corresponding to the annotation container class and the business priority of the initial business class, and compare the business priority with the current priority to obtain a comparison result; and inject the initial business class into the initialized annotation container class for execution based on the comparison result.
15. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the business processing method according to any one of claims 1-13.
16. An electronic device, characterized in that, include: processor; Memory for storing the executable instructions of the processor; The processor is configured to execute the business processing method of any one of claims 1-13 by executing the executable instructions.
Citation Information
Patent Citations
Template rendering method and device and browser
CN107766344A
Service class generation method and device based on spring container
CN114265591A