A method, device and storage medium for non-invasive modification of standard products
By building control inversion replacement combination annotations and target scanning strategies, configuration modifications are made to customized engineering projects, achieving non-invasive modifications to standard products, improving decoupling and efficiency, and solving the problems of low decoupling and large modification granularity in existing technologies.
Patent Information
- Application Number
- CN202411715382.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-27
- Publication Date
- 2025-09-09
- Estimated Expiration
- 2044-11-27
AI Technical Summary
When performing customized development on standard products, existing technologies easily lead to coupling between customized code and standard product code, low decoupling, large modification granularity, and low efficiency. In particular, it is impossible to implement non-invasive modification for classes that are not managed by Spring IOC.
By building a control inversion replacement combination annotation, marking the custom class, sorting the component list, building a target scanning strategy, configuring and modifying the custom engineering project, and using the target scanning strategy to scan and register, instantiate the class definition registrar, and achieve non-invasive modification.
Improve decoupling and efficiency, achieve non-invasive modification of standard products, eliminate the need to rely on standard product source code, decouple standard product Jar packages and custom code, and support modification of any class.
Smart Images

Figure CN119645490B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method, device and storage medium for non-invasive modification of a standard product. Background Art
[0002] Software technology companies typically have product development and project delivery departments. The product development department focuses on developing standard products, while the project delivery department performs customized development and delivery based on standard products. During customization, the method logic of a class in the standard product needs to be modified to meet the customer's personalized needs. If modifications are made directly on the standard product source code, the customized code and the standard product code will be coupled together, which can easily cause confusion. Existing technologies extend the Spring framework and add annotations to standard products, allowing customized code to overwrite the source code corresponding to the annotations. However, this method still modifies the standard product, resulting in a low degree of decoupling. Furthermore, classes in the standard product that are not managed by the Spring framework require rewriting all methods within the class, resulting in large modification granularity and low efficiency.
[0003] In summary, the technical problems existing in the relevant technologies need to be improved. Summary of the Invention
[0004] The embodiments of the present invention provide a method, device and storage medium for non-invasive modification of a standard product, which effectively improves decoupling and efficiency.
[0005] In one aspect, an embodiment of the present invention provides a method for non-invasively modifying a standard product, comprising the following steps:
[0006] Initialize custom engineering projects;
[0007] In the customized engineering project, constructing a control inversion replacement combination annotation, wherein the control inversion replacement combination annotation is used to mark the customized class;
[0008] Sorting the candidate component list to obtain an ordered component list, wherein the ordered component list includes standard product components and customized components, and the customized components include the customized class;
[0009] Build a target scanning strategy;
[0010] Performing configuration modification processing on the customized engineering project;
[0011] In the customized engineering project after the configuration modification process, the ordered component list is scanned and registered using the target scanning strategy to obtain a class definition register;
[0012] The registered class in the class definition register is instantiated to obtain a first non-invasive modification result.
[0013] In some embodiments, constructing an inversion of control replacement combined annotation includes:
[0014] Get component annotations;
[0015] The control inversion replacement combined annotation is constructed according to the component annotation and the annotation parameter value.
[0016] In some embodiments, sorting the candidate component list to obtain an ordered component list includes:
[0017] Judging each candidate component in the candidate component list;
[0018] If the candidate component contains the control inversion replacement combination annotation, the candidate component is used as the custom component;
[0019] The storage position of the customized component is changed to the end of the position sequence of the candidate component list to obtain the ordered component list.
[0020] In some embodiments, constructing a target scanning strategy includes:
[0021] Get the native scanning policy;
[0022] The target scanning strategy is constructed based on the native scanning strategy and the de-conflict detection mechanism.
[0023] In some embodiments, the configuration modification process of the customized engineering project includes:
[0024] The class name override permission attribute value in the custom engineering project is set to true.
[0025] In some embodiments, the scanning and registering of the ordered component list using the target scanning strategy to obtain a class definition register includes:
[0026] According to the list order, each target component in the ordered component list is registered using the target scanning strategy to obtain the class definition register, where the target component includes the standard product component or the customized component.
[0027] In some embodiments, the method further comprises:
[0028] Use the pre-installed plugin to install standard product packages into the local project management repository;
[0029] Construct the overriding class;
[0030] After adding dependency packages and configuring dependency plug-ins to the customized engineering project, a packaging instruction is executed. The packaging instruction is used to overwrite the to-be-overwritten class in the standard product software package according to the overwriting class to obtain a second non-invasive modification result.
[0031] In another aspect, an embodiment of the present invention provides a device for non-invasively modifying a standard product, comprising:
[0032] The first module is used to initialize the custom engineering project;
[0033] The second module is used to construct a control inversion replacement combination annotation in the customized engineering project, and the control inversion replacement combination annotation is used to mark the customized class;
[0034] A third module is configured to sort the candidate component list to obtain an ordered component list, wherein the ordered component list includes standard product components and customized components, and the customized components include the customized class;
[0035] The fourth module is used to build target scanning strategies;
[0036] The fifth module is used to perform configuration modification processing on the customized engineering project;
[0037] A sixth module is configured to scan and register the ordered component list using the target scanning strategy in the customized engineering project after the configuration modification process, to obtain a class definition register;
[0038] The seventh module is used to instantiate the registered class in the class definition register to obtain a first non-invasive modification result.
[0039] In another aspect, an embodiment of the present invention provides a computer device, comprising:
[0040] at least one processor;
[0041] at least one memory for storing at least one program;
[0042] When the at least one program is executed by the at least one processor, the at least one processor implements the method.
[0043] On the other hand, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described above is implemented.
[0044] The beneficial effects of the present invention are as follows:
[0045] The embodiment of the present invention first initializes the customized engineering project, then constructs the control inversion replacement combination annotation, and sorts the candidate component list to obtain an ordered component list, then constructs the target scanning strategy, and performs configuration modification processing on the customized engineering project, and finally uses the target scanning strategy to scan and register the ordered component list to obtain a class definition registrar, and instantiates the registered class in the class definition registrar to obtain a first non-invasive modification result, so that non-invasive modification can be achieved by adding annotations to the customized class, thereby improving decoupling and efficiency.
[0046] Other features and advantages of the present invention will be described in the following description, and in part will become apparent from the description, or will be understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained through the structures particularly pointed out in the description and the drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0048] Figure 1 This is a flow chart of a method for non-invasive modification of a standard product according to an embodiment of the present invention;
[0049] Figure 2 A schematic diagram of the overall process of sorting, registering, and instantiating components according to an embodiment of the present invention;
[0050] Figure 3 A schematic diagram of an overall process of packaging components according to an embodiment of the present invention;
[0051] Figure 4 This is a schematic diagram of the structure of a non-invasive modification device for a standard product according to an embodiment of the present invention;
[0052] Figure 5 The figure is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0053] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the embodiments of the present application. They are merely examples of devices and methods consistent with some aspects of the embodiments of the present application as detailed in the appended claims.
[0054] It will be understood that the terms "first", "second", etc. used in this application may be used herein to describe various concepts, but unless otherwise specified, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another. For example, without departing from the scope of the embodiments of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the words "if" and "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0055] The terms "at least one", "plurality", "each", "any", etc. used in this application include "at least one", "two" or more, "plurality" or "each", "any" or "any one", "each" or "any one" as used herein.
[0056] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which this application pertains. The terms used herein are for the purpose of describing the embodiments of this application only and are not intended to limit this application.
[0057] Before explaining the embodiments of the present application in detail, some of the nouns and terms involved in the embodiments of the present application are first explained. The nouns and terms involved in the embodiments of the present application are subject to the following explanations.
[0058] Class: refers to the code fragment compiled from Java source code.
[0059] Jar package: A compressed package with the suffix .jar (excluding source code) formed by binary class files compiled from Java source code. The Java virtual machine loads its class files to run.
[0060] Maven: refers to the management of project jar package dependencies and construction tools, including a rich set of Maven plug-ins to meet the needs of compilation and packaging.
[0061] Decoupling (non-intrusive): When a project is customized and developed, instead of making modifications directly on the standard product source code (the traditional method is to make modifications directly on it, which is coupled, that is, the customized code and the product source code are mixed together, which is a common traditional project development model), the project customized code inherits the standard product class and then overrides the methods therein. Inheritance only involves changing the customized code, which conforms to the concept of decoupling (non-intrusive).
[0062] Spring: also known as Springframework, an open source framework that is almost known to everyone in the field of Java development. It manages all beans (if a class is managed by Spring, it is called a bean) through the IOC container. When programmers want Spring to help manage a class, they need to manually specify a beanName (class name) for the class in the code or generate it according to the default rules. Each class needs to have a unique beanName. When other objects need to use this class, they specify the target beanName. SpringIOC will inject the corresponding class according to this name or type. This is a popular explanation of IOC (or inversion of control).
[0063] BeanDefinition (Bean definition, class metadata carrier): It is a built-in component of Spring. When a class needs to be managed by Spring, the Spring scanning process will obtain its various metadata information (such as what attributes, methods, annotations, etc. of this class are) and encapsulate it into BeanDefinition.
[0064] BeanDefinitionRegistry (Bean definition register): also known as Bean definition registry, is a built-in component of Spring. It maintains a BeanDefinitionMap internally, the data type is map (dictionary type), the storage key is beanName, and the value is BeanDefinition. The Spring scanning process will store the scanned BeanDefinition in it, waiting to be instantiated and placed in the IOC container, at which time it can be used by other objects.
[0065] Spring scanning process: also known as Spring scanner. After the programmer marks these classes as beans, when our program starts, Spring will start the scanning process, scan these marked classes and put them into the BeanDefinitionRegistry, and then finally take these classes out for instantiation and put them into the SpringIOC container, so that they can be used by other objects.
[0066] In the prior art, software technology companies are generally divided into product development and project delivery departments. The product development department focuses on developing standard products, while the project delivery department performs customized development and delivery based on these standard products. During this process, modifying the method logic of a class in a standard product to meet individual customer requirements requires modifying the logic directly in the standard product source code, which can result in a lack of clarity and difficulty locating issues. Existing extensions based on the Spring framework don't strictly meet the requirements for non-invasive modification of standard products. While they can modify individual methods in a standard product class (with a narrow granularity), they cannot modify classes not managed by Spring IOC. Using Maven plugins, non-invasive modification of standard products for classes not managed by Spring IOC can be achieved through this approach, but this requires overwriting the entire standard product class (i.e., overriding all methods within the class, including those not intended to be modified), resulting in a high granularity of modification. Existing technology annotates standard product classes with the @QzingService annotation, allowing product developers to develop standard implementation classes to implement the standard business requirements designed by product managers. However, annotations must be added to the product code, which doesn't conform to the standard non-invasive product. This means that if others want to use this solution, they must modify the standard product to add annotations, resulting in low decoupling. Furthermore, for classes not managed by Spring IOC, all methods in the class must be rewritten, resulting in large-scale modifications and low efficiency.
[0067] In view of this, this embodiment organizes standard product Jar packages (compiled files, non-source code) and project customized codes (customized components) based on Spring and Maven plug-ins, and can realize non-invasive modification of standard products. For classes managed by SpringIOC, the standard product code does not need to be modified by annotations on the customized code, and a truly non-invasive standard product is achieved. That is, if any other project wants to use it, it does not have to change its own standard product code, but adds annotations to the customized code, and the entire implementation process is simpler. For classes not managed by Spring IOC, the Maven plug-in is used to cover them. This embodiment breaks the traditional development and delivery model, does not need to rely on product source code development and delivery, and decouples the product Jar package (non-source code) and customized code.
[0068] The embodiment of the present application provides a method for non-invasive modification of a standard product, which relates to the field of computer technology. The embodiment of the present application provides a method for non-invasive modification of a standard product, which can be applied to a terminal, a server, or software running in a terminal or a server. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, and a car terminal, etc., but is not limited to this; the server side can be configured as an independent physical server, or as a server cluster or distributed system composed of multiple physical servers, or as a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The server can also be a node server in a blockchain network; the software can be an application that implements a method for non-invasive modification of a standard product, etc., but is not limited to the above forms.
[0069] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, and the like. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, and the like that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments in which tasks are performed by remote processing devices connected via a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media, including storage devices.
[0070] The following is a detailed explanation of the embodiments of the present application with reference to the accompanying drawings:
[0071] Figure 1 This is an optional flow chart of a method for non-invasive modification of a standard product provided in an embodiment of the present application. Figure 1 The method may include but is not limited to steps S101 to S107.
[0072] Step S101: Initialize the customized engineering project;
[0073] Step S102: In the customized engineering project, construct a control inversion replacement combination annotation, which is used to mark the customized class;
[0074] Step S103: sort the candidate component list to obtain an ordered component list, where the ordered component list includes standard product components and customized components, and the customized components include customized classes;
[0075] Step S104: construct a target scanning strategy;
[0076] Step S105: performing configuration modification processing on the customized engineering project;
[0077] Step S106: In the customized engineering project after the configuration modification, the target scanning strategy is used to scan and register the ordered component list to obtain a class definition register;
[0078] Step S107: Instantiate the registered class in the class definition register to obtain a first non-invasive modification result.
[0079] Steps S101 to S107 shown in the embodiment of the present application implement non-invasive modification, thereby improving decoupling and efficiency.
[0080] In some embodiments, in step S101, a custom project may be initialized. Subsequent annotation addition and component scanning processes are implemented within this custom project. For example, a Spring Maven custom project may be initialized. It is understood that the Spring framework is an open-source J2EE application framework, and Maven is a project building and management tool.
[0081] In some embodiments, in step S102, constructing the control inversion replacement combination annotation may include but is not limited to the following steps:
[0082] Get component annotations;
[0083] Construct an inversion of control replacement composite annotation based on component annotations and annotation parameter values.
[0084] In some embodiments, the component annotation can be obtained first, and then a control inversion replacement composite annotation can be constructed based on the component annotation and the annotation parameter value. The control inversion replacement composite annotation is used to mark custom classes. For example, in a custom engineering project, the Spring native @Component component annotation can be obtained first. It is understandable that after the Spring scanning process starts, the class marked with the @Component component annotation will be scanned, and those that are not marked will not be scanned. Then set an annotation parameter value value, value value, and construct a custom control inversion replacement composite annotation @IocReplace based on the component annotation and the annotation parameter value. The annotation parameter value value contained in the control inversion replacement composite annotation represents the beanName (management class name) injected into the Spring IOC container. It is understandable that the class class is called beanName after being added to the IOC management. IocReplace refers to a mechanism for replacing the Bean component in the IOC container in the Spring framework. The program code can be expressed as: public@interface IocReplace{@AliasFor(annotation=Component.class)string value();}
[0085] In some embodiments, in step S103, sorting the candidate component list to obtain an ordered component list may include but is not limited to the following steps:
[0086] Judge each candidate component in the candidate component list;
[0087] If the candidate component contains the Inversion of Control Replacement combination annotation, the candidate component is treated as a custom component;
[0088] The storage position of the custom component is changed to the end of the position sequence of the candidate component list to obtain an ordered component list.
[0089] In some embodiments, each candidate component in the candidate component list can be judged first. If the candidate component contains the control inversion replacement combination annotation, the candidate component is treated as a custom component, and the storage location of the custom component is changed to the end of the position order of the candidate component list to obtain an ordered component list. Among them, the ordered component list includes standard product components and customized components, and the customized components include customized classes. For example, the ClassPathBeanDefinitionScanner#doScan method in the source code of the Spring framework (belonging to the core step of the Spring scanning process) can be rewritten to achieve sorting. When processing the scanned candidate components, each candidate component in the candidate component list is judged and sorted, and the custom class or custom component containing the control inversion replacement combination annotation @IccReplace is stored at the end of the list to obtain an ordered component list. So that the custom class can subsequently cover the class in the standard product and be placed in the BeanDefinitionRegistry (Bean definition register). In the map (dictionary) data type, when two key-value pairs with the same key name are placed in the map one after another, the value placed later will overwrite the value placed earlier.
[0090] In some embodiments, in step S104, constructing a target scanning strategy may include but is not limited to the following steps:
[0091] Get the native scanning policy;
[0092] Build a target scanning strategy based on the native scanning strategy and de-conflict detection mechanism.
[0093] In some embodiments, the native scanning strategy can be obtained first, and then the target scanning strategy can be constructed based on the native scanning strategy and the conflict detection mechanism. For example, the ClassPathBeanDefinitionScanner#checkCandidate method in the source code of the spring framework (belonging to the pre-check step in the Spring scanning process) can be rewritten to improve the scanning strategy. Add judgment logic, when the custom class contains the control inversion replacement combination annotation @IocReplace, no conflict detection is performed, so that even if the same BeanDefinition (Bean definition) exists, the scan is performed normally. It can be understood that in the native scanning strategy, when the existence of the same BeanDefinition is detected, it is treated as a conflict error and no scanning is performed. The improved target scanning strategy can remove conflict detection to achieve a comprehensive scan.
[0094] In some embodiments, in step S105, performing configuration modification processing on the customized engineering project may include but is not limited to the following steps:
[0095] Set the Class Name Override Permit property value in the custom engineering project to true.
[0096] In some embodiments, the custom project can be modified to allow class name overriding in the custom project to be set to true. For example, by setting spring.main.allow-bean-definition-overriding=true in the custom project's configuration file, the Spring built-in property value is set to true. This allows the Spring scanner to allow identical beanName overriding during scanning. This means that if a custom class has the same name as a class in a standard product, the custom class can override the class in the standard product.
[0097] In some embodiments, in step S106, scanning and registering the ordered component list using the target scanning strategy to obtain a class definition register may include but is not limited to the following steps:
[0098] According to the list order, each target component in the ordered component list is registered using a target scanning strategy to obtain a class definition register, where the target components include standard product components or customized components.
[0099] In some embodiments, a target scanning strategy can be used to register each target component in the ordered component list according to the list order, thereby obtaining a class definition register. The target components include standard product components or customized components. For example, the list order is installed, and each target component in the ordered component list is scanned and registered using the target scanning strategy, ignoring conflict detection. When the same class name is scanned, the class with the later order overrides the class with the earlier order, thereby obtaining a class definition register.
[0100] In some embodiments, in step S107, the registered class in the class definition register can be instantiated to obtain a first non-invasive modification result. For example, the Spring scanning process will eventually obtain all beans (class names) in the BeanDefinitionRegistry, instantiate all classes in the Bean definition register, and put them into the IOC container to obtain the first non-invasive modification result. Moreover, the instantiated class can be used by other objects. The effect can be verified. When the class to be rewritten can be managed by Spring IOC, when a method of a class in the standard product needs to be rewritten, a custom class can be customized to inherit the class to be rewritten in the standard product, and the control inversion replacement combination annotation @IocReplace can be annotated on the custom class. The annotation parameter value in the control inversion replacement combination annotation is equal to the beanName injected into the IOC container by the parent class, and then the parent class (standard product class) method logic is rewritten as a custom class. After passing the Spring scanning process, the custom class can cover the standard product class to achieve non-invasive modification.
[0101] In some embodiments, the method further comprises:
[0102] Use the pre-installed plugin to install standard product packages into the local project management repository;
[0103] Construct the overriding class;
[0104] After adding dependency packages and configuring dependency plug-ins in the customized engineering project, the packaging instruction is executed. The packaging instruction is used to overwrite the classes to be overwritten in the standard product software package according to the overwriting class to obtain the second non-invasive modification result.
[0105] In some embodiments, when the class that needs to be rewritten is not managed by Spring IOC, the standard product software package can be installed into the local project management warehouse using a preset installation plug-in. For example, the maven-install-plugin plug-in of Maven can be used to install the jar package (non-source code) of the standard product into the local maven warehouse. Then build the overriding class and rewrite the class that needs to be rewritten. After adding the dependency package and configuring the dependency plug-in to the customized engineering project, execute the packaging instruction, wherein the packaging instruction is used to overwrite the class to be overridden in the standard product software package according to the overriding class, and obtain a second non-invasive modification result. For example, the dependency package of the standard product can be introduced into the pom.xml file of the customized engineering project, and the maven-dependency-plugin plug-in can be configured. With the help of the unpack instruction (packaging instruction) of the plug-in, the class class in the standard product Jar package can be overwritten during packaging. In the customized engineering project, write an overriding class with the same package name and class name as the standard product, and overwrite the method logic in the class. If the method does not need to be overridden, the original method logic can be used. Then execute the Maven clean install command to package. In the classes directory, the class of the standard product can be replaced by the overridden class.
[0106] In some embodiments, the overall process of sorting, registering and instantiating components is as follows: Figure 2 As shown, you can start the project first, execute Spring's doScan method to scan candidate components, and filter and sort the scanned candidate component list, judge each candidate component in the candidate component list, and if the candidate component contains a custom control inversion replacement combination annotation @IocReplace, put the candidate component at the end of the list to get an ordered component list, and then traverse the component list and execute checkCandidate to check the candidate components. If the candidate component contains the control inversion replacement combination annotation, skip the beanDefinition conflict detection mechanism, and inject the final component list into the Bean definition registrar (beanDefinitionMap), and finally use Spring to instantiate the Bean to achieve non-invasive modification of standard products.
[0107] In some embodiments, the overall process of packaging components is as follows: Figure 3As shown, you can first rewrite the methods of the standard product class A, then determine whether class A is managed by Spring IOC. If class A is managed by Spring IOC, create a new project customized class A1 that inherits the standard product class A and rewrites the method logic of the parent class (class A) to package and compile, resulting in a packaged and compiled file. If class A is not managed by Spring IOC, create a new project customized class A with the same class name and package name as class A, overwrite the method logic that needs to be modified, and run the Maven plugin's unpack command to replace the standard product class, resulting in a packaged and compiled file.
[0108] The beneficial effects of implementing the embodiments of the present invention include: the embodiments of the present invention first initialize the customized engineering project, then construct the control inversion replacement combination annotation, and sort the candidate component list to obtain an ordered component list, then construct the target scanning strategy, and perform configuration modification processing on the customized engineering project, and finally use the target scanning strategy to scan and register the ordered component list to obtain a class definition registrar, and instantiate the registered class in the class definition registrar to obtain the first non-invasive modification result, so that non-invasive modification can be achieved by adding annotations to the customized class, thereby improving decoupling and efficiency. At the same time, this embodiment can perform secondary development (project customization) for the standard product without relying on the standard product source code, and decouple the standard product Jar package and the customized code. In addition, by combining the Spring extension and the Maven plug-in, it is possible to rewrite the logic of any method of any class of the standard product (regardless of whether the class is managed by Spring IOC) to meet project requirements without changing the standard product source code.
[0109] like Figure 4 As shown, an embodiment of the present invention further provides a device for non-invasively modifying a standard product, comprising:
[0110] The first module 801 is used to initialize a custom engineering project;
[0111] The second module 802 is used to construct an inversion of control replacement combination annotation in the custom engineering project, and the inversion of control replacement combination annotation is used to mark the custom class;
[0112] The third module 803 is used to sort the candidate component list to obtain an ordered component list, where the ordered component list includes standard product components and customized components, and the customized components include customized classes;
[0113] The fourth module 804 is used to build a target scanning strategy;
[0114] The fifth module 805 is used to modify the configuration of the customized engineering project;
[0115] The sixth module 806 is used to scan and register the ordered component list using the target scanning strategy in the customized engineering project after the configuration modification process to obtain a class definition register;
[0116] The seventh module 807 is used to instantiate the registered class in the class definition register to obtain a first non-invasive modification result.
[0117] The contents of the above method embodiments are all applicable to the present device embodiments. The functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0118] like Figure 5 As shown, an embodiment of the present invention further provides a computer device, including:
[0119] at least one processor 901;
[0120] At least one memory 902, configured to store at least one program;
[0121] When at least one program is executed by at least one processor, the at least one processor implements Figure 1 The method shown.
[0122] The contents of the above method embodiments are all applicable to the present device embodiments. The functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0123] The embodiment of the present invention further provides a computer-readable storage medium, which stores a computer program, which is executed by a processor to implement Figure 1 The method shown.
[0124] The contents of the above method embodiments are all applicable to the present storage medium embodiment. The functions specifically implemented by the present storage medium embodiment are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0125] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but are not intended to limit the scope of the present invention. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and essence of the present invention should be within the scope of the present invention.
Claims
1. A method for non-invasive modification of a standard product, characterized in that: The following steps are involved: Initialize custom engineering projects; In the customized engineering project, constructing a control inversion replacement combination annotation, wherein the control inversion replacement combination annotation is used to mark the customized class; Sorting the candidate component list to obtain an ordered component list, wherein the ordered component list includes standard product components and customized components, and the customized components include the customized class; Build a target scanning strategy; Performing configuration modification processing on the customized engineering project; In the customized engineering project after the configuration modification process, the ordered component list is scanned and registered using the target scanning strategy to obtain a class definition register; Instantiating the registered class in the class definition register to obtain a first non-invasive modification result; The step of sorting the candidate component list to obtain an ordered component list includes: Judging each candidate component in the candidate component list; If the candidate component contains the control inversion replacement combination annotation, the candidate component is used as the custom component; Transforming the storage position of the customized component to the end of the position sequence of the candidate component list to obtain the ordered component list; The configuration modification process of the customized engineering project includes: The class name override permission attribute value in the custom engineering project is set to true.
2. The method according to claim 1, characterized in that The construction of the inversion of control replacement combination annotation includes: Get component annotations; The control inversion replacement combined annotation is constructed according to the component annotation and the annotation parameter value.
3. The method according to claim 1, characterized in that The target scanning strategy is constructed, including: Get the native scanning policy; The target scanning strategy is constructed based on the native scanning strategy and the de-conflict detection mechanism.
4. The method according to claim 1, wherein The step of scanning and registering the ordered component list using the target scanning strategy to obtain a class definition register includes: According to the list order, each target component in the ordered component list is registered using the target scanning strategy to obtain the class definition register, where the target component includes the standard product component or the customized component.
5. The method according to claim 1, wherein The method further comprises: Use the pre-installed plugin to install standard product packages into the local project management repository; Construct the overriding class; After adding dependency packages and configuring dependency plug-ins to the customized engineering project, a packaging instruction is executed. The packaging instruction is used to overwrite the to-be-overwritten class in the standard product software package according to the overwriting class to obtain a second non-invasive modification result.
6. A non-invasive modification device for a standard product, characterized in that include: The first module is used to initialize the custom engineering project; The second module is used to construct an inversion of control replacement combination annotation in the customized engineering project, and the inversion of control replacement combination annotation is used to mark the customized class; A third module is configured to sort the candidate component list to obtain an ordered component list, wherein the ordered component list includes standard product components and customized components, and the customized components include the customized class; The fourth module is used to build target scanning strategies; The fifth module is used to perform configuration modification processing on the customized engineering project; A sixth module is configured to scan and register the ordered component list using the target scanning strategy in the customized engineering project after the configuration modification process, to obtain a class definition register; A seventh module is used to instantiate the registered class in the class definition register to obtain a first non-invasive modification result; The step of sorting the candidate component list to obtain an ordered component list includes: Judging each candidate component in the candidate component list; If the candidate component contains the control inversion replacement combination annotation, the candidate component is used as the custom component; Transforming the storage position of the customized component to the end of the position sequence of the candidate component list to obtain the ordered component list; The configuration modification process of the customized engineering project includes: The class name override permission attribute value in the custom engineering project is set to true.
7. A computer device, characterized in that: include: at least one processor; at least one memory for storing at least one program; When the at least one program is executed by the at least one processor, the at least one processor implements the method according to any one of claims 1 to 5.
8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Spring-based non-intrusive modification standard product service system and method
CN112764723A
Method, apparatus and storage medium for customizing application
US20090031283A1