Disclosure of Invention
In view of the above, the present invention is proposed to provide a traffic processing module generation method and apparatus that overcomes or at least partially solves the above mentioned problems.
According to an aspect of the present invention, a method for generating a service processing module is provided, including:
presetting a component pool comprising a plurality of components, wherein different components finish different processing logics, and each component is provided with an interface for receiving data and an interface for sending data; selecting more than two components from the component pool according to the selection of a user; the more than two components are sequentially connected in series by utilizing the interfaces for receiving data and the interfaces for sending data of the more than two components, so that a service processing module consisting of the more than two components is obtained; and returning the service processing module to the user.
Optionally, each component in the component pool complies with the following constraint rules: each assembly comprising: the system comprises a pre-processing unit, a service logic unit and a post-processing unit; the advanced processing unit receives request data of a user side or data sent by a previous-level component connected in series with a component where the advanced processing unit is located, prepares and processes the received data and sends the processed data to the business logic unit; the business logic unit processes the data sent by the pre-processing unit according to the processing logic of the assembly, judges whether a next-stage assembly connected with the assembly where the business logic unit is located is available or not, if so, the processed data is sent to the next-stage assembly, otherwise, the processed data is sent to the post-processing unit; the post-processing unit receives data sent by the service logic unit or data sent by a next-stage component connected in series with a component where the post-processing unit is located, and sends the received data to a previous-stage component connected in series with the component where the post-processing unit is located after ending the received data or returns the data to the user side.
Optionally, the obtaining of the service processing module composed of the two or more components by sequentially connecting the two or more components in series by using the interfaces for receiving data and the interfaces for sending data of the two or more components respectively includes: sequencing the more than two components according to the service processing requirement; for the first component, the pre-processing unit receives the request of the user terminal, and the post-processing unit returns the processed data to the user terminal; for every two adjacent assemblies, the output of the business logic unit of the upper-level assembly is in butt joint with the prior processing unit of the lower-level assembly, and the output of the post-processing unit of the lower-level assembly is in butt joint with the post-processing unit of the upper-level assembly.
Optionally, the method further comprises: providing a component extension interface; and receiving the components which accord with the constraint rule through the component expansion interface, and putting the components into the component pool.
Optionally, the constraint rule that each component in the component pool complies with further includes: for a component, the processing logic of any two of its pre-processing unit, business logic unit, and post-processing unit may be null.
Optionally, the method further comprises: for the service processing module consisting of more than two components, removing one component from the components connected in series to obtain a new service processing module; or, for the service processing module composed of more than two components, inserting a new component into the serially connected components to obtain a new service processing module.
According to another aspect of the present invention, there is provided a service processing module generating apparatus, including: the component pool storage unit is suitable for storing a preset component pool containing a plurality of components, wherein different components finish different processing logics, and each component is provided with an interface for receiving data and an interface for sending data; the component selection unit is suitable for selecting more than two components from the component pool according to a selection instruction of a user; a service module generating unit, adapted to utilize the respective interfaces for receiving data and sending data of the two or more components to sequentially connect the two or more components in series, so as to obtain a service processing module composed of the two or more components; and the user interface unit is suitable for receiving a selection instruction of a user, sending the selection instruction to the component selection unit and returning the service processing module generated by the service module generation unit to the user.
Optionally, each component in the component pool storage unit complies with the following constraint rules: each assembly comprising: the system comprises a pre-processing unit, a service logic unit and a post-processing unit; the advanced processing unit receives request data of a user side or data sent by a previous-level component connected in series with a component where the advanced processing unit is located, prepares and processes the received data and sends the processed data to the business logic unit; the business logic unit processes the data sent by the pre-processing unit according to the processing logic of the assembly, judges whether a next-stage assembly connected with the assembly where the business logic unit is located is available or not, if so, the processed data is sent to the next-stage assembly, otherwise, the processed data is sent to the post-processing unit; the post-processing unit receives data sent by the service logic unit or data sent by a next-stage component connected in series with a component where the post-processing unit is located, and sends the received data to a previous-stage component connected in series with the component where the post-processing unit is located after ending the received data or returns the data to the user side.
Optionally, the service module generating unit is adapted to sort the two or more components according to service processing requirements; for the first component, the pre-processing unit receives the request of the user terminal, and the post-processing unit returns the processed data to the user terminal; for every two adjacent assemblies, the output of the business logic unit of the upper-level assembly is in butt joint with the prior processing unit of the lower-level assembly, and the output of the post-processing unit of the lower-level assembly is in butt joint with the post-processing unit of the upper-level assembly.
Optionally, the apparatus further comprises: and the component expansion interface is suitable for receiving the components meeting the constraint rules and putting the components into the component pool.
Optionally, the constraint rule that each component in the component pool storage unit conforms to further includes: for a component, the processing logic of any two of its pre-processing unit, business logic unit, and post-processing unit may be null.
Optionally, the service module generating unit is further adapted to, for a service processing module composed of the two or more components, remove one component from the serially connected components to obtain a new service processing module; or, for the service processing module composed of more than two components, inserting a new component into the serially connected components to obtain a new service processing module.
It can be seen from the above that, in the technical scheme of the present invention, a plurality of different components are placed in a preset component pool, wherein the different components can complete different processing logics and have interfaces for receiving data and interfaces for sending data, so that a user can select more than two components from the component pool according to the self requirement, and the components can be connected in series in sequence by using the respective interfaces for receiving data and interfaces for sending data to obtain a service processing module, the technical scheme establishes a normative component pool, so that the components placed in the component pool have the same structural characteristics, the service module which can realize the associated logics by simply connecting the components which complete the required functions in series can be provided for the user, the problem that complicated logic codes need to be compiled in the prior art for integrating the components is overcome, and meanwhile, the components in the component pool have strong normative and wide application, the method has the beneficial effect of good compatibility.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
Fig. 1 is a flowchart illustrating a method for generating a service processing module according to an embodiment of the present invention, where as shown in fig. 1, the method includes:
step S110, a component pool including a plurality of components is preset, wherein different components complete different processing logics, and each component has an interface for receiving data and an interface for sending data.
The processing logic in this step refers to the implementation of specific functions, such as encrypting received data, which requires acquiring data and encrypting the data, and if the encrypted data needs to be called by other components, the encrypted data needs to be sent to other components, where the acquiring data and the sending data are implemented through an interface for receiving data and an interface for sending data.
And step S120, selecting more than two components from the component pool according to the selection of the user.
In this step, the user selects a component with a corresponding function according to the requirement.
Step S130, sequentially connecting the two or more components in series by using their respective interfaces for receiving data and sending data, so as to obtain a service processing module composed of the two or more components.
Step S140, the service processing module is returned to the user.
It can be seen that the method shown in fig. 1, by placing a plurality of different components in a pool of pre-arranged components, where different components may perform different processing logic and have interfaces to receive data and interfaces to transmit data, therefore, a user can select more than two components from the component pool according to the self requirement, and the components are sequentially connected in series by utilizing respective interfaces for receiving data and sending data to obtain the service processing module, the method establishes a normative component pool, so that the components placed in the component pool have the same structural characteristics, can provide a service module for realizing the associated logic by simply connecting the components for completing the required functions in series, overcomes the problem that the complex logic codes need to be written in the prior art for integrating the components, meanwhile, the assembly in the assembly pool is strong in standardization, wide in application and good in compatibility.
Specifically, each component in the component pool complies with the following constraint rules: each assembly comprising: the system comprises a pre-processing unit, a service logic unit and a post-processing unit; the pre-processing unit receives request data of a user side or data sent by a previous-stage component connected in series with a component where the pre-processing unit is located, prepares and processes the received data and sends the data to the service logic unit; the business logic unit processes the data sent by the pre-processing unit according to the processing logic of the assembly, judges whether a next-stage assembly connected with the assembly where the business logic unit is located is available or not, if so, the processed data is sent to the next-stage assembly, otherwise, the processed data is sent to the post-processing unit; the post-processing unit receives data sent by the service logic unit or data sent by a next-stage component connected in series with the component where the post-processing unit is located, and sends the received data to a previous-stage component connected in series with the component where the post-processing unit is located after ending the received data or returns the data to the user side.
Here, it should be noted that: the aforementioned interface for receiving data and the interface for transmitting data are included in the pre-processing unit, the service logic unit, and the post-processing unit. For example, the pre-processing unit receives data, processes the data, and sends the data to the service logic unit, so the pre-processing unit includes both an interface for receiving data and an interface for sending data. The service logic unit and the post-processing unit also comprise an interface for receiving data and an interface for sending data.
More specifically, in the method, the two or more components are sequentially connected in series by using their respective interfaces for receiving data and sending data, and the service processing module composed of the two or more components includes: sequencing more than two components according to the service processing requirement; for the first component, the pre-processing unit receives the request of the user terminal, and the post-processing unit returns the processed data to the user terminal; for every two adjacent assemblies, the output of the business logic unit of the upper-level assembly is in butt joint with the prior processing unit of the lower-level assembly, and the output of the post-processing unit of the lower-level assembly is in butt joint with the post-processing unit of the upper-level assembly.
FIG. 2 is a diagram illustrating a series of components that meet constraint rules. As shown in FIG. 2, if a component A, a component B and a component C in a component pool are required to be selected according to the selection of a user, and the three components have business logic relevance, the components are connected in series in the mode of the figure. Wherein a service module required by a user may contain a plurality of components, only the above components are shown in the figure for describing the connection relationship and logical relationship among the components. It can be seen that component a is at the forefront of the three components, with data (i.e., data in the user request) first being received by the prior processing unit of component a. If the component A is positioned at the forefront end of the service module, the received request data is the request data of the user side; otherwise, receiving the data sent by the upper level component connected in series by the component A. After receiving the data, the pre-processing unit performs preparation processing on the data, for example, in a specific embodiment, the data includes parameter variables named request and response, specifically includes information such as a user ID, a user account balance, a user recharge amount, and the like, and needs to be processed, and is characterized in that other information does not need to be called. The pre-processing unit performs preparation processing on the received data, and then sends the data to the service logic unit, the service logic unit performs specific function realization, and processing is performed according to the processing logic of the component A, for example, changing a key value of a user account balance, and the like. After the function is implemented, the service logic unit determines whether there is a next-stage component connected in series with the component a, in this example, the component a is connected in series with the next-stage component B, and sends the processed data to the component B. Similarly, component B performs the corresponding operations. In the figure, the component C is the rearmost component of the service logic module, the service logic unit of the component C sends the processed data to the post-processing unit of the component C, the post-processing unit receives the data sent by the service logic unit, performs ending processing on the received data, and sends the data to the upper-level component B connected in series with the component C, the post-processing unit of the component B receives the data, performs ending processing on the data, and sends the data to the component a, and finally, the foremost component in the service logic module returns the final data to the user side. It can be seen that the interface for receiving data and the interface for transmitting data are merged in the form described above in the pre-processing unit and the post-processing unit.
In an embodiment of the present invention, the method further includes: providing a component extension interface; and receiving the components which accord with the constraint rules through the component expansion interface, and putting the components into the component pool.
Because the component expansion interface is provided in the embodiment, more developers can develop and realize different business functions, namely, components containing different business logics, the constraint rules described in the embodiment are screened, and the components meeting the constraint rules are placed in the component pool, so that various requirements of users can be better met, and the standardization and the applicability of the components are also ensured.
In an embodiment of the present invention, in the above method, for a component, the processing logic of any two of the prior processing unit, the business logic unit and the post-processing unit may be null.
For example, in a specific implementation, the business process module is used for log-staged processing. The log comprises four levels of debug, info, war and error, and particularly, the service processing module can record the time consumed by data processing when recording the log and can record the time by the info log. At this time, the component which completes the function of recording the time consumption of the request can be arranged at the forefront of the service processing module, when the data of the user end is received, the time is recorded by adopting the pre-processing unit, the service logic unit does not carry out the actual processing, the post-processing unit receives the data transmitted by the next component after the data processing is completed by other components of the service processing module, the time is recorded again, the time consumption of the data processing can be known by the time difference of the recorded time, and the service logic unit does not need to set the processing logic. For another example, neither the pre-processing unit nor the post-processing unit of the XSS (Cross site scripting) filtering component needs to perform preparation processing or ending processing on data, and the processing logic therein may be empty, or even the data needs to be filtered in the service logic unit. Similarly, in practical applications, the processing logic of each unit in the assembly can be set accordingly.
In an embodiment of the present invention, the method further includes: for a service processing module consisting of more than two components, removing one component from the components connected in series to obtain a new service processing module; or, for a service processing module consisting of more than two components, inserting a new component into the serially connected components to obtain a new service processing module.
Because the serial connection rule of each component provided by the technical scheme of the invention is simple, for the service processing module consisting of a plurality of components, the realization that a new service processing module is obtained by removing one component from the components connected in series or inserting a new component into the components connected in series is very easy, and the expansibility is very strong.
Fig. 3 is a schematic structural diagram of a service processing module generating apparatus according to an embodiment of the present invention, and as shown in fig. 3, the service processing module generating apparatus 300 includes:
the component pool storage unit 310 is adapted to store a preset component pool including a plurality of components, wherein different components perform different processing logics, and each component has an interface for receiving data and an interface for transmitting data.
The component selection unit 320 is adapted to select more than two components from the component pool according to a selection instruction of a user.
The service module generating unit 330 is adapted to utilize respective interfaces for receiving data and sending data of more than two components to sequentially connect the more than two components in series, so as to obtain a service processing module composed of more than two components.
The user interface unit 340 is adapted to receive a selection instruction of the user and send the selection instruction to the component selection unit 320, and return the service processing module generated by the service module generation unit 330 to the user.
It can be seen that the apparatus shown in fig. 3, by placing a plurality of different modules in a pool of pre-arranged modules, where different components may perform different processing logic and have interfaces to receive data and interfaces to transmit data, therefore, a user can select more than two components from the component pool according to the self requirement, and the components are sequentially connected in series by utilizing respective interfaces for receiving data and sending data to obtain the service processing module, the device establishes a normative component pool, so that components placed in the component pool have the same structural characteristics, can provide a service module for realizing the associated logic by simply connecting the components for completing the required functions in series, overcomes the problem that the complex logic codes need to be written in the prior art for integrating the components, meanwhile, the assembly in the assembly pool is strong in standardization, wide in application and good in compatibility.
Specifically, each component in the component pool storage unit 310 complies with the following constraint rule: each assembly comprising: the system comprises a pre-processing unit, a service logic unit and a post-processing unit; the pre-processing unit receives request data of a user side or data sent by a previous-stage component connected in series with a component where the pre-processing unit is located, prepares and processes the received data and sends the data to the service logic unit; the business logic unit processes the data sent by the pre-processing unit according to the processing logic of the assembly, judges whether a next-stage assembly connected with the assembly where the business logic unit is located is available or not, if so, the processed data is sent to the next-stage assembly, otherwise, the processed data is sent to the post-processing unit; the post-processing unit receives data sent by the service logic unit or data sent by a next-stage component connected in series with the component where the post-processing unit is located, and sends the received data to a previous-stage component connected in series with the component where the post-processing unit is located after ending the received data or returns the data to the user side.
More specifically, the service module generating unit is adapted to sequence more than two components according to service processing requirements; for the first component, the pre-processing unit receives the request of the user terminal, and the post-processing unit returns the processed data to the user terminal; for every two adjacent assemblies, the output of the business logic unit of the upper-level assembly is in butt joint with the prior processing unit of the lower-level assembly, and the output of the post-processing unit of the lower-level assembly is in butt joint with the post-processing unit of the upper-level assembly.
In an embodiment of the present invention, the above apparatus further comprises: and the component expansion interface is suitable for receiving the components which accord with the constraint rules and placing the components into the component pool.
In an embodiment of the present invention, in the above apparatus, the constraint rule that each component in the component pool storage unit complies with further includes: for a component, the processing logic of any two of its pre-processing unit, business logic unit, and post-processing unit may be null.
In an embodiment of the present invention, in the above apparatus, the service module generating unit is further adapted to, for a service processing module composed of more than two components, remove one component from the serially connected components to obtain a new service processing module; or, for a service processing module consisting of more than two components, inserting a new component into the serially connected components to obtain a new service processing module.
It should be noted that the embodiments of the apparatus described above are the same as the detailed embodiments of the corresponding method described above, and the detailed description is omitted here.
In summary, according to the technical solution of the present invention, a plurality of different components are placed in a preset component pool, where the different components can complete different processing logics and have an interface for receiving data and an interface for sending data, and specifically, each component in the component pool includes: the technical scheme establishes a normative assembly pool, so that the assemblies placed in the assembly pool have the same structural characteristics, the service module can realize the associated logic by simply connecting the assemblies which complete the required functions in series for the user, the problem that complex logic codes need to be compiled in the prior art for integrating the assemblies is solved, and meanwhile, the assemblies in the assembly pool have strong normative performance, wide application and good compatibility.
It should be noted that:
the algorithms and displays presented herein are not inherently related to any particular computer, virtual machine, or other apparatus. Various general purpose devices may be used with the teachings herein. The required structure for constructing such a device will be apparent from the description above. Moreover, the present invention is not directed to any particular programming language. It is appreciated that a variety of programming languages may be used to implement the teachings of the present invention as described herein, and any descriptions of specific languages are provided above to disclose the best mode of the invention.
In the description provided herein, numerous specific details are set forth. It is understood, however, that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure and aiding in the understanding of one or more of the various inventive aspects. However, the disclosed method should not be interpreted as reflecting an intention that: that the invention as claimed requires more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of this invention.
Those skilled in the art will appreciate that the modules in the device in an embodiment may be adaptively changed and disposed in one or more devices different from the embodiment. The modules or units or components of the embodiments may be combined into one module or unit or component, and furthermore they may be divided into a plurality of sub-modules or sub-units or sub-components. All of the features disclosed in this specification (including any accompanying claims, abstract and drawings), and all of the processes or elements of any method or apparatus so disclosed, may be combined in any combination, except combinations where at least some of such features and/or processes or elements are mutually exclusive. Each feature disclosed in this specification (including any accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
Furthermore, those skilled in the art will appreciate that while some embodiments described herein include some features included in other embodiments, rather than other features, combinations of features of different embodiments are meant to be within the scope of the invention and form different embodiments. For example, in the following claims, any of the claimed embodiments may be used in any combination.
The various component embodiments of the invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. Those skilled in the art will appreciate that a microprocessor or Digital Signal Processor (DSP) may be used in practice to implement some or all of the functions of some or all of the components in a traffic processing module generating apparatus according to embodiments of the present invention. The present invention may also be embodied as apparatus or device programs (e.g., computer programs and computer program products) for performing a portion or all of the methods described herein. Such programs implementing the present invention may be stored on computer-readable media or may be in the form of one or more signals. Such a signal may be downloaded from an internet website or provided on a carrier signal or in any other form.
It should be noted that the above-mentioned embodiments illustrate rather than limit the invention, and that those skilled in the art will be able to design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention may be implemented by means of hardware comprising several distinct elements, and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by one and the same item of hardware. The usage of the words first, second and third, etcetera do not indicate any ordering. These words may be interpreted as names.