CN113626225A - Program calling method, terminal device and medium - Google Patents

Program calling method, terminal device and medium Download PDF

Info

Publication number
CN113626225A
CN113626225A CN202111178874.2A CN202111178874A CN113626225A CN 113626225 A CN113626225 A CN 113626225A CN 202111178874 A CN202111178874 A CN 202111178874A CN 113626225 A CN113626225 A CN 113626225A
Authority
CN
China
Prior art keywords
client
annotation
interface
class
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.)
Granted
Application number
CN202111178874.2A
Other languages
Chinese (zh)
Other versions
CN113626225B (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.)
Avic International Golden Net Beijing Technology Co ltd
Original Assignee
AVIC INTERNATIONAL E-BUSINESS Inc
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 AVIC INTERNATIONAL E-BUSINESS Inc filed Critical AVIC INTERNATIONAL E-BUSINESS Inc
Priority to CN202111178874.2A priority Critical patent/CN113626225B/en
Publication of CN113626225A publication Critical patent/CN113626225A/en
Application granted granted Critical
Publication of CN113626225B publication Critical patent/CN113626225B/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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/541Client-server
    • 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)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The invention discloses a program calling method, terminal equipment and a medium, wherein the method comprises the following steps: when detecting that an agent interface of a client is used, acquiring annotation notes added in the agent interface, wherein the annotation notes are used for indicating that the agent interface supports an agent; judging whether a corresponding implementation class exists in the client according to the annotation, wherein the implementation class is used for processing the service request of the client; if not, calling a pre-configured proxy class in a remote calling mode to send the service request to a server for processing, and receiving a request processing result returned by the server. The invention can solve the technical problems of complicated RPC calling and unstable program performance in the prior art.

Description

Program calling method, terminal device and medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a program invoking method, a terminal device, and a medium.
Background
When the engineering for developing the application program is larger and more, and the participators are more and more, the engineering is divided into systems according to the functions and the services, so that the multiple systems are required to cooperatively work for developing the application program, and the cooperation among the systems can not be called by an interface. Currently, the interface calls include Remote Procedure Call (RPC) and local call modes supporting the HTTP protocol. RPC calls are typically employed in view of device performance.
The current state of the art RPC calls rely on an Application Programming Interface (API), which includes some functions that are customized by the developer. However, in practice, it is found that in the RPC call design, the code needs to be modified for splitting between program function modules, and if the number of interfaces on which calls depend is large, too many functions are introduced, and the size of an application package is increased, so that the RPC call is too complicated, and the program performance is unstable.
Disclosure of Invention
By providing the program calling method, the technical problems that RPC calling is too complex and program performance is unstable in the prior art are solved.
In one aspect, the present application provides a program calling method according to an embodiment of the present application, where the method includes:
when detecting that an agent interface of a client is used, acquiring annotation notes added in the agent interface, wherein the annotation notes are used for indicating that the agent interface supports an agent;
judging whether a corresponding implementation class exists in the client according to the annotation, wherein the implementation class is used for processing the service request of the client;
if not, calling a pre-configured proxy class in a remote calling mode to send the service request to a server for processing, and receiving a request processing result returned by the server.
Optionally, the annotation includes a conditional annotation provided by a lightweight Spring container, and the determining, according to the annotation, whether a corresponding implementation class exists in the client includes:
and loading a remote condition RemoteCondition class in the condition annotation, calling a matching matches method of the RemoteCondition class, and judging whether an implementation class of a proxy interface of the server exists in the Spring container.
Optionally, the method further comprises:
and if the corresponding implementation class exists in the client, calling the implementation class to process the service request by adopting a local calling mode.
Optionally, before the obtaining of the annotation added in the proxy interface, the method further includes:
a preset remote module is led into the client, an agent interface of the client is defined in the remote module, and the agent interface supports remote calling;
adding the annotation note in the agent interface of the client, wherein the annotation note comprises a module value which is used for identifying the agent interface of the client;
adding a switch annotation in a starting class of the client, and specifying a basic package basePackage in the switch annotation, wherein the basePackage is used for indicating the agent interface marked by the annotation.
Optionally, before the invoking a pre-configured proxy class in a remote invocation manner sends the service request to the server for processing, the method further includes:
after the client is started, loading the switch annotation, wherein the switch annotation comprises an ImportBeanDefinitionRegistrar interface which is dynamically registered to the outside;
calling a scanning remotecClientScanner class in an outward dynamic registration register BeanDefinitions method of the ImportBeanDefinitionRegistrar interface, scanning a path of a basic packet to be scanned in a light-weight Spring container, and scanning to obtain the proxy interface marked by the mark annotation under the basic packet;
calling an implementation class AkkaClientproxy in the register BeanDefinites method to proxy the proxy interface and generating a proxy class corresponding to the proxy interface;
registering the proxy class in the Spring container using an injector beandefinition registry introduced into the Spring container.
Optionally, the invoking a pre-configured proxy class in a remote invocation manner to send the service request to the server for processing includes:
when the agent class corresponding to the agent interface of the client is called, the client process ClientActor of the client sends the service request to a local process LocalActor of a server, so that the LocalActor searches the implementation class corresponding to the agent interface from a lightweight Spring container of a programming agent worker service after receiving the service request, and reflects and calls the implementation class to process the service request.
Optionally, before the obtaining of the annotation added in the proxy interface when detecting that the proxy interface of the client is used, the method further includes:
and when the client is started, injecting the implementation class into the lightweight Spring container of the client by using the injection Autowired annotation provided by the lightweight Spring container.
Optionally, the service request is a request sent by a Java development framework Akka cluster.
On the other hand, the present application provides a program calling device through an embodiment of the present application, where the device includes an obtaining module, a determining module, and a processing module, where:
the acquisition module is used for acquiring annotation notes added in the agent interface when the agent interface of the client is detected to be used, and the annotation notes are used for indicating that the agent interface supports an agent;
the judging module is used for judging whether a corresponding implementation class exists in the client according to the annotation, and the implementation class is used for processing the service request of the client;
and the processing module is used for calling a pre-configured proxy class in a remote calling mode to send the service request to a server for processing if the corresponding implementation class does not exist in the client, and receiving a request processing result returned by the server.
For the content that is not introduced or not described in the embodiment of the present application, reference may be made to the related descriptions in the foregoing method embodiments, and details are not described here again.
On the other hand, the present application provides a terminal device according to an embodiment of the present application, where the terminal device includes: a processor, a memory, a communication interface, and a bus; the processor, the memory and the communication interface are connected through the bus and complete mutual communication; the memory stores executable program code; the processor executes a program corresponding to the executable program code by reading the executable program code stored in the memory, for executing the program calling method as described above.
On the other hand, the present application provides a computer-readable storage medium storing a program that executes the program calling method described above when the program runs on a terminal device, through an embodiment of the present application.
One or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages: when detecting that an agent interface of a client is used, the method and the device obtain a marking annotation added in the agent interface, then judge whether a corresponding implementation class exists in the client according to the marking annotation, if not, call a pre-configured agent class in a remote call mode to send a service request to a server for processing, and receive a request processing result returned by the server. According to the remote call processing method and device, the remote call processing request is realized by simply adding the annotation in the proxy interface, the program development difficulty is reduced, the program performance stability is ensured, and the technical problems that in the prior art, the code needs to be modified due to module function splitting, RPC calling is too complex, the program performance is unstable and the like are solved.
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 are briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on the drawings without creative efforts.
Fig. 1 is a schematic flowchart of a program calling method according to an embodiment of the present application.
Fig. 2 is a schematic flowchart of an RPC remote call configuration provided in an embodiment of the present application.
Fig. 3 is a schematic flowchart of an implementation of an RPC remote call according to an embodiment of the present application.
Fig. 4 is a schematic flowchart of a method for remotely calling RPC in a program according to an embodiment of the present application.
Fig. 5 is a class diagram of a development framework Akka logic implementation provided in an embodiment of the present application.
Fig. 6 is a schematic structural diagram of a program calling device according to an embodiment of the present application.
Fig. 7 is a schematic structural diagram of a terminal device according to an embodiment of the present application.
Detailed Description
The applicant finds out in the process of the application that: existing RPC calls basically use the HTTP protocol and the split between modules must modify the program code. Although the existing development framework Akka is also applied to large data frameworks such as distributed processing Flink and the like, the existing development framework Akka is not integrated with a lightweight Spring technology and abstracted into a corresponding RPC remote call framework.
By providing the program calling method, the technical problems that RPC calling is too complex and program performance is unstable in the prior art are solved.
In order to solve the technical problems, the general idea of the embodiment of the application is as follows: when detecting that an agent interface of a client is used, acquiring annotation notes added in the agent interface, wherein the annotation notes are used for indicating that the agent interface supports an agent; judging whether a corresponding implementation class exists in the client according to the annotation, wherein the implementation class is used for processing the service request of the client; if not, calling a pre-configured proxy class in a remote calling mode to send the service request to a server for processing, and receiving a request processing result returned by the server.
In order to better understand the technical solution, the technical solution will be described in detail with reference to the drawings and the specific embodiments.
First, it is stated that the term "and/or" appearing herein is merely one type of associative relationship that describes an associated object, meaning that three types of relationships may exist, e.g., a and/or B may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the character "/" herein generally indicates that the former and latter related objects are in an "or" relationship.
In order to solve various problems in the prior art, the application provides an RPC remote call scheme realized based on Spring and Akka frameworks, and the purpose of the RPC remote call scheme is to solve the standardization and the interfacing of remote call. The interface is used for decoupling the modules, the modules can be called locally in the same process, and remote calling is used in different processes. Therefore, when the module is split, the realization class of the proxy interface can be appointed by adding annotation to solve the module splitting. And can support multiple communication protocols on the protocol and support the mutual switching between the protocols.
Fig. 1 is a schematic flowchart of a program calling method according to an embodiment of the present application. The method as shown in fig. 1 comprises the following implementation steps:
s101, when detecting that the agent interface of the client is used, obtaining annotation notes added in the agent interface, wherein the annotation notes are used for indicating that the agent interface supports the agent.
When the client uses the self agent interface, the client can obtain the annotation remotecClient annotation added in advance in the agent interface. The proxy interface is a functional interface used for realizing RPC calling. The RemoteClient annotation is used for identifying/indicating that the proxy interface of the client supports being proxied.
Before step S101, the application may configure and implement the RPC remote call in advance accordingly. Please refer to fig. 2, which is a flowchart illustrating a configuration of an RPC remote call according to an embodiment of the present application. Fig. 2 implements remote invocation by way of annotation and interface, and the method shown in fig. 2 includes the following implementation steps:
s201, a preset remote module is led into a target end, and the target end is a client or a server.
According to the method and the system, the remote module can be respectively led in the client and the server, the remote module can be regarded as an open source frame, and the user-defined function program can be added or modified on the open source frame subsequently.
S202, defining a proxy interface of the target end in the remote module, wherein the proxy interface supports remote calling.
After the target end is created, an agent interface of the target end, such as a WorkerApi interface or other interfaces, may be further defined, which is not limited in the present application. In the following, the description of the related content is made by taking the proxy interface as a WorkerApi interface as an example, but the invention is not limited thereto. The proxy interface supports a remote calling function and is used for realizing the abstraction that the client A calls the server A. The client side clientA maintains the realization of the self-agency interface, and the server side serverA maintains the realization of the self-agency interface.
S203, adding annotation notes in the agent interface of the target end, wherein the annotation notes comprise module values, and the module values are used for identifying the agent interface of the client.
According to the method and the device, a RemoteClient annotation is added and marked on the agent interface, a value is assigned to a module value in the RemoteClient annotation, and the value is used for identifying the agent interface, for example, is represented as a module name where the agent interface is located, such as client side client A or server side server A.
S204, adding a switch annotation in the starting class of the target end, and specifying a basePackage in the switch annotation, wherein the basePackage is used for indicating the agent interface marked by the annotation.
According to the method, a switch annotation EnableRemoteClient can be added in a starting class of a program, a basePackage in the switch annotation EnableRemoteClient is assigned with a value, and a complete package name of an agent interface Workerapi is given. The basePackage is used to indicate the proxy interface marked by the annotated RemoteClient annotation, which may specifically represent the complete package name of the scan interface.
It should be noted that, if the programs of the client clientA and the server a are in the same process, the client clientA can directly call the implementation class of WorkerApi in the server a to implement the method when calling the proxy interface WorkerApi. On the contrary, if the programs of the client clientA and the server A are not in the same process, the client clientA calls the proxy interface WorkerrApi in a remote calling mode to call the implementation class of WorkerrApi in the server A to implement the method.
After a program is started (for example, a starting class of a client is started), all agent interfaces marked by the annotation remotecClient annotation under a basic package basePackage specified in the switch annotation EnableRemoteClient can be automatically scanned, and then the agent classes corresponding to the agent interfaces are generated. Specific embodiments of generating proxy classes are described below. Please refer to fig. 3, which is a flowchart illustrating an implementation of RPC remote call according to an embodiment of the present application. The method as shown in fig. 3 comprises the following implementation steps:
s301, after the client is started, loading the switch annotation EnableRemoteClient at the client side.
According to the method and the device, when client clientA is started, a lightweight Spring container on the client side loads a registered remoteclientRegistrar class which is imported by inputting Import annotation into switch annotation EnableRemoteClientClient. Wherein the Import annotation is an annotation provided by a Spring container. The remotecClientRegistrar class realizes the dynamic registration of the ImportBeanDefinitionRegistrar interface to the outside. The Spring container calls back a foreign dynamic registration register definitions method in the ImportBeanDefinitionRegistrar interface when starting.
S302, a scanning path is obtained from the switch annotation, and the agent interface marked by the mark annotation is obtained by scanning under the scanning path.
When the register BeanDefinitions method is called, an injector BeanDefinitions register of a Spring container and a path of a basic packet to be scanned are transmitted into the method. And then the application calls the scanning remotecclientscanner class under the method of the register beer definitions to scan all the proxy interfaces marked by the marked remotecclientannotation in the basic package under the path.
And S303, circularly generating the proxy class corresponding to the proxy interface after the proxy interface is obtained.
After all the proxy interfaces are obtained, the proxy interfaces for realizing AkkaClientproxy classes can be further used, and then the proxy classes corresponding to the proxy interfaces are generated.
And S304, registering the proxy class into a lightweight Spring container of the client.
The application utilizes an injector BeanDefinitionRegistration to register the proxy classes corresponding to the proxy interfaces into a Spring container, so that the configuration of RPC remote call implementation is completed.
Understandably, the AkkaClientproxy class is an implementation class of a factory Bean interface. When the Spring container obtains the Bean instance, the object obtaining getObject method is called to obtain the proxy AkkaClientproxy class. When each method of the interface is rewritten, a custom-designed client process ClientActor and a local process localack actor are used.
Specifically, for example, when the client clientA calls any method of the proxy class in the proxy interface WorkerApi thereof, that is, when the client clientA calls the proxy class of the proxy interface WorkerApi, the client process clientacter of the client clientA may send a request to the local process localack acter of the server a. The localcactor searches a real implementation class of an agent interface WorkerApi from a Spring container of a programming agent worker service, calls a corresponding method processing request under the implementation class by using a reflection mechanism, and returns a processing result to realize RPC remote calling.
S102, judging whether a corresponding implementation class exists in the client according to the annotation, wherein the implementation class is used for processing the service request of the client.
After the configuration of RPC remote call and the configuration of RPC remote call realization are completed, PRC remote call and local call can be switched according to actual service requirements. Specifically, the code of the client clientA and the code of the server A can be in the same process or different processes. If the local direct call can be selected in the same process, RPC remote call is not needed. If the call cannot be directly called in different processes, RPC remote call needs to be realized through a network.
Specifically, when the client clientA is detected to be started or the client clientA is detected to use the proxy interface WorkerrApi of the client clientA, the implementation class of the proxy interface WorkerrApi for injecting the automatic annotation into the server A of the server side can be used by the client clientA provided by the Spring container. In other words, the application can directly use the automatic annotation to inject the implementation class.
After obtaining the remark RemoteClient annotation in the proxy interface of the client clientA, the method can further judge whether the client clientA has the implementation class of the proxy interface WorkerrApi of the server serverA. Specifically, the RemoteConditional annotation includes a conditional RemoteConditional annotation provided by Spring, and the RemoteConditional annotation can load a remote conditional RemoteConditional class designed by the application in a user-defined manner and call a matching matches method under the remote conditional RemoteConditional class. And then judging whether the implementation class of the proxy interface WorkerrApi of the server A exists in the Spring container or not in the method. If so, determining that the client clientA program and the server A program are in the same process, and then continuing to execute step S104. Otherwise, it is determined that the client clientA and the server a programs are not in the same process, and at this time, the step S103 may be continuously executed.
S103, calling a pre-configured proxy class in a remote calling mode to send the service request to a server for processing, and receiving a request processing result returned by the server.
When determining that no corresponding implementation class exists in the Spring container, the method can call a pre-configured proxy class in a remote call mode to send the service request to the server A for processing, and receive a request processing result returned by the server A.
Specifically, when the client calls the proxy class in the proxy interface WorkerApi, the client process ClientActor of the client sends the service request to the local process LocalActor of the server a. The localcactor searches a real implementation class of an agent interface WorkerApi from a Spring container of a programming agent worker service, calls a corresponding method under the implementation class by using a reflection mechanism to process the request, and returns a request processing result to realize RPC remote call.
In an alternative embodiment, the service request may be a service request generated by a client side, and may also be a service request sent by a Java development framework Akka cluster, which is not limited in this application.
And S104, calling the implementation class to process the service request by adopting a local calling mode.
When the implementation class of the proxy interface WorkerrApi of the server side server A exists in the Spring container, the corresponding method in the implementation class can be directly called in a local calling mode to process the service request.
For better understanding of the present application, a specific embodiment of the RPC remote call is described in detail below with reference to the client clientA and the server a. Please refer to fig. 4, which is a flowchart illustrating a remote RPC call method according to an embodiment of the present application. The method as shown in fig. 4 comprises the following implementation steps:
s401, when detecting the implementation class in the proxy interface of the calling client server A, sending the service request to the server A. Accordingly, the server a receives the service request.
The service request may be a service request sent by an Akka cluster, where the Akka is a development framework under the programming language Java, please refer to fig. 5, which shows an implementation class diagram of a possible Akka logic implementation. As shown in fig. 5, the Akka framework client service (AkkaClientService) supports functions such as an invoking process (actors ref), a message sending (sendmasage), and an invoking process configuration (setacorref). AkkaClientService provides client service, namely message sending; it can also call an object process (ObjectActor) in real applications, which provides/supports process handling methods (actor handler), such as remote calls and local calls. The acterhandler provides various types, process names, method identifiers and other contents, and the application is not limited.
S402, the server A judges whether a corresponding implementation class exists. Specifically, after receiving the service request, the server a may determine whether a corresponding implementation class and a method for processing the service request under the implementation class exist in its own Spring container. If so, continuing to execute step S403; otherwise, step S404 is executed.
And S403, calling the implementation class to process the service request, and returning a calling result, wherein the calling result is used for indicating that the server A is successfully called. Optionally, the call result further carries a request processing result corresponding to the service request.
S404, returning a calling result, wherein the calling result is used for indicating that the server A is failed to call.
S405, the server A packages the calling result into a request processing result and returns the request processing result to the client server A.
For the content not described in the embodiment of the present application, reference may be made to the embodiment corresponding to the method described in fig. 1 to fig. 3, and details of the present application are not repeated herein.
By implementing the method, when the agent interface of the client is detected to be used, the annotation added in the agent interface is obtained, whether the corresponding implementation class exists in the client is judged according to the annotation, if not, the service request is sent to the server to be processed by calling the pre-configured agent class in a remote calling mode, and the request processing result returned by the server is received. According to the remote call processing method and device, the remote call processing request is realized by simply adding the annotation in the proxy interface, the program development difficulty is reduced, the program performance stability is ensured, and the technical problems that in the prior art, the code needs to be modified due to module function splitting, RPC calling is too complex, the program performance is unstable and the like are solved. In addition, various communication protocols can be supported in the remote calling, and the practicability of program calling is improved.
Based on the same inventive concept, another embodiment of the present application provides a device and a terminal device corresponding to the method for invoking the program in the embodiment of the present application.
Fig. 6 is a schematic structural diagram of a program calling device according to an embodiment of the present application. The apparatus shown in fig. 6 includes an obtaining module 601, a determining module 602, and a processing module 603, where:
the obtaining module 601 is configured to obtain an annotation added in an agent interface when detecting that the agent interface of a client is used, where the annotation is used to indicate that the agent interface supports an agent;
the judging module 602 is configured to judge whether a corresponding implementation class exists in the client according to the annotation, where the implementation class is used to process a service request of the client;
the processing module 603 is configured to, if there is no corresponding implementation class in the client, invoke a pre-configured proxy class in a remote invocation manner to send the service request to the server for processing, and receive a request processing result returned by the server.
Optionally, the annotation includes a conditional annotation provided by a lightweight Spring container, and the determining module 602 is specifically configured to:
and loading a remote condition RemoteCondition class in the condition annotation, calling a matching matches method of the RemoteCondition class, and judging whether an implementation class of a proxy interface of the server exists in the Spring container.
Optionally, the processing module 603 is further configured to:
and if the corresponding implementation class exists in the client, calling the implementation class to process the service request by adopting a local calling mode.
Optionally, before the obtaining of the annotation added in the proxy interface, the processing module 603 is further configured to:
a preset remote module is led into the client, an agent interface of the client is defined in the remote module, and the agent interface supports remote calling;
adding the annotation note in the agent interface of the client, wherein the annotation note comprises a module value which is used for identifying the agent interface of the client;
adding a switch annotation in a starting class of the client, and specifying a basic package basePackage in the switch annotation, wherein the basePackage is used for indicating the agent interface marked by the annotation.
Optionally, before the remotely invoking a pre-configured proxy class to send the service request to the server for processing, the processing module 603 is further configured to:
after the client is started, loading the switch annotation, wherein the switch annotation comprises an ImportBeanDefinitionRegistrar interface which is dynamically registered to the outside;
calling a scanning remotecClientScanner class in an outward dynamic registration register BeanDefinitions method of the ImportBeanDefinitionRegistrar interface, scanning a path of a basic packet to be scanned in a light-weight Spring container, and scanning to obtain the proxy interface marked by the mark annotation under the basic packet;
calling the proxy interface for realizing AkkaClientproxy in the register BeanDefinitions method to generate a proxy class corresponding to the proxy interface;
registering the proxy class in the Spring container using an injector beandefinition registry introduced into the Spring container.
Optionally, the processing module 603 is specifically configured to:
when the agent class corresponding to the agent interface of the client is called, the client process ClientActor of the client sends the service request to a local process LocalActor of a server, so that the LocalActor searches the implementation class corresponding to the agent interface from a lightweight Spring container of a programming agent worker service after receiving the service request, and reflects and calls the implementation class to process the service request.
Optionally, before the annotation added in the proxy interface is obtained when the proxy interface of the client is detected to be used, the processing module 603 is further configured to:
and when the client is started, injecting the implementation class into the lightweight Spring container of the client by using the injection Autowired annotation provided by the lightweight Spring container.
Optionally, the service request is a request sent by a Java development framework Akka cluster.
Please refer to fig. 7, which is a schematic structural diagram of a terminal device according to an embodiment of the present application. The terminal device 70 shown in fig. 7 includes: at least one processor 701, a communication interface 702, a user interface 703 and a memory 704, where the processor 701, the communication interface 702, the user interface 703 and the memory 704 may be connected by a bus or by other means, and the embodiment of the present invention is exemplified by being connected by the bus 705. Wherein,
processor 701 may be a general-purpose processor, such as a Central Processing Unit (CPU).
The communication interface 702 may be a wired interface (e.g., an ethernet interface) or a wireless interface (e.g., a cellular network interface or using a wireless local area network interface) for communicating with other terminals or websites. In this embodiment of the present invention, the communication interface 702 is specifically configured to obtain a service request.
The user interface 703 may specifically be a touch panel, including a touch screen and a touch screen, for detecting an operation instruction on the touch panel, and the user interface 703 may also be a physical button or a mouse. The user interface 703 may also be a display screen for outputting, displaying images or data.
The Memory 704 may include Volatile Memory (Volatile Memory), such as Random Access Memory (RAM); the Memory may also include a Non-Volatile Memory (Non-Volatile Memory), such as a Read-Only Memory (ROM), a Flash Memory (Flash Memory), a Hard Disk (Hard Disk Drive, HDD), or a Solid-State Drive (SSD); the memory 704 may also comprise a combination of the above types of memory. The memory 704 is used for storing a set of program codes, and the processor 701 is used for calling the program codes stored in the memory 704 to execute the following operations:
when detecting that an agent interface of a client is used, acquiring annotation notes added in the agent interface, wherein the annotation notes are used for indicating that the agent interface supports an agent;
judging whether a corresponding implementation class exists in the client according to the annotation, wherein the implementation class is used for processing the service request of the client;
if not, calling a pre-configured proxy class in a remote calling mode to send the service request to a server for processing, and receiving a request processing result returned by the server.
Optionally, the annotation includes a conditional annotation provided by a lightweight Spring container, and the determining, according to the annotation, whether a corresponding implementation class exists in the client includes:
and loading a remote condition RemoteCondition class in the condition annotation, calling a matching matches method of the RemoteCondition class, and judging whether an implementation class of a proxy interface of the server exists in the Spring container.
Optionally, the processor 701 is further configured to:
and if the corresponding implementation class exists in the client, calling the implementation class to process the service request by adopting a local calling mode.
Optionally, before the obtaining of the annotation added in the proxy interface, the method further includes:
a preset remote module is led into the client, an agent interface of the client is defined in the remote module, and the agent interface supports remote calling;
adding the annotation note in the agent interface of the client, wherein the annotation note comprises a module value which is used for identifying the agent interface of the client;
adding a switch annotation in a starting class of the client, and specifying a basic package basePackage in the switch annotation, wherein the basePackage is used for indicating the agent interface marked by the annotation.
Optionally, before the invoking a pre-configured proxy class in a remote invocation manner sends the service request to the server for processing, the processor 701 is further configured to:
after the client is started, loading the switch annotation, wherein the switch annotation comprises an ImportBeanDefinitionRegistrar interface which is dynamically registered to the outside;
calling a scanning remotecClientScanner class in an outward dynamic registration register BeanDefinitions method of the ImportBeanDefinitionRegistrar interface, scanning a path of a basic packet to be scanned in a light-weight Spring container, and scanning to obtain the proxy interface marked by the mark annotation under the basic packet;
calling an implementation class AkkaClientproxy in the register BeanDefinites method to proxy the proxy interface and generating a proxy class corresponding to the proxy interface;
registering the proxy class in the Spring container using an injector beandefinition registry introduced into the Spring container.
Optionally, the invoking a pre-configured proxy class in a remote invocation manner to send the service request to the server for processing includes:
when the agent class corresponding to the agent interface of the client is called, the client process ClientActor of the client sends the service request to a local process LocalActor of a server, so that the LocalActor searches the implementation class corresponding to the agent interface from a lightweight Spring container of a programming agent worker service after receiving the service request, and reflects and calls the implementation class to process the service request.
Optionally, before the annotation added in the proxy interface is obtained when the proxy interface of the client is detected to be used, the processor 701 is further configured to:
and when the client is started, injecting the implementation class into the lightweight Spring container of the client by using the injection Autowired annotation provided by the lightweight Spring container.
Optionally, the service request is a request sent by a Java development framework Akka cluster.
Since the terminal device described in this embodiment is a terminal device used for implementing the program calling method in this embodiment, based on the program calling method described in this embodiment, a person skilled in the art can understand the specific implementation manner of the terminal device in this embodiment and various variations thereof, so that a detailed description of how to implement the method in this embodiment by the terminal device is omitted here. As long as a person skilled in the art implements the terminal device used in the method for invoking a program in the embodiment of the present application, the terminal device is within the scope of the present application.
The technical scheme in the embodiment of the application at least has the following technical effects or advantages: when detecting that an agent interface of a client is used, the method and the device obtain a marking annotation added in the agent interface, then judge whether a corresponding implementation class exists in the client according to the marking annotation, if not, call a pre-configured agent class in a remote call mode to send a service request to a server for processing, and receive a request processing result returned by the server. According to the remote call processing method and device, the remote call processing request is realized by simply adding the annotation in the proxy interface, the program development difficulty is reduced, the program performance stability is ensured, and the technical problems that in the prior art, the code needs to be modified due to module function splitting, RPC calling is too complex, the program performance is unstable and the like are solved.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the invention.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include such modifications and variations.

Claims (10)

1. A program call method, the method comprising:
when detecting that an agent interface of a client is used, acquiring annotation notes added in the agent interface, wherein the annotation notes are used for indicating that the agent interface supports an agent;
judging whether a corresponding implementation class exists in the client according to the annotation, wherein the implementation class is used for processing the service request of the client;
if not, calling a pre-configured proxy class in a remote calling mode to send the service request to a server for processing, and receiving a request processing result returned by the server.
2. The method according to claim 1, wherein the annotation includes a conditional annotation provided by a lightweight Spring container, and the determining whether the corresponding implementation class exists in the client according to the annotation includes:
and loading a remote condition RemoteCondition class in the condition annotation, calling a matching matches method of the RemoteCondition class, and judging whether an implementation class of a proxy interface of the server exists in the Spring container.
3. The method of claim 1, further comprising:
and if the corresponding implementation class exists in the client, calling the implementation class to process the service request by adopting a local calling mode.
4. The method of claim 1, wherein before the obtaining of the annotation added in the proxy interface, the method further comprises:
a preset remote module is led into the client, an agent interface of the client is defined in the remote module, and the agent interface supports remote calling;
adding the annotation note in the agent interface of the client, wherein the annotation note comprises a module value which is used for identifying the agent interface of the client;
adding a switch annotation in a starting class of the client, and specifying a basic package basePackage in the switch annotation, wherein the basePackage is used for indicating the agent interface marked by the annotation.
5. The method of claim 4, wherein before the remotely invoking the provisioned proxy class to send the service request to the server for processing, the method further comprises:
after the client is started, loading the switch annotation, wherein the switch annotation comprises an ImportBeanDefinitionRegistrar interface which is dynamically registered to the outside;
calling a scanning remotecClientScanner class in an outward dynamic registration register BeanDefinitions method of the ImportBeanDefinitionRegistrar interface, scanning a path of a basic packet to be scanned in a light-weight Spring container, and scanning to obtain the proxy interface marked by the mark annotation under the basic packet;
calling the proxy interface for realizing AkkaClientproxy in the register BeanDefinitions method to generate a proxy class corresponding to the proxy interface;
registering the proxy class in the Spring container using an injector beandefinition registry introduced into the Spring container.
6. The method of claim 5, wherein the invoking the provisioned proxy class in a remote invocation manner to send the service request to a server for processing comprises:
when the agent class corresponding to the agent interface of the client is called, the client process ClientActor of the client sends the service request to a local process LocalActor of a server, so that the LocalActor searches the implementation class corresponding to the agent interface from a lightweight Spring container of a programming agent worker service after receiving the service request, and reflects and calls the implementation class to process the service request.
7. The method according to claim 1, wherein before the annotation added to the proxy interface is obtained when the proxy interface of the client is detected to be used, the method further comprises:
and when the client is started, injecting the implementation class into the lightweight Spring container of the client by using the injection Autowired annotation provided by the lightweight Spring container.
8. The method of claim 1, wherein the service request is a request sent by a Java development framework (Akka) cluster.
9. A terminal device, characterized in that the terminal device comprises: a processor, a memory, a communication interface, and a bus; the processor, the memory and the communication interface are connected through the bus and complete mutual communication; the memory stores executable program code; the processor executes a program corresponding to the executable program code by reading the executable program code stored in the memory for executing the program calling method according to any one of claims 1 to 8.
10. A computer-readable storage medium characterized by storing a program that executes the program calling method according to any one of claims 1 to 8 when the program is run on a terminal device.
CN202111178874.2A 2021-10-11 2021-10-11 Program calling method, terminal device and medium Active CN113626225B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111178874.2A CN113626225B (en) 2021-10-11 2021-10-11 Program calling method, terminal device and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111178874.2A CN113626225B (en) 2021-10-11 2021-10-11 Program calling method, terminal device and medium

Publications (2)

Publication Number Publication Date
CN113626225A true CN113626225A (en) 2021-11-09
CN113626225B CN113626225B (en) 2022-02-11

Family

ID=78390782

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111178874.2A Active CN113626225B (en) 2021-10-11 2021-10-11 Program calling method, terminal device and medium

Country Status (1)

Country Link
CN (1) CN113626225B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114237774A (en) * 2022-02-14 2022-03-25 北京安盟信息技术股份有限公司 Internal calling method for removing dependence of functional module
CN114398093A (en) * 2021-12-20 2022-04-26 深圳前海环融联易信息科技服务有限公司 Reading method for reading metadata based on annotation

Citations (6)

* 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
CN107301098A (en) * 2017-06-15 2017-10-27 搜易贷(北京)金融信息服务有限公司 A kind of remote procedure call device based on Thrift agreements, method and system
CN108737474A (en) * 2017-04-21 2018-11-02 北京京东尚科信息技术有限公司 The method, apparatus that HTTP interface calls
CN109729149A (en) * 2018-12-03 2019-05-07 国云科技股份有限公司 A kind of micro services framework implementation method based on note
WO2019104975A1 (en) * 2017-11-30 2019-06-06 平安科技(深圳)有限公司 Dubbo framework–based remote invoking method, server, and storage medium
CN110944018A (en) * 2019-12-27 2020-03-31 浪潮通用软件有限公司 Rpc communication method, device and medium based on annotation and dynamic proxy

Patent Citations (6)

* 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
CN108737474A (en) * 2017-04-21 2018-11-02 北京京东尚科信息技术有限公司 The method, apparatus that HTTP interface calls
CN107301098A (en) * 2017-06-15 2017-10-27 搜易贷(北京)金融信息服务有限公司 A kind of remote procedure call device based on Thrift agreements, method and system
WO2019104975A1 (en) * 2017-11-30 2019-06-06 平安科技(深圳)有限公司 Dubbo framework–based remote invoking method, server, and storage medium
CN109729149A (en) * 2018-12-03 2019-05-07 国云科技股份有限公司 A kind of micro services framework implementation method based on note
CN110944018A (en) * 2019-12-27 2020-03-31 浪潮通用软件有限公司 Rpc communication method, device and medium based on annotation and dynamic proxy

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114398093A (en) * 2021-12-20 2022-04-26 深圳前海环融联易信息科技服务有限公司 Reading method for reading metadata based on annotation
CN114237774A (en) * 2022-02-14 2022-03-25 北京安盟信息技术股份有限公司 Internal calling method for removing dependence of functional module

Also Published As

Publication number Publication date
CN113626225B (en) 2022-02-11

Similar Documents

Publication Publication Date Title
CN109547570B (en) Service registration method, device, registration center management equipment and storage medium
CN107979508B (en) Micro-service test method and device
CA2598426C (en) Facilitating mobile device awareness of the availability of new or updated server-side applications
CN107203419B (en) Method, device and system for calling among modules in application program
CN113626225B (en) Program calling method, terminal device and medium
US7920852B2 (en) Compression of data transmitted between server and mobile device
CN107818023B (en) Thread-based message processing method, intelligent device and storage medium
CN107241315B (en) Access method and device of bank gateway interface and computer readable storage medium
CN103942225A (en) Method and system for invoking resources of Hybrid App client and client
CN107729014B (en) Page jump method and structure based on Android
CN105323269A (en) Method for updating APP in Android system, terminal and storage medium
CN111026634A (en) Interface automation test system, method, device and storage medium
US11909640B2 (en) Creating endpoints
US10715628B2 (en) Attribute operating method and device
CN110727524A (en) Method and device for realizing remote procedure call
CN110324722B (en) Method, device, equipment and storage medium for acquiring data in live broadcast room
CN107517188A (en) A kind of data processing method and device based on Android system
CN114417202A (en) Artificial intelligence-based mixed page skipping method, device and equipment
CN111198770A (en) Communication method, device and system, conversion method and device of ROS1 message
CN107105004B (en) Cross-platform service calling method and device
CN116233217B (en) Page jump method and device based on route, electronic equipment and storage medium
CN111158777A (en) Component calling method and device and computer readable storage medium
US20170139758A1 (en) Nondeterministic Operation Execution Environment Utilizing Resource Registry
CN115237459A (en) Software development kit generation method, device, equipment, storage medium and product
CN112416792A (en) Application software compatibility detection 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
GR01 Patent grant
GR01 Patent grant
CP03 Change of name, title or address
CP03 Change of name, title or address

Address after: 101, Floor 1-8, Building 8, Courtyard 13, Ronghua South Road, Beijing Economic and Technological Development Zone, Daxing District, Beijing 100176 (Yizhuang Group, High-end Industrial Zone, Beijing Pilot Free Trade Zone)

Patentee after: AVIC International Golden Net (Beijing) Technology Co.,Ltd.

Country or region after: China

Address before: 100176 room 801, 8 / F, building 10, yard 13, Ronghua South Road, Beijing Economic and Technological Development Zone, Daxing District, Beijing

Patentee before: AVIC INTERNATIONAL E-BUSINESS Inc.

Country or region before: China