[ summary of the invention ]
In view of the foregoing, the present invention provides a method, apparatus, and computer storage medium for starting an applet to save resources.
The specific technical scheme is as follows:
in one aspect, the present invention provides a method for starting an applet, which is executed by a host application of a terminal device, and includes:
acquiring an event for triggering the start of the small program;
confirming whether a file packet with the applet stored in the host application exists in the terminal equipment;
if so, starting the small program by using the file package of the small program;
otherwise, downloading and storing the small program file package from the server side to start the small program, and setting the storage position of the small program file package to be readable by other host applications.
According to a preferred embodiment of the present invention, the determining whether the terminal device has a file package in which the applet is stored by the host application includes: confirming each host application belonging to the same host alliance with the host application in the terminal equipment, and judging whether each determined host application stores the file packet of the small program or not;
setting the storage position of the file packet of the applet to be readable by other host applications, wherein the setting comprises the following steps: setting the storage position of the file packet of the applet to be readable for each host application belonging to the same host alliance with the host application;
wherein, each host application in the same host alliance adopts the same applet standard.
According to a preferred embodiment of the invention, the method further comprises:
and the slave server side synchronizes the information of each host application belonging to the same host alliance with the host application, and determines the host application information of the host alliance which is installed by the terminal equipment.
According to a preferred embodiment of the present invention, the determining whether the terminal device has a file package in which the applet is stored by the host application includes:
and judging whether a host application stores the file packet of the applet or not in the terminal equipment, wherein the file packet of the applet meets the version requirement of the host application.
According to a preferred embodiment of the present invention, after the downloading and storing the package of the applet from the server, the method further comprises:
and reporting the status of the file packet of the local host application storage applet to a server so that other host applications of the terminal equipment can be acquired from the server.
According to a preferred embodiment of the invention, the method further comprises:
after the host application is started, acquiring the status of the file package of each host application storage applet in the terminal equipment from a server side, and storing the status in a private database of the host application;
and inquiring the private database to execute the step of confirming whether the file packet with the applet stored in the host application exists in the terminal equipment.
According to a preferred embodiment of the present invention, after the downloading and storing the package of the applet from the server, the method further comprises:
and synchronizing the state of the host application storing the file packet of the applet to a shared database in the terminal equipment so that other host applications of the terminal equipment can be obtained from the shared database.
According to a preferred embodiment of the present invention, the storage location of the applet package is under a private directory of the host application.
According to a preferred embodiment of the present invention, the determining whether the terminal device has a file package in which the applet is stored by the host application includes:
firstly, determining whether a file package of the small program exists under a private directory applied by a host;
if the small program does not exist, judging whether the terminal equipment has the file package of the small program stored in other host applications, and if so, reading the file package of the small program from the private directories of the other host applications of the file package of the small program.
According to a preferred embodiment of the present invention, the determining whether the terminal device has a file package in which the applet is stored by the host application includes: judging whether the shared storage space of the terminal equipment stores the file packet of the small program or not;
the downloading and storing of the package of the applet from the server side comprises: and downloading the small program file package from the server and storing the small program file package in the shared storage space of the terminal equipment.
In a second aspect, the present invention provides a method for starting an applet, where the method is executed by a server corresponding to a host application, and the method includes:
receiving the status of the file packet of the host application storage applet reported by the corresponding host application; and synchronizing the state of the file package of the applet stored by other host applications from the server side of other host applications;
integrating the conditions of the file packages of all host application storage applets in the same terminal equipment;
and synchronizing the status of the file packet of each host application storage applet in the terminal equipment where the host application is located to the corresponding host application so as to enable the corresponding host application to start the applet for use.
According to a preferred embodiment of the invention, the method further comprises:
and synchronizing the information of each host application belonging to the same host alliance with the corresponding host application to the corresponding host application, wherein the same applet standard is adopted by each host application in the same host alliance.
According to a preferred embodiment of the present invention, the integrating the status of the file package of each hosted application storage applet in the same terminal device includes:
and merging and de-duplicating the condition of the file packet of the host application storage small program stored by the server side and the condition of the file packet of each host application storage small program synchronized from the server sides of other host applications aiming at the same terminal equipment.
In a third aspect, the present invention provides an apparatus comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement a method as in any above.
In a fourth aspect, the present invention provides a storage medium containing computer-executable instructions for performing a method as described in any one of the above when executed by a computer processor.
According to the technical scheme, all hosts in the same terminal equipment share the downloaded applet file package to start the applet, so that the problem of repeated downloading of the applet is solved, and resources are saved.
[ detailed description ] embodiments
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in detail with reference to the accompanying drawings and specific embodiments.
In order to facilitate an understanding of the present invention, a system architecture and a main concept to which the present invention relates will be described first. As shown in fig. 1, the system architecture mainly includes a host application and a server corresponding to the host application.
The small program runs on the terminal equipment depending on the host application, and the environment where the small program runs is provided by the host application. Wherein the terminal devices may include, but are not limited to, devices such as: intelligent mobile terminals, intelligent home devices, network devices, wearable devices, intelligent medical devices, PCs (personal computers), and the like. Wherein the smart mobile device may include devices such as a cell phone, a tablet computer, a notebook computer, a PDA (personal digital assistant), an internet automobile, etc. The smart home device may include a smart home device, such as a smart television, a smart sound box, and the like. The network devices may include devices such as switches, wireless APs, servers, and the like. Wearable devices may include devices such as smart watches, smart glasses, smart bracelets, virtual reality devices, augmented reality devices, mixed reality devices (i.e., devices that can support virtual reality and augmented reality), and so forth.
Multiple host applications may be contained in the same terminal device, and fig. 1 illustrates an example of the host application 1 and the host application 2. Multiple applets may also be run in one host application, and different host applications may run different applets, or the same applet. As shown in fig. 1, an applet a and an applet b are run in the host application 1, and an applet b and an applet c are run in the host application 2.
Each host application has a corresponding server side, as shown in fig. 1, a host application 1 corresponds to a server side 1, and a host application 2 corresponds to a server side 2. Each host application can interact with the corresponding server side, and in the embodiment of the invention, data interaction can be performed between different server sides.
Each server may be a single server or a server group consisting of a plurality of servers. It should be understood that the number of terminal devices, hosting applications, applets, server sides in fig. 1 is merely illustrative. Any number of terminal devices, host applications, applets, server sides may be present, as desired for implementation.
The core idea of the invention is that all hosts in the same terminal equipment share the downloaded applet file package to start the applet, thereby realizing the problem of repeated downloading of the applet and saving resources. Fig. 2 is a flowchart of a main method provided in an embodiment of the present invention, where the method is executed by a host application of a terminal device, and an execution device may be a functional unit located in the host application of the terminal device, such as a plug-in or a Software Development Kit (SDK). As shown in fig. 2, the method mainly includes the following steps:
in 201, an event is acquired that triggers the start of an applet.
The invention is not limited to the type of event that triggers the launching of the applet in the host application, and for example, the user may click the applet icon in the host application to trigger the launching of the applet, or the user may click a link in the host application to trigger the launching of the corresponding applet, and so on.
In 202, confirming whether a file package with the applet stored in the host application exists in the terminal equipment, if so, executing 203; otherwise, 204 is performed.
Since the applet does not need to be installed in the host application, the package of the applet involved in the embodiment of the present invention is not an installation package, but contains the applet files required for starting the applet and running the applet, and may include, for example: source files, compressed code, resource files, and the like.
At 203, the applet is started using the package of the applet and the process ends.
If the host application already stores the file package of the applet in the terminal device, the applet can be started by directly utilizing the stored file package of the applet without repeated downloading.
At 204, the applet is started by downloading and storing the applet package from the server side, and the storage location of the applet package is set to be readable by other host applications.
If the host application does not store the file package of the applet in the terminal equipment, the file package of the applet needs to be downloaded from the server side and stored. In order for the package of applets downloaded to be usable by other hosting applications, the storage location of the package is readable by other hosting applications in addition to the storage location where the application can read the package.
In the embodiment of the present invention, a way of sharing a stored package of applets by a host application in the same terminal device is adopted, wherein the sharing way may adopt, but is not limited to, the following several ways:
the first mode is as follows: and the host application stores the downloaded applet file package in a private directory of the host application, and the private directory is set to be readable to other host applications. And meanwhile, the host application reports the status of the file package for storing the small program to the corresponding server side, and the server side of each host application synchronizes the status of the file package for storing the small program by the host application, so that other host applications can acquire the status of the file package for storing the small program by each host application in the same terminal equipment from the corresponding server side.
That is, in the first mode, the applet packages are stored in the private directory of the host application by the host application, and the states of the applet packages stored by the host applications are synchronized at the server side and acquired from the server side.
The second mode is as follows: and the host application stores the downloaded applet file package in a private directory of the host application, and the private directory is set to be readable to other host applications. Meanwhile, the host application records the status of the file package storing the small programs in a shared database in the terminal equipment. And each host application can acquire the storage condition of the applet file package from the shared database.
The third mode is as follows: and the host application stores the downloaded applet file packages in the shared storage space of the terminal equipment, and all the host applications in the terminal equipment read the applet file packages from the shared storage space to start the applets.
The above three modes will be described in detail with reference to specific embodiments. In addition, it should be noted that it is desirable that all host applications use the same applet standard. Often times, however, in practice, some host applications use the same applet standard, while other host applications use other applet standards. Then a hosting application that employs the same applet standards may be referred to as a hosting federation. The method for sharing the applet file package provided by the embodiment of the invention is adopted for each host application belonging to the same host alliance. And the host applications belong to the same host alliance, the host applications can be uniformly configured at the server side, and then the host applications are obtained from the server side. In the following embodiments, the manner in which the applet packages are shared by the hosting applications of the same hosting federation is described as an example. In addition, for all the host applications of the host alliance, a uniform naming mechanism is adopted for the file packages of all the applets, so that the corresponding applets can be known through the file package names of the applets.
The first embodiment,
Fig. 3 is a flowchart of a method according to an embodiment of the present invention, and the first implementation manner is described in this embodiment. Assuming that the user wants to start the applet c in the host application 1, as shown in fig. 3, the method performed by the host application 1 may include the following processes:
in 301, when the host application 1 is started, the information of the host federation is synchronized from the server and stored in the database local to the host application 1.
When the host application 1 is started, a synchronization request of the host federation may be sent to the corresponding server side, and the corresponding server side returns information of each host application of the host federation, such as a packet name, to the host application 1. The host application 1 can then determine the host application information of the host alliance that the terminal device has installed.
When the host application 1 is started, the locally installed application program of the terminal device can be scanned, and then the host application information of the host alliance installed in the terminal device can be determined by further using the information of the host alliance synchronized from the server, and the information of the host application can be stored in a database of the host application in a list form.
For example, it is assumed that the information of the hosting federation sent by the server includes: host application 1, host application 2, host application 3, host application 4 … …. After scanning the terminal device, the host application 1 finds that the terminal device is provided with the host application 1 and the host application 2, and then the host application 1 can store the information of the host application 1 and the host application 2 in a local database of the host application 1.
In 302, after the host application 1 is started, the server synchronizes the status of the applet storage packages of each host application in the same host federation in the terminal device, and stores the applet storage packages in the local database of the host application 1.
That is, after the host application 1 is started, it can be obtained from the server side which applet file packages, including package names, version numbers, etc., are stored in all the host applications of the host alliance in the terminal device.
In the above example, if the host application 1 obtains from the server side that the host application 1 stores the applet a and the applet b, and the host application 2 stores the applet b and the applet c, the information is stored in the local database of the host application 1.
In 303, after an event that the applet c is started in the host application 1 is acquired, whether a file package of the applet c is stored in a private directory of the host application 1 is judged, and if so, 304 is executed; otherwise 305 is performed.
In 304, the applet c is started by using the file package of the applet c stored in the private directory of the host application 1, and the starting process is ended.
In 305, a local database of the host application 1 is queried, whether other host applications of the same host alliance store the file package of the applet c is determined, and if so, 306 is executed; otherwise, 307 is performed.
In this step, it is determined whether other hosted applications of the same hosted federation store the package of the applet c on the one hand, and whether the stored package of the applet c meets the version requirement of the hosted application 1 on the other hand, if both are met, 306 is executed, otherwise 307 is executed. Typically the host application 1 considers the version requirements to be met if the required version is lower than or equal to the version of the applet c stored by the other host application.
In 306, the host application 1 reads the file package of the applet c from the private directories of other host applications, and starts the applet c in the host application 1, and ends the start process.
For example, if the host application 2 stores the package of the applet c already, the host application 1 reads the package of the applet c from the private directory of the host application 2 to start the applet c.
In 307, the host application 1 downloads the package of the applet c from the corresponding server, stores the package in the private directory of the host application 1, and sets the authority of the private directory to be readable by each host application of the host federation.
As a preferred embodiment, in order to ensure the security of the content in the private directory, the authority of the private directory may be set to be readable and unwritable by each host application of the host federation.
In 308, the host application 1 starts the applet c by using the downloaded package, and reports the status of the package storing the applet c to the server.
In this embodiment, the flow shown in fig. 4 may be executed for the server side, and includes:
in 401, a status of a file package of the applet stored in the host application reported by the corresponding host application is received.
When the host application reports the status of the file packet storing the applet, the host application can carry information such as a terminal device identifier, a host application identifier, an applet identifier, and an applet version number. And after receiving the information, the server side carries out corresponding maintenance on a local database of the server side.
For example, a relationship item "terminal device identification-hosting application identification-applet version number" is maintained.
At 402, the status of the package of files of the applet stored by the other hosting applications is synchronized from the server side of the other hosting applications.
The above 401 and 402 are not necessarily performed in the above order, and the synchronization in step 402 may be periodically or based on an event trigger.
The server side of each host application can open an interface for synchronization aiming at the host alliance, and the server side can synchronize the status of the file packet of each host application storage applet stored in the local database to other server sides in the host alliance.
At 403, the status of the package of files of the storage applet by each hosting application in the same terminal device is integrated.
The conditions stored in the local database of the server and the conditions synchronized from other servers are in the forms of terminal device identification, host application identification, applet identification and applet version number, and information under the same terminal device identification can be merged and subjected to deduplication processing, so that the conditions of the file packets of the applets stored in the hosts under the same terminal device identification can be obtained.
In 404, the status of the package of the applet stored by each host application in the terminal device where the host application is located is synchronized with the corresponding host application, so as to be used by the corresponding host application to start the applet.
The terminal device identifier of the hosting application may be obtained in a situation such as step 302 in fig. 3, and a situation of a file package of each hosting application storage applet under the terminal device identifier is issued thereto.
Example II,
Fig. 5 is a flowchart of a method provided in a second embodiment of the present invention, and the second implementation manner is described in this embodiment. Assuming that the user wants to start the applet c in the host application 1, as shown in fig. 5, the method performed by the host application 1 may include the following processes:
in 501, an event of the start of applet c in the host application 1 is obtained.
In 502, judging whether a file package of the applet c is stored in the private directory of the host application 1, if so, executing 503; otherwise 504 is performed.
At 503, the applet c is started by using the package of the applet c stored in the private directory of the host application 1, and the starting process is ended.
In 504, inquiring a shared database of the terminal device, determining whether other host applications of the same host alliance store the file package of the applet c, and if so, executing 505; otherwise, 506 is performed.
In the embodiment of the present invention, a shared database may be set in the terminal device, and the shared database opens read-write permission to all the host applications in the host federation. The shared database maintains the status of the file package of each hosted application storage applet in the terminal device under the hosting federation, including, for example, the package name and version number.
In this step, it is also determined whether other hosted applications of the same hosted federation store the package of the applet c on the one hand, and on the other hand, whether the stored package of the applet c meets the version requirement of the hosted application 1, if both are met, the step is executed 505, otherwise, the step is executed 506. Typically the host application 1 considers the version requirements to be met if the required version is lower than or equal to the version of the applet c stored by the other host application.
In 505, the host application 1 reads the file package of the applet c from the private directories of other host applications, and starts the applet c in the host application 1, and ends the start process.
For example, if the host application 2 stores the package of the applet c already, the host application 1 reads the package of the applet c from the private directory of the host application 2 to start the applet c.
In 506, the host application 1 downloads the package of the applet c from the corresponding server, stores the package in the private directory of the host application 1, and sets the authority of the private directory to be readable by each host application of the host federation.
As a preferred embodiment, in order to ensure the security of the content in the private directory, the authority of the private directory may be set to be readable and unwritable by each host application of the host federation.
At 507, the host application 1 starts the applet c using the downloaded package and records the status of the package storing the applet c in the shared database.
Example III,
Fig. 6 is a flowchart of a method provided by a third embodiment of the present invention, and the third implementation manner is described in this embodiment. Assuming that the user wants to start an applet c in the host application 1, as shown in fig. 6, the method may include the following processes:
in 601, the host application 1 gets the event that applet c starts.
In 602, the host application 1 determines whether the shared storage space of the terminal device stores the package of the applet c, and if so, executes 603; otherwise, 604 is performed.
In this embodiment, a shared storage space is set in the terminal device, and the shared storage space opens read-write permission for each host application in the host federation. The host applications in the host alliance all store the downloaded applet file package in the shared storage space to share in the host alliance range.
In this step, it is also determined whether the shared storage space stores the package of the applet c on the one hand, and whether the stored package of the applet c meets the version requirement of the host application 1 on the other hand, if both are met, 603 is executed, otherwise 604 is executed. Typically the host application 1 considers the version requirements to be met if the version required is lower than or equal to the version of the applet c already stored.
In 603, the host application 1 reads the file package of the applet c from the shared storage space, starts the applet c, and ends the start process.
At 604, the host application 1 downloads the package of the applet c from the corresponding server and stores the package in the shared storage space of the terminal device.
For the host application 1, the higher version of the package of the applet c needs to be downloaded due to the version, and the existing lower version of the package of the applet c in the shared storage space may be retained or deleted.
The form of the shared memory space is not limited in the present invention, and for example, SDCard may be used, and other forms of shared memory space may also be used.
At 605, the host application 1 starts applet c using the downloaded package.
Fig. 7 illustrates a block diagram of an exemplary computer system 012 suitable for use to implement an embodiment of the invention. The computer system 012 shown in fig. 7 is only an example, and should not bring any limitation to the function and the scope of use of the embodiment of the present invention.
As shown in fig. 7, the computer system 012 is represented in the form of a general purpose computing device. The components of computer system 012 may include, but are not limited to: one or more processors or processing units 016, a system memory 028, and a bus 018 that couples various system components including the system memory 028 and the processing unit 016.
Bus 018 represents one or more of any of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, or a local bus using any of a variety of bus architectures. By way of example, such architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, micro-channel architecture (MAC) bus, enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
The computer system 012 typically includes a variety of computer system readable media. These media may be any available media that may be accessed by computer system 012 and includes both volatile and nonvolatile media, removable and non-removable media.
System memory 028 can include computer system readable media in the form of volatile memory, such as Random Access Memory (RAM)030 and/or cache memory 032. The computer system 012 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, storage system 034 may be used to read from and write to non-removable, nonvolatile magnetic media (not shown in FIG. 7, commonly referred to as a "hard drive"). Although not shown in FIG. 7, a magnetic disk drive for reading from and writing to a removable, nonvolatile magnetic disk (e.g., a "floppy disk") and an optical disk drive for reading from or writing to a removable, nonvolatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In such cases, each drive may be connected to bus 018 via one or more data media interfaces. System memory 028 can include at least one program product having a set (e.g., at least one) of program modules configured to carry out the functions of embodiments of the present invention.
Program/utility 040 having a set (at least one) of program modules 042 may be stored, for example, in system memory 028, such program modules 042 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which examples or some combination thereof may comprise an implementation of a network environment. Program modules 042 generally perform the functions and/or methodologies of embodiments of the present invention as described herein.
The computer system 012 may also communicate with one or more external devices 014 (e.g., keyboard, pointing device, display 024, etc.), hi the present invention, the computer system 012 communicates with an external radar device, and may also communicate with one or more devices that enable a user to interact with the computer system 012, and/or with any devices (e.g., network card, modem, etc.) that enable the computer system 012 to communicate with one or more other computing devices. Such communication may occur through an input/output (I/O) interface 022. Also, the computer system 012 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network such as the internet) via the network adapter 020. As shown, the network adapter 020 communicates with the other modules of the computer system 012 via bus 018. It should be appreciated that although not shown in fig. 7, other hardware and/or software modules may be used in conjunction with the computer system 012, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
The processing unit 016 executes programs stored in the system memory 028, thereby executing various functional applications and data processing, such as implementing the method flow provided by the embodiment of the present invention.
The computer program described above may be provided in a computer storage medium encoded with a computer program that, when executed by one or more computers, causes the one or more computers to perform the method flows and/or apparatus operations shown in the above-described embodiments of the invention. For example, the method flows provided by the embodiments of the invention are executed by one or more processors described above.
With the development of time and technology, the meaning of media is more and more extensive, and the propagation path of computer programs is not limited to tangible media any more, and can also be downloaded from a network directly and the like. Any combination of one or more computer-readable media may be employed. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like made within the spirit and principle of the present invention should be included in the scope of the present invention.