Movatterモバイル変換


[0]ホーム

URL:


CN105389222A - Method, apparatus and system for dynamically calling native interface - Google Patents

Method, apparatus and system for dynamically calling native interface
Download PDF

Info

Publication number
CN105389222A
CN105389222ACN201510937805.3ACN201510937805ACN105389222ACN 105389222 ACN105389222 ACN 105389222ACN 201510937805 ACN201510937805 ACN 201510937805ACN 105389222 ACN105389222 ACN 105389222A
Authority
CN
China
Prior art keywords
interface
module
native interface
native
call
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
CN201510937805.3A
Other languages
Chinese (zh)
Other versions
CN105389222B (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.)
Zhengzhou Xinrand Network Technology Co ltd
Original Assignee
Institute of Acoustics CAS
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 Institute of Acoustics CASfiledCriticalInstitute of Acoustics CAS
Priority to CN201510937805.3ApriorityCriticalpatent/CN105389222B/en
Publication of CN105389222ApublicationCriticalpatent/CN105389222A/en
Application grantedgrantedCritical
Publication of CN105389222BpublicationCriticalpatent/CN105389222B/en
Activelegal-statusCriticalCurrent
Anticipated expirationlegal-statusCritical

Links

Classifications

Landscapes

Abstract

Translated fromChinese

本发明涉及一种动态调用原生接口的方法、装置与系统,所述装置包括:原生接口管理服务器和原生接口管理引擎;其中;原生接口管理服务器管理所有Web应用的原生接口,提供增加、更新原生接口操作,发出接口调用请求的Web应用为基于HTML、Javascript和CSS语言开发的应用;原生接口管理引擎包括接口执行模块,接口更新模块和本地存储单元,响应Web应用发出的调用本地原生接口的请求,并根据原生接口管理服务器的指示进行接口更新。本发明通过在嵌入式终端上集成为Web应用提供接口服务并且与服务端的接口管理服务器进行交互的原生接口管理引擎,实现了对所需要的原生接口的动态更新或扩充,并且实现了嵌入式终端上Web应用或浏览器内核无需升级即可调用相应接口。

The present invention relates to a method, device and system for dynamically invoking a native interface. The device includes: a native interface management server and a native interface management engine; wherein the native interface management server manages all native Interface operation, the web application that sends the interface call request is an application developed based on HTML, Javascript and CSS languages; the native interface management engine includes an interface execution module, an interface update module and a local storage unit, and responds to the request sent by the web application to call the local native interface , and update the interface according to the instructions of the native interface management server. The present invention realizes the dynamic update or expansion of the required native interface by integrating the native interface management engine that provides interface services for Web applications and interacts with the interface management server of the server on the embedded terminal, and realizes the embedded terminal Web applications or browser kernels can call corresponding interfaces without upgrading.

Description

Translated fromChinese
一种动态调用原生接口的方法、装置和系统A method, device and system for dynamically calling native interface

技术领域technical field

本发明涉及计算机领域,尤其涉及一种动态调用原生接口的方法、装置和系统。The invention relates to the field of computers, in particular to a method, device and system for dynamically calling native interfaces.

背景技术Background technique

Web应用由于采用HTML、CSS、JavaScript等作为开发语言,具有天然的跨平台优势,一次性开发就可以运行在多种类型的嵌入式终端平台上,大大提高了多平台开发的效率,受到了越来越多人的青睐。然而,由于Web应用运行于浏览器中,与设备API相隔离,功能受到一定的限制,并且运行效率也一直为人们所诟病。另外,Web应用通常需要访问系统的设备功能,包括:摄像头、加速计、地理位置信息、通讯录、照片库、存储卡和媒体播放等,这些功能与硬件或操作系统底层有关,Web应用不具备所需的较高权限,无法直接调用。因此,迫切需要一种新的开发模式,可以结合使用原生技术与Web技术,既可以实现设备功能的调用以及丰富高效的系统原生接口,又能够在一定程度上保证跨平台的特性。Since Web applications use HTML, CSS, JavaScript, etc. as development languages, they have natural cross-platform advantages, and can run on various types of embedded terminal platforms after one-time development, which greatly improves the efficiency of multi-platform development and has been favored by more and more favored by more and more people. However, since web applications run in browsers and are isolated from device APIs, their functions are limited to a certain extent, and their operating efficiency has always been criticized by people. In addition, web applications usually need to access the device functions of the system, including: camera, accelerometer, geographic location information, address book, photo library, memory card and media playback, etc. These functions are related to the underlying hardware or operating system, and web applications do not have them Higher privilege required, cannot be called directly. Therefore, there is an urgent need for a new development model that can combine the use of native technology and Web technology, which can not only realize the call of device functions and rich and efficient system native interfaces, but also ensure cross-platform characteristics to a certain extent.

然而,由于目前嵌入式终端上浏览器比较精简,同时原生接口存在多种形式,如Java,C/C++等,现有的浏览器插件机制难以支撑以上需求。应此问题,目前的嵌入式终端浏览器多采用修改Web引擎源码,从浏览器内核部分支持扩展的原生接口,实现与JavaScript的绑定。这种方法需要获取平台源码,对平台依赖性很大;而且对于不同的操作系统,需要在不同的平台源码环境中进行重复编译开发,开发工作量大,维护困难。目前新兴的一种技术是采用JavaScript框架来扩展原生接口,通过在应用层实现原生接口。例如,在Android的APP层实现Java对象,将应用启动时将该对象注册到Web引擎中,当JavaScript调用到该接口时,调用该对象接口运行。However, due to the relatively streamlined browsers on embedded terminals and the existence of various forms of native interfaces, such as Java, C/C++, etc., the existing browser plug-in mechanism is difficult to support the above requirements. In response to this problem, the current embedded terminal browsers mostly modify the source code of the Web engine, and support the extended native interface from the browser kernel to realize the binding with JavaScript. This method needs to obtain the platform source code, which is highly dependent on the platform; and for different operating systems, it needs to be repeatedly compiled and developed in different platform source code environments, resulting in a large development workload and difficult maintenance. A currently emerging technology is to use the JavaScript framework to extend the native interface by implementing the native interface at the application layer. For example, implement a Java object in the APP layer of Android, register the object in the Web engine when the application starts, and call the object interface to run when JavaScript calls the interface.

以上方法均可以实现在嵌入式浏览器的Web应用中通过JavaScript脚本调用原生接口的技术,但均需要事先在Web引擎、应用或者系统中内置原生接口,当原生接口需要更新或增加时,需要升级系统或者应用;另外,在应用中扩展的原生接口,只能为该应用本身所调用,无法为其他应用提供服务,这些都给Web应用的开发和推广带来了极大的不便。All of the above methods can realize the technology of calling the native interface through JavaScript script in the web application of the embedded browser, but all need to build the native interface in the web engine, application or system in advance. When the native interface needs to be updated or added, it needs to be upgraded. system or application; in addition, the native interface extended in the application can only be called by the application itself, and cannot provide services for other applications, which brings great inconvenience to the development and promotion of Web applications.

因此,需要一种新的调用原生接口的方法,能够在不升级系统或应用的前提下,动态扩展和增加应用所需的原生接口,并且能为所有运行于该系统之上的Web应用所调用。Therefore, there is a need for a new method of calling native interfaces, which can dynamically expand and increase the native interfaces required by applications without upgrading the system or applications, and can be called by all web applications running on the system .

发明内容Contents of the invention

本发明的目的是提供一种能够克服上述缺陷的动态调用原生接口的方法、装置和系统。The purpose of the present invention is to provide a method, device and system for dynamically invoking native interfaces that can overcome the above-mentioned defects.

在第一方面,本发明提供了一种动态调用原生接口的方法,包括:监听Web应用或浏览器内核对原生接口的调用请求;对监听到的调用请求进行解析;根据所述解析结果,查找所请求的原生接口并将其加载到内存中;从内存中调用已加载的原生接口,将执行结果返回给发出请求的Web应用或浏览器内核。In the first aspect, the present invention provides a method for dynamically invoking a native interface, comprising: monitoring a call request from a web application or a browser kernel to a native interface; parsing the monitored call request; The requested native interface is loaded into the memory; the loaded native interface is called from the memory, and the execution result is returned to the requesting web application or browser kernel.

优选地,所述调用请求中包含的接口名称和相关参数通过http链接中的扩展参数传递,所述解析所述调用请求是对所述接口名称和相关参数进行解析,所述执行结果的返回是通过http链接进行的,所述监听是通过呈现状态转换的应用程序接口RESTfulAPI进行的;所述方法还包括将解析后的相关参数传入所述原生接口。Preferably, the interface name and related parameters contained in the call request are passed through extended parameters in the http link, the parsing of the call request is to analyze the interface name and related parameters, and the return of the execution result is The monitoring is performed through an http link, and the monitoring is performed through an application program interface RESTful API that presents state transitions; the method also includes passing the parsed related parameters into the native interface.

优选地,所述原生接口是Java接口:所述监听是监听通过JavaScript方式调用原生接口的事件;所述查找和加载是查找Jar包并将其加载到内存中;Preferably, the native interface is a Java interface: the monitoring is to monitor the event of calling the native interface through JavaScript; the searching and loading is to find the Jar package and load it into the memory;

所述调用是从内存中加载所述Jar包并通过Java反射机制来执行的。The calling is performed by loading the Jar package from the memory and using the Java reflection mechanism.

优选地,所述原生接口是C/C++接口:所述监听是监听通过JavaScript方式调用原生接口的事件;利用动态链接库来执行所述查找;利用动态链接库的库函数来执行所述调用。Preferably, the native interface is a C/C++ interface: the monitoring is to monitor the event of calling the native interface through JavaScript; use the dynamic link library to perform the search; use the library function of the dynamic link library to perform the call.

优选地,所述方法还包括检测是否有需要更新或扩充的原生接口,基于检测结果发出更新或扩充接口请求;对所述检测模块进行响应;在接收到所述响应后,下载需要更新或扩充的原生接口;对下载的原生接口进行完整性和可靠性的验证;存储通过校验的原生接口以供调用。Preferably, the method further includes detecting whether there is a native interface that needs to be updated or expanded, and sending an interface update or expansion request based on the detection result; responding to the detection module; after receiving the response, downloading the interface that needs to be updated or expanded native interface; verify the integrity and reliability of the downloaded native interface; store the verified native interface for calling.

在第二方面,本发明提供了一种动态调用原生接口的装置,包括监听模块、解析模块、加载模块、执行模块和本地存储模块,其中:所述监听模块用于监听Web应用或浏览器内核对原生接口的调用请求,并将所述调用请求传递给所述解析模块;所述解析模块用于解析所述调用请求,并将解析结果传递给加载模块;所述加载模块用于根据所述解析结果,在所述本地存储模块中查找所请求的原生接口并将其加载到内存中;所述执行模块从内存中调用已加载的原生接口,将执行结果返回给发出请求的Web应用。In a second aspect, the present invention provides a device for dynamically calling a native interface, including a monitoring module, a parsing module, a loading module, an execution module, and a local storage module, wherein: the monitoring module is used to monitor web applications or browser kernels A call request to the native interface, and pass the call request to the parsing module; the parsing module is used to parse the call request, and pass the parsing result to the loading module; the loading module is used to Analyzing the result, searching for the requested native interface in the local storage module and loading it into the memory; the executing module invokes the loaded native interface from the memory, and returns the execution result to the requesting Web application.

优选地,所述监听模块将所述调用请求中包含的接口名称和相关参数通过http链接中的扩展参数传递给所述解析模块;所述解析模块是对是对所述接口名称和相关参数进行解析:所述执行模块还用于将解析后的相关参数传入所述原生接口,并且通过http链接将所述执行结果返回给发出请求的Web应用;所述监听模块是呈现状态转换的应用程序接口RESTfulAPI。Preferably, the monitoring module passes the interface name and related parameters contained in the call request to the analysis module through the extended parameters in the http link; Parsing: the execution module is also used to pass parsed related parameters into the native interface, and return the execution result to the requesting Web application through the http link; the monitoring module is an application program that presents state transitions Interface RESTful API.

优选地,所述原生接口是Java接口:所述监听模块监听通过JavaScript方式调用原生接口的事件;所述加载模块将在本地存储模块中查找到的Jar包加载到内存中;所述执行模块从内存中加载所述Jar包,通过Java反射机制来执行原生接口的调用。Preferably, the native interface is a Java interface: the monitoring module monitors the event of calling the native interface through JavaScript; the loading module loads the Jar package found in the local storage module into the memory; The Jar package is loaded in the memory, and the call of the native interface is executed through the Java reflection mechanism.

优选地,所述原生接口是C/C++接口:所述监听模块是监听通过JavaScript方式调用原生接口的事件;所述加载模块利用动态链接库在本地存储模块中查找所请求的原生接口;所述执行模块利用动态链接库的库函数来调用所请求的原生接口。Preferably, the native interface is a C/C++ interface: the monitoring module listens to an event calling the native interface through JavaScript; the loading module uses a dynamic link library to search for the requested native interface in the local storage module; the The execution module uses the library functions of the dynamic link library to call the requested native interface.

在第三方面,本发明提供了一种动态调用原生接口的系统,包括第一方面所述的装置、检测模块、下载模块、校验模块、更新模块和原生接口管理服务器,其中:所述检测模块用于检测是否有需要更新或扩充的原生接口,基于检测结果向所述原生接口管理服务器发出更新或扩充接口请求;所述原生接口管理服务器对所述检测模块进行响应;检测模块在接收到所述响应后,调用所述下载模块从原生接口管理服务器下载需要更新或扩充的原生接口;所述校验模块对下载的原生接口进行完整性和可靠性的验证;所述更新模块将通过校验的原生接口加载到所述本地存储模块中,以供所述执行模块调用。In a third aspect, the present invention provides a system for dynamically calling a native interface, including the device described in the first aspect, a detection module, a download module, a verification module, an update module, and a native interface management server, wherein: the detection The module is used to detect whether there is a native interface that needs to be updated or expanded, and sends an interface update or expansion request to the native interface management server based on the detection result; the native interface management server responds to the detection module; the detection module receives After the response, call the download module to download the native interface that needs to be updated or expanded from the native interface management server; the verification module verifies the integrity and reliability of the downloaded native interface; The native interface of the test is loaded into the local storage module for the execution module to call.

本发明通过在嵌入式终端上集成为Web应用提供接口服务并且与服务端的接口管理服务器进行交互的原生接口管理引擎,实现了对所需要的原生接口的动态更新或扩充,并且实现了嵌入式终端上Web应用或浏览器内核无需升级即可调用相应接口。The present invention realizes the dynamic update or expansion of the required native interface by integrating the native interface management engine that provides interface services for Web applications and interacts with the interface management server of the server on the embedded terminal, and realizes the embedded terminal Web applications or browser kernels can call corresponding interfaces without upgrading.

附图说明Description of drawings

图1是根据本发明实施例的原生接口动态扩展装置的示意图;Fig. 1 is a schematic diagram of a native interface dynamic extension device according to an embodiment of the present invention;

图2为根据本发明一个实施例的Web应用调用原生接口的流程图;FIG. 2 is a flow chart of calling a native interface by a Web application according to an embodiment of the present invention;

图3为根据本发明另一个实施例的Web应用调用原生接口的流程图;FIG. 3 is a flowchart of a Web application calling a native interface according to another embodiment of the present invention;

图4为根据本发明又一个实施例的Web应用调用原生接口的流程图;FIG. 4 is a flow chart of calling a native interface by a Web application according to yet another embodiment of the present invention;

图5为根据本发明实施例的更新原生接口模块的流程图。Fig. 5 is a flowchart of updating a native interface module according to an embodiment of the present invention.

具体实施方式detailed description

下面通过附图和实施例,对本发明的技术方案做进一步的详细描述。The technical solutions of the present invention will be described in further detail below with reference to the accompanying drawings and embodiments.

本发明目的在于克服目前嵌入式浏览器Web应用调用原生接口技术中存在的上述缺陷,提出一种动态调用原生接口的方法、装置及系统,可以实现在服务端动态扩展或修改所需原生接口,终端上Web应用或浏览器内核无需升级就可以调用相应接口,达到了动态扩充原生接口的目的。The purpose of the present invention is to overcome the above-mentioned defects existing in the current embedded browser Web application calling native interface technology, and propose a method, device and system for dynamically calling the native interface, which can realize the dynamic expansion or modification of the required native interface on the server side, The web application or browser kernel on the terminal can call the corresponding interface without upgrading, achieving the purpose of dynamically expanding the native interface.

图1是根据本发明实施例的原生接口动态扩展系统的示意图。Fig. 1 is a schematic diagram of a system for dynamically extending a native interface according to an embodiment of the present invention.

如图1所示,所述原生接口动态扩展系统包括原生接口管理引擎和原生接口管理服务器。As shown in FIG. 1 , the native interface dynamic extension system includes a native interface management engine and a native interface management server.

原生接口管理引擎包括接口执行模块,本地存储模块和接口更新模块,其负责管理Web应用调用的所有原生接口,为Web应用提供接口服务,同时根据接口管理服务器的内容进行动态更新。接口管理服务器在服务端为用户提供增加、更新原生接口的操作,管理所有支撑Web应用的原生接口。Web应用可是为基于HTML、Javascript和CSS语言开发的应用,这样既可以利用Web语言的跨平台优势,又可以调用丰富而高效的系统原生接口。当Web应用需要访问系统的设备功能时,如摄像头、加速计、地理位置信息、通讯录、照片库、存储卡和媒体播放等,Web应用向原生接口管理引擎发出调用系统原生接口请求,Web应用可以为基于HTML、Javascript和CSS语言开发的应用。应当理解,图1中所示的Web应用应当理解为一个或多个。The native interface management engine includes an interface execution module, a local storage module and an interface update module, which is responsible for managing all native interfaces invoked by web applications, providing interface services for web applications, and dynamically updating according to the content of the interface management server. The interface management server provides users with operations to add and update native interfaces on the server side, and manages all native interfaces supporting Web applications. Web applications are applications developed based on HTML, Javascript and CSS languages, which can not only take advantage of the cross-platform advantages of Web languages, but also call rich and efficient system native interfaces. When a web application needs to access the device functions of the system, such as camera, accelerometer, geographic location information, address book, photo library, memory card, and media player, the web application sends a request to the native interface management engine to call the system's native interface, and the web application Applications can be developed based on HTML, Javascript and CSS languages. It should be understood that the Web applications shown in FIG. 1 should be understood as one or more.

进一步,所述原生接口管理引擎中的接口执行模块包括监听、解析、加载、执行四个模块。监听模块负责监听Web应用的接口调用请求,并将请求内容传递给接口执行模块中的解析模块;解析模块通过解析请求内容,得到Web应用请求调用接口的的接口名称及相关参数并将其传递给加载模块;根据解析模块所传递的接口名称和相关参数,加载模块在本地存储模块中查找对应的接口,并将查找到的接口从本地存储模块中加载到内存(图1中未示出)中;执行模块从内存中调用已加载的对应接口,并传入参数,将其执行结果返回给Web应用。Further, the interface execution module in the native interface management engine includes four modules of monitoring, parsing, loading and executing. The monitoring module is responsible for monitoring the interface call request of the Web application, and passes the request content to the analysis module in the interface execution module; the analysis module obtains the interface name and related parameters of the Web application request call interface by analyzing the request content, and passes it to the Loading module; according to the interface name and related parameters passed by the parsing module, the loading module searches for the corresponding interface in the local storage module, and loads the found interface from the local storage module into the memory (not shown in Figure 1) ; The execution module invokes the loaded corresponding interface from the memory, and passes in parameters, and returns the execution result to the web application.

优选地,考虑到浏览器对HTTP协议的良好支持性,监听模块可以采用呈现状态转换的应用程序接口(REpresentationalStateTransferApplicationProgrammingInterface,RESTfulAPI)形式的接口为Web应用提供服务,即可通过HTTPGET、POST、PUSH、DELETE等方法实现接口调用,接口名称及相关参数可通过http链接中的扩展参数进行传递。Preferably, considering the browser's good support for the HTTP protocol, the monitoring module can use an interface in the form of a REpresentationalStateTransferApplicationProgrammingInterface (RESTfulAPI) to provide services for the Web application, that is, through HTTPGET, POST, PUSH, DELETE and other methods to implement interface calls, the interface name and related parameters can be passed through the extended parameters in the http link.

原生接口一般以Java接口或C++/C接口的形式存在于终端系统中。对于Java接口,可采用动态加载Jar包的方式实现原生接口的调用,首先将所需的原生接口打包成Jar包,通过接口更新模块将Jar包更新到终端系统的存储模块中。当需要运行接口时,加载相应的Jar包,利用Java的反射机制进行调用。对于C/C++接口,可采用动态库的方式实现接口调用,例如利用dlopen系列库函数实现接口的查找、加载与运行。Native interfaces generally exist in the terminal system in the form of Java interfaces or C++/C interfaces. For the Java interface, the native interface can be called by dynamically loading the Jar package. First, the required native interface is packaged into a Jar package, and the Jar package is updated to the storage module of the terminal system through the interface update module. When the interface needs to be run, the corresponding Jar package is loaded, and the reflection mechanism of Java is used for calling. For the C/C++ interface, the interface call can be implemented in the form of a dynamic library, for example, the search, loading and operation of the interface can be realized by using the dlopen series library functions.

进一步,接口更新模块包括检测、下载、校验与更新四个模块。检测模块检测是否有需要更新或扩充的接口,基于检测结果与前端的原生接口管理服务器通信,发出更新或扩充接口请求;对应地,接口管理服务器对接收到的更新或扩充接口请求进行判断后,对该请求进行响应。检测模块接收到接口管理服务器的接口更新或扩充操作的响应后,调用下载模块对接口更新或扩充进行下载。下载完成后,校验模块验证下载接口的完整性和可靠性;通过校验的接口由更新模块加载到本地存储模块中,供接口执行模块调用。Further, the interface update module includes four modules of detection, download, verification and update. The detection module detects whether there is an interface that needs to be updated or expanded, communicates with the front-end native interface management server based on the detection result, and issues an interface update or expansion request; correspondingly, after the interface management server judges the received update or expansion interface request, Respond to the request. After the detection module receives the interface update or expansion operation response from the interface management server, it calls the download module to download the interface update or expansion. After the download is completed, the verification module verifies the integrity and reliability of the download interface; the interface that passes the verification is loaded into the local storage module by the update module, and is called by the interface execution module.

图2为根据本发明一个实施例的Web应用调用原生接口的流程图,如图2所示:Fig. 2 is a flowchart of calling a native interface by a Web application according to an embodiment of the present invention, as shown in Fig. 2:

在步骤201,Web应用发出本地接口调用请求,其可以体现为一个通过JavaScript方式调用本地接口的事件;In step 201, the web application sends a local interface invocation request, which may be embodied as an event invoking the local interface through JavaScript;

在步骤202,原生接口管理引擎中的监听模块监听到该事件/接收本地接口调用请求,并且将该请求传递给解析模块,其中,请求调用的接口名称及相关参数可以通过http链接中的扩展参数传递。In step 202, the listening module in the native interface management engine listens to the event/receives the local interface calling request, and passes the request to the parsing module, wherein the interface name and related parameters of the request calling can be passed through the extended parameters in the http link transfer.

在步骤203,解析模块对http链接中的扩展参数中的接口名称及相关参数进行解析,然后将解析后的内容传递给加载模块;In step 203, the parsing module parses the interface name and related parameters in the extended parameters in the http link, and then passes the parsed content to the loading module;

在步骤204,根据解析模块传递来的接口名称及相关参数,加载模块在本地存储模块中查找对应的接口,并将查找到的对应接口从本地存储模块中加载到内存中;In step 204, according to the interface name and related parameters passed by the parsing module, the loading module searches for the corresponding interface in the local storage module, and loads the found corresponding interface from the local storage module into the memory;

在步骤205,执行模块从内存中调用已加载的对应接口,并传入所述相关参数,将其执行结果通过http链接返回给Web应用。In step 205, the execution module invokes the loaded corresponding interface from the memory, and passes in the relevant parameters, and returns the execution result to the Web application through the http link.

下面通过一个具体实例来更清楚地了解本发明接口调用方法的流程。本具体实例中,原生接口以Java接口的形式存在于终端系统中。图3为根据本发明另一个实施例的Web应用调用原生接口的流程图,如图3所示:A specific example is used below to understand more clearly the flow of the interface calling method of the present invention. In this specific example, the native interface exists in the terminal system in the form of a Java interface. Fig. 3 is a flow chart of calling a native interface by a Web application according to another embodiment of the present invention, as shown in Fig. 3:

在步骤301,Web应用发出调用接口请求;In step 301, the web application sends a call interface request;

在步骤302,原生接口管理引擎中的监听模块监听通过JavaScript方式调用本地接口的事件,并通过http链接中的扩展参数将请求调用的接口名称和相关参数传递给接口执行模块中的解析模块;In step 302, the monitoring module in the native interface management engine monitors the event of calling the local interface through JavaScript, and passes the name of the interface called and related parameters requested to be called to the parsing module in the interface execution module through the extended parameters in the http link;

在步骤303,接口执行模块中的解析模块解析http链接扩展参数中的接口名称及相关参数,并将解析后的内容传递给加载模块;In step 303, the parsing module in the interface execution module parses the interface name and related parameters in the http link extension parameters, and passes the parsed content to the loading module;

在步骤304,加载模块根据解析模块传递的接口名称和相关参数在本地存储模块中查找对应的接口。对于Java原生接口,预先打包成Jar包,并通过接口更新模块将Jar包更新到终端系统的本地存储中。加载模块加载相应的Jar包,并将Jar包放入到执行模块的类加载器中。In step 304, the loading module searches for the corresponding interface in the local storage module according to the interface name and related parameters passed by the parsing module. For the Java native interface, it is pre-packaged into a Jar package, and the Jar package is updated to the local storage of the terminal system through the interface update module. The loading module loads the corresponding Jar package, and puts the Jar package into the class loader of the execution module.

在步骤305,执行模块获取Jar包中的类,将指定一个路径将jar包或者类文件加载到类空间。加载完毕后,直接调用ClassLoader就可以加载指定的类,然后,通过反射生成实例或者调用方法来执行调用本地接口,并将其执行结果通过http链接返回给Web应用。In step 305, the execution module obtains the classes in the Jar package, and specifies a path to load the jar package or class file into the class space. After loading, directly call ClassLoader to load the specified class, then generate an instance through reflection or call a method to execute the call to the local interface, and return the execution result to the Web application through the http link.

下面通过一个具体实例来更清楚地了解本发明接口调用方法的流程。在本具体实例中,原生接口以C/C++接口的形式存在于终端系统中。图4为根据本发明又一个实施例的Web应用调用原生接口的流程图,如图4所示:A specific example is used below to understand more clearly the flow of the interface calling method of the present invention. In this specific example, the native interface exists in the terminal system in the form of a C/C++ interface. Fig. 4 is a flow chart of calling a native interface by a Web application according to yet another embodiment of the present invention, as shown in Fig. 4:

在步骤401,Web应用发出调用接口请求;In step 401, the web application sends a call interface request;

在步骤402,原生接口管理引擎中的接口执行模块监听通过JavaScript方式调用本地接口的事件,并通过http链接中的扩展参数传递请求调用的接口名称和相关参数;In step 402, the interface execution module in the native interface management engine monitors the event of invoking the local interface through JavaScript, and transmits the interface name and related parameters of the requested invocation through the extended parameters in the http link;

在步骤403,接口执行模块中的解析模块解析Web应用调用接口的接口名称及相关参数,并将解析后的内容传递给加载模块;In step 403, the parsing module in the interface execution module parses the interface name and related parameters of the Web application calling interface, and passes the parsed content to the loading module;

在步骤404,加载模块则根据解析模块传递的接口名称和相关参数在本地存储中查找对应的接口。对于C/C++接口,采用动态链接库的形式加载。In step 404, the loading module searches the local storage for the corresponding interface according to the interface name and related parameters passed by the parsing module. For the C/C++ interface, it is loaded in the form of a dynamic link library.

在步骤405,执行模块利用dlopen,dlsym等系列库函数以指定模式打开指定的动态连接库文件,通过句柄和连接符名称获取函数名或者变量名,并返回一个句柄给调用进程,执行模块以动态链接库的形式实现接口的查找、加载与运行。In step 405, the execution module uses dlopen, dlsym and other series of library functions to open the specified dynamic link library file in the specified mode, obtains the function name or variable name through the handle and the connector name, and returns a handle to the calling process, and the execution module dynamically The search, loading and operation of the interface are realized in the form of a link library.

图5为根据本发明实施例的更新原生接口模块的流程图,如图5所示:Fig. 5 is the flow chart of updating native interface module according to the embodiment of the present invention, as shown in Fig. 5:

在步骤501,原生接口管理引擎中的接口更新模块检测本地系统的接口更新或扩充需求,并向接口管理服务器发出接口更新或扩充请求;In step 501, the interface update module in the native interface management engine detects the interface update or expansion requirements of the local system, and sends an interface update or expansion request to the interface management server;

在步骤502,接口管理服务器对该接口更新或扩充请求进行响应,应当理解,该请求也可以来自用户;In step 502, the interface management server responds to the interface update or expansion request, it should be understood that the request may also come from the user;

在步骤503,接口管理服务器判断是否进行接口更新或扩充操作。基于判断,如果接受该请求,则流程进行到步骤504;如果拒绝该请求,则流程返回到步骤502。In step 503, the interface management server determines whether to perform an interface update or expansion operation. Based on the judgment, if the request is accepted, the process proceeds to step 504; if the request is rejected, the process returns to step 502.

在步骤504,接口管理服务器向原生接口管理引擎的接口更新模块返回接口更新或扩充命令。应当理解,当用户向接口管理服务器发起更新或扩充接口请求时,接口管理服务器也向原生接口管理引擎的接口更新模块发起接口更新或扩展命令,具体实施与上述操作类似,在此不再赘述。In step 504, the interface management server returns an interface update or extension command to the interface update module of the native interface management engine. It should be understood that when the user initiates an interface update or extension request to the interface management server, the interface management server also initiates an interface update or extension command to the interface update module of the native interface management engine. The specific implementation is similar to the above operation and will not be repeated here.

在步骤505,原生接口管理引擎接收到接口管理服务器的接口更新或扩充命令后,调用下载模块进行接口更新;In step 505, after receiving the interface update or expansion command from the interface management server, the native interface management engine invokes the download module to update the interface;

在步骤506,在接口下载更新后,调用校验模块验证接口的完整性与可靠性;In step 506, after the interface is downloaded and updated, call the verification module to verify the integrity and reliability of the interface;

在步骤507,由更新模块将校验通过的接口加载到本地存储中。In step 507, the interface that passes the verification is loaded into the local storage by the update module.

本发明的优点在于,嵌入式终端无需升级Web应用或浏览器内核,就可以为Web应用提供新的或修改后的原生接口方法。应当理解,本发明中的原生接口并不是集成在单个Web应用中,而是通过RESTFULAPI的机制提供给所有Web应用调用,因此对于同一份接口无需每个应用都集成,提高了接口的易用性。本领域技术人员应当理解,替代于Web应用,说明书中描述的多个实施例同样适合由Web浏览器内核发出对原生接口的调用请求的情况。另外,虽然图1中的一部分子模块虽没有“模块”二字,但也应理解为对应上述的各模块的描述。The advantage of the present invention is that the embedded terminal can provide a new or modified native interface method for the Web application without upgrading the Web application or the browser kernel. It should be understood that the native interface in the present invention is not integrated in a single web application, but is provided to all web application calls through the RESTFUL API mechanism, so it is not necessary to integrate every application for the same interface, which improves the usability of the interface . Those skilled in the art should understand that, instead of web applications, the multiple embodiments described in the specification are also suitable for the situation where the web browser kernel issues a call request to the native interface. In addition, although some sub-modules in FIG. 1 do not have the word "module", they should also be understood as corresponding to the descriptions of the above-mentioned modules.

专业人员应该还可以进一步意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、计算机软件或者二者的结合来实现,为了清楚地说明硬件和软件的可互换性,在上述说明中已经按照功能一般性地描述了各示例的组成及步骤。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本发明的范围。Professionals should further realize that the units and algorithm steps described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the relationship between hardware and software Interchangeability. In the above description, the composition and steps of each example have been generally described according to their functions. Whether these functions are executed by hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art may use different methods to implement the described functions for each specific application, but such implementation should not be regarded as exceeding the scope of the present invention.

结合本文中所公开的实施例描述的方法或算法的步骤可以用硬件、处理器执行的软件模块,或者二者的结合来实施。软件模块可以置于随机存储器(RAM)、内存、只读存储器(ROM)、电可编程ROM、电可擦除可编程ROM、寄存器、硬盘、可移动磁盘、CD-ROM、或技术领域内所公知的任意其它形式的存储介质中。The steps of the methods or algorithms described in connection with the embodiments disclosed herein may be implemented by hardware, software modules executed by a processor, or a combination of both. Software modules can be placed in random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other Any other known storage medium.

以上所述的具体实施方式,对本发明的目的、技术方案和有益效果进行了进一步详细说明。所应理解的是,以上所述仅为本发明的具体实施方式而已,并不用于限定本发明的保护范围。凡在本发明的精神和原则之内,所做的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。The specific implementation manners described above further describe the purpose, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above descriptions are only specific implementations of the present invention, and are not intended to limit the protection scope of the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention shall be included within the protection scope of the present invention.

Claims (10)

CN201510937805.3A2015-12-152015-12-15A kind of methods, devices and systems of dynamic call native interfaceActiveCN105389222B (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN201510937805.3ACN105389222B (en)2015-12-152015-12-15A kind of methods, devices and systems of dynamic call native interface

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN201510937805.3ACN105389222B (en)2015-12-152015-12-15A kind of methods, devices and systems of dynamic call native interface

Publications (2)

Publication NumberPublication Date
CN105389222Atrue CN105389222A (en)2016-03-09
CN105389222B CN105389222B (en)2018-12-21

Family

ID=55421529

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN201510937805.3AActiveCN105389222B (en)2015-12-152015-12-15A kind of methods, devices and systems of dynamic call native interface

Country Status (1)

CountryLink
CN (1)CN105389222B (en)

Cited By (27)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN106484467A (en)*2016-09-222017-03-08浪潮软件集团有限公司Method for loading dynamic library in jar package by java
CN106502668A (en)*2016-10-202017-03-15武汉斗鱼网络科技有限公司A kind of interface package method for realizing Android JNI reflections and system
CN106850756A (en)*2016-12-292017-06-13广州凯耀资产管理有限公司A kind of method and system for realizing web page and locally applied communication
CN107239265A (en)*2016-03-282017-10-10阿里巴巴集团控股有限公司The binding method and device of Java functions and C function
CN107451162A (en)*2016-06-012017-12-08广州市动景计算机科技有限公司Network resource accession equipment, mixing apparatus and method
CN107592358A (en)*2017-09-192018-01-16广州视源电子科技股份有限公司Application program interface calling method and device based on HTTP service
CN107885502A (en)*2017-11-102018-04-06广州市千钧网络科技有限公司Interface processing method, processing unit, interface managerial method and managing device
CN108345507A (en)*2017-01-222018-07-31腾讯科技(深圳)有限公司Communication means and device between a kind of JS modules and Java modules
CN108363590A (en)*2018-05-172018-08-03珠海横琴盛达兆业科技投资有限公司A kind of method of webpage version free switching computer camera
CN108804243A (en)*2018-05-232018-11-13北京五八信息技术有限公司A kind of exchange method, device, computer equipment and computer readable storage medium
CN109032583A (en)*2018-07-252018-12-18北京小米移动软件有限公司Data interactive method and device
CN109388430A (en)*2017-08-022019-02-26丰郅(上海)新能源科技有限公司Realize microprocessor to the method for peripheral hardware hardware controls
CN109684106A (en)*2018-12-242019-04-26国网江苏省电力有限公司A method of supporting more mobile browser engine load operatings
CN109902500A (en)*2019-03-112019-06-18北京城市网邻信息技术有限公司A kind of method and system for realizing calling service data safety by chained library
CN110187940A (en)*2019-05-302019-08-30深圳市康冠商用科技有限公司A kind of interface package method, system and electronic equipment and storage medium
CN110673892A (en)*2019-09-172020-01-10中电万维信息技术有限责任公司Interface unified calling method based on component configuration
CN110673970A (en)*2019-09-292020-01-10郑州信大捷安信息技术股份有限公司Cross-process calling system and method based on web application
CN110688180A (en)*2019-09-032020-01-14无锡华云数据技术服务有限公司Front-end system, front-end data flow control method, electronic device and storage medium
CN110704131A (en)*2019-08-292020-01-17北京三快在线科技有限公司Method and device for calling native application by HTML5 application
CN110764836A (en)*2019-09-182020-02-07华为技术有限公司 Plug-in implementation method and plug-in implementation system
CN111176629A (en)*2019-12-242020-05-19中国建设银行股份有限公司Application development method and device
CN111880953A (en)*2020-07-312020-11-03北京致远互联软件股份有限公司Application program communication method and device, electronic equipment and storage medium
CN112035097A (en)*2020-08-252020-12-04华东计算技术研究所(中国电子科技集团公司第三十二研究所) C++ adaptation layer based on Galaxy Ruihua operating system
WO2020248172A1 (en)*2019-06-122020-12-17深圳市大疆创新科技有限公司Functional module invoking method, device and computer readable storage medium
CN112817783A (en)*2021-03-042021-05-18中国人民解放军国防科技大学Implementation method of digital wrist type terminal system
CN112866182A (en)*2019-11-282021-05-28浙江宇视科技有限公司Data interfacing method, device and computer-readable storage medium
CN114089975A (en)*2022-01-202022-02-25北京大学Expansion method and device of computing software, nonvolatile storage medium and processor

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN110610069A (en)*2019-09-092019-12-24苏州浪潮智能科技有限公司 A method and device for calling a REST interface in a web system

Citations (5)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
US20090150417A1 (en)*2007-12-052009-06-11Box.Net, Inc.Methods and systems for open source collaboration in an application service provider environment
CN103176834A (en)*2011-12-262013-06-26腾讯科技(深圳)有限公司Method and device for calling expansion interface
CN103645904A (en)*2013-12-202014-03-19北京京东尚科信息技术有限公司Cache realization method of interface calling
CN104281455A (en)*2014-10-112015-01-14北京金山安全软件有限公司Interface calling method and device and terminal
CN104932910A (en)*2014-03-202015-09-23中国移动通信集团公司Method and system for application program interface extension

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
US20090150417A1 (en)*2007-12-052009-06-11Box.Net, Inc.Methods and systems for open source collaboration in an application service provider environment
CN103176834A (en)*2011-12-262013-06-26腾讯科技(深圳)有限公司Method and device for calling expansion interface
CN103645904A (en)*2013-12-202014-03-19北京京东尚科信息技术有限公司Cache realization method of interface calling
CN104932910A (en)*2014-03-202015-09-23中国移动通信集团公司Method and system for application program interface extension
CN104281455A (en)*2014-10-112015-01-14北京金山安全软件有限公司Interface calling method and device and terminal

Cited By (45)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN107239265A (en)*2016-03-282017-10-10阿里巴巴集团控股有限公司The binding method and device of Java functions and C function
CN107239265B (en)*2016-03-282020-04-07阿里巴巴集团控股有限公司Binding method and device of Java function and C function
CN107451162A (en)*2016-06-012017-12-08广州市动景计算机科技有限公司Network resource accession equipment, mixing apparatus and method
CN106484467A (en)*2016-09-222017-03-08浪潮软件集团有限公司Method for loading dynamic library in jar package by java
CN106502668B (en)*2016-10-202019-08-23武汉斗鱼网络科技有限公司A kind of interface package method and system for realizing Android JNI reflection
CN106502668A (en)*2016-10-202017-03-15武汉斗鱼网络科技有限公司A kind of interface package method for realizing Android JNI reflections and system
CN106850756A (en)*2016-12-292017-06-13广州凯耀资产管理有限公司A kind of method and system for realizing web page and locally applied communication
CN106850756B (en)*2016-12-292019-12-10航天信息(广东)有限公司Method and system for realizing communication between web page and local application
CN108345507B (en)*2017-01-222022-01-07腾讯科技(深圳)有限公司Communication method and device between JS module and Java module
CN108345507A (en)*2017-01-222018-07-31腾讯科技(深圳)有限公司Communication means and device between a kind of JS modules and Java modules
CN109388430A (en)*2017-08-022019-02-26丰郅(上海)新能源科技有限公司Realize microprocessor to the method for peripheral hardware hardware controls
CN107592358A (en)*2017-09-192018-01-16广州视源电子科技股份有限公司Application program interface calling method and device based on HTTP service
CN107885502A (en)*2017-11-102018-04-06广州市千钧网络科技有限公司Interface processing method, processing unit, interface managerial method and managing device
CN107885502B (en)*2017-11-102021-10-15广州市千钧网络科技有限公司Interface processing method, processing device, interface management method and management device
CN108363590A (en)*2018-05-172018-08-03珠海横琴盛达兆业科技投资有限公司A kind of method of webpage version free switching computer camera
CN108804243A (en)*2018-05-232018-11-13北京五八信息技术有限公司A kind of exchange method, device, computer equipment and computer readable storage medium
CN108804243B (en)*2018-05-232022-11-25北京五八信息技术有限公司Interaction method, interaction device, computer equipment and computer-readable storage medium
CN109032583A (en)*2018-07-252018-12-18北京小米移动软件有限公司Data interactive method and device
CN109032583B (en)*2018-07-252022-06-17北京小米移动软件有限公司Data interaction method and device
CN109684106A (en)*2018-12-242019-04-26国网江苏省电力有限公司A method of supporting more mobile browser engine load operatings
CN109902500B (en)*2019-03-112021-02-26北京城市网邻信息技术有限公司Method and system for realizing service call data security through link library
CN109902500A (en)*2019-03-112019-06-18北京城市网邻信息技术有限公司A kind of method and system for realizing calling service data safety by chained library
CN110187940A (en)*2019-05-302019-08-30深圳市康冠商用科技有限公司A kind of interface package method, system and electronic equipment and storage medium
WO2020248172A1 (en)*2019-06-122020-12-17深圳市大疆创新科技有限公司Functional module invoking method, device and computer readable storage medium
CN110704131B (en)*2019-08-292020-11-20北京三快在线科技有限公司Method and device for calling native application by HTML5 application
CN110704131A (en)*2019-08-292020-01-17北京三快在线科技有限公司Method and device for calling native application by HTML5 application
CN110688180B (en)*2019-09-032021-05-11华云数据控股集团有限公司Front-end system, front-end data flow control method, electronic device and storage medium
CN110688180A (en)*2019-09-032020-01-14无锡华云数据技术服务有限公司Front-end system, front-end data flow control method, electronic device and storage medium
CN110673892B (en)*2019-09-172023-01-03中电万维信息技术有限责任公司Interface unified calling method based on component configuration
CN110673892A (en)*2019-09-172020-01-10中电万维信息技术有限责任公司Interface unified calling method based on component configuration
CN110764836B (en)*2019-09-182024-02-09华为技术有限公司 Plug-in implementation method and plug-in implementation system
US11880695B2 (en)2019-09-182024-01-23Huawei Technologies Co., Ltd.Plug-in implementation method and plug-in implementation system
CN110764836A (en)*2019-09-182020-02-07华为技术有限公司 Plug-in implementation method and plug-in implementation system
CN110673970A (en)*2019-09-292020-01-10郑州信大捷安信息技术股份有限公司Cross-process calling system and method based on web application
CN110673970B (en)*2019-09-292022-12-23郑州信大捷安信息技术股份有限公司Cross-process calling system and method based on web application
CN112866182B (en)*2019-11-282023-05-23浙江宇视科技有限公司Data docking method, device and computer readable storage medium
CN112866182A (en)*2019-11-282021-05-28浙江宇视科技有限公司Data interfacing method, device and computer-readable storage medium
CN111176629A (en)*2019-12-242020-05-19中国建设银行股份有限公司Application development method and device
CN111176629B (en)*2019-12-242024-07-30中国建设银行股份有限公司Application development method and device
CN111880953A (en)*2020-07-312020-11-03北京致远互联软件股份有限公司Application program communication method and device, electronic equipment and storage medium
CN112035097B (en)*2020-08-252023-10-13华东计算技术研究所(中国电子科技集团公司第三十二研究所)C++ adaptation layer device based on Galaxy Ruihua operating system
CN112035097A (en)*2020-08-252020-12-04华东计算技术研究所(中国电子科技集团公司第三十二研究所) C++ adaptation layer based on Galaxy Ruihua operating system
CN112817783A (en)*2021-03-042021-05-18中国人民解放军国防科技大学Implementation method of digital wrist type terminal system
CN112817783B (en)*2021-03-042023-06-23中国人民解放军国防科技大学 A Realization Method of Digital Wrist Terminal System
CN114089975A (en)*2022-01-202022-02-25北京大学Expansion method and device of computing software, nonvolatile storage medium and processor

Also Published As

Publication numberPublication date
CN105389222B (en)2018-12-21

Similar Documents

PublicationPublication DateTitle
CN105389222A (en)Method, apparatus and system for dynamically calling native interface
US9235451B2 (en)Browser kernel switching method
CN103685251B (en)A kind of Android malware detection platform towards mobile Internet
US7779408B1 (en)Method and system for downloading and managing portable applications on a mobile device
CN104504060B (en)Method, browser client and the device of file are downloaded in browser
CN102073507B (en)Method, device and system for calling widget
US20150378864A1 (en)Systems and methods for instrumenting applications for performance monitoring
US9690761B1 (en)Systems and methods for providing mobile browser access to mobile device functionalities
CN106445583A (en)Page display method, equipment and system
CN106569856B (en)A kind of loading method and device of application view resource file
CN108647032B (en) Application loading method and apparatus, computer apparatus and computer-readable storage medium
CN106406961A (en)Method and device for loading and providing application based on browser
WO2011088714A1 (en)Method, device and system for running application
CN104636122B (en)The sharing method and equipment of a kind of capability component
CN110968331B (en) Methods and devices for running applications
CN106686038A (en) Method and device for invoking cloud desktop
CN105262608A (en)Monitoring method and monitoring device for network service
CN104615462A (en)Cross-platform mobile application generating server side and system
CN103152327A (en)Configuration method, client and system for plug-in unit compressing and uncompressing
CN103677956A (en)Method and device for simulating application operation of mobile equipment on calculating equipment
CN107798064A (en)Page processing method, electronic equipment and computer-readable recording medium
CN105955833A (en)Engine calling method and device
CN107391182A (en)Generation method, device, server and storage medium of theme installation package
CN102156650A (en) A method and device for automatic patch analysis
CN103258055B (en) A file downloading device and method

Legal Events

DateCodeTitleDescription
C06Publication
PB01Publication
C10Entry into substantive examination
SE01Entry into force of request for substantive examination
GR01Patent grant
GR01Patent grant
TR01Transfer of patent right

Effective date of registration:20210802

Address after:Room 1601, 16th floor, East Tower, Ximei building, No. 6, Changchun Road, high tech Industrial Development Zone, Zhengzhou, Henan 450001

Patentee after:Zhengzhou xinrand Network Technology Co.,Ltd.

Address before:100190, No. 21 West Fourth Ring Road, Beijing, Haidian District

Patentee before:INSTITUTE OF ACOUSTICS, CHINESE ACADEMY OF SCIENCES

TR01Transfer of patent right

[8]ページ先頭

©2009-2025 Movatter.jp