CN114895882A - Secondary development method of non-invasive Java open source software - Google Patents
Secondary development method of non-invasive Java open source software Download PDFInfo
- Publication number
- CN114895882A CN114895882A CN202210458243.4A CN202210458243A CN114895882A CN 114895882 A CN114895882 A CN 114895882A CN 202210458243 A CN202210458243 A CN 202210458243A CN 114895882 A CN114895882 A CN 114895882A
- Authority
- CN
- China
- Prior art keywords
- plug
- open source
- source software
- java
- development
- 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
Links
- 238000000034 method Methods 0.000 title claims abstract description 85
- 238000011161 development Methods 0.000 title claims abstract description 55
- 230000008569 process Effects 0.000 claims abstract description 9
- 230000006870 function Effects 0.000 claims description 14
- 238000012986 modification Methods 0.000 claims description 9
- 230000004048 modification Effects 0.000 claims description 9
- 230000007246 mechanism Effects 0.000 claims description 6
- 238000004806 packaging method and process Methods 0.000 claims description 4
- 238000011144 upstream manufacturing Methods 0.000 abstract description 10
- 238000012423 maintenance Methods 0.000 abstract description 7
- 238000010586 diagram Methods 0.000 description 3
- 238000013459 approach Methods 0.000 description 1
- 238000004590 computer program Methods 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000012856 packing Methods 0.000 description 1
- 238000012545 processing Methods 0.000 description 1
- 238000009877 rendering Methods 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
- 230000001360 synchronised effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/31—Programming languages or programming paradigms
- G06F8/315—Object-oriented languages
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44521—Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
- G06F9/44526—Plug-ins; Add-ons
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computing Systems (AREA)
- Devices For Executing Special Programs (AREA)
Abstract
The invention discloses a secondary development method of non-invasive Java open source software, which is characterized in that the secondary development method of the open source software modified based on byte codes in operation specifically comprises the following steps: the method comprises the steps of plug-in development, dynamic replacement and the like, wherein the plug-in development uses Java language to write program logic of each modified specified method and compiles codes into plug-ins; the dynamic replacement includes: reading the plug-in compiled and packaged in the plug-in development step, modifying the byte code loading flow of the original open source software, and dynamically replacing the content of the plug-in with the byte code of the corresponding plug-in method when the byte code containing the specified method is loaded. Compared with the prior art, the method and the system have the advantages that the requirement of performing secondary development by enterprises under the condition of not directly modifying the source code is met, the problem that the secondary development is difficult to maintain due to the fact that the upstream code and the secondary development code are mixed in the secondary development process of the Java open source software is solved, the secondary development code is independently used as a plug-in, the development efficiency is improved, and the maintenance difficulty is reduced.
Description
Technical Field
The invention relates to the technical field of application program development, in particular to a non-invasive secondary development method for expanding or modifying functions of Java open source software.
Background
With the enlargement of the enterprise scale and the increase of the business, unified and mature software tools are expected to support the daily office work of each department in the enterprise, so that the work efficiency is improved. Currently, few enterprises will build their own software tools from zero because this approach is costly and requires a long time to perfect the tools enough to support large-scale use. Generally, enterprises can reuse existing open source software to carry out secondary development customization, and the functions of the open source software are expanded or modified to meet the field requirements of the enterprises.
While many open source software provide an extended interface or plug-in mechanism to meet the needs of the user to customize the function, the degree of customization of the software is often limited, and enterprise users often need to implement their needs by directly modifying the source code.
There are two major drawbacks to the way of directly modifying software source code: first, if a user directly modifies the software source code, the inserted custom code is often scattered in multiple places of the software project and mixed in the original code, which presents a significant challenge to subsequent maintenance work. It is not hard to imagine that after undergoing several development iterations and merging with upstream code (code publicly released by open source software official maintainers), these custom codes will become very difficult to track and maintain.
Second, the multiplexed open source software itself is continually updated, and modifications made by the user are not always merged upstream. On the one hand because these modifications may contain confidential information and on the other hand because the domain-specific requirements are not necessarily compatible with the upstream original version. However, users often want the software and the upstream to keep synchronous to acquire updated functions in a new version or improve performance. Without other options, the user must merge the upstream code with the local modifications at each version update.
The custom code of the prior art open source software, developed secondarily, often conflicts with code updated upstream, which is time consuming and error prone even with the use of versioning tools.
Disclosure of Invention
The invention aims to design a secondary development method of non-invasive Java open source software aiming at the defects of the prior art, adopts a non-invasive plug-in method to expand or modify the functions of the Java open source software and support a development kit, thereby meeting the requirement of secondary development of enterprises under the condition of not directly modifying source codes, avoiding the need of providing an extension interface or a plug-in mechanism by the original open source software, solving the problem of difficult maintenance caused by the mixing of upstream codes and secondary development codes in the secondary development process of the Java open source software, improving the development efficiency and reducing the maintenance difficulty.
The purpose of the invention is realized as follows: a secondary development method of non-invasive Java open source software is characterized in that functions of the Java open source software are expanded or modified in a non-invasive mode, secondary development codes are independent as plug-ins, and the method specifically comprises the following steps:
a, step a: plug-in development
According to the actual requirements of secondary development, based on an application program interface provided by a development kit, specifying the method to be modified in the original open source software, writing the program logic of each specified method after modification by using Java language, and compiling the codes into plug-ins.
b, step (b): dynamic replacement
And c, reading the plug-in after compiling and packaging in the step a, and modifying the Java byte code loading flow of the original open source software, so that when the byte code containing the specified method in the plug-in is loaded, the byte code related to the method is dynamically replaced by the byte code corresponding to the plug-in method.
The step a specifically comprises the following steps:
a-1: writing code using the Java language to specify a method that should be modified in the original open source software (called a target method) and a method for replacing the target method (called a plug-in method) based on an application program interface provided by a development kit;
a-2: writing the code of the plug-in method in the step a1 by using Java language;
a-3: compiling and packaging the codes into a plug-in format, wherein the plug-in format is determined according to the specific implementation of the development kit, for example: compiling and packing all codes into a universal Jar format, and listing the specific implementation classes of all plug-in methods in the META-INF/MANIFEST.
The step b specifically comprises the following steps:
b-1: reading the plug-ins compiled and packaged in the step a, and acquiring each target method and a corresponding plug-in method;
b-2: intercepting a class loading process of original open source software through a Java Agent mechanism provided by a JVM (Java virtual machine) when the original open source software runs;
b-3: when the class containing the target method is loaded, modifying the byte code to be loaded, and replacing the original byte code with the byte code of the plug-in method corresponding to the target method.
Compared with the prior art, the method has the advantages that the requirement of performing secondary development by enterprises under the condition of not directly modifying the source code is met, the original open source software does not need to provide an extension interface or a plug-in mechanism, the problem that the secondary development code is mixed with the upstream code in the secondary development process of the Java open source software to cause difficulty in maintenance is solved, the development efficiency is greatly improved, and the maintenance difficulty is reduced.
Drawings
FIG. 1 is a user interface of an Archi software script of embodiment 1;
FIG. 2 is a user interface of the Archi software of example 1 after the secondary development is completed;
FIG. 3 is a user interface of embodiment 1 after modification of source code using the prior art;
FIG. 4 is a class page (interface) interface for implementing the ClassHook interface in embodiment 1;
FIG. 5 is a plug-in page (interface) plane implemented in example 1;
fig. 6 is a schematic diagram of a dynamic replacement flow in embodiment 1.
Detailed Description
The following detailed description of the embodiments of the invention refers to the accompanying drawings and an example of a practical application. The following description of specific embodiments of the present invention will help one skilled in the art to further understand the present invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the spirit of the invention, and still fall within the scope of the invention.
Example 1
An example of this practical application, Archi, is a Java open source software for rendering ArchiMate enterprise architecture diagrams.
Referring to FIG. 1, the canvas portion of the native user interface of Archi software is shown in FIG. 1 (the portion of the data in all figures that does not affect the description of the embodiments has been obfuscated due to data privacy requirements). The square primitives in the user interface represent individual components in the architecture diagram, and the solid or dashed lines with arrows represent associations between components. The architecture drawing part of the application program has the following secondary development requirements:
referring to fig. 2, in order to keep the user interface beautiful, the partial association relationship meeting the specific requirement is represented by a dotted line, and is displayed only when the source primitive or the target primitive is selected, as shown in fig. 2.
Referring to fig. 3, in the conventional secondary development mode, a developer needs to directly modify source code of Archi to meet the requirement. In this example, the developer needs to modify the selectorchanged method in the treeselectionsyncroniser class, the specific modification of which is shown in the grayed out portion of fig. 3.
The following describes in further detail specific embodiments of the present invention and examples of specific development procedures in which the present invention is used.
The embodiment discloses a computer program which is released in a Jar package form. The invention includes application program interface and dynamic replacement function needed by the invention. This program is referred to as a development kit in the following description. In the development step of the plug-in, a developer needs to implement the interface class in the plug-in code, and specifies a target method by implementing a handleLoadClass method therein.
Referring to fig. 4, in this example, the target method is a selectorchanged method in the treeselectionsyncroniser class, and a specific implementation class is shown in fig. 4, when the treeselectionsyncroniser class is loaded, a modifiedselection changed method in selectorhook in a plug-in is used to replace the selectorchanged method (i.e., the modifiedselection changed method is a plug-in method corresponding to the selectorchanged method).
Referring to fig. 5, a specific implementation of the modifiedSelectionChanged method is shown in fig. 5.
After the development of the plug-ins is completed, the developer needs to compile and package the code into a specified plug-in format. The tool in this embodiment requires that the compiled code is packaged into a common Jar package format, and a class name of a specific implementation class that implements the interface class ClassHook is listed in META-INF/manual. And then, when the original open source software runs, the original function is modified by dynamically replacing the function by using a method of a development kit, so that the requirement of secondary development is met.
Referring to fig. 6, the method for dynamically replacing the original function by using the development kit modifies the original function to meet the requirement of secondary development, which comprises the following specific steps:
a, step a: before the original open source software runs, reading each plug-in which needs to be applied, reading the class name of the concrete implementation class of the interface class ClassHook listed in the META-INF/MANIFEST. In the subsequent class loading process, the handleLoadClass methods of the classes are called to obtain the corresponding target method and the corresponding plug-in method.
b, step (b): intercepting a class loading process in original open source software through a Java Agent mechanism, wherein the specific implementation method is to create a class realizing a ClassFileTransformer interface and add an instance of the class into a class loading processing process through an application program interface provided by JDK.
c, step (c): and (b) calling a transform method of the instance created in the step (b) every time a class of the original open source software is to be loaded by the JVM, and if the class contains a certain target method, replacing the definition of the target method in the byte codes of the class with the definition of the corresponding plug-in method when the JVM loads the class, thereby realizing the modification of the functions of the original open source software.
The invention provides a non-invasive development method and a kit support for expanding or modifying functions of Java open source software, and solves the problem of difficult maintenance caused by mixing of upstream codes and secondary development codes in the secondary development process of the Java open source software. The invention has been described in further detail in order to avoid limiting the scope of the invention, and it is intended that all such equivalent embodiments be included within the scope of the following claims.
Claims (3)
1. A secondary development method of non-invasive Java open source software is characterized in that a non-invasive plug-in method is adopted to expand or modify the functions of the Java open source software, secondary development codes are independent to be plug-ins, and the method specifically comprises the following steps:
a, step a: plug-in development
Based on an application program interface provided by a development kit, specifying a method to be modified in original open source software, writing program logic of each specified method after modification by using Java language, and compiling the codes into plug-ins;
b, step (b): dynamic replacement
And c, reading the plug-in after compiling and packaging in the step a, and modifying the Java byte code loading flow of the original open source software, so that when the byte code containing the specified method in the plug-in is loaded, the byte code related to the method is dynamically replaced by the byte code corresponding to the plug-in method.
2. The secondary development method of non-invasive Java open source software according to claim 1, wherein the step a specifically includes:
a-1: based on an application program interface provided by a development kit, writing codes by using Java language to specify a method which should be modified in original source software as a target method, and a method for replacing the target method as a plug-in method;
a-2: writing a program of the plug-in method in the step a-1 by using Java language;
a-3: compiling and packaging the codes into a plug-in format, wherein the plug-in format is determined according to the specific implementation of the development kit.
3. The secondary development method of the non-invasive Java open source software according to claim 1, wherein the step b specifically comprises:
b-1: reading the plug-ins compiled and packaged in the step a, and acquiring each target method and a corresponding plug-in method;
b-2: intercepting a class loading process of original open source software through a Java Agent mechanism provided by a JVM (Java virtual machine) when the original open source software runs;
b-3: when the class containing the target method is loaded, modifying the byte code to be loaded, and replacing the original byte code with the byte code of the plug-in method corresponding to the target method.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210458243.4A CN114895882A (en) | 2022-04-28 | 2022-04-28 | Secondary development method of non-invasive Java open source software |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210458243.4A CN114895882A (en) | 2022-04-28 | 2022-04-28 | Secondary development method of non-invasive Java open source software |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114895882A true CN114895882A (en) | 2022-08-12 |
Family
ID=82720606
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210458243.4A Pending CN114895882A (en) | 2022-04-28 | 2022-04-28 | Secondary development method of non-invasive Java open source software |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114895882A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117150515A (en) * | 2023-10-31 | 2023-12-01 | 上海合见工业软件集团有限公司 | Safety protection method for EDA secondary development source code, electronic equipment and storage medium |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106502757A (en) * | 2016-12-27 | 2017-03-15 | 北京恒华伟业科技股份有限公司 | A kind of plug-in management method and device |
CN111625225A (en) * | 2020-05-28 | 2020-09-04 | 北京达佳互联信息技术有限公司 | Program specified data output method and device |
-
2022
- 2022-04-28 CN CN202210458243.4A patent/CN114895882A/en active Pending
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106502757A (en) * | 2016-12-27 | 2017-03-15 | 北京恒华伟业科技股份有限公司 | A kind of plug-in management method and device |
CN111625225A (en) * | 2020-05-28 | 2020-09-04 | 北京达佳互联信息技术有限公司 | Program specified data output method and device |
Non-Patent Citations (2)
Title |
---|
徐慧慧: "开源J2SE项目Harmony-Instrument模块的设计与实现", 中国优秀硕士学位论文全文数据库 信息科技辑, no. 2, 15 August 2007 (2007-08-15), pages 138 - 126 * |
阚旭 等: "基于uDig的开源GIS态势图的设计研究", 科技创新与应用, no. 05, 18 February 2016 (2016-02-18), pages 29 - 30 * |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117150515A (en) * | 2023-10-31 | 2023-12-01 | 上海合见工业软件集团有限公司 | Safety protection method for EDA secondary development source code, electronic equipment and storage medium |
CN117150515B (en) * | 2023-10-31 | 2024-01-26 | 上海合见工业软件集团有限公司 | Safety protection method for EDA secondary development source code, electronic equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10795660B1 (en) | Live code updates | |
US20160299745A1 (en) | Development method for web development system, and web development system | |
US7603658B2 (en) | Application functionality for a test tool for application programming interfaces | |
US7716246B2 (en) | Dynamic mechanism for providing metadata | |
US8813047B2 (en) | Yet another transformation language (YATL) | |
US8448132B2 (en) | Systems and methods for modifying code generation templates | |
US6795963B1 (en) | Method and system for optimizing systems with enhanced debugging information | |
CN110727438B (en) | Web system automatic generation tool based on SpringBoot | |
US20200167143A1 (en) | Systems and methods for automated retrofitting of customized code objects | |
US8261248B2 (en) | System and method of executing a dynamic program in a structured environment | |
US20050065953A1 (en) | System and method for changing defined elements in a previously compiled program using a description file | |
JP2005078649A (en) | Branding framework | |
WO2019005228A1 (en) | Automated source code adaption to inject features between platform versions | |
CN112835584B (en) | Method for realizing component expansion and management based on REACTNATIVE | |
CN111984235A (en) | Customizable front-end low-code development system and method | |
KR20220132455A (en) | User interface platform developing system and method with micro service architecture | |
CN114895882A (en) | Secondary development method of non-invasive Java open source software | |
JPH10254689A (en) | Application constitution design supporting system for client/server system | |
US7487498B2 (en) | Strategy for referencing code resources | |
CN114371850A (en) | Management method for project construction compiling and code development | |
CN112148283B (en) | Method for realizing cross-platform ABI compatible C++ component framework | |
Hähnle et al. | HATS abstract behavioral specification: The architectural view | |
JP2010205068A (en) | Software resource transition system and transition method thereof | |
CN115098158A (en) | SDK packaging method and device, computer equipment and storage medium | |
US20110321009A1 (en) | Implementing encryption via aspect oriented programming |
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 |