CN113656057A - JAVA file updating method, network equipment and storage medium - Google Patents

JAVA file updating method, network equipment and storage medium Download PDF

Info

Publication number
CN113656057A
CN113656057A CN202110988304.3A CN202110988304A CN113656057A CN 113656057 A CN113656057 A CN 113656057A CN 202110988304 A CN202110988304 A CN 202110988304A CN 113656057 A CN113656057 A CN 113656057A
Authority
CN
China
Prior art keywords
java file
system object
class loader
java
updating
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
CN202110988304.3A
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.)
Shenzhen Tiantianlaiwan Technology Co ltd
Original Assignee
Shenzhen Tiantianlaiwan Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Tiantianlaiwan Technology Co ltd filed Critical Shenzhen Tiantianlaiwan Technology Co ltd
Priority to CN202110988304.3A priority Critical patent/CN113656057A/en
Publication of CN113656057A publication Critical patent/CN113656057A/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
    • 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 invention provides a JAVA file updating method, network equipment and a storage medium, which are used for reading an uploaded JAVA file; judging whether the JAVA file meets the updating condition; when the JAVA file meets the updating condition, loading the JAVA file through a custom class loader to form a system object; the custom class loader is independent of all system class loaders and is associated with at least one system class loader; and replacing the original historical system object with the system object. Therefore, the invention realizes the loading and updating of the JAVA file by setting the custom class loader without influencing the original system class loader, thereby realizing the hot updating of the JAVA file and reducing the system risk without restarting the system in the updating process.

Description

JAVA file updating method, network equipment and storage medium
Technical Field
The present invention relates to the field of communications, and in particular, to a JAVA file updating method, a network device, and a storage medium.
Background
JAVA is a program language for compiling and executing, when the operations of compiling packages, restarting servers and the like are required to be uploaded again and avoided when bug repair or some functions are iterated, if the operations are large-flow services, the current service flow needs to be switched to a standby server to achieve smooth updating, the starting cost and the risk are relatively high, and if the operation complexity is not completed by a large number of auxiliary systems, a lot of avoided risks can occur.
Disclosure of Invention
In view of the above deficiencies of the related art, the present application aims to provide a JAVA file updating method, a network device and a storage medium, and aims to solve the problems that the JAVA file cannot be updated hot and the system risk is high in the related art.
In order to solve the above technical problem, the present invention provides a JAVA file updating method, including:
reading the uploaded JAVA file;
judging whether the JAVA file meets the updating condition or not;
when the JAVA file meets the updating condition, loading the JAVA file through a custom class loader to form a system object; the custom class loader is independent of each system class loader and is associated with at least one system class loader;
and replacing the original historical system object with the system object.
Optionally, before the reading of the uploaded JAVA file, the method further includes:
and creating the custom class loader, wherein the custom class loader inherits any one system class loader.
Optionally, the loading the JAVA file through a custom class loader to form a system object includes:
loading the JAVA file through the custom class loader;
and instantiating the JAVA file to process to form the system object.
Optionally, the instantiating the JAVA file to form the system object includes:
and instantiating the JAVA file through defiineclass to form the system object.
Optionally, the replacing the system object with the original historical system object includes:
and saving the system object and unloading the historical system object.
Optionally, the determining whether the JAVA file meets the update condition includes:
scanning the JAVA file to acquire version information in the JAVA file;
comparing the version information of the JAVA file with the version information of the existing historical system object;
and when the version information is changed, the updating condition is met.
Optionally, before the scanning the JAVA file and acquiring the version information therein, the method further includes:
acquiring the packed JAVA file, and marking the JAVA file through the version information; the version information is generated by a version control system SVN.
Optionally, after replacing the original historical system object with the system object, the method further includes:
and updating the version information of the system object.
The invention also provides a network device comprising a processor, a memory and a communication bus;
the communication bus is used for realizing connection communication between the processor and the memory;
the processor is configured to execute one or more computer programs stored in the memory to implement the steps of the JAVA file updating method described above.
The present invention also provides a computer readable storage medium storing one or more computer programs, which are executable by one or more processors to implement the steps of the JAVA file updating method described above.
Advantageous effects
The invention provides a JAVA file updating method, network equipment and a storage medium, which are used for reading an uploaded JAVA file; judging whether the JAVA file meets the updating condition; when the JAVA file meets the updating condition, loading the JAVA file through a custom class loader to form a system object; the custom class loader is independent of all system class loaders and is associated with at least one system class loader; and replacing the original historical system object with the system object. Therefore, the invention realizes the loading and updating of the JAVA file by setting the custom class loader without influencing the original system class loader, thereby realizing the hot updating of the JAVA file and reducing the system risk without restarting the system in the updating process.
Drawings
Fig. 1 is a flowchart of a JAVA file updating method according to an embodiment of the present invention;
fig. 2 is a flowchart of another JAVA file updating method according to an embodiment of the present invention;
fig. 3 is a schematic diagram of a network device according to an embodiment of the present invention.
Detailed Description
To facilitate an understanding of the present application, the present application will now be described more fully with reference to the accompanying drawings. Preferred embodiments of the present application are given in the accompanying drawings. This application may, however, be embodied in many different forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein in the description of the present application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application.
Referring to fig. 1, fig. 1 shows a flowchart of a JAVA file updating method in an embodiment of the present invention, where the method includes:
s101, reading the uploaded JAVA file;
s102, judging whether the JAVA file meets the updating condition;
s103, when the JAVA file meets the updating condition, loading the JAVA file through a custom class loader to form a system object; the custom class loader is independent of all system class loaders and is associated with at least one system class loader;
and S104, replacing the original historical system object with the system object.
In the JAVA platform-based service system, all JAVA files are loaded through a built-in class loader. In the embodiment of the invention, the updating of the JAVA file is realized by additionally arranging the custom class loader without executing the original system class loader in the system, so that silent updating, namely hot updating, of the JAVA file can be realized, the user experience is improved, the service interruption is avoided, and the system risk is also reduced.
In S101, the uploaded JAVA file is read. If the system file is updated, the updated file is packaged and uploaded; and packaging the uploaded files as potentially available files for updating.
In some optional embodiments, before reading the uploaded JAVA file, the method may further include:
and creating a custom class loader, wherein the custom class loader inherits any system class loader. In the embodiment of the invention, the updating of the JAVA file is realized by additionally arranging the custom class loader; therefore, the newly added custom class loader needs to be created in the system, and when the custom class loader is created, the custom class loader inherits any system class loader as an association with the system class loader. The meaning of the system class loader inherited by the custom class loader is that a new custom class loader is created by taking the method, the attribute and the like contained in the existing original system class loader as the basis, the newly established custom class loader can use the required method and attribute contained in the inherited system class loader, and the new method and attribute can be expanded.
Specifically, in the embodiment of the present invention, the custom class loader may inherit the system class loader at the top layer, including Appclassloader, BootStrapclassloader, extcssloader, and the like. In the newly-built custom class loader, the system class loader corresponding to the new custom class loader does not participate in the hot update process, so that the system class loader can be ensured not to influence the hot update process, and the system can normally realize silent update.
In S102, it is determined whether the JAVA file meets the update condition, which means that it is required to determine whether the uploaded JAVA file is the file that needs to be updated accordingly. When the JAVA file is uploaded, the system does not represent a new file, and therefore the file needs to be judged. Generally, when the file is different from an existing JAVA file, it can be considered as belonging to a file that needs to be updated, and if it is identical to the current JAVA file, it is considered as not needing to be updated.
In some optional embodiments, the determining whether the JAVA file meets the update condition may specifically include:
scanning a JAVA file to acquire version information in the JAVA file;
comparing the version information of the JAVA file with the version information of the existing historical system object;
and when the version information is changed, the updating condition is met. In order to determine whether the JAVA file meets the update condition, corresponding version information may be set in the JAVA file, so that whether the JAVA file meets the update condition may be determined through the difference between the version information. Specifically, if the newly uploaded JAVA file is consistent with the version information of the existing historical system object, the newly uploaded JAVA file and the historical system object are considered to be the same content, and at this time, updating is not required; and if the newly uploaded JAVA file is inconsistent with the version information of the existing historical system object, the newly uploaded JAVA file is considered to be in accordance with the updating condition.
In some optional embodiments, before scanning the JAVA file and acquiring the version information therein, the method may further include:
obtaining a packed JAVA file, and marking the JAVA file through version information; the version information is generated by the version control system SVN. The JAVA file carries version information; correspondingly, before acquiring the version information, the version information needs to be written in the JAVA file; that is, the JAVA file is marked by version information. The version information marking mode may be generated by a version control system SVN.
The subversion represented by the SVN is a version control system of an open source code, and efficient management is achieved by adopting a branch management system. As an open source version control system, SVNs manage data that changes over time. This data is placed in a central Repository (Repository) similar to a file server, but which keeps track of each change to the file, so that the archive can be restored to an old version, or the history of the changes to the file can be viewed. The SVN is a general system that may be used to manage any type of file, including but not limited to JAVA files and the like in the embodiments of the present application.
The SVN adopts a client/server system, various versions of a project are stored on a server, program developers firstly obtain a latest version of the project from the server and copy the latest version of the project to a local computer, and then on the basis, each developer can carry out independent development work on own client and can submit new codes to the server at any time. Of course, the latest code on the server can be obtained through the updating operation, so that the consistency with the version used by other developers is maintained.
In some optional embodiments, loading the JAVA file through a custom class loader, and forming the system object may specifically include:
loading a JAVA file through a custom class loader;
and (5) instantiating the JAVA file to process to form a system object. Specifically, the instantiating process, that is, instantiating the JAVA file, to form the system object may include:
and instantiating the JAVA file through defiineclass to form a system object. Defineclass can convert binary character arrays into instances, thereby forming system objects.
In some optional embodiments, the step of replacing the original historical system object with the system object may specifically include:
save system objects and unload historical system objects. After the system object is obtained through conversion, the system object can be stored, and meanwhile, the original historical system object is unloaded; after the series of actions is completed, the new system object replaces the original historical system object, and therefore hot updating is achieved.
In some optional embodiments, after replacing the system object with the original historical system object, the method may further include:
version information of the system object is updated. The version information is determined according to the version information of the JAVA file corresponding to the system object, so that the subsequent version information of the newly uploaded JAVA file can be verified subsequently according to the version information corresponding to the system object, and whether the subsequent version information meets the update condition is judged.
The embodiment of the invention provides a JAVA file updating method, which comprises the steps of reading an uploaded JAVA file; judging whether the JAVA file meets the updating condition; when the JAVA file meets the updating condition, loading the JAVA file through a custom class loader to form a system object; the custom class loader is independent of all system class loaders and is associated with at least one system class loader; and replacing the original historical system object with the system object. Therefore, the invention realizes the loading and updating of the JAVA file by setting the custom class loader without influencing the original system class loader, thereby realizing the hot updating of the JAVA file and reducing the system risk without restarting the system in the updating process.
An embodiment of the present invention further provides a JAVA file updating method, please refer to fig. 2, where the method includes:
s201, packaging the JAVA files;
s202, generating version information through the SVN, and marking the JAVA file;
s203, reading the version information of the JAVA file;
s204, judging whether the version information of the JAVA file changes; if yes, go to S205; if not, ending the current flow;
s205, loading the JAVA file by a custom class loader;
s206, instantiating the JAVA file to form a system object;
s207, saving the system object;
s208, unloading the original historical system object;
s209, providing access by using the new system object and completing hot updating.
Referring to fig. 3, the network device according to an embodiment of the present invention further includes a processor 31, a memory 32, and a communication bus 33;
the communication bus 33 is used for realizing connection communication between the processor 31 and the memory 32;
the processor 31 is configured to execute one or more computer programs stored in the memory 32 to implement the steps of the JAVA file updating method in the embodiment of the present invention.
Embodiments of the present invention also provide a computer-readable storage medium including volatile or non-volatile, removable or non-removable media implemented in any method or technology for storage of information such as computer-readable instructions, data structures, computer program modules or other data. Computer-readable storage media include, but are not limited to, RAM (Random Access Memory), ROM (Read-Only Memory), EEPROM (Electrically Erasable Programmable Read-Only Memory), flash Memory or other Memory technology, CD-ROM (Compact disk Read-Only Memory), Digital Versatile Disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can be accessed by a computer.
The computer readable storage medium in the embodiment of the present invention may be used to store one or more computer programs, and the one or more computer programs stored therein may be executed by one or more processors to implement the steps of the JAVA file updating method in the embodiment of the present invention.
The embodiment of the present invention further provides a computer program (or computer software), which can be distributed on a computer readable medium and executed by a computing device to implement at least one step of the JAVA file updating method; and in some cases at least one of the steps shown or described may be performed in an order different than that described in the embodiments above.
Embodiments of the present invention further provide a computer program product, which includes a computer readable device, where the computer program as shown above is stored on the computer readable device. The computer readable device in the embodiment of the present invention may include a computer readable storage medium as shown above.
It will be apparent to those skilled in the art that all or some of the steps of the methods, systems, functional modules/units in the devices disclosed above may be implemented as software (which may be implemented in computer program code executable by a computing device), firmware, hardware, and suitable combinations thereof. In a hardware implementation, the division between functional modules/units mentioned in the above description does not necessarily correspond to the division of physical components; for example, one physical component may have multiple functions, or one function or step may be performed by several physical components in cooperation. Some or all of the physical components may be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application specific integrated circuit.
In addition, communication media typically embodies computer readable instructions, data structures, computer program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media as known to one of ordinary skill in the art. Thus, the present invention is not limited to any specific combination of hardware and software.
It is to be understood that the invention is not limited to the examples described above, but that modifications and variations may be effected thereto by those of ordinary skill in the art in light of the foregoing description, and that all such modifications and variations are intended to be within the scope of the invention as defined by the appended claims.

Claims (10)

1. A JAVA file updating method, comprising:
reading the uploaded JAVA file;
judging whether the JAVA file meets the updating condition or not;
when the JAVA file meets the updating condition, loading the JAVA file through a custom class loader to form a system object; the custom class loader is independent of each system class loader and is associated with at least one system class loader;
and replacing the original historical system object with the system object.
2. The JAVA file updating method of claim 1, further comprising, before said reading the uploaded JAVA file:
and creating the custom class loader, wherein the custom class loader inherits any one system class loader.
3. The JAVA file updating method of claim 1, wherein said loading the JAVA file through a custom class loader to form a system object comprises:
loading the JAVA file through the custom class loader;
and instantiating the JAVA file to process to form the system object.
4. The JAVA file updating method of claim 3, wherein said instantiating the JAVA file to form the system object comprises:
and instantiating the JAVA file through defiineclass to form the system object.
5. The JAVA file updating method of claim 1, wherein said replacing the system object with the original historical system object comprises:
and saving the system object and unloading the historical system object.
6. The JAVA file updating method of any of claims 1 to 5, wherein said determining whether said JAVA file complies with the update condition comprises:
scanning the JAVA file to acquire version information in the JAVA file;
comparing the version information of the JAVA file with the version information of the existing historical system object;
and when the version information is changed, the updating condition is met.
7. The JAVA file updating method as claimed in claim 6, wherein before the scanning the JAVA file for the version information therein, the method further comprises:
acquiring the packed JAVA file, and marking the JAVA file through the version information; the version information is generated by a version control system SVN.
8. The JAVA file updating method of claim 6, further comprising, after replacing the system object with the original historical system object:
and updating the version information of the system object.
9. A network device, comprising a processor, a memory, and a communication bus;
the communication bus is used for realizing connection communication between the processor and the memory;
the processor is adapted to execute one or more computer programs stored in the memory to implement the steps of the JAVA file updating method as claimed in any of claims 1 to 8.
10. A computer readable storage medium, storing one or more computer programs, which are executable by one or more processors to implement the steps of the JAVA file updating method as claimed in any one of claims 1 to 8.
CN202110988304.3A 2021-08-26 2021-08-26 JAVA file updating method, network equipment and storage medium Pending CN113656057A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110988304.3A CN113656057A (en) 2021-08-26 2021-08-26 JAVA file updating method, network equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110988304.3A CN113656057A (en) 2021-08-26 2021-08-26 JAVA file updating method, network equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113656057A true CN113656057A (en) 2021-11-16

Family

ID=78492990

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110988304.3A Pending CN113656057A (en) 2021-08-26 2021-08-26 JAVA file updating method, network equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113656057A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101174217A (en) * 2007-11-22 2008-05-07 上海交通大学 Method for implementing dynamic update of Java program
CN105068852A (en) * 2015-09-22 2015-11-18 普元信息技术股份有限公司 System and method for realizing Java class on-line hot updating in cloud computing environment
CN106980512A (en) * 2017-05-15 2017-07-25 中国建设银行股份有限公司 Update the system and method for JAVA application services
CN107239313A (en) * 2017-06-09 2017-10-10 中国建设银行股份有限公司 The upgrade method and storage medium of Spring application services

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101174217A (en) * 2007-11-22 2008-05-07 上海交通大学 Method for implementing dynamic update of Java program
CN105068852A (en) * 2015-09-22 2015-11-18 普元信息技术股份有限公司 System and method for realizing Java class on-line hot updating in cloud computing environment
CN106980512A (en) * 2017-05-15 2017-07-25 中国建设银行股份有限公司 Update the system and method for JAVA application services
CN107239313A (en) * 2017-06-09 2017-10-10 中国建设银行股份有限公司 The upgrade method and storage medium of Spring application services

Similar Documents

Publication Publication Date Title
CN106227579B (en) Docker container construction method and Docker management console
CN109857423B (en) Program version updating method and device, server and readable storage medium
CN108762825B (en) Method and system for realizing heavy load of dynamic library
US9542173B2 (en) Dependency handling for software extensions
CN104731622A (en) Application program loading method and device and mobile terminal
US10896109B2 (en) Non-monotonic eventual convergence for desired state configuration
CN111273942A (en) Code generation method, storage medium, electronic device and system
CN110007935B (en) Processing method, device and equipment for program upgrading
CN112486552A (en) Server hot update method, device, equipment and storage medium
CN116049207A (en) Application SQL script processing method and device, processor and electronic equipment
WO2019041891A1 (en) Method and device for generating upgrade package
CN113656057A (en) JAVA file updating method, network equipment and storage medium
CN108052335B (en) Data management method and device, computing equipment and storage medium
CN112988181A (en) Application updating method, device, terminal, server and readable storage medium
US20190065218A1 (en) Context Check Bypass To Enable Opening Shared-Object Libraries
CN113791809B (en) Application exception handling method and device and computer readable storage medium
US20070079279A1 (en) Embedded device with software registry
US11360761B2 (en) Operational file management and storage
CN114860202A (en) Project operation method, device, server and storage medium
CN106886420B (en) Program code management device and method and program code manager
CN115964061A (en) Plug-in updating method and device, electronic equipment and computer readable storage medium
CN107908441B (en) Database upgrading method and upgrading device
CN112035192A (en) Java class file loading method and device supporting component hot deployment
CN116204199B (en) Command line-based project management method, system, equipment and storage medium
CN109996262B (en) AC starting method and device

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