CN112181535A - Interface calling method, device, server and storage medium - Google Patents

Interface calling method, device, server and storage medium Download PDF

Info

Publication number
CN112181535A
CN112181535A CN202010994608.6A CN202010994608A CN112181535A CN 112181535 A CN112181535 A CN 112181535A CN 202010994608 A CN202010994608 A CN 202010994608A CN 112181535 A CN112181535 A CN 112181535A
Authority
CN
China
Prior art keywords
interface
class
annotation
called
calling
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010994608.6A
Other languages
Chinese (zh)
Inventor
李镭
余化
陶晖
齐珑
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Construction Bank Corp
Original Assignee
China Construction Bank Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Construction Bank Corp filed Critical China Construction Bank Corp
Priority to CN202010994608.6A priority Critical patent/CN112181535A/en
Publication of CN112181535A publication Critical patent/CN112181535A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4488Object-oriented
    • G06F9/449Object-oriented method invocation or resolution

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The embodiment of the invention discloses an interface calling method, an interface calling device, a server and a storage medium. The method is applied to the server and can comprise the following steps: when a trigger event of interface calling is monitored, acquiring an interface calling parameter corresponding to the trigger event; determining an interface to be called in a scene to be called corresponding to an interface calling parameter in a mapping relation, wherein the mapping relation is constructed in advance in an annotation dynamic mapping mode; and calling the interface to be called to realize the function corresponding to the interface to be called. According to the technical scheme of the embodiment of the invention, the calling process of each interface in various scenes can be uniformly realized in a unique entry through the provided simpler, more flexible, more uniform and standardized interface calling mode, so that the problem of high difficulty in realizing interface calling is solved, the working intensity of developers is reduced, and the efficiency of subsequent interface calling is improved.

Description

Interface calling method, device, server and storage medium
Technical Field
The embodiment of the invention relates to the technical field of computers, in particular to an interface calling method, an interface calling device, a server and a storage medium.
Background
In the development process of the software application, the call of the back-end interface is the basis of the interaction between the front end and the back end and the interaction between systems, and is the basic function in the software application.
In the field of financial services, there are demands for time-consuming monitoring, synchronization and synchronization, filtering, adding of a journal and the like for various financial transactions, which makes the implementation process of calling corresponding interfaces for fulfilling respective demands in different scenarios very cumbersome. Particularly, because actual scenes are many, the implementation manners of interface calling under various scenes with the same requirement are not uniform, which also increases the implementation difficulty of interface calling.
Disclosure of Invention
The embodiment of the invention provides an interface calling method, an interface calling device, a server and a storage medium, and solves the problem of high difficulty in realizing interface calling.
In a first aspect, an embodiment of the present invention provides an interface calling method, applied to a server, including:
when a trigger event of interface calling is monitored, acquiring an interface calling parameter corresponding to the trigger event;
determining an interface to be called in a scene to be called corresponding to an interface calling parameter in a mapping relation, wherein the mapping relation is constructed in advance in an annotation dynamic mapping mode;
and calling the interface to be called to realize the function corresponding to the interface to be called.
Optionally, the mapping relationship may be pre-constructed by the following steps:
obtaining class annotation and method annotation in custom operation and entity class corresponding to the class annotation and method annotation, writing the class annotation and method annotation into the entity class based on preset annotation scanning class, and constructing a mapping relation based on the written entity class.
Optionally, the entity class is provided with a transaction code, a class name, a class object and a method.
Optionally, writing the class annotation and the method annotation into the entity class based on the preset annotation scan class may include:
and calling the constructed annotation writing function by taking the acquired class object and the class name as the parameter to write the class annotation and the method annotation into the entity class, wherein the annotation writing function is arranged in a preset annotation processing class, a mapping variable is arranged in the annotation processing class, the annotation writing function writes the class annotation and the method annotation into the entity class through the mapping variable, and the mapping variable is a static Map type member variable.
Optionally, the annotation writing function may implement the annotation writing function by:
determining a class annotation corresponding to the class object, acquiring a method array formed by methods associated with the class object when the class annotation is not empty, and judging whether the method array is empty or not;
if not, sequentially acquiring each method object in the method array and method annotation of each method object, and acquiring a transaction code of the method annotation when the method annotation is not empty;
and when the transaction code is not empty, acquiring an entity object corresponding to the class name and the class object from the mapping variable according to the transaction code, and writing the class annotation and the method annotation into the entity class based on the entity object, wherein the entity object is an object in the entity class.
Optionally, the interface calling method may further include: annotating the interface to be called through the method and annotating the scene to be called through the class annotation.
Optionally, determining, in the mapping relationship, an interface to be called in a scene to be called corresponding to the interface calling parameter may include:
and taking the interface calling parameter as an access parameter, calling the established interface determining function, and determining the interface to be called in the scene to be called corresponding to the interface calling parameter in the mapping relation, wherein the interface determining function is arranged in an interface service class, and the interface service class comprises a FacadeService class.
Optionally, the interface determination function may implement the interface determination function by:
acquiring an entity object corresponding to the interface calling parameter, and acquiring a class object and a method object from the entity object when the entity object is not empty;
and determining a scene to be called in the mapping relation according to the class object, and determining an interface to be called in the scene to be called according to the method object.
Optionally, the obtaining of the interface call parameter corresponding to the trigger event may include:
and acquiring an interface calling parameter corresponding to the trigger event based on the entry class, and injecting an interface service object of the interface service class into the entry class in an annotation mode.
On this basis, optionally, determining the interface to be called in the scene to be called corresponding to the interface calling parameter in the mapping relationship may include: and determining the interface to be called in the scene to be called corresponding to the interface calling parameter in the mapping relation through the interface service object in the entry class.
Optionally, the invoking the interface to be invoked to implement the function corresponding to the interface to be invoked may include:
calling an interface to be called to perform time recording on a preset reflection algorithm to monitor time consumption; or the light source is used for emitting light,
calling an interface to be called to control the execution of synchronous and asynchronous in a preset reflection algorithm according to the synchronous and asynchronous parameters in the variable length parameters in the interface calling parameters; or the light source is used for emitting light,
calling an interface to be called to judge the variable length parameter to filter data; or the light source is used for emitting light,
and calling the interface to be called to classify the transaction codes in the interface calling parameters so as to realize the operation flow record under the corresponding requirements.
Optionally, the mapping relationship stores a corresponding relationship between the interface calling parameter, the scene to be called, and the interface to be called.
In a second aspect, an embodiment of the present invention further provides an interface invoking device, configured on a server, where the interface invoking device may include:
the parameter acquisition module is used for acquiring interface calling parameters corresponding to the triggering events when the triggering events of the interface calling are monitored;
the interface determining module is used for determining an interface to be called in a scene to be called corresponding to the interface calling parameter in the mapping relation, and the mapping relation is constructed in advance in an annotation dynamic mapping mode;
and the interface calling module is used for calling the interface to be called so as to realize the function corresponding to the interface to be called.
In a third aspect, an embodiment of the present invention further provides a server, where the server may include:
one or more processors;
a memory for storing one or more programs;
when executed by one or more processors, cause the one or more processors to implement the interface call method provided by any of the embodiments of the present invention.
In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the interface calling method provided in any embodiment of the present invention.
According to the technical scheme of the embodiment of the invention, when the only entry in the server receives the interface calling parameter transmitted from the front end, the interface to be called under the scene to be called corresponding to the only entry can be obtained in the mapping relation according to the interface calling parameter; therefore, the corresponding function is realized by calling the interface to be called. According to the technical scheme, the calling process of each interface under various scenes can be uniformly realized in the unique entry through the provided simpler, more flexible, more uniform and standardized interface calling mode, so that the problem of high difficulty in realizing interface calling is solved, the working strength of developers is reduced, and the efficiency of subsequent interface calling is improved.
Drawings
Fig. 1 is a flowchart of an interface calling method according to a first embodiment of the present invention;
fig. 2 is a flowchart of an interface calling method according to a second embodiment of the present invention;
fig. 3 is a flowchart of an interface calling method in the third embodiment of the present invention;
fig. 4 is a block diagram of an interface calling apparatus according to a fourth embodiment of the present invention;
fig. 5 is a schematic structural diagram of a server in the fifth embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
Example one
Fig. 1 is a flowchart of an interface calling method according to an embodiment of the present invention. The embodiment can be applied to the condition that the interfaces corresponding to various requirements in various scenes are called through the unique entrance. The method can be executed by an interface calling device provided by the embodiment of the invention, the device can be realized by software and/or hardware, and the device can be integrated on a server.
Referring to fig. 1, the method of the embodiment of the present invention specifically includes the following steps:
s110, when a trigger event of interface calling is monitored, acquiring an interface calling parameter corresponding to the trigger event.
The triggering event may be an event triggered by a front end (i.e., a client) for calling an interface in a back end (i.e., a server), the interface may be an interface to be called corresponding to a certain requirement in a certain scenario, the scenario may be a scenario related to financial transactions, the requirement may be time-consuming monitoring, asynchronous and synchronous, filtering, adding a journal, and the like, which are not specifically limited herein.
When a trigger event of interface calling is monitored, acquiring an interface calling parameter which is corresponding to the trigger event and is transmitted from a front end, the interface call parameters may include a transaction code, variable length parameters, etc., the acquisition process may be performed by the only entry of the Java backend service set by embodiments of the present invention, the unique entrance can unify various interfaces under different scenes, and the setting has the advantages that by providing a simpler, more flexible, unified and standardized interface calling mode, the requirements under various scenes can be uniformly realized in the unique entry, thereby solving the problem that codes are required to be repeatedly written in various scenes due to the application of the same requirement in different scenes, only the codes related to various requirements are required to be written in the unique entry, therefore, the working intensity of developers is reduced, and the efficiency of subsequent interface calling is improved.
S120, determining an interface to be called in the scene to be called corresponding to the interface calling parameter in the mapping relation, wherein the mapping relation is constructed in advance in an annotation dynamic mapping mode.
The scene to be called is a scene to be called corresponding to the interface calling parameter in each scene, the interface to be called is an interface to be called corresponding to the parameter to be called in each interface in the scene to be called, and the mapping relation stores the corresponding relation among the interface calling parameter, the scene and the interface, so that the scene to be called corresponding to the interface calling parameter and the interface to be called in the scene to be called can be obtained in the mapping relation.
It should be noted that the mapping relationship may be pre-constructed in an annotation dynamic mapping manner, for example, annotate a scene and an interface that need to be unified into a unique entry, and map the scene and the interface according to an annotation result, and because each interface has a transaction code, which is one of interface call parameters, the mapping relationship constructed in the annotation dynamic mapping manner may include a mapping relationship among the scene, the interface, and the interface call parameters.
On this basis, optionally, the obtaining of the interface call parameter corresponding to the trigger event may specifically include: acquiring an interface calling parameter corresponding to a trigger event based on an entry class, and injecting an interface service object of an interface service class into the entry class in an annotation mode, wherein the entry class can be expressed as WebController, and the interface service class can be expressed as a FacadeService class, and the technical scheme realizes the calling process of a unique entry; therefore, determining the interface to be called in the scene to be called corresponding to the interface calling parameter in the mapping relationship may specifically include: and determining the interface to be called in the scene to be called corresponding to the interface calling parameter in the mapping relation through the interface service object in the entry class.
And S130, calling the interface to be called to realize the function corresponding to the interface to be called.
Each interface to be called corresponds to a function, a method and the like, so that the function corresponding to the interface to be called can be realized by calling the interface to be called. Illustratively, calling an interface to be called to perform time recording on a preset reflection algorithm to monitor time consumption; or, calling the interface to be called so as to control the execution of synchronous and asynchronous in the preset reflection algorithm according to the synchronous and asynchronous parameters in the variable length parameters in the interface calling parameters; or calling an interface to be called so as to judge the variable-length parameter to filter data; or calling the interface to be called so as to classify the transaction codes in the interface calling parameters to realize the operation flow record under the corresponding requirement; etc., and are not specifically limited herein.
According to the technical scheme of the embodiment of the invention, when the only entry in the server receives the interface calling parameter transmitted from the front end, the interface to be called under the scene to be called corresponding to the only entry can be obtained in the mapping relation according to the interface calling parameter; therefore, the corresponding function is realized by calling the interface to be called. According to the technical scheme, the calling process of each interface under various scenes can be uniformly realized in the unique entry through the provided simpler, more flexible, more uniform and standardized interface calling mode, so that the problem of high difficulty in realizing interface calling is solved, the working strength of developers is reduced, and the efficiency of subsequent interface calling is improved.
Example two
Fig. 2 is a flowchart of an interface calling method according to a second embodiment of the present invention. The present embodiment is optimized based on the above technical solutions. In this embodiment, optionally, the mapping relationship may be pre-constructed by the following steps: obtaining a class annotation and a method annotation in a custom operation and an entity class corresponding to the class annotation and the method annotation, wherein the entity class is provided with a transaction code, a class name, a class object and a method; writing the class annotation and the method annotation into the entity class based on the preset annotation scanning class, and constructing a mapping relation based on the written entity class. The same or corresponding terms as those in the above embodiments are not explained in detail herein. Referring to fig. 2, the method of the present embodiment may specifically include the following steps:
s210, obtaining a class annotation and a method annotation of the custom runtime and an entity class corresponding to the class annotation and the method annotation, wherein the entity class is provided with a transaction code, a class name, a class object and a method.
The class annotation and method annotation can be understood as tags, the entity class is a class corresponding to each tag, the entity class can be provided with transaction codes, class names, class objects and methods corresponding to each tag, and the entity class can be represented by a DealaAction. In practical application, optionally, each interface to be called may be annotated by method annotation, and each scene to be called is annotated by class annotation, that is, the scenes and interfaces that need to be unified into a unique entry are tagged. It should be noted that the class and the scene have a corresponding relationship, and the method in the class and the interface in the scene have a corresponding relationship.
S220, writing the class annotation and the method annotation into the entity class based on the preset annotation scanning class, and constructing a mapping relation based on the written entity class.
The method comprises the steps that various interfaces under various scenes are scanned based on annotation scanning classes, the scenes with class annotations and the interfaces with method annotations can be obtained, and therefore the scanned class annotations and method annotations can be written into entity classes, and the mapping relation is built.
On this basis, optionally, writing the class annotation and the method annotation into the entity class based on the preset annotation scan class may specifically include: calling the constructed annotation writing function by taking the obtained class object and the class name as the parameter to write the class annotation and the method annotation into the entity class; the annotation writing function is arranged in a preset annotation processing class, mapping variables are arranged in the annotation processing class, the annotation writing function writes class annotations and method annotations into the entity class through the mapping variables, and the mapping variables are static Map type member variables. On this basis, optionally, the annotation writing function may implement the annotation writing function by: determining a class annotation corresponding to the class object, acquiring a method array formed by methods associated with the class object when the class annotation is not empty, and judging whether the method array is empty or not; if not, sequentially acquiring each method object in the method array and method annotation of each method object, and acquiring a transaction code of the method annotation when the method annotation is not empty; and when the transaction code is not empty, acquiring an entity object corresponding to the class name and the class object from the mapping variable according to the transaction code, and writing the class annotation and the method annotation into the entity class based on the entity object, wherein the entity object is an object in the entity class.
And S230, when the trigger event of the interface calling is monitored, acquiring the interface calling parameter corresponding to the trigger event.
S240, determining the interface to be called in the scene to be called corresponding to the interface calling parameter in the mapping relation, wherein the mapping relation is constructed in advance in an annotation dynamic mapping mode.
And S250, calling the interface to be called to realize the function corresponding to the interface to be called.
According to the technical scheme of the embodiment of the invention, the class annotation and the method annotation in the custom operation and the entity class corresponding to the class annotation and the method annotation are obtained, so that the class annotation and the method annotation can be written into the entity class based on the annotation scanning class, and the mapping relation is constructed based on the written entity class, thereby realizing the construction effect of the mapping relation.
EXAMPLE III
Fig. 3 is a flowchart of an interface calling method provided in the third embodiment of the present invention. The present embodiment is optimized based on the above technical solutions. In this embodiment, optionally, determining, in the mapping relationship, an interface to be called in a scene to be called corresponding to the interface calling parameter may specifically include: and taking the interface calling parameter as an access parameter, calling the established interface determining function so as to determine the interface to be called in the scene to be called corresponding to the interface calling parameter in the mapping relation, wherein the interface determining function is arranged in an interface service class, and the interface service class comprises a FacadeService class. The same or corresponding terms as those in the above embodiments are not explained in detail herein.
Referring to fig. 3, the method of this embodiment may specifically include the following steps:
s310, when a trigger event of the interface calling is monitored, acquiring an interface calling parameter corresponding to the trigger event.
S320, taking the interface calling parameter as an entry parameter, calling the constructed interface determining function, and determining the interface to be called in the scene to be called corresponding to the interface calling parameter in a mapping relation, wherein the mapping relation is constructed in advance in an annotation dynamic mapping mode, the interface determining function is arranged in an interface service class, and the interface service class comprises a FacadeeService class.
The interface service class can be arranged in the entry class, the interface calling parameter can be obtained based on the entry class, and the interface determining function is arranged in the interface service class. On this basis, optionally, the interface determination function may implement the interface determination function by: acquiring an entity object corresponding to the interface calling parameter, wherein the entity object is an object in an entity class; when the entity object is not empty, acquiring a class object and a method object from the entity object; because the class and the scene have a corresponding relation and the method and the interface have a corresponding relation, the scene to be called can be determined in the mapping relation according to the class object, and the interface to be called can be determined in the scene to be called according to the method object, so that the effect of accurately determining the interface to be called is achieved.
S330, calling the interface to be called to realize the function corresponding to the interface to be called.
According to the technical scheme of the embodiment of the invention, the interface calling parameter is taken as the parameter to be entered, the established interface determining function is called, and the interface to be called in the scene to be called corresponding to the interface calling parameter is determined in the mapping relation, so that the effect of accurately determining the interface to be called is realized.
In order to better understand the specific implementation process of the above steps, the following describes an exemplary interface calling method according to this embodiment with reference to a specific example. In an exemplary manner, the first and second electrodes are,
1) class annotation @ Deal and method annotation @ Action at runtime (runtime) are added, and at this time, class annotation and method annotation can be understood as tags, and each tag is given to a corresponding class and method, wherein the class and the scene have correspondence, and the method in the class and the interface in the scene have correspondence, so that the class and the method marked with the tag are called at the unique entrance set in each embodiment of the invention.
2) The entity class DealAction of adding class note and method note can add the following fields: code (transaction code defined in method annotation), bean (class name), bean (class object), and method, and the corresponding get (value) method and set (set value) method. That is, the DealAction stores the code, the bean name, the bean and the method of the class/method, so that the various tagged classes/methods are stored in the DealAction, at this time, the DealAction can be understood as a mapping relation, a key value pair, a list, a set and the like, the mapping relation can be stored in the memory, and the subsequent unique entry determines which classes/methods are marked and can be called through the DealAction.
3) Adding an annotation processing class DeltaActionHolder, defining a method postProcess in the DeltaActionHolder, and storing the tagged class/method in the DeltaAction based on the DeltaActionHolder, which is a definition process, and step 4) storing the tagged class/method in the DeltaAction by calling the postProcess in an initialization scanning process, which is an execution process. In particular, the method comprises the following steps of,
i, adding a static Map type member variable findDealAtionicache to the DealActionHolder and initializing, wherein the findDealAtionicache is equivalent to a key-value pair;
and II, adding a static method postProcess (Object bean, String bean name) of an initialized assignment findDelaliAtionCache, wherein the input parameters are bean and bean name, the Deal annotation is a class annotation and the Action annotation is a method annotation, the relevant content of the Deal annotation is firstly put into the Deal bean, and then the relevant content of the Action annotation in the content is put into the Deal bean (namely, all methods in the Action annotation are read in a circulating mode). The specific implementation process is seen in the following 5 steps:
firstly, acquiring a Deal annotation of a class through beans in a parameter, and if the Deal annotation is empty, directly returning; otherwise, continuing to execute downwards;
acquiring method arrays of all methods through beans, and circularly acquiring method objects in the method arrays if the method arrays are not empty;
thirdly, acquiring Action annotation of method in the circulating process, if the Action annotation is not empty, acquiring a transaction code of the Action annotation, and if the code is empty, throwing exception; otherwise, continuing to execute downwards;
fourthly, acquiring the DealAction object from the findDealAtioncache according to the code, if the DealAction object exists, throwing an abnormal prompt, and if the DealAction object does not exist, continuing to execute downwards;
newly building a DealAction object, setting corresponding bean, bean name, method and code, and adding the above objects into the method array;
and III, adding a static method findDealAction (String code) for querying the annotation object according to the code, and acquiring a corresponding DealAction object from Map findDealAtioncache according to the code of the incoming parameter and returning.
4) Adding an annotation scanning class DeltaActionScannerConfiguer and realizing a spring post processor interface BeanPostprocessor, specifically:
i, rewriting postProcessBeforeInitialization and postProcesssAfterInitialization, wherein the rewriting process of postProcessBeforeInitialization is executed after instantiation, dependency injection and initialization, and the rewriting process of postProcessBeforeInitialization is executed after instantiation, dependency injection and initialization;
II, directly returning the transmitted bean in the postprocessBeforeImitialization method;
III, postProcesssAfterInitialization method calls postProcess in DeaActionHolder to scan the object added with the Deal and Action to write to findDealAtionCache.
5) Adding a FacadeService class (interface service class) to execute the annotated method instance, wherein a unique entry is defined to unify various interfaces to the unique entry so that the front end can call the interfaces through the unique entry without calling the interfaces through different interfaces. In particular, the method comprises the following steps of,
i, adding an annotation execution method excete (functions of time consumption monitoring, synchronous and asynchronous, filtering, adding a streaming log and the like can be added in the excete), transmitting a transaction code and a variable length parameter args, and throwing out a method Exception-the excete comprises a parameter and a parameter transferred from a foreground to a background
II, acquiring a dealAction object dealAction through findDelAction (code) in the dealAction holder, if the dealAction is not null, indicating that the current transaction code is defined, and continuing to execute downwards;
III, acquiring a class object (bean) and a method object (method) from the dealAction;
IV, reflecting and executing the method and returning the content returned by the method, namely, the method can be found by the excute according to the parameter of the.
6) The method for annotating the Service object by @ Deal and annotating the Services object by @ Action is characterized in that the first steps are equivalent to a process of defining a tag, and the step is equivalent to a process of marking the tag.
7) Adding an entry class WebController to realize the calling process of the unique entry, and 5) calling a corresponding method according to a corresponding entry parameter when the unique entry is called. In particular, the method comprises the following steps of,
i, annotating @ automated to inject a FacadeService object fs;
do mapping method test of the addition request test, the parameter of entry is paramJson;
III, acquiring a transaction code tranId and parameter object data through Json conversion;
IV, defining a returned Man resultMap, a returned transaction state bkStatus (if 00 represents normal transaction) and a returned description bkDesc;
judging whether the data is empty through a trinocular operation, if so, executing an exit method of FacadeService, and not transmitting variable parameters; otherwise, the variable parameter transmits data, executes the excute to obtain a return object resultObj, and writes the resultObj in the Controller return object resultMap;
VI, capturing the abnormity in the execution process of the excute, changing the transaction state bkStatus to 01, and putting the obtained abnormal information into bkDesc;
and VII, writing a transaction state bkStatus and a return description bkDesc into the return object resultMap.
In the above example, by unifying the unique entries of the Java background service, a series of operations can be added to the aggregate method in the faceservice class, for example:
1. time consumption monitoring is realized by recording the execution time of the reflection method;
2. controlling synchronous and asynchronous execution of the reflection method through the incoming synchronous and asynchronous parameters in the args;
3. transaction filtering is realized by judging the data transmitted into the args;
4. and the code codes are classified (such as addition, deletion, modification and check) to realize the operation flow records with different requirements.
Example four
Fig. 4 is a block diagram of an interface calling apparatus according to a fourth embodiment of the present invention, where the apparatus is configured to execute an interface calling method according to any of the embodiments. The device and the interface calling method of each embodiment belong to the same inventive concept, and details which are not described in detail in the embodiment of the interface calling device can refer to the embodiment of the interface calling method. Referring to fig. 4, the apparatus is configured in a server, and may specifically include: a parameter acquisition module 410, an interface determination module 420, and an interface call module 430.
The parameter obtaining module 410 is configured to, when a trigger event of interface calling is monitored, obtain an interface calling parameter corresponding to the trigger event;
the interface determining module 420 is configured to determine an interface to be called in a scene to be called, which corresponds to the interface calling parameter, in a mapping relationship, where the mapping relationship is pre-constructed in an annotation dynamic mapping manner;
the interface calling module 430 is configured to call the interface to be called to implement a function corresponding to the interface to be called.
Optionally, on this basis, the interface invoking device may further include:
the entity class acquisition module is used for acquiring class annotation and method annotation in the custom operation and an entity class corresponding to the class annotation and the method annotation;
and the mapping relation construction module is used for writing the class annotation and the method annotation into the entity class based on the preset annotation scanning class and constructing the mapping relation based on the written entity class.
Optionally, the entity class is provided with a transaction code, a class name, a class object and a method.
Optionally, the mapping relationship building module may specifically include:
the annotation writing unit is used for calling the constructed annotation writing function by taking the obtained class object and the obtained class name as the parameter of the entry, so as to write the class annotation and the method annotation into the entity class;
the annotation writing function is arranged in a preset annotation processing class, mapping variables are arranged in the annotation processing class, the annotation writing function writes class annotations and method annotations into the entity class through the mapping variables, and the mapping variables are static Map type member variables.
Optionally, the annotation writing function implements the annotation writing function by the following sub-units:
the method array judging subunit is used for determining the class annotation corresponding to the class object, acquiring a method array formed by each method associated with the class object when the class annotation is not empty, and judging whether the method array is empty or not;
the transaction code acquisition subunit is used for sequentially acquiring each method object in the method array and the method annotation of each method object if the transaction code acquisition subunit does not acquire the transaction code of the method annotation when the method annotation is not empty;
and the annotation writing subunit is used for acquiring an entity object corresponding to the class name and the class object from the mapping variable according to the transaction code when the transaction code is not empty, and writing the class annotation and the method annotation into the entity class based on the entity object, wherein the entity object is an object in the entity class.
Optionally, on the basis of the above apparatus, the apparatus may further include: and the annotation module is used for annotating the interface to be called through the method and annotating the scene to be called through the class annotation.
Optionally, the interface determining module 420 may specifically include:
the first interface determining unit is used for calling the established interface determining function by taking the interface calling parameter as the parameter to determine the interface to be called in the scene to be called corresponding to the interface calling parameter in the mapping relation, wherein the interface determining function is arranged in an interface service class, and the interface service class comprises a FacadeService class.
Optionally, the interface determination function implements the interface determination function through the following sub-units:
the object obtaining subunit is used for obtaining an entity object corresponding to the interface calling parameter and obtaining a class object and a method object from the entity object when the entity object is not empty;
and the interface determining subunit is used for determining a scene to be called in the mapping relation according to the class object and determining an interface to be called in the scene to be called according to the method object.
Optionally, the parameter obtaining module 410 may specifically include:
the parameter acquiring unit is used for acquiring an interface calling parameter corresponding to the trigger event based on an entry class, wherein an interface service object of the interface service class is injected into the entry class in an annotation mode;
on this basis, optionally, the interface determining module 420 may specifically include:
and the second interface determining unit is used for determining the interface to be called in the scene to be called corresponding to the interface calling parameter in the mapping relation through the interface service object in the entry class.
Optionally, the interface invoking module 430 may be specifically configured to:
calling an interface to be called to perform time recording on a preset reflection algorithm to monitor time consumption; or the light source is used for emitting light,
calling an interface to be called to control the execution of synchronous and asynchronous in a preset reflection algorithm according to the synchronous and asynchronous parameters in the variable length parameters in the interface calling parameters; or the light source is used for emitting light,
calling an interface to be called to judge the variable length parameter to filter data; or the light source is used for emitting light,
and calling the interface to be called to classify the transaction codes in the interface calling parameters so as to realize the operation flow record under the corresponding requirements.
Optionally, the mapping relationship stores a corresponding relationship between the interface calling parameter, the scene to be called, and the interface to be called.
In the interface calling device provided by the fourth embodiment of the present invention, the parameter obtaining module and the interface determining module are mutually matched, and when the only entry in the server receives the interface calling parameter transmitted from the front end, the interface to be called under the scene to be called corresponding to the only entry can be obtained in the mapping relationship according to the interface calling parameter; therefore, the interface calling module can realize corresponding functions by calling the interface to be called. According to the device, the calling process of each interface under various scenes can be uniformly realized in the unique entry through the provided simpler, more flexible, more uniform and standardized interface calling mode, so that the problem of high difficulty in realizing interface calling is solved, the working intensity of developers is reduced, and the efficiency of subsequent interface calling is improved.
The interface calling device provided by the embodiment of the invention can execute the interface calling method provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method.
It should be noted that, in the embodiment of the interface invoking device, each included unit and module are only divided according to functional logic, but are not limited to the above division as long as the corresponding functions can be implemented; in addition, specific names of the functional units are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present invention.
EXAMPLE five
Fig. 5 is a schematic structural diagram of a server according to a fifth embodiment of the present invention, and as shown in fig. 5, the server includes a memory 510, a processor 520, an input device 530, and an output device 540. The number of the processors 520 in the server may be one or more, and one processor 520 is taken as an example in fig. 5; the memory 510, processor 520, input device 530, and output device 540 in the server may be connected by a bus or other means, such as by bus 550 in fig. 5.
The memory 510 is used as a computer-readable storage medium for storing software programs, computer-executable programs, and modules, such as program instructions/modules corresponding to the interface calling method in the embodiment of the present invention (for example, the parameter obtaining module 410, the interface determining module 420, and the interface calling module 430 in the interface calling device). The processor 520 executes various functional applications of the server and data processing, i.e., implements the interface call method described above, by executing software programs, instructions, and modules stored in the memory 510.
The memory 510 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created according to the use of the server, and the like. Further, the memory 510 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some examples, memory 510 may further include memory located remotely from processor 520, which may be connected to devices through a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input device 530 may be used to receive input numeric or character information and generate key signal inputs related to user settings and function control of the device. The output device 540 may include a display device such as a display screen.
EXAMPLE six
An embodiment of the present invention provides a storage medium containing computer-executable instructions, where the computer-executable instructions are used to execute an interface calling method when executed by a computer processor, and the method is applied to a server and may include:
when a trigger event of interface calling is monitored, acquiring an interface calling parameter corresponding to the trigger event;
determining an interface to be called in a scene to be called corresponding to an interface calling parameter in a mapping relation, wherein the mapping relation is constructed in advance in an annotation dynamic mapping mode;
and calling the interface to be called to realize the function corresponding to the interface to be called.
Of course, the storage medium provided by the embodiment of the present invention contains computer-executable instructions, and the computer-executable instructions are not limited to the method operations described above, and may also perform related operations in the interface call method provided by any embodiment of the present invention.
From the above description of the embodiments, it is obvious for those skilled in the art that the present invention can be implemented by software and necessary general hardware, and certainly, can also be implemented by hardware, but the former is a better embodiment in many cases. With this understanding, the technical solutions of the present invention may be embodied in the form of a software product, which can be stored in a computer-readable storage medium, such as a floppy disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a FLASH Memory (FLASH), a hard disk or an optical disk of a computer, and includes instructions for enabling a computer device (which may be a personal computer, a server, or a network device) to execute the methods according to the embodiments of the present invention.
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims (15)

1. An interface calling method applied to a server, the method comprising:
when a trigger event of interface calling is monitored, acquiring an interface calling parameter corresponding to the trigger event;
determining an interface to be called in a scene to be called corresponding to the interface calling parameter in a mapping relation, wherein the mapping relation is constructed in advance in an annotation dynamic mapping mode;
and calling the interface to be called to realize the function corresponding to the interface to be called.
2. The method of claim 1, wherein the mapping is pre-constructed by:
obtaining a class annotation and a method annotation of a custom runtime and an entity class corresponding to the class annotation and the method annotation, writing the class annotation and the method annotation into the entity class based on a preset annotation scanning class, and constructing the mapping relation based on the written entity class.
3. The method of claim 2, wherein a transaction code, a class name, a class object, and a method are provided in the entity class.
4. The method of claim 3, wherein writing the class annotation and the method annotation into the entity class based on a preset annotation scan class comprises:
calling a constructed annotation writing function by taking the obtained class object and the class name as entry parameters so as to write the class annotation and the method annotation into the entity class;
the annotation writing function is arranged in a preset annotation processing class, a mapping variable is arranged in the annotation processing class, the annotation writing function writes the class annotation and the method annotation into the entity class through the mapping variable, and the mapping variable is a static Map type member variable.
5. The method of claim 4, wherein the annotation write function implements an annotation write function by:
determining the class annotation corresponding to the class object, acquiring a method array formed by each method associated with the class object when the class annotation is not empty, and judging whether the method array is empty or not;
if not, sequentially acquiring each method object in the method array and the method annotation of each method object, and acquiring the transaction code of the method annotation when the method annotation is not empty;
and when the transaction code is non-empty, acquiring an entity object corresponding to the class name and the class object from the mapping variable according to the transaction code, and writing the class annotation and the method annotation into the entity class based on the entity object, wherein the entity object is an object in the entity class.
6. The method of claim 2, further comprising: annotating the interface to be called through the method and annotating the scene to be called through the class annotation.
7. The method according to claim 1, wherein the determining, in the mapping relationship, the interface to be called in the scene to be called corresponding to the interface calling parameter includes:
and calling the established interface determining function by taking the interface calling parameter as a parameter to determine an interface to be called in a scene to be called corresponding to the interface calling parameter in a mapping relation, wherein the interface determining function is arranged in an interface service class, and the interface service class comprises a FacadeService class.
8. The method of claim 7, wherein the interface determination function implements the interface determination function by:
acquiring an entity object corresponding to the interface calling parameter, and acquiring a class object and a method object from the entity object when the entity object is not empty;
and determining a scene to be called in the mapping relation according to the class object, and determining an interface to be called in the scene to be called according to the method object.
9. The method according to claim 1, wherein the obtaining of the interface call parameter corresponding to the trigger event includes: and acquiring an interface calling parameter corresponding to the trigger event based on an entry class, wherein an interface service object of the interface service class is injected into the entry class in an annotation mode.
10. The method according to claim 9, wherein the determining, in the mapping relationship, the interface to be called in the scene to be called corresponding to the interface calling parameter includes:
and determining the interface to be called in the scene to be called corresponding to the interface calling parameter in the mapping relation through the interface service object in the entry class.
11. The method according to claim 1, wherein the calling the interface to be called to realize the function corresponding to the interface to be called comprises:
calling the interface to be called to perform time recording on a preset reflection algorithm so as to monitor the consumed time; or the light source is used for emitting light,
calling the interface to be called to control the execution of synchronous and asynchronous in the preset reflection algorithm according to the synchronous and asynchronous parameters in the variable length parameters in the interface calling parameters; or the light source is used for emitting light,
calling the interface to be called to judge the variable-length parameter to filter data; or the light source is used for emitting light,
and calling the interface to be called to classify the transaction codes in the interface calling parameters so as to realize the operation flow record under the corresponding requirements.
12. The method according to claim 1, wherein the mapping relationship stores a corresponding relationship among the interface calling parameter, the scene to be called, and the interface to be called.
13. An interface calling apparatus configured to a server, the apparatus comprising:
the parameter acquisition module is used for acquiring interface calling parameters corresponding to a triggering event when the triggering event of the interface calling is monitored;
the interface determining module is used for determining an interface to be called in a scene to be called corresponding to the interface calling parameter in a mapping relation, and the mapping relation is constructed in advance in an annotation dynamic mapping mode;
and the interface calling module is used for calling the interface to be called to realize the function corresponding to the interface to be called.
14. A server, comprising:
one or more processors;
a memory for storing one or more programs;
when executed by the one or more processors, cause the one or more processors to implement the interface call method as recited in any of claims 1-12.
15. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the interface call method according to any one of claims 1 to 12.
CN202010994608.6A 2020-09-21 2020-09-21 Interface calling method, device, server and storage medium Pending CN112181535A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010994608.6A CN112181535A (en) 2020-09-21 2020-09-21 Interface calling method, device, server and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010994608.6A CN112181535A (en) 2020-09-21 2020-09-21 Interface calling method, device, server and storage medium

Publications (1)

Publication Number Publication Date
CN112181535A true CN112181535A (en) 2021-01-05

Family

ID=73955673

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010994608.6A Pending CN112181535A (en) 2020-09-21 2020-09-21 Interface calling method, device, server and storage medium

Country Status (1)

Country Link
CN (1) CN112181535A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113625998A (en) * 2021-08-10 2021-11-09 北京京东振世信息技术有限公司 Request processing method and device

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2017008645A1 (en) * 2015-07-13 2017-01-19 阿里巴巴集团控股有限公司 Method of collectively mapping http request and device utilizing same
CN108255905A (en) * 2017-05-04 2018-07-06 平安科技(深圳)有限公司 Interface calls data processing method, device and computer equipment
CN110971664A (en) * 2019-10-31 2020-04-07 北京浪潮数据技术有限公司 Interface service management system
CN111027295A (en) * 2019-11-11 2020-04-17 浙江大搜车软件技术有限公司 Data processing method, data processing device, computer equipment and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2017008645A1 (en) * 2015-07-13 2017-01-19 阿里巴巴集团控股有限公司 Method of collectively mapping http request and device utilizing same
CN108255905A (en) * 2017-05-04 2018-07-06 平安科技(深圳)有限公司 Interface calls data processing method, device and computer equipment
CN110971664A (en) * 2019-10-31 2020-04-07 北京浪潮数据技术有限公司 Interface service management system
CN111027295A (en) * 2019-11-11 2020-04-17 浙江大搜车软件技术有限公司 Data processing method, data processing device, computer equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113625998A (en) * 2021-08-10 2021-11-09 北京京东振世信息技术有限公司 Request processing method and device
CN113625998B (en) * 2021-08-10 2023-11-03 北京京东振世信息技术有限公司 Request processing method and device

Similar Documents

Publication Publication Date Title
US10216527B2 (en) Automated software configuration management
US9311214B2 (en) System and methods for tracing individual transactions across a mainframe computing environment
KR101669630B1 (en) Conditional dynamic instrumentation of software in a specified transaction context
CN110944048B (en) Service logic configuration method and device
CN112148610A (en) Test case execution method and device, computer equipment and storage medium
CN104346148A (en) Method, device and system for acquiring program performance consumption information
CN114595201A (en) Method, equipment and storage medium for inquiring acquisition record of interface access log
CN112559306A (en) User behavior track obtaining method and device and electronic equipment
CN112527600A (en) Monitoring log processing method, device, equipment and storage medium
CN110457132B (en) Method and device for creating functional object and terminal equipment
CN111309743A (en) Report pushing method and device
CN112181535A (en) Interface calling method, device, server and storage medium
CN110443044A (en) Block chain client bug excavation method, device, equipment and storage medium
CN113360210A (en) Data reconciliation method and device, computer equipment and storage medium
CN111124627A (en) Method, device, terminal and storage medium for determining application program caller
CN112817782B (en) Data acquisition reporting method and device, electronic equipment and storage medium
CN110554892A (en) Information acquisition method and device
CN114648323A (en) Service scene oriented call chain processing method, device and medium
CN113448985A (en) API (application program interface) interface generation method, calling method and device and electronic equipment
CN113254399A (en) Log query method and device, electronic equipment and medium
CN109542413B (en) Data processing method and device, storage medium and electronic device
CN109995617A (en) Automated testing method, device, equipment and the storage medium of Host Administration characteristic
CN116644425B (en) Web vulnerability instant blocking method, device, equipment and storage medium based on Java agent
US20240039929A1 (en) System and method for threat detection across multiple cloud environments utilizing normalized event logs
CN117131086A (en) Verification code query method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination