CN113204391A - Program modification method and device - Google Patents

Program modification method and device Download PDF

Info

Publication number
CN113204391A
CN113204391A CN202110642838.0A CN202110642838A CN113204391A CN 113204391 A CN113204391 A CN 113204391A CN 202110642838 A CN202110642838 A CN 202110642838A CN 113204391 A CN113204391 A CN 113204391A
Authority
CN
China
Prior art keywords
code data
program
loading
code
stored
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
CN202110642838.0A
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.)
Bank of China Ltd
Original Assignee
Bank of China 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 Bank of China Ltd filed Critical Bank of China Ltd
Priority to CN202110642838.0A priority Critical patent/CN113204391A/en
Publication of CN113204391A publication Critical patent/CN113204391A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The invention discloses a program modification method and a device, which relate to the technical field of mobile interconnection, and the method comprises the following steps: receiving a program modification request; calling a code loading interface according to the program modification request; loading pre-stored code data from a server based on a code loading interface; and modifying the original code data in the Spring container of the program to be modified according to the pre-stored code data. The invention can complete the behavior of dynamically modifying the program without redeploying and has strong flexibility.

Description

Program modification method and device
Technical Field
The invention relates to the technical field of mobile interconnection, in particular to a program modification method and device.
Background
This section is intended to provide a background or context to the embodiments of the invention that are recited in the claims. The description herein is not admitted to be prior art by inclusion in this section.
In a software system for developing java programs, once software development is completed and deployed on line, the behavior of the programs is determined, the execution logic of the programs can be adjusted only through preset parameters, and once errors occur in the programs, the programs can be repaired only by modifying codes and re-deploying the codes.
The inventor finds that the prior art has at least the following problems:
the prior art can only modify parameters, so that the purpose of adjusting programs is achieved by modifying the parameters, the flexibility is poor, the switching can be performed only under several preset conditions, and for the conditions except the preset conditions, the processing cannot be performed, and only codes can be modified to relocate the programs.
Disclosure of Invention
The embodiment of the invention provides a program modification method, which can realize dynamic modification of a program without redeploying the program and has strong flexibility, and the method comprises the following steps:
receiving a program modification request;
calling a code loading interface according to the program modification request;
loading pre-stored code data from a server based on the code loading interface;
and modifying the original code data in the Spring container of the program to be modified according to the prestored code data, wherein the file identification of the prestored code data is the same as that of the original code data.
Optionally, the loading, based on the code loading interface, pre-stored code data from a server includes:
determining the code loading interface;
and loading the pre-stored code data from the server through a class loader Classloader based on the code loading interface.
Optionally, the modifying, according to the pre-stored code data, original code data in the Spring container of the program to be modified includes:
acquiring original code data in a Spring container of a program to be modified;
and replacing the original code data in the Spring container of the program to be modified based on the pre-stored code data.
Optionally, the code data is Java code data.
The embodiment of the present invention further provides a program modification apparatus, which implements dynamic modification of a program without redeploying the program, and has strong flexibility, and the apparatus includes:
a request receiving module for receiving a program modification request;
the interface calling module is used for calling a code loading interface according to the program modification request;
the code data loading module is used for loading pre-stored code data from the server based on the code loading interface;
and the program modification module is used for modifying the original code data in the Spring container of the program to be modified according to the prestored code data.
Optionally, the code data loading module is further configured to:
determining the code loading interface;
and loading the pre-stored code data from the server through a class loader Classloader based on the code loading interface.
Optionally, the program modification module is further configured to:
acquiring original code data in a Spring container of a program to be modified;
and replacing the original code data in the Spring container of the program to be modified based on the pre-stored code data.
Optionally, the code data is Java code data.
The embodiment of the present invention further provides a computer device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the method when executing the computer program.
An embodiment of the present invention further provides a computer-readable storage medium, in which a computer program for executing the above method is stored.
In the embodiment of the invention, the remote calling of the code data is realized by receiving the program modification request, calling the code loading interface according to the program modification request and loading the pre-stored code data from the server based on the code loading interface without modifying the code data of the program to be modified from the local. Because the file identification of the prestored code data is the same as the file identification of the original code data, the original code data in the Spring container of the program to be modified is modified according to the prestored code data, so that the dynamic modification of the program can be realized, the operation of the program is not influenced, namely, the program does not need to be redeployed, and the flexibility is strong.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts. In the drawings:
FIG. 1 is a flow chart of a method of program modification in an embodiment of the present invention;
FIG. 2 is a flow chart of a method of program modification in an embodiment of the present invention;
FIG. 3 is a flow chart of a method of program modification in an embodiment of the present invention;
FIG. 4 is a schematic structural diagram of a program modification apparatus according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of a computer apparatus according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the embodiments of the present invention are further described in detail below with reference to the accompanying drawings. The exemplary embodiments and descriptions of the present invention are provided to explain the present invention, but not to limit the present invention.
The names involved in the present invention are explained below:
classloader refers to: the class loader, specifically, the virtual machine loads data describing the class from the class bytecode file to the memory, and performs inspection, conversion, analysis and initialization on the data, and finally forms a Java type that can be directly used by the virtual machine, which is a class loading mechanism of the virtual machine.
The Spring container refers to: an instance of a class that implements an ApplicationContext interface. That is, from the code level, the Spring container is actually an ApplicationContext (an instantiation object)
In a software system for developing java programs, once software development is completed and deployed on line, the behavior of the programs is determined, the execution logic of the programs can be adjusted only through preset parameters, and once errors occur in the programs, the programs can be repaired only by modifying codes and re-deploying the codes.
However, the prior art can only modify parameters, so that the purpose of adjusting the program is achieved by modifying the parameters, the flexibility is poor, the program can only be switched under several preset conditions, and for the conditions other than the preset conditions, the program cannot be processed, and only the program can be modified to be redeployed. In order to solve the above problem, an embodiment of the present invention provides a program modification method.
Fig. 1 is a flowchart of a program modification method according to an embodiment of the present invention, and as shown in fig. 1, the method includes:
step 101, receiving a program modification request.
In an embodiment, when a user needs to modify a program, a program modification request may be sent to the terminal.
And 102, calling a code loading interface according to the program modification request.
During specific implementation, the code can be compiled and uploaded to a designated position of the server in an independent user operation page, and then a code loading interface is called to start loading operation.
And 103, loading pre-stored code data from the server based on the code loading interface.
In specific implementation, as shown in fig. 2, step 103 includes:
step 201, determining the code loading interface;
and 202, loading pre-stored code data from the server through a class loader Classloader based on the code loading interface.
In specific implementation, modified code data can be loaded to a specified position of a server through a class loader Classloader according to a user request.
And 104, modifying the original code data in the Spring container of the program to be modified according to the prestored code data, wherein the file identification of the prestored code data is the same as that of the original code data.
In specific implementation, as shown in fig. 3, step 104 includes:
301, acquiring original code data in a Spring container of a program to be modified;
and 302, replacing original code data in the Spring container of the program to be modified based on the pre-stored code data.
It should be understood that, in order to avoid redeployment of the program while modifying the functions of the program, in the embodiment of the present invention, the file identifier of the pre-stored code data is the same as the file identifier of the original code data, for example, if the file name (i.e., the file identifier) of the original code data is a, it contains X, Y, Z three functions, and the pre-stored code data contains X, Y, Z, C four functions, at this time, it is only necessary to set the file name of the pre-stored code data as a, and then replace X, Y, Z under the original code data file with X, Y, Z, C that it contains.
Wherein, the code data may be java code data.
The Spring container is used for storing code data required by program operation.
As can be seen from the above, in the program modification method provided in the embodiment of the present invention, by receiving the program modification request, calling the code loading interface according to the program modification request, and loading the pre-stored code data from the server based on the code loading interface, the remote call of the code data is realized without modifying the code data of the program to be modified locally. Because the file identification of the prestored code data is the same as the file identification of the original code data, the original code data in the Spring container of the program to be modified is modified according to the prestored code data, so that the dynamic modification of the program can be realized, the operation of the program is not influenced, namely, the program does not need to be redeployed, and the flexibility is strong.
Based on the same inventive concept, the embodiment of the present invention further provides a program modification apparatus, as described in the following embodiments. Because the principle of solving the problem of the program modification device is similar to that of the program modification method, the implementation of the program modification device can refer to the implementation of the program modification method, and repeated details are not repeated. As used hereinafter, the term "unit" or "module" may be a combination of software and/or hardware that implements a predetermined function. Although the means described in the embodiments below are preferably implemented in software, an implementation in hardware, or a combination of software and hardware is also possible and contemplated.
Fig. 4 is a schematic structural diagram of a program modification apparatus according to an embodiment of the present invention, as shown in fig. 4, the apparatus includes:
a request receiving module 401, configured to receive a program modification request;
an interface calling module 402, configured to call a code loading interface according to the program modification request;
a code data loading module 403, configured to load pre-stored code data from the server based on the code loading interface;
and the program modification module 404 is configured to modify original code data in the Spring container of the program to be modified according to the pre-stored code data.
In this embodiment of the present invention, the code data loading module 403 is further configured to:
determining the code loading interface;
and loading the pre-stored code data from the server through a class loader Classloader based on the code loading interface.
In this embodiment of the present invention, the program modification module 404 is further configured to:
acquiring original code data in a Spring container of a program to be modified;
and replacing the original code data in the Spring container of the program to be modified based on the pre-stored code data.
In an embodiment of the present invention, the code data is Java code data.
To achieve the above object, according to another aspect of the present application, there is also provided a computer apparatus. As shown in fig. 5, the computer device comprises a memory, a processor, a communication interface and a communication bus, wherein a computer program that can be run on the processor is stored in the memory, and the steps of the method of the above embodiment are realized when the processor executes the computer program.
The processor may be a Central Processing Unit (CPU). The Processor may also be other general purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components, or a combination thereof.
The memory, which is a non-transitory computer readable storage medium, may be used to store non-transitory software programs, non-transitory computer executable programs, and units, such as the corresponding program units in the above-described method embodiments of the present invention. The processor executes various functional applications of the processor and the processing of the work data by executing the non-transitory software programs, instructions and modules stored in the memory, that is, the method in the above method embodiment is realized.
The memory may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created by the processor, and the like. Further, the memory may include high speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid state storage device. In some embodiments, the memory optionally includes memory located remotely from the processor, and such remote memory may be coupled to the processor via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The one or more units are stored in the memory and when executed by the processor perform the method of the above embodiments.
An embodiment of the present invention further provides a computer-readable storage medium, in which a computer program for executing the above method is stored.
In summary, the present invention receives the program modification request, calls the code loading interface according to the program modification request, and loads the pre-stored code data from the server based on the code loading interface, thereby implementing remote call of the code data without modifying the code data of the program to be modified locally. Because the file identification of the prestored code data is the same as the file identification of the original code data, the original code data in the Spring container of the program to be modified is modified according to the prestored code data, so that the dynamic modification of the program can be realized without redeploying the program, and the flexibility is strong.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The above-mentioned embodiments are intended to illustrate the objects, technical solutions and advantages of the present invention in further detail, and it should be understood that the above-mentioned embodiments are only exemplary embodiments of the present invention, and are not intended to limit the scope of the present invention, and any modifications, equivalent substitutions, improvements and the like made within the spirit and principle of the present invention should be included in the scope of the present invention.

Claims (10)

1. A program modification method, comprising:
receiving a program modification request;
calling a code loading interface according to the program modification request;
loading pre-stored code data from a server based on the code loading interface;
and modifying the original code data in the Spring container of the program to be modified according to the prestored code data, wherein the file identification of the prestored code data is the same as that of the original code data.
2. The method of claim 1, wherein loading pre-stored code data from a server based on the code loading interface comprises:
determining the code loading interface;
and loading the pre-stored code data from the server through a class loader Classloader based on the code loading interface.
3. The method according to claim 1, wherein the modifying the original code data in the Spring container of the program to be modified according to the pre-stored code data comprises:
acquiring original code data in a Spring container of a program to be modified;
and replacing the original code data in the Spring container of the program to be modified based on the pre-stored code data.
4. The method of claim 1, wherein the code data is Java code data.
5. A program modification apparatus, comprising:
a request receiving module for receiving a program modification request;
the interface calling module is used for calling a code loading interface according to the program modification request;
the code data loading module is used for loading pre-stored code data from the server based on the code loading interface;
and the program modification module is used for modifying the original code data in the Spring container of the program to be modified according to the prestored code data.
6. The apparatus of claim 5, wherein the code data loading module is further to:
determining the code loading interface;
and loading the pre-stored code data from the server through a class loader Classloader based on the code loading interface.
7. The apparatus of claim 5, wherein the program modification module is further to:
acquiring original code data in a Spring container of a program to be modified;
and replacing the original code data in the Spring container of the program to be modified based on the pre-stored code data.
8. The apparatus according to claim 5, wherein the code data is Java code data.
9. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method of any one of claims 1 to 4 when executing the computer program.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program for executing the method of any one of claims 1 to 4.
CN202110642838.0A 2021-06-09 2021-06-09 Program modification method and device Pending CN113204391A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110642838.0A CN113204391A (en) 2021-06-09 2021-06-09 Program modification method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110642838.0A CN113204391A (en) 2021-06-09 2021-06-09 Program modification method and device

Publications (1)

Publication Number Publication Date
CN113204391A true CN113204391A (en) 2021-08-03

Family

ID=77024752

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110642838.0A Pending CN113204391A (en) 2021-06-09 2021-06-09 Program modification method and device

Country Status (1)

Country Link
CN (1) CN113204391A (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110210188A (en) * 2019-06-04 2019-09-06 武汉神算云信息科技有限责任公司 Code encryption method, apparatus, equipment and storage medium under Spring frame
CN111736916A (en) * 2020-06-08 2020-10-02 北京达佳互联信息技术有限公司 Dynamic expansion method and device based on Java language, electronic equipment and storage medium

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110210188A (en) * 2019-06-04 2019-09-06 武汉神算云信息科技有限责任公司 Code encryption method, apparatus, equipment and storage medium under Spring frame
CN111736916A (en) * 2020-06-08 2020-10-02 北京达佳互联信息技术有限公司 Dynamic expansion method and device based on Java language, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
US20190324772A1 (en) Method and device for processing smart contracts
CN110704037B (en) Rule engine implementation method and device
CN104834555A (en) Method for invoking functional module, related device and device repairing method
CN109933350B (en) Method and device for embedding codes in application and electronic equipment
CN108141378B (en) Dormant VDU in VNFD
CN111596927B (en) Service deployment method and device and electronic equipment
CN105159738A (en) Hot patch implementation method and system
WO2014200511A1 (en) Unified extensible firmware interface (uefi) driver and protocol
CN110362356B (en) Function data processing method and device, computer equipment and storage medium
CN108021405B (en) Method and device for driving storage medium in SOC system starting process
CN111666210A (en) Chip verification method and device
TW202403541A (en) System, method and device for introducing applet into third-party APP and medium
CN107977243A (en) A kind of third party's interface call method and device
CN107733866A (en) RPC requests, RPC request processing methods, device and equipment
CN107066255A (en) A kind of the Internet of Things apparatus control method and device of shared Internet of Things apparatus logic
CN111722857A (en) Updating method and device of software development kit, electronic equipment and storage medium
CN112134922B (en) Service calling method and device based on micro-service and storage medium
CN111949297B (en) Block chain intelligent contract upgrading method and device and electronic equipment
CN113204391A (en) Program modification method and device
CN111796864A (en) Data verification method and device
CN108052335B (en) Data management method and device, computing equipment and storage medium
CN107704279B (en) Data loading method and device
CN116382713A (en) Method, system, device and storage medium for constructing application mirror image
CN110275710B (en) Java local interface consistency checking method and system, storage medium and terminal
CN115374083A (en) Data source switching method and device, electronic 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