Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and do not limit the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The invention provides an interface calling method and device of a calling module, computer equipment and a storage medium, which are suitable for the technical field of computer development and are used for providing an interface calling method based on an interface construction module, a starting construction module, a screening extraction module and an information conversion module. The invention acquires the service module of the software project and constructs an interface for calling at least one service module; a starter is built in a calling module of a software project, so that the calling module calls an interface through the starter to control a service module to convert an acquired request message into a response message according to a preset rule; screening out a response message meeting preset response conditions through a scanning process configured in the starter, and extracting a response body in the response message; the response body is converted into a return value by the initiator.
The first embodiment is as follows:
referring to fig. 1, an interface calling method for calling a module according to the embodiment includes:
s101: acquiring a service module of a software project and constructing an interface for calling at least one service module, wherein the service module is a computer module for completing a specified task;
s102: a starter is built in a calling module of the software project, so that the calling module calls the interface through the starter to control the service module to convert the acquired request message into a response message according to a preset rule;
s104: screening out a response message meeting a preset response condition through a scanning process configured in the starter, and extracting a response body in the response message;
s106: and converting the response body into a return value through the starter, and sending the return value to the calling module.
In an exemplary embodiment, the business modules in the software project are computer modules for accomplishing specified tasks, such as: the business module comprises a business module for inquiring the name information of the user, a business module for inquiring the contact information of the user and the like; the interface records the method characteristics of all the service modules, so that all the service modules can be called to realize corresponding services, for example, a first query module for querying a user name is called through the interface to realize the query of user information, and a second query module for querying the user contact information is called through the interface to realize the query of the user contact information. Compared with the prior art, the interface of a plurality of service modules is integrated into one interface, so that the code amount is greatly reduced.
Because the interface method is an abstract method without a method body, the interface method cannot be directly called by a calling module before being realized, so that a large number of implementation classes for realizing the interface method are required to be written before the current interface method is called, once a software project needs to be frequently updated, a developer is required to write a large number of implementation classes for realizing the interface, and the interface can be called by the calling module. According to the method, the realization method which is configured in the starter and is associated with the interface method of the interface is used as a method body of the interface method to realize the interface method, and the realization method which can be called by a calling module is obtained. Therefore, compared with the mode that a large number of implementation classes need to be written in the prior art, the interface method can be realized and the realization method can be obtained according to the implementation class method only by configuring the implementation class method in the starter; for example: the implementation method is that the user name information is inquired according to the user ID, and then the implementation method can be obtained by directly inquiring the user information in the implementation interface method.
The response messages are screened through the configurable scanning process, so that the response conditions of all the service modules are conveniently recorded into the scanning process, a large number of judgment back-reference codes are prevented from being written, a response list with the response conditions is only required to be configured, the operation effect of the judgment back-reference codes can be realized by operating the scanning thread, the writing amount of the codes is greatly reduced, and meanwhile, the response list is obtained by configuring the response conditions, so that the configuration and modification efficiency of the response conditions is improved. The response code is data reflecting the state attribute of the response message, and the response body refers to content information transmitted by the response message.
The response body in the response message which meets the response condition is converted into the return value through the starter, so that the condition that the computational power consumption of the server is overlarge due to frequent conversion because the response body in each response message needs to be frequently converted when each service module is called to generate the response message at present is avoided.
Example two:
the embodiment is a specific application scenario of the first embodiment, and the method provided by the present invention can be more clearly and specifically explained through the embodiment.
The method provided in this embodiment is specifically described below by taking an example in which, in a server running an interface calling method of a calling module, the calling module can directly call an interface and a service module and obtain a return value by constructing an interface and a starter. It should be noted that the present embodiment is only exemplary, and does not limit the protection scope of the embodiment of the present invention.
Fig. 2 schematically illustrates an environment application diagram of an interface calling method of a calling module according to a second embodiment of the present application.
In an exemplary embodiment, the servers 2 in which the interface calling methods of the calling module are located are respectively connected with the control terminals 4 through thenetwork 3; the server 2 may provide services through one ormore networks 3, and thenetworks 3 may include various network devices, such as routers, switches, multiplexers, hubs, modems, bridges, repeaters, firewalls, proxy devices, and/or the like. Thenetwork 3 may include physical links, such as coaxial cable links, twisted pair cable links, fiber optic links, combinations thereof, and/or the like. Thenetwork 3 may include wireless links, such as cellular links, satellite links, wi-Fi links, and/or the like; the control terminal 4 may be a computer device such as a smart phone, a tablet computer, a notebook computer, and a desktop computer.
Fig. 3 is a flowchart of a specific method for invoking a module interface invoking method according to an embodiment of the present invention, where the method specifically includes steps S201 to S206.
S201: the method comprises the steps of obtaining a service module of a software project and constructing an interface for calling at least one service module, wherein the service module is a computer module for completing a specified task.
In this step, the service module in the software project is a computer module for implementing a specified task, for example: the business module comprises a business module for inquiring the name information of the user, a business module for inquiring the contact information of the user and the like; the interface records the method characteristics of all the service modules, so that all the service modules can be called to realize corresponding services, for example, a first query module for querying a user name is called through the interface to realize the query of user information, and a second query module for querying the user contact information is called through the interface to realize the query of the user contact information. Compared with the prior art, the interface of a plurality of service modules is integrated into one interface, so that the code amount is greatly reduced.
In a preferred embodiment, the acquiring the service modules of the software project and constructing an interface for calling at least one of the service modules includes:
s11: and acquiring at least one service module from the software project according to the task information sent by the control terminal, and acquiring an abstract class from the service module, wherein the abstract class is a class defining the calling function of the service module.
In this step, the task information includes a name of a service module in a software project to be called to complete a certain specified task, and the abstract class is a service class defining a calling function of the service module.
S12: and combining the abstract classes of at least one business module into a class set according to the task information.
In this step, a Facade mode is adopted to aggregate the abstract classes in the service modules to obtain a class set, and the class set is encapsulated to obtain an external interface of the at least one service module, and obtain a higher-layer interface relative to the service module, where the interface is used to call the at least one service module and proxy a request of a client to an appropriate service module. The abstract classes of all the service modules are integrated into an integrated class set, so that when all the abstract classes are called, a large number of codes do not need to be written to call all the service modules in sequence, and then the abstract classes in all the service modules are called, and therefore the code amount is greatly reduced.
S13: and encapsulating the class set into the interface for calling the at least one service module.
In this step, the class set is packaged and encapsulated based on a facede mode (appearance mode) to form a uniform interface, so that the interface can call the abstract class in the service module.
In this embodiment, a fa ade mode is adopted to aggregate the abstract classes in the service modules to obtain a class set, and the class set is encapsulated to obtain an external interface of the at least one service module, and obtain an interface higher than the service module, where the interface is used to call the at least one service module, proxy a request of a client to an appropriate service module, call the abstract classes in the service module to execute the request proxy, and feed back a corresponding result; the method comprises the steps of receiving a service module, determining a class of the service module, and packaging the service module into a Facade mode, wherein the Facade mode is a computer management method for gathering interfaces of all the service modules and defining a uniform interface which is convenient for a client to use, and the method meets the 'discode rule', namely the client does not need to know a subsystem, and can use all the service modules only by knowing the class packaged by the Facade mode.
Therefore, in the embodiment, the client and the service module are isolated through the Facade mode, the client and the service module are decoupled, and once the service module is modified, only the class packaged in the interface needs to be modified, and the client does not need to modify codes; in addition, the classes in the service module can be directly called in a static mode without instantiation through the interface generated by the Facade mode, so that the calling and developing efficiency of the service module in the software project is improved.
Further, the aggregating abstractions of at least one of the business modules into a set of classes includes:
s121: and extracting a logic flow in the task information, wherein the logic flow comprises abstract classes required to be called for completing the task information and a logic relation between the abstract classes.
In this step, the logic flow recorded in the task information includes abstract classes that the control end needs to call to complete a certain specified task, and a logic relationship between the abstract classes, for example: in order to complete the designated task M, the abstract class A, the abstract class B and the abstract class C need to be called in sequence.
S122: and arranging the abstract classes according to the logic flow, and constructing a logic relation among the abstract classes to enable the abstract classes to be combined into a class set.
In this step, a logical relationship between the abstract classes is constructed according to the logical flow of the abstract classes, for example: calling the abstract class A, calling the abstract class B, and calling the abstract class C, wherein the finally aggregated abstract class is as follows: order 1-abstract class a, order 2-abstract class B, and order 3-abstract class C.
S202: and constructing a starter in a calling module of the software project, so that the calling module calls the interface through the starter to control the service module to convert the acquired request message into a response message according to a preset rule.
Because the interface method is an abstract method without a method body, the interface method cannot be directly called by a calling module before being realized, so that a large number of implementation classes for realizing the interface method are required to be written before the current interface method is called, once a software project needs to be frequently updated, a developer is required to write a large number of implementation classes for realizing the interface, and the interface can be called by the calling module. According to the method, the realization method which is configured in the starter and is associated with the interface method of the interface is used as a method body of the interface method to realize the interface method, and the realization method which can be called by a calling module is obtained. Therefore, compared with the mode that a large number of implementation classes need to be written in the prior art, the interface method can be realized and the realization method can be obtained according to the implementation class method only by configuring the implementation class method in the starter; for example: the implementation method is that the user name information is inquired according to the user ID, and then the implementation method can be obtained by directly inquiring the user information in the implementation interface method.
In a preferred embodiment, said building a launcher in a calling module of said item of software comprises:
s21: acquiring a pom file and a calling module of the software project, constructing a starter in the pom file, and constructing a starting annotation for operating the starter in the calling module;
in this step, a launcher is constructed in a pom file of the software project, a dubbo-wing-spring-boot-launcher is used as the launcher, the pom file refers to a project object model, which is an XML file, is a basic component unit of work in Maven, and is stored in a basic directory of the software project (Maven project), and the pom file includes all computer rules of the software project. The calling module is a computer module for calling an interface in a software project (maven project), for example: by constructing a starting annotation @ dubboFeignClient { }, the starting annotation serves as a method for operating the initiator by the calling module, so that the InvokeServiceImpl service module can call an interface in the initiator through the annotation.
S22: and writing the interface name of the interface in the initiator to bind the initiator and the interface.
In this step, the initiator and the interface are bound through a feign method, wherein the feign method is an explicit web service client and is used for realizing mutual calling between different server interfaces, namely a cross-domain request, which is similar to a controller calling service, so that when the initiator is called, the interface bound with the initiator can be called.
Illustratively, the code of the initiator is as follows:
@dubboFeignClient{}
UserFacadeClient.java
the initiator comprises a power supply, a controller, a power supply, a controller and a power supply, wherein @ dubboFeignClient { } is an annotation for operating the initiator, and UserFacadeClientClient.
S23: and constructing a logic thread in the initiator for acquiring the logic relation among the abstract classes in the interface.
In this step, a logical thread is built in the initiator, so that the initiator can know the logical relationship between the abstract classes before calling the interface, and the initiator calls the abstract classes in the interface according to the logical relationship, so as to finally and smoothly obtain the required response message.
In a preferred embodiment, after the initiator is built in the calling module of the software project, the method further includes:
s24: receiving an implementation method sent by a control terminal, and configuring the implementation method in the starter; making an implementation annotation for operating the implementation method in the interface, writing a method name of the implementation method in a class name definition item of the implementation annotation, and associating the interface with the implementation method; the implementation method is used for implementing the interface method of the interface to obtain a specific method capable of being instantiated.
Specifically, the realization method obtained by configuration in the realization annotation @ DubboMethod enables a calling module to realize the interface method 'queryUserInfo' directly through the realization method 'queryUserInfoByUserId' when the calling module calls the interface method, and avoids the situation that the development efficiency is too low due to overlarge code amount caused by writing a large number of realization class codes.
Illustratively, the Public interface UserFacadient {/section is the definition {/of an interface {/is {/the definition of an interface {/the section
The section @ DubboMethod = "queryUserInfoByUserId"./this section defines/calls implementation class methods by implementing annotations
remotemethodparamtynames = { }/this section defines the implementation method parameter { } {
Timeout = '5 seconds'/this portion is in response to a Timeout parameter +
Retries = 1./this portion is the retry number parameter @
Public QueryUserInfoRespqueryUserInfo(QueryUserInfoReqreq).
S25: the implementation method is used as a method body of the interface method through the starter to realize the interface method and obtain an implementation method; calling the implementation method through the calling module according to the received request message, so that the service module converts the request message into a response message according to a preset rule; the implementation method is a specific method.
In this step, an implementation method configured in the initiator and associated with the interface method of the interface is used as a method body of the interface method to implement the interface method, so as to obtain an implementation method that can be called by a calling module, and further enable each module to calculate the request message according to a preset rule to obtain a response message. Compared with the mode that a large number of implementation classes need to be written in the prior art, the interface method can be realized and the realization method can be obtained according to the implementation class method only by configuring the implementation class method in the starter; for example: the implementation method is that the user name information is inquired according to the user ID, and then the implementation method can be obtained by directly inquiring the user information in the implementation interface method.
In a preferred embodiment, the method of the implementation class is used as a method body of the interface method through the initiator, so as to implement the interface method and obtain an implementation method, including:
s25-1: and operating a starting annotation through the calling module, and starting the starter and acquiring an interface bound with the starter.
In this step, a launcher is built in a pom file of the software project, and a dubbo-femto-spring-boot-starter is used as the launcher, where the pom file is a project object model, is an XML file, is a basic component unit of work in Maven, and is stored in a basic directory of the software project (Maven project), and the pom file includes all computer rules of the software project. The calling module is a computer module for calling an interface in a software project (maven project), such as: an InvokeServiceImpl business module; by constructing a starting annotation @ dubboFeignClient { }, the starting annotation serves as a method for operating the initiator by the calling module, so that the InvokeServiceImpl service module can call an interface in the initiator through the annotation.
S25-2: and operating an implementation annotation through the starter to obtain an implementation method associated with the interface, and using the implementation method as a method body of the interface method to realize the interface method of the interface to obtain the implementation method.
In this embodiment, when the user faceclient interface is called, the call module runs the implementation annotation @ DubboMethod, which is used to obtain the utility method "queryuserlnfobyuserld" in the implementation annotation, and generally, only the method name of the utility method needs to be recorded in the implementation annotation, so that the utility method corresponding to the method name can be obtained from the initiator, that is: remotemethodname = 'queryUserInfoByUserId', so that the condition that the interface method 'queryUserInfo' can be directly realized by realizing a class method 'queryUserInfoByUserId' when a calling module calls the interface method is realized, and the condition that the development efficiency is too low due to the fact that the code quantity is too large due to the fact that a large number of realization class codes are written is avoided.
S203: and constructing a scanning process in the initiator, and writing the method name of the implementation method in the scanning process to associate the implementation method with the scanning process.
In this step, a scanning process is built in the initiator, so that when the calling module runs the start annotation @ dubboFeignClient { }, the scanning process is directly configured to the implementation method, so that when the calling module calls the service module through the implementation method and according to the request message, the response message of the service module can be directly screened through the scanning process, and developers do not need to compile a large amount of identification screening processes and execution codes aiming at the response message.
It should be noted that the Dubbo is a high-performance and light-weight open source Java RPC framework which is used for enabling an application to realize the output and input functions of a service through a high-performance RPC and can be seamlessly integrated with a Spring framework; the feign method is an explicit web service client, and is used for realizing mutual calling between different server interfaces, namely cross-domain request, which is similar to a controller calling service. The spring-boot-startup is a computer module based on a spring boot framework for integrating all dependencies in a maven project. An invoke service im business module (called instance in full for impl) is a computer module which is under the service (i.e. a service business module of a control layer) of the control layer (wherein, a back-end framework, such as an mvc framework, usually includes a model layer, a view layer and the control layer), and is used for storing the implementation classes of the interface and calling the implementation classes in Java development.
In a preferred embodiment, the method for constructing the scanning process includes:
s31: and constructing a code receiving thread and an information extracting thread of the implementation method in the initiator, wherein the code extracting thread is used for extracting a response code obtained by calling the implementation method by the initiator, and the information extracting thread is used for extracting a response body in the response message.
In the step, the realization method which needs to be called for completing the task is called by defining the accurate class name, and the message receiving thread and the information extraction thread corresponding to the realization method are configured, so that the starter only needs to extract the response message and the response body through the pre-configured thread, and developers do not need to write a large amount of codes to define the information extraction method of each realization method, thereby greatly reducing the development code amount and reducing the development strength.
S32: receiving a response condition sent by the control end according to the implementation method, and constructing a result judgment thread with a response list in the starter according to the response condition; wherein the response list has the response condition therein.
Because the calling success conditions of the calling results of the implementation methods are usually different, in the step, according to the response conditions sent by the control terminal, result judgment threads with response lists are built in the implementation methods, and the response conditions meeting the calling success conditions of the implementation methods are recorded in the response lists, so that the calling success conditions of each implementation method are configurable, and the availability and the reliability of the implementation methods are ensured.
S33: and integrating the code extraction thread, the information extraction thread and the result judgment thread into a scanning process of the implementation method, so that the result judgment thread screens out a response body meeting the response condition in the response list.
Because the realization methods of the interfaces in the software project are mostly the same, if the realization method of each interface is compiled, a large amount of repeated codes appear in the software project, and the software development efficiency is seriously reduced; therefore, in the embodiment, only the control end needs to send the class name and the response condition, the implementation methods in the interface can be configured and the scanning process can be finally generated, and a large number of codes with logical relations do not need to be written to define the implementation methods, so that the code amount in a software project is greatly reduced, and the software development efficiency is greatly improved.
Further, after the integrating the packet receiving thread, the information extracting thread, and the result determining thread into the scanning process of the implementation-type method, the method further includes:
s34: and constructing a scanning switch for opening and closing the scanning process in the starter, and controlling the scanning switch to open or close the scanning process according to the switch information sent by the control end.
Because some implementation methods do not need to extract the response body and judge the response result, in order to ensure the application range of the starter relative to various implementation methods, the step constructs a scanning switch for opening and closing the scanning process in the starter, so as to open the scanning process for the implementation methods which need to extract the response body and/or judge the response result, and ensure the adaptability of the starter to various implementation methods in a mode of closing the scanning process for the implementation methods which do not need to extract the response body and/or judge the corresponding result.
Illustratively, the scanning process is as follows:
the part of @ dubboFeignClient {/is to monitor the scanning annotation {/which is required by the initiator to call the implementation class method in the interface
remoteClass = com. Xxx. Userfacade. Class./this section is the class name | _ or | _ that defines the implementation of the class method
needResultJudge = true/scan switch |/for whether response message of implementation class method needs to make response body extraction and/or response result judgment
resultJudage=@DubboFeignClient.ResultJudge(
Remotecodenodeoi = "respCode"/this section acquires the response message, that is: the packet receive thread-
RemoteMsgNode = "resppmemo"/this part is the response body in the acquisition response message, and is used for the response message to convey the body information, that is: the information fetch thread-
Remotecodesucccvaluelist = { "000000" })/this portion is a result judging thread with a response list, where "000000" is the response condition { -based on the status of the response
Java and said initiator interface name of bound interface
Public interface UserFacadeClient{
Public QueryUserInfoRespqueryUserInfo(QueryUserInfoReqreq).
The public interface + interface name defines the initiator call interface and the abstract method in the interface.
S204: screening out a response message meeting a preset response condition through a scanning process configured in the starter, and extracting a response body in the response message;
in the step, the response messages are screened through the configurable scanning process, so that the response conditions of all the service modules are conveniently recorded into the scanning process, the writing of a large number of judgment back parameter codes is avoided, only a response list with the response conditions is configured, and the operation effect of the judgment back parameter codes can be realized by operating the scanning thread, the writing amount of the codes is greatly reduced, and meanwhile, the response list is obtained by configuring the response conditions, so that the configuration and modification efficiency of the response conditions is improved. The response code is data reflecting the state attribute of the response message, and the response body refers to content information transmitted by the response message.
Specifically, the step of running the scanning process includes:
s41: and judging whether the starter receives a response message sent by a service module corresponding to the implementation method.
S42: and if so, acquiring the response message and a response body in the response message.
S43: if not, determining that the implementation method fails to be called;
s44: judging whether the response body belongs to the response list or not;
s45: if yes, judging that the response body meets the response condition;
s46: if not, judging that the response body does not accord with the response condition, and determining that the implementation method is failed to call.
S205: constructing a return function associated with the implementation method in the initiator, wherein the construction method of the return function comprises the following steps:
s51: receiving a return type sent by a control terminal, and obtaining the implementation method through the implementation annotation of the starter;
s52: constructing a return function with a return value as the return type in the implementation annotation, and associating the return function with the implementation method; and the return function is used for converting the response bodies screened by the scanning process into the return values.
Further, after constructing, in the initiator, a return function with the instance of the return class as the return value according to the method information, the method further includes:
s53: and receiving type information sent by a control terminal, and writing the type information into the parameter definition item of the implementation method for implementing annotation, so as to define the parameter type of the implementation method.
In this step, the type information sent by the control end is written into the parameter definition item "remotemethodparamsttypename" of the implementation method of the initiator, so as to define the parameter type of the implementation method.
S54: receiving the overtime information sent by the control terminal, and writing the overtime information into the overtime definition item for realizing annotation, wherein the overtime information is used for defining the time upper limit of the operation time of the realization method.
In this step, the Timeout information '5seconds' is entered into a Timeout definition item Timeout for defining an upper time limit of the implementation method running time.
S55: and receiving retry information sent by a control terminal, and writing the retry information into a retry definition item for realizing annotation, wherein the retry definition item is used for defining the upper limit of the running times of the realization method.
In this step, the retry information 2 is entered into a retry definition item Retries to define an upper line of the operation times of the implementation method, that is: the number of call retry calls of the implementation method is at most 2.
In an exemplary embodiment, the implementation annotations are as follows:
Public interface UserFacadeClient{
@ DubboMethod (remoteMethodname = "queryUserInfoByUserId"/this section defines @ implementing class method @
remoteMethodParamsTypeName = { }/this portion defines an implementation method parameter { } { -
Timeout = '5 seconds'/this portion is in response to a Timeout parameter &
Retries = 1./this portion is the retry number parameter @
Public QueryUserInfoRespqueryUserInfo(QueryUserInfoReqreq).
Therefore, the interface bound with the starter can be configured only by editing the interface name in the scanning process, so that the technical effect of rapidly configuring the interface is realized, and the interface is not required to be configured by writing a large number of codes. Meanwhile, only the definition items required by the control end need to be constructed in the implementation annotation to manage and configure any interface in the scanning process, so that the parameter type, response timeout and retry of the interface can be managed at the moment, and the technical effect of quickly and efficiently managing the interface without writing a large amount of configuration codes is realized.
Specifically, the starter is limited according to the upper time limit and the upper number limit by the following method:
m1: and constructing a timing thread and a counting thread in the starter, wherein the timing thread is used for recording the running time of the implementation method according to the request message, and the counting thread is used for recording the running times of the implementation method.
And M2: and constructing a time judgment process in the starter, wherein the time judgment process is used for acquiring the running time in the timing thread and the time upper limit in the implementation annotation, and controlling the starter to stop running the implementation method and call back when the running time exceeds the time upper limit.
M3: and constructing a frequency judgment process in the starter, wherein the frequency judgment process is used for acquiring the running frequency in the technical thread and the frequency upper limit in the implementation annotation, and controlling the starter to forbid the operation of the implementation method for calling the interface when the running frequency exceeds the frequency upper limit.
S206: and converting the response body into a return value through the starter, and sending the return value to the calling module.
In this step, a response body in a response message meeting a response condition is converted into a return value through a starter, and after receiving the return value, the calling module forwards the return value to a client side which provides a request message for the service module; the situation that the computational power consumption of the server is overlarge due to frequent conversion is avoided because the response bodies in the response messages need to be frequently converted when the response messages are generated by calling each service module at present.
Specifically, the converting, by the initiator, the response body into a return value includes:
s61: and acquiring a return function associated with the implementation class.
S62: and calling the return function to convert the response body into a return value.
In this embodiment, the return function is constructed by combining a public method with the return class, and the response body meeting the response condition obtained in the implementation method can be converted into the return value by the return function. For example: public QueryUserInfoRespqqueryUserInfo (QueryUserInfReqreq.) this section of code expresses: through a queryusenlnfo (queryurinforqreq) method (namely, the realization method), an example of a queryusenforResp class (namely, the return class) is obtained as a return value.
Preferably, after the initiator converts the response body into a return value, the method further includes:
and uploading the return value to a block chain.
It should be noted that the corresponding digest information is obtained based on the return value, and specifically, the digest information is obtained by hashing the return value, for example, using the sha256s algorithm. Uploading summary information to the blockchain can ensure the safety and the fair transparency of the user. The user equipment may download the digest information from the blockchain to verify that the return value has been tampered with. The blockchain referred to in this example is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, encryption algorithm, and the like. A block chain (Blockchain), which is essentially a decentralized database, is a string of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, which is used for verifying the validity (anti-counterfeiting) of the information and generating a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
Example three:
referring to fig. 4, an interface calling apparatus 1 for calling a module in this embodiment includes:
the interface construction module 11 is used for acquiring a service module of a software project and constructing an interface for calling at least one service module, wherein the service module is a computer module for completing a specified task;
a starting construction module 12, configured to construct a starter in the calling module of the software project, so that the calling module calls the interface through the starter, and is used to control the service module to convert the acquired request packet into a response packet according to a preset rule;
a screening and extracting module 14, configured to screen out, through a scanning process configured in the initiator, a response message that meets a preset response condition, and extract a response body in the response message;
and the information conversion module 16 is configured to convert the response body into a return value through the initiator, and send the return value to the calling module.
Optionally, the interface building module 11 includes:
the class extraction unit 111 is configured to obtain at least one service module from the software project according to the task information sent by the control end, and obtain an abstract class from the service module, where the abstract class is a class that defines a function called by the service module.
And a class aggregation unit 112, configured to aggregate abstractions of at least one of the service modules into a class set according to the task information.
A class encapsulation unit 113, configured to encapsulate the class set into the interface, and configured to invoke the at least one service module.
Optionally, the start building block 12 includes:
a start building unit 121, configured to obtain a pom file and a call module of the software item, build a starter in the pom file, and build a start annotation for running the starter in the call module.
An interface binding unit 122, configured to write an interface name of the interface in the initiator, so as to bind the initiator and the interface.
A logic constructing unit 123, configured to construct a logic thread in the initiator, and configured to obtain a logic relationship between the abstract classes in the interface.
Optionally, the start building block 12 includes:
a class method defining unit 124, configured to receive an implementation class method sent by a control end, and configure the implementation class method in the initiator; making an implementation annotation for operating the implementation method in the interface, writing a method name of the implementation method in a class name definition item of the implementation annotation, and associating the interface with the implementation method; the implementation method is used for implementing the interface method of the interface to obtain a specific method capable of being instantiated.
A method implementation unit 125, configured to use the implementation-type method as a method body of the interface method through the initiator, so as to implement the interface method and obtain an implementation method; the implementation method is called by the calling module according to the received request message, so that the service module converts the request message into a response message according to a preset rule; the implementation method is a specific method.
Optionally, the interface calling device 1 for calling the module further includes:
a scan building module 13, configured to build a scan process in the initiator, and write a method name of the implementation method in the scan process, so that the implementation method is associated with the scan process.
Optionally, the interface calling device 1 for calling the module further includes:
a function building module 15, configured to build a return function associated with the implementation method in the initiator, where the function building module 15 includes:
a class method identification unit 151, configured to receive a return type sent by the control end, and obtain the implementation class method through an implementation annotation of the initiator;
a function constructing unit 152, configured to construct a return function with a return value being the return type in the implementation annotation, and associate the return function with the implementation class method; and the return function is used for converting the response bodies screened by the scanning process into the return values. The technical scheme is applied to the field of computer development of research and development management, at least one interface for calling the business module is constructed, a starter for calling the interface is constructed in a software project, a scanning process is constructed in the starter, the scanning process is used for defining a method for calling the interface, and a management rule is constructed in the scanning process, wherein the management rule is used for defining the scanning process. Therefore, the technical scheme realizes the effect of further and rapidly developing the current research and development framework, so that developers can update and configure the software project only by configuring and managing the software project developed based on the research and development framework.
Example four:
in order to achieve the above object, the present invention further provides a computer device 5, in which components of the interface invoking device of the invoking module in the third embodiment may be dispersed in different computer devices, and the computer device 5 may be a smart phone, a tablet computer, a notebook computer, a desktop computer, a rack server, a blade server, a tower server, or a rack server (including an independent server or a server cluster formed by multiple application servers) for executing programs, and the like. The computer device of the embodiment at least includes but is not limited to: a memory 51, a processor 52, which may be communicatively coupled to each other via a system bus, as shown in FIG. 5. It should be noted that fig. 5 only shows a computer device with components, but it should be understood that not all of the shown components are required to be implemented, and more or fewer components may be implemented instead.
In the present embodiment, the memory 51 (i.e., a readable storage medium) includes a flash memory, a hard disk, a multimedia card, a card-type memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a Read Only Memory (ROM), an Electrically Erasable Programmable Read Only Memory (EEPROM), a Programmable Read Only Memory (PROM), a magnetic memory, a magnetic disk, an optical disk, and the like. In some embodiments, the memory 51 may be an internal storage unit of the computer device, such as a hard disk or a memory of the computer device. In other embodiments, the memory 51 may be an external storage device of a computer device, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), or the like, provided on the computer device. Of course, the memory 51 may also include both internal and external storage devices of the computer device. In this embodiment, the memory 51 is generally used for storing an operating system installed in the computer device and various application software, such as program codes of the interface calling device of the calling module in the third embodiment. Further, the memory 51 may also be used to temporarily store various types of data that have been output or are to be output.
Processor 52 may be a Central Processing Unit (CPU), controller, microcontroller, microprocessor, or other data Processing chip in some embodiments. The processor 52 generally serves to control the overall operation of the computer apparatus. In this embodiment, the processor 52 is configured to run a program code stored in the memory 51 or process data, for example, run an interface calling device of a calling module, so as to implement the interface calling method of the calling module in the first embodiment and the second embodiment.
Example five:
to achieve the above objects, the present invention also provides a computer readable storage medium, such as a flash memory, a hard disk, a multimedia card, a card type memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a Read Only Memory (ROM), an Electrically Erasable Programmable Read Only Memory (EEPROM), a Programmable Read Only Memory (PROM), a magnetic memory, a magnetic disk, an optical disk, a server, an App, etc., on which a computer program is stored, which when executed by a processor 52 implements corresponding functions. The computer-readable storage medium of this embodiment is used for storing a computer program for implementing the interface calling method of the calling module, and when executed by the processor 52, implements the interface calling method of the calling module of the first embodiment and the second embodiment.
The above-mentioned serial numbers of the embodiments of the present invention are only for description, and do not represent the advantages and disadvantages of the embodiments.
Through the description of the foregoing embodiments, it is clear to those skilled in the art that the method of the foregoing embodiments may be implemented by software plus a necessary general hardware platform, and certainly may also be implemented by hardware, but in many cases, the former is a better implementation.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.