CN114253587A - Application program updating method and device, electronic equipment and readable storage medium - Google Patents

Application program updating method and device, electronic equipment and readable storage medium Download PDF

Info

Publication number
CN114253587A
CN114253587A CN202111555175.5A CN202111555175A CN114253587A CN 114253587 A CN114253587 A CN 114253587A CN 202111555175 A CN202111555175 A CN 202111555175A CN 114253587 A CN114253587 A CN 114253587A
Authority
CN
China
Prior art keywords
file
java
target
java object
application
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.)
Pending
Application number
CN202111555175.5A
Other languages
Chinese (zh)
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.)
Zhongdian Jinxin Software Co Ltd
Original Assignee
Zhongdian Jinxin Software 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 Zhongdian Jinxin Software Co Ltd filed Critical Zhongdian Jinxin Software Co Ltd
Priority to CN202111555175.5A priority Critical patent/CN114253587A/en
Publication of CN114253587A publication Critical patent/CN114253587A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • G06F8/656Updates while running
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading

Abstract

The embodiment of the application provides an application program updating method and device, electronic equipment and a readable storage medium, and relates to the technical field of computers. The method comprises the following steps: the method comprises the steps of monitoring file state information of a Java archive file of a target application, if the file state information changes, indicating that the file content of the Java archive file changes, further determining first version information of at least one Java object of the Java archive file loaded into a memory, detecting the at least one Java object based on the Java archive file and the determined first version information, and if the detection result shows that the changed target Java object exists in the at least one Java object, automatically loading the target Java object in the running process of the target application, so that the target application is updated in the running state of the application program, the application program does not need to be stopped or restarted, the waiting time of a user is reduced, and the user experience is improved.

Description

Application program updating method and device, electronic equipment and readable storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to an application updating method and apparatus, an electronic device, and a readable storage medium.
Background
For a piece of application software, if the application software occupies the market for a long time, various functions of the application software need to be continuously perfected according to market demands and technical development, and various update data packets can be written according to needs so as to update the application software through the update data packets.
Currently, multiple classes or/and objects may be included within the update package. If the class or/and the object of the application software content need to be modified or added according to the update data packet, the application software needs to be stopped from running, and the application software can be updated based on the update data packet, so that the application software cannot run for a period of time.
Disclosure of Invention
The embodiment of the application aims to solve the technical problem that the application program needs to be stopped and restarted when being updated.
In a first aspect, an application program updating method is provided, and the method includes:
monitoring file state information of a Java archive file of a target application in a running state; the Java archive file comprises at least one Java object;
if the file state information changes, determining first version information of at least one Java object of the Java archive file loaded into the memory before the file state information changes;
detecting at least one Java object based on the Java archive file and the first version information;
and if the detection result is that at least one Java object has a changed target Java object, loading the target Java object in the running process of the target application so as to update the target application.
In an optional embodiment of the first aspect, before determining, if the file state information changes, first version information of at least one Java object of the Java archive file that was loaded into the memory before the file state information changed, the method further comprises:
monitoring file state information of a Java archive file of a target application according to a preset time interval to obtain current file state information;
and if the current file state information is different from the last acquired file state information of the Java archive file, determining that the file state information changes.
In an optional embodiment of the first aspect, the detecting at least one Java object based on the Java archive file and the first version information comprises:
for each Java object, acquiring current second version information of the Java object from a Java archive file;
and comparing the first version information and the second version information corresponding to the Java object aiming at each Java object, if the first version information and the second version information of the Java object are different, determining that the Java object is changed, and taking the Java object as a target Java object.
In an optional embodiment of the first aspect, loading the target Java object during running of the target application comprises:
determining a target class loader corresponding to the target Java object aiming at each target Java object;
and loading the target Java object into the memory through the target class loader.
In an optional embodiment of the first aspect, the method further comprises:
acquiring an update file aiming at a target application and file identification information corresponding to the update file;
and determining a target Java archived file matched with the updated file from the current file of the target application based on the file identification information, replacing the target Java archived file by using the updated file, and updating the file state information of the target Java archived file.
In a second aspect, an application updating apparatus is provided, the apparatus comprising:
the monitoring module is used for monitoring the file state information of the Java archive file of the target application in the running state; the Java archive file comprises at least one Java object;
the version information acquisition module is used for determining first version information of at least one Java object of the Java archive file loaded into the memory before the file state information changes if the file state information changes;
the application program updating module is used for detecting at least one Java object based on the Java archive file and the first version information; and if the detection result is that at least one Java object has a changed target Java object, loading the target Java object in the running process of the target application so as to update the target application.
In an optional embodiment of the second aspect, the system further includes a file status information determining module, specifically configured to:
monitoring file state information of a Java archive file of a target application according to a preset time interval to obtain current file state information;
and if the current file state information is different from the last acquired file state information of the Java archive file, determining that the file state information changes.
In an optional embodiment of the second aspect, the application update module, when detecting the at least one Java object based on the Java archive file and the first version information, is specifically configured to:
for each Java object, acquiring current second version information of the Java object from a Java archive file;
and comparing the first version information and the second version information corresponding to the Java object aiming at each Java object, if the first version information and the second version information of the Java object are different, determining that the Java object is changed, and taking the Java object as a target Java object.
In an optional embodiment of the second aspect, when the application update module loads the target Java object in the running process of the target application, the application update module is specifically configured to:
determining a target class loader corresponding to the target Java object aiming at each target Java object;
and loading the target Java object into the memory through the target class loader.
In an optional embodiment of the second aspect, the system further includes a status information updating module, specifically configured to:
acquiring an update file aiming at a target application and file identification information corresponding to the update file;
and determining a target Java archived file matched with the updated file from the current file of the target application based on the file identification information, replacing the target Java archived file by using the updated file, and updating the file state information of the target Java archived file.
In a third aspect, an electronic device is provided, which includes:
the application program updating method comprises a memory, a processor and a computer program which is stored on the memory and can run on the processor, and the application program updating method of any embodiment is realized when the processor executes the program.
In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored, which when executed by a processor implements the method for application update of any of the above embodiments.
In a fifth aspect, a computer program product or computer program is provided, the computer program product or computer program comprising computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device implements the method provided in the embodiment of the first aspect when executed.
According to the application program updating method, the file state information of the Java archive file of the target application in the running state is monitored, if the file state information changes, the file content of the Java archive file changes, and the first version information of at least one Java object of the Java archive file loaded into the memory is further determined. And if the target Java object which is changed exists in at least one Java object is determined based on the Java archive file and the first file attribute information, loading the target Java object in the running process of the target application so as to update the target application. The method comprises the steps of monitoring file state information, determining first version information of a Java filing file with changed file state information, detecting at least one Java object based on the Java filing file and the determined first version information, and loading the target Java object in the running process of the target application if the detection result indicates that the target Java object with changed Java object exists in the at least one Java object, so that the target application is updated in the running state of the application program, the application program does not need to stop running or restart, the waiting time of a user is reduced, and the user experience is improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings used in the description of the embodiments of the present application will be briefly described below.
Fig. 1 is a schematic flowchart of an application updating method according to an embodiment of the present application;
fig. 2 is a schematic flowchart of an application updating method according to an embodiment of the present application;
fig. 3 is a flowchart illustrating an application updating method according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of an application updating apparatus according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of an electronic device for updating an application according to an embodiment of the present application.
Detailed Description
Embodiments of the present application are described below in conjunction with the drawings in the present application. It should be understood that the embodiments set forth below in connection with the drawings are exemplary descriptions for explaining technical solutions of the embodiments of the present application, and do not limit the technical solutions of the embodiments of the present application.
As used herein, the singular forms "a", "an", "the" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should be further understood that the terms "comprises" and/or "comprising," when used in this specification in connection with embodiments of the present application, specify the presence of stated features, information, data, steps, operations, elements, and/or components, but do not preclude the presence or addition of other features, information, data, steps, operations, elements, components, and/or groups thereof, as embodied in the art. It will be understood that when an element is referred to as being "connected" or "coupled" to another element, it can be directly connected or coupled to the other element or intervening elements may be present. Further, "connected" or "coupled" as used herein may include wirelessly connected or wirelessly coupled. The term "and/or" as used herein indicates at least one of the items defined by the term, e.g., "a and/or B" may be implemented as "a", or as "B", or as "a and B".
To make the objects, technical solutions and advantages of the present application more clear, embodiments of the present application will be described in further detail below with reference to the accompanying drawings.
The terms referred to in this application will first be introduced and explained:
java: the one-door object-oriented programming language has the characteristics of simplicity, object orientation, distribution, robustness, safety, platform independence and portability, multithreading, dynamics and the like.
Java interface: a statement that a series of methods is a collection of method features, an interface is a collection of method features that only the method features and not the implementation of the method, so that the methods can be implemented in different places by different classes, and the implementations can have different behaviors (functions).
Java bean: the Java bean is a reusable component written in the Java language. To write as a Java bean, classes must be specific and public, and have a constructor without parameters. Java beans expose member attributes of the internal domain through a public method which can provide a consistent design mode, the member attributes can be obtained through set and get methods, and other Java classes can discover and operate the Java bean attributes through a introspection mechanism (reflection mechanism). In general, functions, processes, values, database accesses, and any other objects that may be created in Java code may be packaged using Java beans, and may be used by other developers via corresponding programs or applications.
Class and object: class (class) and object (object) are generic terms of two computer languages carried by a computer. An object is an abstraction of an objective thing, and a class is an abstraction of an object. Wherein a class is an abstract data type, the reflection of an entity in the real world or thought world in a computer, which encapsulates data and operations on the data together; an object is a variable having a class type. Classes and objects are the most basic concepts in object-oriented programming techniques. Their relationship is that an object is an instance of a class, which is a template of the object.
The application program updating method, device, electronic equipment, computer readable storage medium and computer program product provided by the application program aim at solving the technical problem that the application program updating efficiency in the prior art is low.
The technical solutions of the embodiments of the present application and the technical effects produced by the technical solutions of the present application will be described below through descriptions of several exemplary embodiments. It should be noted that the following embodiments may be referred to, referred to or combined with each other, and the description of the same terms, similar features, similar implementation steps and the like in different embodiments is not repeated.
The method for updating the application program provided by the embodiment of the application program can be applied to the terminal.
As will be understood by those skilled in the art, the "terminal" used herein may be a Personal computer, a Mobile phone, a tablet computer, a PDA (Personal Digital Assistant), an MID (Mobile Internet Device), etc.
An embodiment of the present application provides a method for updating an application program, and as shown in fig. 1, the method includes:
step S101, monitoring the file state information of the Java archive file of the target application in the running state; the Java archive file may comprise at least one Java object.
In the embodiment of the present application, the Java Archive file may be a JAR (Java Archive) file, a software package file format, which is generally used to aggregate a large number of Java class files, related metadata and resource (text, picture, etc.) files into one file in order to develop Java platform application software or library.
Specifically, the Java archive file in the present application may be all Java archive files in a data package of the target application, or may be a file specified in the target application.
The file state information may be time attribute information of the file, such as a timestamp of the file, and the timestamp may include a content modification time (modification time) and a state modification time (change time), and the like. The content modification time can refer to the time when the content of the file changes and is updated, and in the application program updating method provided by the application program, the content modification time of the Java archive file can be monitored.
The monitoring mode can be that the file state information of the Java archive file corresponding to the target is scanned and recorded at preset time intervals. It is understood that, when the file state information of the Java archive file is recorded, the file identification information (e.g., file name, file ID, etc.) and the file state information of the Java archive file are recorded. When the file state information of the Java archived file changes, the file content of the Java archived file is indicated to change, but the file identification information of the Java archived file does not change, so that whether the file state information of the Java archived file changes or not can be determined by comparing the file state information corresponding to the same file identification information at different times.
Step S102, if the file state information changes, determining first version information of at least one Java object of the Java archive file that is loaded into the memory before the file state information changes.
The file state information may be content modification time (one of timestamps), and the change in the content modification time may be a change in content modification time corresponding to the Java archive file, indicating that file content in the Java archive file has changed. When the file state information of the Java archive file changes, determining first version information of at least one Java object of the Java archive file loaded into the memory before the change, wherein the first version information form comprises but is not limited to a version number.
In this embodiment, the Java archive file may be a jar package including a plurality of Java classes (or objects), and at least one Java object of the Java archive file may be an object in the jar package for storing data and performing data processing to implement a certain function of the application program.
In one example, when the file status information of the Java archive file changes, version information of at least one Java object (or class) of the Java archive file that has been loaded into the memory before the content of the Java archive file changes (i.e., before the file status information changes) may be further determined, where each Java object (or class) may correspond to respective version information.
In this embodiment of the present application, before determining, if the file state information changes, first version information of at least one Java object of the Java archive file that is loaded into the memory before the file state information changes, the method may further include the following steps: monitoring the file state information of the Java archive file of the target application according to a preset time interval to obtain the current file state information; and if the current file state information is different from the last acquired file state information of the Java archived file, determining that the file state information changes.
Specifically, the preset monitoring module may be a plug-in with a file monitoring function or an Application Programming Interface (API), and may be configured to obtain file status information of the monitored file at regular intervals.
In one example, the file state information of the Java archive file of the target application is monitored by a preset monitoring module at preset time intervals, and the file state information may be content modification time. Assume that the current state information of the acquired Java archive file is "2021-04-0907: 28: 51 ", and the file state information of the last acquired Java archive file is" 2021-03-0213: 24: 45', the current state information is different from the file state information of the Java archive file obtained last time, which indicates that the file content of the Java archive file changes, may further determine first version information of at least one Java object of the Java archive file loaded into the memory, and detect the at least one Java object based on the Java archive file and the first version information. And if the detection result is that the target Java object which is changed exists in at least one Java object, loading the target Java object to update the target application. The specific loading method will be described in detail below.
In one example, the predetermined monitoring module may be java nio.2, a file system interface that is capable of batch fetching file attributes. Specifically, the monitoring of the file can be realized by WatchService (monitoring service) in java nio.2. The WatchService is essentially a class in java NIO.2, the object of the class is a file system monitor native to the operating system, and the file system monitor can monitor all files on the system for changes. After the file system monitor is packaged by Java, the file system monitor can be used in a Java program through WatchService, so that the file state information of the Java archived file can be monitored.
Step S103, detecting the at least one Java object based on the Java archive file and the first version information; if the detection result indicates that a changed target Java object exists in the at least one Java object, the target Java object can be loaded in the running process of the target application so as to update the target application.
In the embodiment of the present application, when the file state information of the Java archive file changes, it indicates that the file content of the Java archive file changes. The Java archive file may include at least one Java object, and it may be further determined which Java objects in the Java archive file have changed, where the determining method may be: determining first version information of at least one Java object which is loaded to a memory in a Java archive file, comparing the first version information of the at least one Java object which is loaded to the memory with second version information of a corresponding Java object in the modified Java archive file, and if a changed target Java object exists in the at least one Java object, loading the target Java object to update the target application.
It is understood that when the file state information of the Java archive file is changed, it indicates that the Java archive file is changed.
And for the Java objects which are not loaded into the memory in the changed Java archive file, when the unloaded Java objects are to be called when the target application runs, directly loading the Java objects in the changed Java archive file into the memory and then calling.
And for the Java objects which are already loaded into the memory in the changed Java archive file, determining whether a changed target Java object exists in at least one Java object loaded into the memory based on the Java archive file and the first version information, and if it is determined that the changed target Java object exists, immediately loading the target Java object to update the target application.
According to the application program updating method, the file state information of the Java archive file of the target application in the running state is monitored, if the file state information changes, the file content of the Java archive file changes, and the first version information of at least one Java object of the Java archive file loaded into the memory is further determined. And if the target Java object which is changed exists in at least one Java object is determined based on the Java archive file and the first file attribute information, loading the target Java object in the running process of the target application so as to update the target application. The method comprises the steps of monitoring file state information, determining first version information of a Java filing file with changed file state information, detecting at least one Java object based on the Java filing file and the determined first version information, and loading the target Java object in the running process of the target application if the detection result indicates that the target Java object with changed Java object exists in the at least one Java object, so that the target application is updated in the running state of the application program, the application program does not need to stop running or restart, the waiting time of a user is reduced, and the user experience is improved.
In this embodiment of the present application, detecting the at least one Java object based on the Java archive file and the first version information may include the following steps: for each Java object, acquiring current second version information of the Java object from the Java archive file; and comparing the first version information and the second version information corresponding to the Java object aiming at each Java object, if the first version information and the second version information of the Java object are different, determining that the Java object changes, and taking the Java object as a target Java object.
And if the detection result is that a changed target Java object exists in the at least one Java object, loading the target Java object in the running process of the target application so as to update the target application.
Each Java object has corresponding version information, and the version information may refer to a version number.
For each Java object in at least one Java object loaded into a memory, first version information of the Java object can be acquired; second version information for each of the at least one Java object may then be determined from the Java archive file. And comparing the first version information and the second version information of each Java object aiming at each Java object, and if the first version information and the second version information are different, indicating that the Java object is changed. And if any Java object in at least one Java object loaded into the memory changes, loading the target Java object by taking the changed Java object as the target Java object, and updating the target application.
It can be understood that, for each Java object in the at least one Java object that has been loaded into the memory, the first version information refers to version information (i.e., historical version information) of the at least one Java object when loaded into the memory, and the second version information obtained from the Java archive file refers to version information (i.e., current version information) of each Java object after the state information of the Java archive file changes, and by comparing the first version information with the second version information, it can be determined which Java objects in the Java archive file have changed when the file state information change indicates that the file content of the Java archive file has changed. If the first version information and the second version information corresponding to any Java object are different, this indicates that the Java object has changed.
In this embodiment of the present application, when any Java object in at least one Java object that has been loaded into the memory changes, all at least one Java object that has been loaded into the memory in the Java archive file may be reloaded into the memory based on the changed Java archive file, so as to overwrite the Java object that was loaded into the memory before.
Another loading mode may be partial loading, and when the first version information and the second version information of at least one Java object are different, only the target Java object with different first version information and second version information in the Java archive file is loaded, that is, the target Java object with the changed internal memory is covered, so that the loading efficiency of the Java object is improved by this incremental loading mode, and the update efficiency of the application program is further improved.
Specifically, the method for loading the target Java object may be: determining a target class loader corresponding to a Java object with different first version information and second version information in a Java archive file;
and loading the target Java object with different first version information and second version information into the memory through the target class loader.
The class loader can read java byte codes from different data sources (jar packets,. class files, network files and the like) and loads classes into the memory. In java, the following classes loader may be included: the Java application software comprises a Boot Class Loader (Boot Strap Class Loader), an extension Class Loader (Ext Class Loader), an application Class Loader (App Class Loader) and a user-defined Class Loader (Class Loader), wherein the four classes have obvious hierarchical relations, and the Boot Class Loader is used for loading a Java core library; the extension class loader is responsible for loading jar packages placed under the specified directory, the application class loader loads contents under a system variable 'classpath' path, and in addition, a self-defined class loader can be set, and the class loading process can be controlled and managed according to project requirements.
In this embodiment of the present application, an object class loader corresponding to each object Java object in object Java objects in a Java archive file, where first version information and second version information are different, may be determined first, and each object Java object may be loaded into a memory through the object class loader corresponding to each object Java object.
A possible implementation manner is provided in the embodiment of the present application, and the application program updating method further includes the following steps:
(1) and acquiring an update file aiming at the target application and file identification information corresponding to the update file. Specifically, an initial update file for the target application may be obtained first. The initial update file can be written by java language, and is obtained by encapsulating a streaming processor which needs to be modified or newly added and other related data (specified class or object) through a java bean component, and at this time, the format of the initial update file is ". java". The initial update file can be packaged and compiled through a preset programming platform, so that a jar package corresponding to the initial update file is obtained, and the jar package is used as the update file.
The file identification information corresponding to the update file may be a file name or a file path, and which file of the original files in the application program is to be replaced by the update file may be determined according to the file name and the file path.
(2) The update file and the second target file may correspond to the same file identification information. Therefore, a second target file matched with the updated file can be determined from the current file of the target application based on the file identification information, the updated file is adopted to replace the second target file, a new second target file is obtained, and the file state information corresponding to the file identification information is updated; and, the updated file state information may be used as the file state information corresponding to the new second target file.
Specifically, the second target file may be replaced by an update file, and the file state information corresponding to the file identification information may be updated. The file state information may be a content modification time. For example, suppose that before replacing the second target file with the updated file, the file status information corresponding to the file identification information is "2021-03-0213: 24: 45' when the second target file is replaced by the updated file at a time point of No. 4/9/2021, and a new second target file is obtained, the file state information corresponding to the file identification information may be updated to "2021-04-0907: 28: 51' and takes the updated file state information as the file state information corresponding to the new second target file.
The following describes an application program update method provided by the present application with specific embodiments.
The method for updating an application program provided in this alternative embodiment, as shown in fig. 2, may include the following steps:
step S201, monitoring file state information of a Java archive file of a target application through a preset monitoring module according to a preset time interval to obtain current state information;
step S202, comparing whether the current state information is consistent with the file state information of the last acquired Java archive file, if so, entering step S203, otherwise, entering step S204;
step S203, the file content of the Java archive file is not changed, and the process is ended;
step S204, determining first version information of at least one Java object of the Java archive file loaded into the memory; wherein, for each of the at least one Java object loaded into the memory, the first version information includes, but is not limited to, a version number;
step S205, for each Java object in at least one Java object loaded into the memory, acquiring the current second version information of the Java object from the Java archive file;
step S206, aiming at each Java object, comparing the first version information and the second version information of the Java object, if the first version information and the second version information are the same, entering step S207, otherwise, entering step S208;
step S207, the Java object is not changed, and the process is ended;
step S208, determining that the Java object changes, using the Java object as a target Java object, and loading the target Java object through a class loader corresponding to the target Java object.
In one example, as shown in fig. 3, the content that the application needs to be updated may be a streaming processor, and the streaming processor may refer to an implementation class (or object) that implements a specific function or java interface in the application. In this application scenario, the application program updating method provided by the present application may include the following steps:
in a first step, an initial update file for a target application is obtained. The initial update file can be written by java language, and is obtained by encapsulating a streaming processor which needs to be modified or newly added and other related data (specified class or object) through a java bean component, and at this time, the format of the initial update file is ". java".
And secondly, packaging and compiling the initial update file through a preset programming platform to obtain a jar package corresponding to the initial update file, replacing the original jar package in the application program corresponding to the specified path with the jar package, and realizing the replacement of the jar package in the application program.
The format of a file in a java package after package compilation is represented by ". java" as ". class", the java package is a product after package compilation of an initial update file, and contains related data of a streaming processor which needs to be modified or newly added, and the related data is encapsulated in java beans. The initial update file can be used for packing and compiling to obtain a jar packet to replace the corresponding original jar packet in the application program. For a developer, the file path of the jar package needing to be replaced in the application program is known, and replacement can be carried out according to the file path.
Replacement mode this application does not limit, can be that research personnel replace by hand, also can be through the framework of java automated deployment, accomplish the replacement of jar package automatically.
Thirdly, detecting the change of the jar packet in the application program through a monitoring module (such as java NIO2), acquiring first version information (namely historical version information) of the stream processor loaded into the memory, comparing the first version information with second version information of the stream processor in the replaced jar packet, and determining the stream processor with changed data. Specifically, the version information may refer to a version number, and when the first version information corresponding to any flow processor is "V0", if the second version information corresponding to the flow processor in the replaced jar packet is "V1", and is different from the first version information, it is described that data of the flow processor changes, and the flow processor needs to be loaded into the memory again.
It can be understood that, for any modified flow processor, the first version information and the second version information corresponding to the flow processor are compared, a matching relationship between the flow processor in the jar packet after replacement and the flow processor already loaded in the memory can be established through the identification information corresponding to the flow processor, and then the first version information and the second version information are compared based on the matching relationship. For example, the identification information may be a class name or an object name of the stream processor, the replaced jar packet includes the modified stream processor a, and if the class name corresponding to the stream processor a is "java class a" and corresponding second version information, it may be determined that the first version information corresponding to the class name "java class a" loaded into the memory before the jar packet is replaced (i.e., an original jar packet in the application program) is compared with the second version information, and if the first version information is different from the second version information, it is determined that the stream processor corresponding to the "java class a" is changed, and a java bean corresponding to the stream processor needs to be reloaded into the memory. The java bean corresponding to the modified streaming processor can be loaded into the memory through the class loader corresponding to the streaming processor, the streaming processor loaded into the memory before modification is covered, and the application program is updated.
In some embodiments, after the new streaming processor is loaded into memory, the old streaming processor may be reclaimed as garbage data by the java virtual machine.
An embodiment of the present application provides an application updating apparatus, and as shown in fig. 4, the application updating apparatus 40 may include: a monitoring module 401, a version information acquisition module 402, and an application update module 403, wherein,
the monitoring module 401 is configured to monitor file state information of a Java archive file of a target application in an operating state; the Java archive file comprises at least one Java object;
a version information obtaining module 402, configured to determine, if the file state information changes, first version information of at least one Java object of the Java archive file that is loaded into the memory before the file state information changes;
an application update module 403, configured to detect at least one Java object based on the Java archive file and the first version information; and if the detection result is that at least one Java object has a changed target Java object, loading the target Java object in the running process of the target application so as to update the target application.
The application program updating device monitors the file state information of the Java archive file of the target application in the running state, if the file state information changes, the file content of the Java archive file changes, and further determines the first version information of at least one Java object of the Java archive file loaded into the memory. And if the target Java object which is changed exists in at least one Java object is determined based on the Java archive file and the first file attribute information, loading the target Java object in the running process of the target application so as to update the target application. The method comprises the steps of monitoring file state information, determining first version information of a Java filing file with changed file state information, detecting at least one Java object based on the Java filing file and the determined first version information, and loading the target Java object in the running process of the target application if the detection result indicates that the target Java object with changed Java object exists in the at least one Java object, so that the target application is updated in the running state of the application program, the application program does not need to stop running or restart, the waiting time of a user is reduced, and the user experience is improved.
In an embodiment of the present application, the apparatus further includes a file status information determining module, specifically configured to:
monitoring file state information of a Java archive file of a target application according to a preset time interval to obtain current file state information;
and if the current file state information is different from the last acquired file state information of the Java archive file, determining that the file state information changes.
In this embodiment of the present application, when detecting at least one Java object based on the Java archive file and the first version information, the application update module 403 is specifically configured to:
for each Java object, acquiring current second version information of the Java object from a Java archive file;
and comparing the first version information and the second version information corresponding to the Java object aiming at each Java object, if the first version information and the second version information of the Java object are different, determining that the Java object is changed, and taking the Java object as a target Java object.
In this embodiment of the present application, when the target Java object is loaded in the running process of the target application, the application update module 403 is specifically configured to:
determining a target class loader corresponding to the target Java object aiming at each target Java object;
and loading the target Java object into the memory through the target class loader.
In an embodiment of the present application, the system further includes a status information updating module, specifically configured to:
acquiring an update file aiming at a target application and file identification information corresponding to the update file;
and determining a target Java archived file matched with the updated file from the current file of the target application based on the file identification information, replacing the target Java archived file by using the updated file, and updating the file state information of the target Java archived file.
The apparatus of the embodiment of the present application may execute the method provided by the embodiment of the present application, and the implementation principle is similar, the actions executed by the modules in the apparatus of the embodiments of the present application correspond to the steps in the method of the embodiments of the present application, and for the detailed functional description of the modules of the apparatus, reference may be specifically made to the description in the corresponding method shown in the foregoing, and details are not repeated here.
The embodiment of the present application provides an electronic device (computer apparatus/device/system), which includes a memory, a processor, and a computer program stored on the memory, where the processor executes the computer program to implement the steps of the application program updating method, and compared with the related art, the method can implement: the target application is updated in the running state of the application program, the application program does not need to stop running or restart, the waiting time of a user is reduced, and the user experience is improved.
In an alternative embodiment, an electronic device is provided, as shown in fig. 5, the electronic device 4000 shown in fig. 5 comprising: a processor 4001 and a memory 4003. Processor 4001 is coupled to memory 4003, such as via bus 4002. Optionally, the electronic device 4000 may further include a transceiver 4004, and the transceiver 4004 may be used for data interaction between the electronic device and other electronic devices, such as transmission of data and/or reception of data. In addition, the transceiver 4004 is not limited to one in practical applications, and the structure of the electronic device 4000 is not limited to the embodiment of the present application.
The Processor 4001 may be a CPU (Central Processing Unit), a general-purpose Processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other Programmable logic device, a transistor logic device, a hardware component, or any combination thereof. Which may implement or perform the various illustrative logical blocks, modules, and circuits described in connection with the disclosure. The processor 4001 may also be a combination that performs a computational function, including, for example, a combination of one or more microprocessors, a combination of a DSP and a microprocessor, or the like.
Bus 4002 may include a path that carries information between the aforementioned components. The bus 4002 may be a PCI (Peripheral Component Interconnect) bus, an EISA (Extended Industry Standard Architecture) bus, or the like. The bus 4002 may be divided into an address bus, a data bus, a control bus, and the like. For ease of illustration, only one thick line is shown in FIG. 5, but this is not intended to represent only one bus or type of bus.
The Memory 4003 may be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory) or other optical Disc storage, optical Disc storage (including Compact Disc, laser Disc, optical Disc, digital versatile Disc, blu-ray Disc, etc.), a magnetic Disc storage medium, other magnetic storage devices, or any other medium that can be used to carry or store a computer program and that can be Read by a computer, without limitation.
The memory 4003 is used for storing computer programs for executing the embodiments of the present application, and is controlled by the processor 4001 to execute. The processor 4001 is used to execute computer programs stored in the memory 4003 to implement the steps shown in the foregoing method embodiments.
Among them, electronic devices include but are not limited to: mobile terminals such as mobile phones, notebook computers, PADs, etc. and fixed terminals such as digital TVs, desktop computers, etc.
Embodiments of the present application provide a computer-readable storage medium, on which a computer program is stored, and when being executed by a processor, the computer program may implement the steps and corresponding contents of the foregoing method embodiments.
Embodiments of the present application further provide a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps and corresponding contents of the foregoing method embodiments can be implemented.
The terms "first," "second," "third," "fourth," "1," "2," and the like in the description and in the claims of the present application and in the above-described drawings (if any) are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It should be understood that the data so used are interchangeable under appropriate circumstances such that the embodiments of the application described herein are capable of operation in other sequences than illustrated or otherwise described herein.
It should be understood that, although each operation step is indicated by an arrow in the flowchart of the embodiment of the present application, the implementation order of the steps is not limited to the order indicated by the arrow. In some implementation scenarios of the embodiments of the present application, the implementation steps in the flowcharts may be performed in other sequences as desired, unless explicitly stated otherwise herein. In addition, some or all of the steps in each flowchart may include multiple sub-steps or multiple stages based on an actual implementation scenario. Some or all of these sub-steps or stages may be performed at the same time, or each of these sub-steps or stages may be performed at different times, respectively. In a scenario where execution times are different, an execution sequence of the sub-steps or the phases may be flexibly configured according to requirements, which is not limited in the embodiment of the present application.
The foregoing is only an optional implementation manner of a part of implementation scenarios in this application, and it should be noted that, for those skilled in the art, other similar implementation means based on the technical idea of this application are also within the protection scope of the embodiments of this application without departing from the technical idea of this application.

Claims (9)

1. An application program update method, comprising:
monitoring file state information of a Java archive file of a target application in a running state; the Java archive file comprises at least one Java object;
if the file state information changes, determining first version information of at least one Java object of the Java archive file loaded into a memory before the file state information changes;
detecting the at least one Java object based on the Java archive file and the first version information;
and if the detection result is that a changed target Java object exists in the at least one Java object, loading the target Java object in the running process of the target application so as to update the target application.
2. The method of claim 1, wherein before determining the first version information of the at least one Java object of the Java archive file that was loaded into memory before the change in the file state information if the change in the file state information occurred, the method further comprises:
monitoring the file state information of the Java archive file of the target application according to a preset time interval to obtain the current file state information;
and if the current file state information is different from the last acquired file state information of the Java archived file, determining that the file state information changes.
3. The application updating method according to any one of claims 1 to 2, wherein the detecting the at least one Java object based on the Java archive file and the first version information comprises:
for each Java object, acquiring current second version information of the Java object from the Java archive file;
and comparing the first version information and the second version information corresponding to the Java object aiming at each Java object, if the first version information and the second version information of the Java object are different, determining that the Java object changes, and taking the Java object as a target Java object.
4. The application program updating method according to claim 3, wherein the loading the target Java object during the running of the target application comprises:
for each target Java object, determining a target class loader corresponding to the target Java object;
and loading the target Java object into a memory through the target class loader.
5. The application program update method according to claim 1, wherein the method further comprises:
acquiring an update file aiming at the target application and file identification information corresponding to the update file;
and determining a target Java archived file matched with the updated file from the current file of the target application based on the file identification information, replacing the target Java archived file by using the updated file, and updating the file state information of the target Java archived file.
6. An application program update apparatus, comprising:
the monitoring module is used for monitoring the file state information of the Java archive file of the target application in the running state; the Java archive file comprises at least one Java object;
the version information acquisition module is used for determining first version information of at least one Java object of the Java archive file loaded into the memory before the file state information changes if the file state information changes;
an application update module for detecting the at least one Java object based on the Java archive file and the first version information; and if the detection result is that a changed target Java object exists in the at least one Java object, loading the target Java object in the running process of the target application so as to update the target application.
7. The apparatus according to claim 6, further comprising a status information updating module, configured to obtain an update file for the target application and file identification information corresponding to the update file;
and determining a target Java archived file matched with the updated file from the current file of the target application based on the file identification information, replacing the target Java archived file by using the updated file, and updating the file state information of the target Java archived file.
8. An electronic device comprising a memory, a processor and a computer program stored on the memory, characterized in that the processor executes the computer program to implement the steps of the method according to any of claims 1-5.
9. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the application update method of any one of claims 1 to 5.
CN202111555175.5A 2021-12-17 2021-12-17 Application program updating method and device, electronic equipment and readable storage medium Pending CN114253587A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111555175.5A CN114253587A (en) 2021-12-17 2021-12-17 Application program updating method and device, electronic equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111555175.5A CN114253587A (en) 2021-12-17 2021-12-17 Application program updating method and device, electronic equipment and readable storage medium

Publications (1)

Publication Number Publication Date
CN114253587A true CN114253587A (en) 2022-03-29

Family

ID=80792803

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111555175.5A Pending CN114253587A (en) 2021-12-17 2021-12-17 Application program updating method and device, electronic equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN114253587A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116974653A (en) * 2023-09-21 2023-10-31 阿里云计算有限公司 Class loading method and system

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116974653A (en) * 2023-09-21 2023-10-31 阿里云计算有限公司 Class loading method and system
CN116974653B (en) * 2023-09-21 2024-01-09 阿里云计算有限公司 Class loading method and system

Similar Documents

Publication Publication Date Title
KR101699981B1 (en) Memory optimization of virtual machine code by partitioning extraneous information
US6298353B1 (en) Checking serialization compatibility between versions of java classes
CN106844136B (en) Method and system for collecting program crash information
US20130185708A1 (en) Determining compatibility of an application with different versions of an operating system
CN111324359B (en) Plug-in deployment method and device
CN105278996A (en) Log collection method and device and log service system
CN111930382B (en) Application page access method, device and equipment
CN108595319B (en) Function selection method and server
CN111158741A (en) Method and device for monitoring change of dependency relationship of business module on third-party class library
CN114138281A (en) Compiling method, device, equipment and medium of software engineering
CN114253587A (en) Application program updating method and device, electronic equipment and readable storage medium
CN111767056A (en) Source code compiling method, executable file running method and terminal equipment
CN109284222B (en) Software unit, project testing method, device and equipment in data processing system
CN111352631B (en) Interface compatibility detection method and device
CN112306507A (en) Picture resource processing method, device, terminal and storage medium
CN114860204A (en) Program processing method, program operating device, terminal, smart card and storage medium
CN114416057A (en) Project code packaging method and device, terminal equipment and storage medium
CN114356779A (en) Programming language debugging method and device and terminal equipment
CN110008035B (en) Data interface extension method, data processing method, device and equipment
CN107451050B (en) Function acquisition method and device and server
CN114371949A (en) Application program exception handling method, device, equipment and storage medium
CN114595106B (en) Service control equipment debugging method and device
CN112558975B (en) Method and device for switching codes of components, electronic equipment and readable storage medium
CN113656044B (en) Android installation package compression method and device, computer equipment and storage medium
CN114661313A (en) Software package issuing method, software package generating method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination