CN110300082B - Interface generation method and device and storage medium - Google Patents

Interface generation method and device and storage medium Download PDF

Info

Publication number
CN110300082B
CN110300082B CN201810237215.3A CN201810237215A CN110300082B CN 110300082 B CN110300082 B CN 110300082B CN 201810237215 A CN201810237215 A CN 201810237215A CN 110300082 B CN110300082 B CN 110300082B
Authority
CN
China
Prior art keywords
remote service
file
interface
calling
service
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.)
Active
Application number
CN201810237215.3A
Other languages
Chinese (zh)
Other versions
CN110300082A (en
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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201810237215.3A priority Critical patent/CN110300082B/en
Publication of CN110300082A publication Critical patent/CN110300082A/en
Application granted granted Critical
Publication of CN110300082B publication Critical patent/CN110300082B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services
    • G06F9/548Object oriented; Remote method invocation [RMI]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/133Protocols for remote procedure calls [RPC]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/60Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/544Remote

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Telephonic Communication Services (AREA)
  • Stored Programmes (AREA)

Abstract

The embodiment of the invention discloses an interface generation method, an interface generation device and a storage medium; the embodiment of the invention adopts the protocol file for acquiring the service; analyzing the protocol file to obtain the description information of the service; generating a remote service calling interface file with a uniform format according to the description information; and generating a remote service calling interface implementation file of the service according to the remote service calling interface file, wherein the remote service calling interface implementation file is implemented by byte codes and comprises a remote service calling interface implementation class and a calling function of remote service logic processing. The scheme can automatically generate the remote service calling interface implementation file based on the protocol file of the service, does not need service developers to pay attention to relevant information (such as route discovery, protocols and the like) of the service, and can unify the remote service calling mode, simplify the remote service calling mode and improve the service development efficiency.

Description

Interface generation method and device and storage medium
Technical Field
The present invention relates to the field of communications technologies, and in particular, to an interface generation method, an interface generation apparatus, and a storage medium.
Background
RPC (Remote Procedure Call) is a protocol that requests services from Remote computer programs over a network without knowledge of the underlying network technology.
Currently, RPC calls in the Jungle framework are usually executed by using a static class as a unified entry, and different service frameworks encapsulate their RPC static class, such as the Jungle-Web-Core providing ServiceAdapter class, the Jungle-Server-Core providing clientapi class, and the like. Meanwhile, for the back-end services using different protocols, different RPC interfaces are required to be used for remote calling, and the calling mode is relatively complex and non-uniform. Moreover, after a service developer needs to know a specific protocol of the back-end service, the service developer selects an interface suitable for calling a certain back-end service from the RPC interfaces, so that the service development efficiency is reduced.
Disclosure of Invention
The embodiment of the invention provides an interface generation method, an interface generation device and a storage medium, which can unify remote service calling modes and improve service development efficiency.
The embodiment of the invention provides an interface generation method, which comprises the following steps:
acquiring a protocol file of a service;
analyzing the protocol file to obtain the description information of the service;
generating a remote service calling interface file with a uniform format according to the description information;
and generating a remote service calling interface implementation file of the service according to the remote service calling interface file, wherein the remote service calling interface implementation file is implemented by byte codes and comprises a remote service calling interface implementation class and a calling function of remote service logic processing.
Correspondingly, an embodiment of the present invention further provides an interface generating apparatus, including:
an acquisition unit, configured to acquire a protocol file of a service;
the analysis unit is used for analyzing the protocol file to obtain the description information of the service;
the first generating unit is used for generating a remote service calling interface file with a uniform format according to the description information;
and the second generating unit is used for generating a remote service calling interface implementation file of the service according to the remote service calling interface file, wherein the remote service calling interface implementation file is implemented by byte codes and comprises a remote service calling interface implementation class and a calling function of remote service logic processing.
Correspondingly, the embodiment of the present invention further provides a storage medium, where the storage medium stores instructions, and the instructions, when executed by a processor, implement the steps of any of the methods provided in the embodiment of the present invention.
The embodiment of the invention adopts the protocol file for acquiring the service; analyzing the protocol file to obtain the description information of the service; generating a remote service calling interface file with a uniform format according to the description information; and generating a remote service calling interface implementation file of the service according to the remote service calling interface file, wherein the remote service calling interface implementation file is implemented by byte codes and comprises a remote service calling interface implementation class and a calling function of remote service logic processing. The scheme can automatically generate the remote service calling interface implementation file based on the protocol file of the service, does not need service developers to pay attention to relevant information (such as route discovery, protocols and the like) of the service, and can unify the remote service calling mode, simplify the remote service calling mode and improve the service development efficiency.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1a is a schematic view of a scenario of a remote service invocation system according to an embodiment of the present invention;
fig. 1b is a schematic flowchart of an interface generation method according to an embodiment of the present invention;
FIG. 1c is a diagram illustrating a structure of a protocol file according to an embodiment of the present invention;
FIG. 1d is a code diagram of an interface file according to an embodiment of the present invention;
FIG. 1e is a schematic diagram of dynamic generation of bytecode according to an embodiment of the invention;
FIG. 1f is a code diagram of an interface implementation class provided by an embodiment of the present invention;
FIG. 1g is a schematic diagram of RPC call logic provided by an embodiment of the present invention;
FIG. 2a is a schematic flow chart of an RPC call according to an embodiment of the present invention;
FIG. 2b is a flow chart of the unified RPC framework usage provided by the embodiment of the present invention;
fig. 3a is a schematic diagram of a first structure of an interface generating apparatus according to an embodiment of the present invention;
fig. 3b is a schematic structural diagram of a second interface generating apparatus according to an embodiment of the present invention;
fig. 3c is a schematic structural diagram of an interface generating apparatus according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of a terminal according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. 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 embodiment of the invention provides an interface generation method, an interface generation device and a storage medium.
The embodiment of the invention provides a remote service calling system, which can comprise any interface generation device provided by the embodiment of the invention. Wherein the interface generation may be integrated into the terminal. Can be a mobile phone, a tablet computer and other equipment.
In addition, the remote service invocation system may also include other devices, including servers, such as remote servers and the like.
For example, referring to fig. 1a, there is provided a remote service invocation system, comprising: a terminal 10 and a server 20, the terminal 10 and the server 20 being connected via a network 30. The network 30 includes network entities such as routers and gateways, which are shown schematically in the figure. The terminal 10 may communicate with the server 20 via a wired network or a wireless network to request a service on the server 20, such as downloading an application and/or an application update package and/or data information or service information related to the application from the server 20. The terminal 10 may be a mobile phone, a tablet computer, a notebook computer, etc., and fig. 1a illustrates the terminal 10 as a notebook computer. The terminal 10 may also have various user-desired applications installed therein, such as entertainment-enabled applications (e.g., image processing applications, audio playback applications, gaming applications, reading software), and service-enabled applications.
When a remote service call interface of a service needs to be generated, the terminal 10 acquires a protocol file of the service; analyzing the protocol file to obtain the description information of the service; generating a remote service calling interface file with a uniform format according to the description information; and generating a remote service calling interface implementation file of the service according to the remote service calling interface file, wherein the remote service calling interface implementation file is implemented by byte codes and comprises a remote service calling interface implementation class and a calling function of remote service logic processing.
After generating the remote service invocation interface implementation file, the terminal 10 may invoke a service of the remote service, such as the RPC request server 20, such as downloading data, etc., through the remote service invocation interface file. Specifically, a calling function for calling the remote service logic processing in a class-uniform mode is realized through the remote service calling interface so as to execute the logic processing of the remote service calling.
The details will be described below separately.
The present embodiment will be described from the perspective of an interface generation apparatus, which may be a terminal, such as a mobile phone, a tablet computer, a notebook computer, etc.
As shown in fig. 1b, the specific flow of the interface generation method may be as follows:
101. and acquiring a protocol file of the service.
The service can be a service of a terminal background or a backend, and the service is a service which needs to call a remote service, such as a service which calls an RPC service. The service may be various, such as a download service, an image processing service, a video playing service, and so on.
The protocol file includes various description information or definition information of the service, and may include protocol information, route discovery information, service quality monitoring information, and the like of the service.
For example, the protocol file may include a service name, a command word name, route discovery information, timeout time information, and the like. The format of the protocol file may be various, for example, it may be a protocol buffer, which is an RPC data exchange format used by google corporation. The protocol file may be provided by a service developer.
In practical applications, the protocol file of the service and the like can be acquired through the plug-in, such as the IDEA plug-in acquiring the protocol file.
102. And analyzing the protocol file to obtain the description information of the service.
Specifically, the protocol file can be parsed by the plug-in to obtain the description information of the service.
The description information of the service may include: protocol information for the service, route discovery information, quality of service monitoring information, and the like may be included.
For example, in the java domain, the plug-in may be an IntelliJ IDEA plug-in. The IDEA is named IntelliJ IDEA, is an integrated environment for java language development, is recognized as one of the best java development tools in the industry, and particularly has supernormal functions in the aspects of intelligent code assistant, code automatic prompting, reconstruction, J2EE support, various version tools (git, svn, github and the like), JUnit, CVS integration, code analysis, innovative GUI design and the like.
For example, the protocol file of the service may be parsed by a jungle-tool-idea plug-in, and in particular, the jungle-tool-idea plug-in may parse the protocol file of the service using a protoparser package. Referring to fig. 1c, a jungle-tool-ideal plug-in is used to resolve the service name, command word name, and their route discovery information of the backend service, etc.
103. And generating a remote service calling interface file with a uniform format according to the description information.
For example, a remote service call interface file with a uniform format, such as an RPC call interface file, may be generated by the java plug-in according to the description information. For example, a unified format RPC call interface file can be generated by a jungle-tool-idea plug-in.
The remote service calling interface file is a definition file of the remote service calling interface, and the remote service calling interface file may include description information, and the description information is set according to a predetermined format in the remote service calling interface file. See, for example, fig. 1 d.
In one embodiment, to facilitate subsequent retrieval of the description information to generate the interface, the description information in the remote service invocation interface file may also be annotated. That is, the step "generating a unified format remote service invocation interface file according to the description information" includes: and generating a remote service call interface file with a uniform format according to the description information, and marking the description information in the remote service call interface file in an annotation mode. For example, referring to fig. 1d, the tag description information is annotated by RpcCmd (Rpc request command).
In practical application, the RPC call interface file with a uniform format can be generated through a jungle-tool-ideal plug-in, and the description information is marked in an annotation mode.
104. And generating a remote service calling interface implementation file of the service according to the remote service calling interface file, wherein the remote service calling interface implementation file is implemented by byte codes and comprises a remote service calling interface implementation class and a calling function of remote service logic processing.
The remote service call interface implementation file comprises an interface implementation class and a call function of remote service logic processing, the call function is used for calling the remote service logic processing, and the call function can be a handle function in java.
For example, the remote service invocation interface implementation file of the service may be generated from the remote service invocation interface file using bytecode dynamic enhancement or generation techniques. Specifically, the byte code is dynamically generated according to the remote service calling interface file, and a remote service calling interface implementation file implemented by the byte code is obtained.
The bytecode dynamic generation technology refers to a technology for dynamically adding/modifying Java bytecode at runtime.
In an embodiment, a JAR package may be introduced, and the bytecode generation class in the JAR package performs dynamic bytecode generation according to the remote service invocation interface file to obtain the remote service invocation interface implementation file implemented by the bytecode.
Wherein, the JAR package can be a JAR dependent package. A JAR (english abbreviation of Java Archive) package is a compressed package of Java, and may also be considered as a set of a series of class files, and when a JAR package is used in a project, a path of the JAR package needs to be set in a related parameter (usually, a class path parameter) for specifying a class loading path, so that a virtual machine can dynamically load a class included in the JAR package at runtime.
In practical application, a byte code dynamic enhancement or generation technology (namely, during compiling or in the process) can be utilized in a java compiler to generate a corresponding remote service invocation interface implementation file according to a remote service invocation interface file.
Referring to fig. 1e, in Java programming, a Java compiler compiles Java source code into platform-independent byte code (byte code) and stores the byte code on a disk in the form of class files (. class). The Java Virtual Machine (JVM) would be responsible for loading and executing Java bytecode. During operation, the byte code of the remote service call interface file (such as the byte code of the implementation class of the RPC framework) is loaded into the class loader to be directly operated after binary coding.
Referring to fig. 1f, in order to receive the implementation class through the remote service call dynamically generated by the bytecode, it should be noted that the actual service developer cannot see the file because the implementation class is directly loaded into jvm for running by the bytecode generation, and here, it is only an example of the implementation file after the bytecode file is decompiled.
In the embodiment of the invention, the RPC method in class realization of dynamic byte code generation can throw out Pausible exception, so that the RPC method can be normally called in a Kilim mode and supports RPC calling in a Kilim protocol.
In one embodiment, when the description information is annotated in the remote service call interface file, the description information in the remote call interface file can be acquired through the annotation; and generating a remote service call interface implementation file implemented by byte codes according to the description information.
For example, the description information in the remote call interface file is obtained through RpcCmd annotation, and then the remote service call interface implementation file implemented by bytecode is generated according to the description information.
In an embodiment, a JAR package (such as rpc-proxy dependency package) may also be introduced, and the description information in the remote call interface file is obtained based on the annotation by a bytecode generation class in the JAR package; dynamically generating the byte codes according to the description information through byte code generation classes in the JAR packet to obtain a remote service call interface implementation file realized by the byte codes
For example, the bytecode generation class in the JAR package obtains the description information in the remote call interface file through RpcCmd annotation, and then generates the remote service call interface implementation file implemented by the bytecode according to the description information.
The JAR package not only includes the bytecode generation class, but also includes the logic processing class of the remote service call, and the like. The logical processing class implements logical processing of service calls to remote services. For example, referring to FIG. 1g, a logical process of the remote service is invoked for a logical process class. The RPC call main logic may include:
obtaining description information of the service such as a service name, a command word name and the like through annotation;
creating a request of an opposite terminal server, such as a request packet, and filling request parameters;
setting service timeout time;
setting a service failure retry;
synchronously calling back-end service;
judging whether the data packet is replied normally or not;
when the packet is returned normally, the monitor is called to report the monitoring data, and the process is finished;
when the normal packet return does not exist, a service failure retry mechanism is started, and the remote service is called again;
and judging whether the retry is less than the set times, if so, continuing to recall the remote service, otherwise, performing exception handling on the remote service, calling the monitor to report the monitoring data, and ending.
The above is merely an example of the logic of the remote service, and in practical application, the logic may be set according to actual requirements, and the like.
The embodiment of the invention can also compile the logic processing class in the JAR packet into the logic processing class realized by byte codes; and realizing a class calling function through a remote service calling interface, executing a logic processing class realized by byte codes, and realizing the logic processing of remote service calling.
For example, the handle function is uniformly called by the class realized by the remote service call interface, the logic processing class realized by the byte code is executed, and the logic processing of the remote service call is realized.
As can be seen from the above, the embodiment of the present invention employs a protocol file for acquiring a service; analyzing the protocol file to obtain the description information of the service; generating a remote service calling interface file with a uniform format according to the description information; and generating a remote service calling interface implementation file of the service according to the remote service calling interface file, wherein the remote service calling interface implementation file is implemented by byte codes and comprises a remote service calling interface implementation class and a calling function of remote service logic processing. According to the scheme, the remote service calling interface implementation file can be automatically generated based on the protocol file of the service, developers do not need to know related information of concerned services, such as protocol information, routing information and the like, remote service calling modes of different protocols and different service frameworks can be unified, the developers only need to pay attention to specific service logic, codes are simpler, compiling and maintaining are easy, the efficiency of service and interface development is improved, and the labor cost is reduced.
In addition, in the original Jungle framework, service agreement information, route discovery information, service quality monitoring information and the like are distributed in a plurality of configuration files. Service developers need to maintain multiple copies of files. The scheme provided by the embodiment of the invention can uniformly gather the relevant information of the service in one protocol file, and the service developer only needs to maintain the file, so that the project is simple and easy to maintain.
The method described in the above embodiments is further illustrated in detail by way of example.
In one embodiment, the interface generation method of the present invention will be described by taking RPC call interface generation as an example.
Referring to fig. 2a and 2b, a RPC calling method flows as follows:
201. and the interface generation plug-in acquires the JAR packet and the protocol file of the service.
For example, the interface generates a plug-in to obtain a protocol file of the terminal background service or the backend service.
The interface generation plug-in may be an Idea plug-in java, such as an Intellij Idea auxiliary plug-in.
The protocol file includes various description information or definition information of the service, and may include protocol information, route discovery information, service quality monitoring information, and the like of the service.
For example, the protocol file may include a service name, a command word name, route discovery information, timeout time information, and the like. The format of the protocol file may be various, for example, it may be a protocol buffer, which is an RPC data exchange format used by google corporation. The protocol file may be provided by a service developer.
Wherein, the JAR package can be a JAR dependent package. Jar includes various processing classes (e.g., logical processing classes), tool classes, bytecode generation classes, etc. that the RPC process needs to use.
202. And the interface generation plug-in analyzes the protocol file to obtain the description information of the service.
For example, the IntelliJ IDEA plug-in module is used to analyze the protocol file to obtain the service description information.
203. And the interface generation plug-in generates an RPC call interface file with a uniform format according to the description information, and marks the description information of the RPC call interface file in an annotation mode.
The RPC call interface file may include description information of the service.
The RPC call interface file with the uniform format can be generated through the jungle-tool-ideal plug-in, and the description information is marked in a comment mode.
The annotation may be multiple ways, for example, the tag description information may be annotated by RpcCmd (Rpc request command), referring to fig. 1 d.
204. And obtaining the description information in the RPC call interface file according to the annotation through the byte code generation class in the JAR packet.
For example, the bytecode generation class in the JAR package acquires the description information in the remote call interface file through RpcCmd annotation.
In practical application, a byte code dynamic enhancement or generation technology (i.e. during compilation or in the process) may be utilized in the java compiler to generate a corresponding RPC call interface implementation file according to the RPC call interface file, referring to fig. 1 f.
205. And dynamically generating the byte codes according to the description information through byte code generation classes to obtain an RPC calling interface implementation file implemented by the byte codes, and loading the RPC calling interface implementation file to the JVM.
The RPC call interface implementation file may include RPC call interface implementation classes, and call functions of RPC logic processing classes, such as handle functions.
206. Compiling the RPC logical processing class in the JAR packet into an RPC logical processing class realized by byte codes, and loading the RPC logical processing class into the JVM.
The timing sequence of steps 205 and 206 is not limited by the sequence number, and may be executed simultaneously or sequentially.
207. The JVM realizes class calling of a calling function of RPC logic processing through an RPC calling interface, and executes the RPC logic processing class realized by byte codes, thereby realizing the RPC logic processing of the service.
As can be seen from the above, the interface generation scheme provided in the embodiment of the present invention can unify RPC calls of different backend protocols and different service frameworks (e.g., Jungle-server-core, Jungle-web-core, etc.). Service developers only pay attention to specific service logic, the efficiency of service and interface development is improved, and the labor cost rate is reduced.
Specifically, for RPC calls among different service modules, the scheme configures description information of the remote service such as command words, routing, timeout, retry, logs and the like in an annotation mode, and a user can realize the remote service call only by defining a service Protocol Buffer file, so that the method is simple and convenient. In addition, the RPC framework automatically generates RPC implementation classes based on a byte code dynamic generation technology, and shields details such as protocol packaging, route discovery, quality monitoring, log reporting, error retry and the like involved in RPC development, so that the RPC development is really as concise as local interface development, and developed codes are concise and uniform and are easy to maintain.
In order to better implement the above method, an embodiment of the present invention further provides an interface generating apparatus, as shown in fig. 3a, the interface generating apparatus may include: acquisition section 301, analysis section 302, first generation section 303, and second generation section 304 are as follows:
an obtaining unit 301, configured to obtain a protocol file of a service;
an analyzing unit 302, configured to analyze the protocol file to obtain description information of the service;
a first generating unit 303, configured to generate a remote service invocation interface file in a unified format according to the description information;
a second generating unit 304, configured to generate a remote service invocation interface implementation file of the service according to the remote service invocation interface file, where the remote service invocation interface implementation file is implemented by a bytecode and includes a remote service invocation interface implementation class and a invocation function processed by a remote service logic.
In an embodiment, referring to fig. 3b, the first generating unit 303 is configured to generate a remote service call interface file in a unified format according to the description information, and annotate the description information in the remote service call interface file;
the second generating unit 304 includes:
an information obtaining subunit 3041, configured to obtain, through the annotation, description information in the remote call interface file;
an interface implementation subunit 3042, configured to generate a remote service call interface implementation file implemented by a bytecode according to the description information.
In an embodiment, the first generating unit 303 is configured to annotate the description information in the remote service call interface file with a remote service request command.
In an embodiment, the first generating unit 303 is configured to generate a remote service invocation interface file in a unified format according to the description information through a plug-in;
the interface implementing subunit 3042 is configured to: and dynamically generating the byte codes according to the description information through byte code generation classes in the JAR packet to obtain a remote service call interface implementation file realized by the byte codes.
In one embodiment, the JAR package further comprises: a logical processing class of remote service invocation; referring to fig. 3c, the interface generating apparatus further includes:
a compiling unit 305, configured to compile the logical processing classes in the JAR package into logical processing classes implemented by byte codes;
a calling unit 306, configured to call the calling function through the remote service calling interface implementation class, and execute a logic processing class implemented by bytecode.
The steps performed by the above units may refer to the description of the above method embodiments.
In a specific implementation, the above units may be implemented as independent entities, or may be combined arbitrarily to be implemented as the same or several entities, and the specific implementation of the above units may refer to the foregoing method embodiments, which are not described herein again.
The interface generation apparatus may be integrated into a terminal, for example, a mobile phone, a tablet computer, a notebook computer, or the like.
As can be seen from the above, the information interaction apparatus according to the embodiment of the present invention obtains the protocol file of the service through the obtaining unit 301; analyzing the protocol file by an analyzing unit 302 to obtain the description information of the service; generating a remote service call interface file with a uniform format by the first generating unit 303 according to the description information; and generating a remote service call interface implementation file of the service by the second generating unit 304 according to the remote service call interface file, wherein the remote service call interface implementation file is implemented by byte codes and comprises a remote service call interface implementation class and a call function of remote service logic processing. The scheme can automatically generate the remote service calling interface implementation file based on the protocol file of the service, does not need service developers to pay attention to relevant information (such as route discovery, protocols and the like) of the service, and can unify the remote service calling mode, simplify the remote service calling mode and improve the service development efficiency.
Referring to fig. 4, an embodiment of the present invention provides a terminal 400, which may include one or more processors 401 of a processing core, one or more memories 402 of a computer-readable storage medium, a Radio Frequency (RF) circuit 403, a power supply 404, an input unit 405, and a display unit 406. Those skilled in the art will appreciate that the terminal configuration shown in fig. 4 is not intended to be limiting and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components. Wherein:
the processor 401 is a control center of the terminal, connects various parts of the entire terminal using various interfaces and lines, and performs various functions of the terminal and processes data by operating or executing software programs and/or modules stored in the memory 402 and calling data stored in the memory 402, thereby performing overall monitoring of the terminal. Optionally, processor 401 may include one or more processing cores; preferably, the processor 401 may integrate an application processor, which mainly handles operating systems, user interfaces, application programs, etc., and a modem processor, which mainly handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into the processor 401.
The memory 402 may be used to store software programs and modules, and the processor 401 executes various functional applications and data processing by operating the software programs and modules stored in the memory 402.
The RF circuit 403 may be used for receiving and transmitting signals during information transmission and reception, and in particular, for receiving downlink information of a base station and then processing the received downlink information by the one or more processors 401; in addition, data relating to uplink is transmitted to the base station.
The terminal also includes a power supply 404 (e.g., a battery) for powering the various components, which may preferably be logically coupled to the processor 401 via a power management system to manage charging, discharging, and power consumption management functions via the power management system. The power supply 404 may also include any component of one or more dc or ac power sources, recharging systems, power failure detection circuitry, power converters or inverters, power status indicators, and the like.
The terminal may further include an input unit 405, and the input unit 405 may be used to receive input numeric or character information and generate a keyboard, mouse, joystick, optical or trackball signal input in relation to user settings and function control.
The terminal may further include a display unit 406, and the display unit 406 may be used to display information input by the user or provided to the user, as well as various graphical user interfaces of the terminal, which may be made up of graphics, text, icons, video, and any combination thereof. The Display unit 408 may include a Display panel, and optionally, the Display panel may be configured in the form of a Liquid Crystal Display (LCD), an Organic Light-Emitting Diode (OLED), or the like.
Specifically, in this embodiment, the processor 401 in the terminal loads the executable file corresponding to the process of one or more application programs into the memory 402 according to the following instructions, and the processor 401 runs the application programs stored in the memory 402, thereby implementing various functions as follows:
acquiring a protocol file of a service;
analyzing the protocol file to obtain the description information of the service;
generating a remote service calling interface file with a uniform format according to the description information;
and generating a remote service calling interface implementation file of the service according to the remote service calling interface file, wherein the remote service calling interface implementation file is implemented by byte codes and comprises a remote service calling interface implementation class and a calling function of remote service logic processing.
In an embodiment, when the remote service invocation interface file with the unified format is generated according to the description information, the processor 402 may specifically perform the steps of: generating a remote service calling interface file with a uniform format according to the description information, and marking the description information in the remote service calling interface file in an annotation mode;
when the remote service invocation interface implementation file of the service is generated according to the remote service invocation interface file, the processor 402 may specifically perform the following steps:
obtaining description information in the remote calling interface file through annotation;
and generating a remote service call interface implementation file implemented by byte codes according to the description information.
In an embodiment, when the remote service call interface file in the unified format is generated according to the description information, the processor 402 may specifically perform the steps of: generating a remote service calling interface file with a uniform format according to the description information through the plug-in;
when the remote service call interface implementation file implemented by the bytecode is generated according to the description information, the processor 402 may specifically perform the steps of: and dynamically generating the byte codes according to the description information through byte code generation classes in the JAR packet to obtain a remote service call interface implementation file realized by the byte codes.
In one embodiment, the JAR package further comprises: a logical processing class of remote service invocation; the processor 402 may also perform the following steps:
compiling the logical processing classes in the JAR package into logical processing classes implemented by byte codes;
and calling the calling function through the remote service calling interface implementation class, and executing the logic processing class implemented by byte codes.
The terminal of the embodiment of the invention can acquire the protocol file of the service; analyzing the protocol file to obtain the description information of the service; generating a remote service calling interface file with a uniform format according to the description information; and generating a remote service calling interface implementation file of the service according to the remote service calling interface file, wherein the remote service calling interface implementation file is implemented by byte codes and comprises a remote service calling interface implementation class and a calling function of remote service logic processing. The scheme can automatically generate the remote service calling interface implementation file based on the protocol file of the service, does not need service developers to pay attention to relevant information (such as route discovery, protocols and the like) of the service, and can unify the remote service calling mode, simplify the remote service calling mode and improve the service development efficiency.
Those skilled in the art will appreciate that all or part of the steps in the methods of the above embodiments may be implemented by associated hardware instructed by a program, which may be stored in a computer-readable storage medium, and the storage medium may include: read Only Memory (ROM), Random Access Memory (RAM), magnetic or optical disks, and the like.
The foregoing describes in detail an interface generation method, apparatus, and storage medium provided by an embodiment of the present invention, and a specific example is applied in the present disclosure to explain the principle and the implementation of the present invention, and the description of the foregoing embodiments is only used to help understand the method and the core idea of the present invention; meanwhile, for those skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

Claims (11)

1. An interface generation method, comprising:
a terminal acquires a protocol file of a service, wherein the service is a service for calling a remote service;
analyzing the protocol file to obtain the description information of the service;
generating a remote service calling interface file with a uniform format according to the description information;
generating a remote service calling interface implementation file of the service according to the remote service calling interface file, wherein the remote service calling interface implementation file is implemented by byte codes and comprises a remote service calling interface implementation class and a calling function of remote service logic processing;
calling a remote service through the remote service calling interface file;
and calling functions of the remote service logic processing are called in a similar and unified mode through the remote service calling interface so as to execute the logic processing for calling the remote service.
2. The interface generation method according to claim 1, wherein generating a remote service invocation interface file in a unified format according to the description information includes:
generating a remote service calling interface file with a uniform format according to the description information, and marking the description information in the remote service calling interface file in an annotation mode;
generating a remote service call interface implementation file of the service according to the remote service call interface file, including:
obtaining description information in the remote calling interface file through annotation;
and generating a remote service call interface implementation file implemented by byte codes according to the description information.
3. The interface generation method according to claim 2, wherein generating a remote service invocation interface file in a unified format according to the description information includes:
generating a remote service calling interface file with a uniform format according to the description information through the plug-in;
generating a remote service call interface implementation file implemented by byte codes according to the description information, comprising:
and dynamically generating the byte codes according to the description information through byte code generation classes in the JAR packet to obtain a remote service call interface implementation file realized by the byte codes.
4. The interface generation method according to claim 3, wherein the JAR package further includes: a logical processing class of remote service invocation; the method further comprises the following steps:
compiling the logical processing classes in the JAR package into logical processing classes implemented by byte codes;
and calling the calling function through the remote service calling interface implementation class, and executing the logic processing class implemented by byte codes.
5. The interface generation method according to claim 2, wherein annotating the description information in the remote service call interface file comprises:
annotating the description information in the branding remote service invocation interface file with the remote service request command.
6. An interface generation apparatus, comprising:
the terminal comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring a protocol file of a service by the terminal, and the service is a service for calling a remote service;
the analysis unit is used for analyzing the protocol file to obtain the description information of the service;
the first generating unit is used for generating a remote service calling interface file with a uniform format according to the description information;
a second generating unit, configured to generate a remote service call interface implementation file of the service according to the remote service call interface file, where the remote service call interface implementation file is implemented by a bytecode and includes a remote service call interface implementation class and a call function of remote service logic processing;
the first calling unit is used for calling the remote service through the remote service calling interface file;
and the second calling unit is used for realizing the calling function of the remote service logic processing by the remote service calling interface in a similar and unified mode so as to execute the logic processing for calling the remote service.
7. Interface generation apparatus according to claim 6,
the first generating unit is used for generating a remote service calling interface file with a uniform format according to the description information and marking the description information in the remote service calling interface file in an annotation mode;
the second generation unit includes:
the information acquisition subunit is used for acquiring the description information in the remote call interface file through the annotation;
and the interface realization subunit is used for generating a remote service call interface realization file realized by byte codes according to the description information.
8. Interface generation apparatus according to claim 7,
the first generating unit is used for generating a remote service calling interface file with a uniform format according to the description information through a plug-in;
the interface implementing subunit is configured to: and dynamically generating the byte codes according to the description information through byte code generation classes in the JAR packet to obtain a remote service call interface implementation file realized by the byte codes.
9. The interface generating apparatus according to claim 8, wherein the JAR package further includes: a logical processing class of remote service invocation; the interface generation apparatus further includes:
the compiling unit is used for compiling the logic processing classes in the JAR package into logic processing classes realized by byte codes;
and the calling unit is used for calling the calling function through the remote service calling interface implementation class and executing the logic processing class realized by byte codes.
10. A storage medium storing instructions which, when executed by a processor, carry out the steps of the method according to any one of claims 1 to 5.
11. A terminal, characterized in that the terminal comprises a memory and a processor, the memory having stored therein a computer program which, when executed by the processor, causes the processor to carry out the steps of the method according to any one of claims 1 to 5.
CN201810237215.3A 2018-03-21 2018-03-21 Interface generation method and device and storage medium Active CN110300082B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810237215.3A CN110300082B (en) 2018-03-21 2018-03-21 Interface generation method and device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810237215.3A CN110300082B (en) 2018-03-21 2018-03-21 Interface generation method and device and storage medium

Publications (2)

Publication Number Publication Date
CN110300082A CN110300082A (en) 2019-10-01
CN110300082B true CN110300082B (en) 2022-03-08

Family

ID=68025493

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810237215.3A Active CN110300082B (en) 2018-03-21 2018-03-21 Interface generation method and device and storage medium

Country Status (1)

Country Link
CN (1) CN110300082B (en)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111142860B (en) * 2019-12-31 2023-05-23 广州酷狗计算机科技有限公司 Method and device for realizing interface call
CN111338637A (en) * 2020-02-26 2020-06-26 腾讯科技(深圳)有限公司 Code generation method and device
CN111367685B (en) * 2020-02-28 2022-11-15 深圳平安医疗健康科技服务有限公司 Interface calling method and device, computer equipment and storage medium
CN111625585B (en) * 2020-05-22 2021-08-31 中科驭数(北京)科技有限公司 Access method, device, host and storage medium of hardware acceleration database
CN111857657B (en) * 2020-06-15 2024-02-09 杭州数跑科技有限公司 Activity creation method, apparatus, storage medium and computer device
CN114244820A (en) * 2020-09-07 2022-03-25 宝能汽车集团有限公司 Embedded distribution system and data communication method thereof
CN112965832B (en) * 2021-02-18 2023-09-26 腾讯科技(深圳)有限公司 Remote Procedure Call (RPC) service calling method and related device
CN113467972B (en) * 2021-06-30 2024-05-24 广州华多网络科技有限公司 Communication interface construction method and device, computer equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1852209A (en) * 2006-05-31 2006-10-25 北京和利时系统工程股份有限公司 Remote process transfering method and system in distribution type control system
CN101776994A (en) * 2009-01-13 2010-07-14 迪斯尼实业公司 System and method for integrated hardware platform for Flash applications with distributed objects
CN104363285A (en) * 2014-11-18 2015-02-18 东方网力科技股份有限公司 Network communication program generating method and device
CN107592359A (en) * 2017-09-19 2018-01-16 郑州云海信息技术有限公司 A kind of service end response method, device and medium based on RPC agreements
CN107643953A (en) * 2016-07-20 2018-01-30 深圳市祈飞科技有限公司 A kind of remote object invocation method and system

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103399734B (en) * 2013-07-10 2017-02-08 北京慧点科技有限公司 Method for generating REST service and achieving REST and corresponding equipment
CN106412086B (en) * 2016-10-31 2020-01-03 武汉斗鱼网络科技有限公司 Method and system for automatically generating communication code by using protocol description file

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1852209A (en) * 2006-05-31 2006-10-25 北京和利时系统工程股份有限公司 Remote process transfering method and system in distribution type control system
CN101776994A (en) * 2009-01-13 2010-07-14 迪斯尼实业公司 System and method for integrated hardware platform for Flash applications with distributed objects
CN104363285A (en) * 2014-11-18 2015-02-18 东方网力科技股份有限公司 Network communication program generating method and device
CN107643953A (en) * 2016-07-20 2018-01-30 深圳市祈飞科技有限公司 A kind of remote object invocation method and system
CN107592359A (en) * 2017-09-19 2018-01-16 郑州云海信息技术有限公司 A kind of service end response method, device and medium based on RPC agreements

Also Published As

Publication number Publication date
CN110300082A (en) 2019-10-01

Similar Documents

Publication Publication Date Title
CN110300082B (en) Interface generation method and device and storage medium
US8364786B2 (en) Synthesizing a scalable and incrementally updatable system software infrastructure for sensor networks
US7337436B2 (en) System and method for cross platform and configuration build system
US8595700B2 (en) Method and apparatus for reusing components of a component-based software system
CN101930400B (en) SDK (Software Development Kit) automatic test system and method
US7908580B2 (en) Connecting an integrated development environment with an application instance
US7610529B2 (en) Testing mobile wireless devices during device production
CN110187912B (en) Node selection method and device
CN109426516A (en) Software version management method and device
US9104804B2 (en) Method and system for invoking just-in-time debugger
CN111740948B (en) Data packet issuing method, dynamic updating method, device, equipment and medium
CN110569130A (en) Cross-process communication method, device and equipment
CN111338637A (en) Code generation method and device
US20240054366A1 (en) AI Application Deployment Method and Related Platform, Cluster, Medium, and Program Product
CN112769706B (en) Componentized routing method and system
CN104239114A (en) Application compiling method and device
CN107577609A (en) A kind of embedded system dynamic module adjustment method of Intrusion Detection based on host end dynamic link
CN111913741A (en) Object interception method, device, medium and electronic equipment
CN110457013B (en) Program component configuration device and method
CN110221840B (en) Function implementation method and device of application program, equipment and storage medium
EP1657636A1 (en) Program generation system, program generation program, and program generation module
CN116627850B (en) Function debugging method and device, storage medium and electronic equipment
CN106775916B (en) Method and device for reducing application installation packages and electronic equipment
CN110620819B (en) Block chain interaction method and device, computer equipment and readable storage medium
CN115291928A (en) Task automatic integration method and device of multiple technology stacks and electronic equipment

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
GR01 Patent grant
GR01 Patent grant