CN108287710B - Java module communication method and system - Google Patents

Java module communication method and system Download PDF

Info

Publication number
CN108287710B
CN108287710B CN201810140939.6A CN201810140939A CN108287710B CN 108287710 B CN108287710 B CN 108287710B CN 201810140939 A CN201810140939 A CN 201810140939A CN 108287710 B CN108287710 B CN 108287710B
Authority
CN
China
Prior art keywords
interface object
java module
module
java
communication
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
CN201810140939.6A
Other languages
Chinese (zh)
Other versions
CN108287710A (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.)
Beijing Forever Technology Co Ltd
Original Assignee
Beijing Forever Technology 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 Beijing Forever Technology Co Ltd filed Critical Beijing Forever Technology Co Ltd
Priority to CN201810140939.6A priority Critical patent/CN108287710B/en
Publication of CN108287710A publication Critical patent/CN108287710A/en
Application granted granted Critical
Publication of CN108287710B publication Critical patent/CN108287710B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages

Abstract

The invention discloses a Java module communication method, which comprises the following steps: importing a Java module to be subjected to inter-module communication into a preset public API; when the first Java module communicates with the second Java module, a first interface object of the first Java module and a second interface object of the second Java module are obtained through the preset public API; and establishing communication connection between the first Java module and the second Java module through the first interface object and the second interface object to realize communication between the first Java module and the Java module. The invention solves the communication problem between API dependence and Java module.

Description

Java module communication method and system
Technical Field
The invention relates to the technical field of Java, in particular to a Java module communication method and system.
Background
Along with the development of software technology, modularization is a better organization system management mode, so that management, deployment and testing are facilitated, and the cooperation among modules is clearer, so that modularization is more and more common in the software development process.
In recent years, with the modular development of Java applications, the isolation between modules raises the problem of communication between modules, and currently, communication between modules is usually achieved through the following methods: an API (Application Programming Interface) call; REST (Representational State Transfer) interface calls; RPC (Remote Procedure Call) mode Call. The existing communication mode between Java modules often needs to depend on API of the modules, and in addition, the performance effect is poor, so that the communication between the modules is influenced.
Disclosure of Invention
Aiming at the problems, the invention provides a Java module communication method and system, which solve the problems of API dependence and poor communication performance between Java modules.
In order to achieve the purpose, the invention provides the following technical scheme:
a Java module communication method comprises the following steps:
importing a Java module to be subjected to inter-module communication into a preset public API;
when the first Java module communicates with the second Java module, a first interface object of the first Java module and a second interface object of the second Java module are obtained through the preset public API;
and establishing communication connection between the first Java module and the second Java module through the first interface object and the second interface object to realize communication between the first Java module and the Java module.
Preferably, the importing the Java module to be subjected to inter-module communication into a preset public API includes:
acquiring interface information of a Java module to be subjected to inter-module communication;
defining a public API according to the interface information;
and accessing the Java module to be subjected to inter-module communication to the public API.
Preferably, when the first Java module communicates with the second Java module, the obtaining, through the preset public API, the first interface object of the first Java module and the second interface object of the second Java module includes:
determining an identification name of a second interface object of a second Java module which communicates with the first Java module;
acquiring the second interface object through the preset public API according to the identification name of the second interface object;
determining the identification name of a first interface object of a first Java module which communicates with the second Java module;
and acquiring the first interface object through the preset public API according to the identification name of the first interface object.
Preferably, the method further comprises the following steps:
and defining an interface object calling function in the preset public API.
Preferably, the method further comprises the following steps:
and calling the first interface object and the second interface object based on the interface object calling function.
A Java module communication system, comprising:
the import unit is used for importing the Java module to be subjected to inter-module communication into a preset public API;
the obtaining unit is used for obtaining a first interface object of the first Java module and a second interface object of the second Java module through the preset public API when the first Java module communicates with the second Java module;
and the communication unit is used for establishing communication connection between the first Java module and the second Java module through the first interface object and the second interface object so as to realize communication between the first Java module and the Java module.
Preferably, the introduction unit includes:
the information acquisition subunit is used for acquiring interface information of the Java module to be subjected to inter-module communication;
the definition subunit is used for defining a public API according to the interface information;
and the access subunit is used for accessing the Java module to be subjected to inter-module communication to the public API.
Preferably, when the first Java module communicates with the second Java module, the obtaining unit includes:
the first determining subunit is used for determining the identification name of a second interface object of a second Java module which communicates with the first Java module;
the first obtaining subunit is configured to obtain the second interface object through the preset public API according to the identifier name of the second interface object;
the second determining subunit is used for determining the identification name of the first interface object of the first Java module which communicates with the second Java module;
and the second obtaining subunit is configured to obtain the first interface object through the preset public API according to the identifier name of the first interface object.
Preferably, the method further comprises the following steps:
and the function definition unit is used for defining an interface object calling function in the preset public API.
Preferably, the method further comprises the following steps:
and the calling unit is used for calling a function based on the interface object and realizing the calling of the first interface object and the second interface object.
Compared with the prior art, the method and the device have the advantages that the Java modules to be subjected to inter-module communication are imported into the preset public API, and the preset public API is imported into each Java module, so that the public API is depended by each module, and the modules do not have mutual dependence. Then, the communication of the Java modules is realized by obtaining the interface objects of the Java modules to be communicated based on the public API, and because the interface objects are not directly called among the Java modules, the mutual API dependence is avoided, the high-efficiency calling of the interfaces is realized, and the problem of poor communication performance among the Java modules is solved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
Fig. 1 is a schematic flow chart of a Java module communication method according to an embodiment of the present invention;
fig. 2 is a schematic structural diagram of a Java module communication system 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 terms "first" and "second," and the like in the description and claims of the present invention and the above-described drawings are used for distinguishing between different objects and not for describing a particular order. Furthermore, the terms "comprising" and "having," as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not set forth for a listed step or element but may include steps or elements not listed.
An embodiment of the present invention provides a Java module communication method, which may include, referring to fig. 1:
s11, importing the Java module to be subjected to inter-module communication into a preset public API;
specifically, this step can be implemented by:
acquiring interface information of a Java module to be subjected to inter-module communication;
defining a public API according to the interface information;
and accessing the Java module to be subjected to inter-module communication to the public API.
For example, a service agent class CrossService is defined according to the interface information of the Java module as the public API content, and when a module needs to perform inter-module communication, the module needs to actively rely on the API, that is, the API interface is imported through the import.
S12, when the first Java module communicates with the second Java module, a first interface object of the first Java module and a second interface object of the second Java module are obtained through the preset public API;
specifically, the implementation manner of the process may be:
determining an identification name of a second interface object of a second Java module which communicates with the first Java module;
acquiring the second interface object through the preset public API according to the identification name of the second interface object;
determining the identification name of a first interface object of a first Java module which communicates with the second Java module;
and acquiring the first interface object through the preset public API according to the identification name of the first interface object.
When the first Java module and the second Java module carry out inter-module communication, namely the first Java module needs to call an interface of the second Java module, the cross service is injected into a public API (application program interface), namely the cross service, in a spring-dependent injection mode, a cross service variable name is referred to as a bean name of an actually-referred interface object, and the cross service acquires a corresponding interface object from a spring container through the bean name. The spring is a coupling mode, and is coupled with the public API, and the modules are directly coupled. The bean is a concept in spring, and is that a Java class defines a unique name identifier to be used for referencing an object of the class in dependence injection.
S13, establishing communication connection between the first Java module and the second Java module through the first interface object and the second interface object, and realizing communication between the first Java module and the Java module.
On the basis of the embodiment, another embodiment of the present invention further includes:
and defining an interface object calling function in the preset public API.
And calling the first interface object and the second interface object based on the interface object calling function.
It should be noted that the public API provides an application method function execution interface method call, and the application needs to transfer an interface method name, that is, a function name and a parameter. The actual calling of the interface object is realized by Java reflection in the apple method.
In the application method, the declaration of the interface call is interpreted, and the object to be called is fetched from the spring container. By executing the interface method to be called in reverse.
Embodiments of code implementations of a Java module communication method are provided below.
CrossService is first defined.
And identifying an interface calling statement in an annotated mode, calling an interface object to be called from a module container specified by the statement, and executing the requested method through an application method.
Schematic code for the application method may be as follows:
v. interface object +
Object bean=ContainerHelper.getBean(beanName,pluginName);
Method m=getMethod(method,args);
Object result=m.invoke(bean,args);
Then, the open interface of the module is declared.
For example, in module plugin a, the interface object to be developed is declared:
@CommonService
@Component("service1")
publicclass Service1{
}
and (4) interface communication, and calling the open interfaces of other modules.
@Plugin(name="pluginA",serviceName="service1")
CrossService invokeService;
The "name" in @ Plugin (name ═ Plugin a ", and the serviceName ═ service1") is the name of the module referred to, and the "serviceName" is the name of the interface object referred to (i.e., bean name);
Object result=invokeService.apply("list",new Object[]{"001"});
wherein the 'invokeService' is referred to the proxy object of the interface object; "apply" is the common execution method that executes the interface call, the first parameter "list" is the called interface name, and the second parameter is the parameter array of the called interface. "result" is the result returned by the calling interface.
According to the Java module communication method provided by the embodiment of the invention, the Java module to be subjected to inter-module communication is imported into the preset public API, and the preset public API is imported into each Java module, so that the public API is depended by each module, and no mutual dependence exists between the modules. Then, the communication of the Java modules is realized by obtaining the interface objects of the Java modules to be communicated based on the public API, and because the interface objects are not directly called among the Java modules, the mutual API dependence is avoided, the high-efficiency calling of the interfaces is realized, and the problem of poor communication performance among the Java modules is solved.
Corresponding to the Java module communication method provided by the embodiment of the present invention, an embodiment of the present invention further provides a Java module communication system, which includes, referring to fig. 2:
the system comprises an importing unit 1, a processing unit and a processing unit, wherein the importing unit is used for importing a Java module to be subjected to inter-module communication into a preset public API;
the obtaining unit 2 is configured to obtain a first interface object of the first Java module and a second interface object of the second Java module through the preset public API when the first Java module communicates with the second Java module;
and the communication unit 3 is used for establishing communication connection between the first Java module and the second Java module through the first interface object and the second interface object so as to realize communication between the first Java module and the Java module.
Optionally, on the basis of this embodiment, in another embodiment of the present invention, the importing unit includes:
the information acquisition subunit is used for acquiring interface information of the Java module to be subjected to inter-module communication;
the definition subunit is used for defining a public API according to the interface information;
and the access subunit is used for accessing the Java module to be subjected to inter-module communication to the public API.
Optionally, on the basis of this embodiment, in another embodiment of the present invention, when the first Java module communicates with the second Java module, the obtaining unit includes:
the first determining subunit is used for determining the identification name of a second interface object of a second Java module which communicates with the first Java module;
the first obtaining subunit is configured to obtain the second interface object through the preset public API according to the identifier name of the second interface object;
the second determining subunit is used for determining the identification name of the first interface object of the first Java module which communicates with the second Java module;
and the second obtaining subunit is configured to obtain the first interface object through the preset public API according to the identifier name of the first interface object.
Optionally, on the basis of this embodiment, in another embodiment of the present invention, the method further includes:
and the function definition unit is used for defining an interface object calling function in the preset public API.
Optionally, on the basis of this embodiment, in another embodiment of the present invention, the method further includes:
and the calling unit is used for calling a function based on the interface object and realizing the calling of the first interface object and the second interface object.
In the Java module communication system provided in the embodiment of the present invention, a predetermined public API is imported to a Java module to be subjected to inter-module communication, and the predetermined public API imports each Java module, so that the public API is relied on by each module, and there is no mutual dependency between modules. Then, the communication of the Java modules is realized by obtaining the interface objects of the Java modules to be communicated based on the public API, and because the interface objects are not directly called among the Java modules, the mutual API dependence is avoided, the high-efficiency calling of the interfaces is realized, and the problem of poor communication performance among the Java modules is solved.
The embodiments in the present description are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (6)

1. A Java module communication method is characterized by comprising the following steps:
importing a Java module to be subjected to inter-module communication into a preset public API, wherein the method comprises the following steps:
acquiring interface information of a Java module to be subjected to inter-module communication;
defining a public API according to the interface information;
accessing the Java module to be subjected to inter-module communication to the public API;
when the first Java module communicates with the second Java module, the first interface object of the first Java module and the second interface object of the second Java module are obtained through the preset public API, including:
determining an identification name of a second interface object of a second Java module which communicates with the first Java module;
acquiring the second interface object through the preset public API according to the identification name of the second interface object;
determining the identification name of a first interface object of a first Java module which communicates with the second Java module;
acquiring the first interface object through the preset public API according to the identification name of the first interface object;
and establishing communication connection between the first Java module and the second Java module through the first interface object and the second interface object to realize communication between the first Java module and the Java module.
2. The method of claim 1, further comprising:
and defining an interface object calling function in the preset public API.
3. The method of claim 2, further comprising:
and calling the first interface object and the second interface object based on the interface object calling function.
4. A Java module communication system, comprising:
the import unit is used for importing the Java module to be subjected to inter-module communication into a preset public API, and comprises the following steps:
the information acquisition subunit is used for acquiring interface information of the Java module to be subjected to inter-module communication;
the definition subunit is used for defining a public API according to the interface information;
the access subunit is used for accessing the Java module to be subjected to inter-module communication to the public API;
an obtaining unit, configured to obtain, through the preset public API, a first interface object of the first Java module and a second interface object of the second Java module when the first Java module communicates with the second Java module, where the obtaining unit includes:
the first determining subunit is used for determining the identification name of a second interface object of a second Java module which communicates with the first Java module;
the first obtaining subunit is configured to obtain the second interface object through the preset public API according to the identifier name of the second interface object;
the second determining subunit is used for determining the identification name of the first interface object of the first Java module which communicates with the second Java module;
the second obtaining subunit is configured to obtain the first interface object through the preset public API according to the identifier name of the first interface object;
and the communication unit is used for establishing communication connection between the first Java module and the second Java module through the first interface object and the second interface object so as to realize communication between the first Java module and the Java module.
5. The system of claim 4, further comprising:
and the function definition unit is used for defining an interface object calling function in the preset public API.
6. The system of claim 5, further comprising:
and the calling unit is used for calling a function based on the interface object and realizing the calling of the first interface object and the second interface object.
CN201810140939.6A 2018-02-11 2018-02-11 Java module communication method and system Active CN108287710B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810140939.6A CN108287710B (en) 2018-02-11 2018-02-11 Java module communication method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810140939.6A CN108287710B (en) 2018-02-11 2018-02-11 Java module communication method and system

Publications (2)

Publication Number Publication Date
CN108287710A CN108287710A (en) 2018-07-17
CN108287710B true CN108287710B (en) 2021-02-12

Family

ID=62832928

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810140939.6A Active CN108287710B (en) 2018-02-11 2018-02-11 Java module communication method and system

Country Status (1)

Country Link
CN (1) CN108287710B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102591623A (en) * 2012-01-20 2012-07-18 周超勇 Distributed inter-module communication method
CN107092501A (en) * 2017-03-20 2017-08-25 武汉斗鱼网络科技有限公司 The implementation method and device of advertisement general-purpose interface in a kind of android system
CN107643953A (en) * 2016-07-20 2018-01-30 深圳市祈飞科技有限公司 A kind of remote object invocation method and system

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9430452B2 (en) * 2013-06-06 2016-08-30 Microsoft Technology Licensing, Llc Memory model for a layout engine and scripting engine

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102591623A (en) * 2012-01-20 2012-07-18 周超勇 Distributed inter-module communication method
CN107643953A (en) * 2016-07-20 2018-01-30 深圳市祈飞科技有限公司 A kind of remote object invocation method and system
CN107092501A (en) * 2017-03-20 2017-08-25 武汉斗鱼网络科技有限公司 The implementation method and device of advertisement general-purpose interface in a kind of android system

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
JAVA9模块间的服务化详解;研发之道;《CSDN https://blog.csdn.net/lsgqjh/article/details/78721472》;20171205;第1-24页 *
基于JavaScript的动态Web应用系统设计;赵书田;《现代电子技术》;20170801;第44-46+51页 *

Also Published As

Publication number Publication date
CN108287710A (en) 2018-07-17

Similar Documents

Publication Publication Date Title
EP3029907A1 (en) Remote calling method and apparatus
CN103294455A (en) Software service implementation method and system, as well as Java platform
CN107368334B (en) Business plug-in interaction system and method
CN108287710B (en) Java module communication method and system
CN112966833A (en) Machine learning model platform based on Kubernetes cluster
CN110022332B (en) Hypertext transfer security protocol proxy method, device, equipment and medium
CN106598642B (en) Method and device for using service in plug-in
CN110308999B (en) Method for dynamically sharing dependency package between applications, storage medium and mobile terminal
CN113190565B (en) Data updating method and device, storage medium and electronic device
CN101227349A (en) Device and method for automatically testing system change
CN110298654B (en) Mobile phone payment method and system based on 5G network
CN113242313B (en) Data synchronization method, system, device, server and storage medium
CN112099814B (en) System and method for managing vehicle-mounted machine application software installation environment
CN112752258B (en) eSIM card opening method, mobile phone terminal and service acceptance system
CN110958594B (en) Effectiveness filtering method for searching Bluetooth BLE equipment
CN114416396A (en) Interface version control method and device, electronic equipment and storage medium
CN104219258A (en) Method and system of real-time query of number attribution as well as terminal and server
CN105763422A (en) Method of rapidly inviting new users to group
CN108920328B (en) Method and device for discovering terminal application change
CN106936869A (en) A kind of car interconnection plane method and system based on AOA agreements
CN107846300B (en) Method and device for providing service interface
CN106534279A (en) Dynamic native interface invoking method and system
CN104836708A (en) Method and device for binding information
CN109871288A (en) Execute method, apparatus, equipment and the medium of android system order
CN110557428B (en) Script interpretation type service agent method and system based on Kubernetes

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