Standard product non-intrusive modification method and device and storage medium
By constructing a control inversion replacement combination annotation and target scanning strategy in standard products, non-invasive modification of standard products is achieved, and the problems of low decoupling and low modification efficiency in the prior art are solved, and the fineness and efficiency of modification are improved.
Patent Information
- Application Number
- CN202411715382.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-27
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2044-11-27
AI Technical Summary
The prior art when standard products are not modified without intrusively, the decoupling degree is low, the modification granularity is large, and the efficiency is low. Especially for classes that are not managed by Spring IOC, it is difficult to achieve non-intrusively modified.
By initializing custom engineering projects, building control inversion replacement combination annotations, sorting candidate component lists, building target scanning strategies, performing configuration modification processing on custom engineering projects, and using target scanning strategies to scan and register the ordered component lists, obtaining the class definition registrant, and instantiating it to achieve non-invasive modification.
Improves the decoupling and efficiency, so that standard products can be modified without intrusion, have high decoupling and small modification granularity, and are suitable for classes managed by Spring IOC and not managed.
Smart Images

Figure CN119645490A_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 generally have product development departments and project delivery departments. The product development department focuses on standard product development, while the project delivery department performs customized development and delivery based on standard products. During customization, the method logic of a certain class of the standard product needs to be modified to meet the personalized needs of customers. If the modification is performed directly on the source code of the standard product, the customized code and the standard product code will be coupled together, which is easy to cause confusion. The existing technology is based on the Spring framework for expansion. By adding annotations to the standard product, the customized code can be used to cover the source code corresponding to the annotation. However, this method still modifies the standard product and has a low degree of decoupling. At the same time, classes in the standard product that are not managed by the Spring framework need to rewrite all methods in the class, with 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 the decoupling degree 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, construct 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 targeted scanning strategy;
[0010] Performing configuration modification processing on the customized engineering project;
[0011] In the customized engineering project after the configuration modification processing, 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-intrusive modification result.
[0013] In some embodiments, the constructing the 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, the step of 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 inversion of control replacement combination annotation, the candidate component is used as the custom component;
[0019] The storage position of the custom 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, the constructing a target scanning strategy includes:
[0021] Get the native scanning strategy;
[0022] The target scanning strategy is constructed according to 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 step of scanning and registering 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, wherein the target component includes the standard product component or the customized component.
[0027] In some embodiments, the method further comprises:
[0028] Use the preset installation plug-in to install standard product packages into the local project management repository;
[0029] Construct the override class;
[0030] After the custom engineering project adds a dependent package and configures a dependent plug-in, a packaging instruction is executed, wherein the packaging instruction is used to overwrite the class to be overwritten in the standard product software package according to the overwriting class to obtain a second non-intrusive modification result.
[0031] On the other hand, an embodiment of the present invention provides a standard product non-invasive modification device, including:
[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] The third module is used 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] The sixth module 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;
[0038] The seventh module is used to instantiate the registered class in the class definition register to obtain a first non-intrusive 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 described 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-intrusive modification result, so that non-intrusive 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 partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by 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 drawings required for use in the description of the embodiments will be briefly introduced below. 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 creative work.
[0048] Figure 1 A flowchart 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 an 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 in conjunction with 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 only examples of devices and methods consistent with some aspects of the embodiments of the present application as detailed in the attached claims.
[0054] It is understood that the terms "first", "second", etc. used in this application can be used to describe various concepts in this article, but unless otherwise specified, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another concept. For example, without departing from the scope of the embodiment 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 can be interpreted as "at the time of" or "when" or "in response to determination".
[0055] The terms "at least one", "multiple", "each", "any", etc. used in this application, at least one includes one, two or more, multiple includes two or more, each refers to each of the corresponding multiple, and any refers to any one of the multiple.
[0056] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0057] Before describing the embodiments of the present application in detail, some nouns and terms involved in the embodiments of the present application are first described. 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 jar package dependency and build tool for managing projects, including a variety of Maven plug-ins to meet the needs of compilation and packaging.
[0061] Decoupling (non-intrusive): refers to the situation that 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 is in line with 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 through the IOC container (if the class is managed by Spring, it is called a Bean). When the programmer wants Spring to help manage a class, he needs 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, and 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 related art, software technology companies are generally divided into product development departments and project delivery departments: product development departments focus on standard product development, and project delivery departments carry out customized development and delivery based on standard products; during this period, the method logic of a certain class of standard products needs to be modified to meet the personalized needs of customers. This operation of directly modifying the source code of standard products will couple the customized code with the standard product code, which is not clear enough and difficult to locate when problems occur. The existing extensions based on the Spring framework do not strictly meet the requirements of non-invasive modification of standard products. A certain method of the standard product class can be modified (the modification granularity is small), but it is impossible to modify classes that are not managed by Spring IOC. When based on Maven plug-ins, classes that are not managed by Spring IOC can achieve non-invasive modification of standard products through this method, but the entire standard product class needs to be overwritten (that is, all methods in the class are overwritten, and methods that do not want to be changed must also be overwritten), and the modification granularity is large. The existing technology marks the @QzingService annotation on the standard product class, and the product development personnel develop the product standard implementation class to implement the standard business requirements designed by the product manager. However, the annotations need to be marked on the product code, which does not meet the requirements of non-intrusive standard products. If others want to use this solution, it means that they have to modify the standard product to add annotations, which leads to low decoupling. In addition, for classes that are not managed by Spring IOC, all methods in the class need to be rewritten, which has a large modification granularity 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 truly non-invasive standard products are achieved. That is, if any other project wants to use it, it does not have to change its own standard product code, but annotates 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] A method for non-invasive modification of a standard product provided in an embodiment of the present application relates to the field of computer technology. A method for non-invasive modification of a standard product provided in an embodiment of the present application can be applied to a terminal, can be applied to a server, or can be 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 can be configured as a server cluster or distributed system composed of multiple physical servers, and can also be configured 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, etc. 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, etc. 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 through 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 in conjunction with the accompanying drawings:
[0071] Figure 1 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, initializing a customized engineering project;
[0073] Step S102: In the customized engineering project, construct a control inversion replacement combination annotation, where the control inversion replacement combination annotation is used to mark the customized class;
[0074] Step S103: 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 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 ordered component list is scanned and registered using the target scanning strategy to obtain a class definition register;
[0078] Step S107: instantiate the registered class in the class definition register to obtain a first non-intrusive modification result.
[0079] Steps S101 to S107 shown in the embodiment of the present application implement non-invasive modification and improve decoupling and efficiency.
[0080] In some embodiments, in step S101, a custom engineering project may be initialized, and the subsequent annotation addition and component scanning processes are all implemented in the custom engineering project. Exemplarily, a Spring Maven custom engineering 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 software.
[0081] In some embodiments, in step S102, constructing a 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 the control inversion replacement combination annotation can be constructed according to the component annotation and the annotation parameter value. Among them, the control inversion replacement combination annotation is used to mark the custom class. Exemplarily, in a custom engineering project, the Spring native @Component component annotation can be obtained first. It can be understood that after the Spring scanning process starts, the class marked with the @Component component annotation will be scanned, and the unmarked will not be scanned. Then set an annotation parameter value value, value value, and construct a custom control inversion replacement combination annotation @IocReplace according to the component annotation and the annotation parameter value. The annotation parameter value value contained in the control inversion replacement combination annotation represents the beanName (management class name) injected into the Spring IOC container. It can be understood that the class class is called beanName after being added to the IOC management, and 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 inversion of control replacement combination annotation, the candidate component is used as a custom component, and the storage position 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 custom components, and the custom components contain custom classes. Exemplarily, the ClassPathBeanDefinitionScanner#doScan method (belonging to the core step of the Spring scanning process) in the source code of the Spring framework can be rewritten to achieve sorting. When processing the scanned candidate components, each candidate component in the candidate component list is judged, and the candidate components are sorted, and the custom class or custom component containing the inversion of control replacement combination annotation @IccReplace is stored at the end of the list to obtain an ordered component list. So that the custom class can cover the class in the standard product and put it into the BeanDefinitionRegistry (Bean definition register) later. 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 cover 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 strategy;
[0092] Build a target scanning strategy based on the native scanning strategy and de-confliction detection mechanism.
[0093] In some embodiments, the native scanning strategy can be obtained first, and then the target scanning strategy can be constructed according to the native scanning strategy and the conflict detection mechanism. Exemplarily, 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, the configuration modification process of 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 customized project can be modified to set the class name overriding permission attribute value in the customized project to true. For example, spring.main.allow-bean-definition-overriding=true is set in the configuration file of the customized project, so that the spring built-in attribute value is true, and the Spring scanner will allow the same beanName to be overridden during the scanning process, that is, when the class name of the customized class is the same as the class name of the class in the standard product, the customized class can be used to overwrite 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, wherein the target components include standard product components or customized components.
[0099] In some embodiments, each target component in the ordered component list can be registered using a target scanning strategy according to the list order to obtain a class definition register. The target component includes a standard product component or a customized component. Exemplarily, the list order is installed, and each target component in the ordered component list is scanned and registered using a target scanning strategy, ignoring conflict detection. When the same class name is scanned, the class in the later order is used to overwrite the class in the earlier order to obtain a class definition register.
[0100] In some embodiments, in step S107, the registered class in the class definition register can be instantiated to obtain the first non-invasive modification result. Exemplarily, 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. More importantly, 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 a 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 is annotated on the custom class. The annotation parameter value 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 (class of the standard product) method logic is rewritten as a custom class. After passing the Spring scanning process, the custom class can cover the class of the standard product to achieve non-invasive modification.
[0101] In some embodiments, the method further comprises:
[0102] Use the preset installation plug-in to install standard product packages into the local project management repository;
[0103] Construct the override 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 overwritten classes to obtain the second non-intrusive modification result.
[0105] In some embodiments, when the class to be rewritten is not managed by Spring IOC, the standard product software package can be installed to the local project management warehouse using the 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 to the local maven warehouse. Then build the overriding class and rewrite the class that needs to be rewritten. After adding the dependency package to the customized engineering project and configuring the dependency plug-in, 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 the second non-intrusive modification result. For example, the dependency package of the standard product can be introduced in the pom.xml file of the customized engineering project, and the maven-dependency-plugin plug-in can be configured, and the unpack instruction (packaging instruction) of the plug-in can be used to implement the overriding of the class class in the standard product Jar package during packaging. In the customized engineering project, write an overriding class with the same package name and class name as the standard product, and rewrite 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, 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 to 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 method of the standard product class A, and 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 to inherit the standard product class A, and rewrite the method logic of the parent class (class A) to package and compile, and obtain the packaged and compiled file. If class A is not managed by Spring IOC, create a new project customized class A, whose class name and package name are consistent with class A, rewrite the method logic that needs to be modified, and run the unpack instruction of the Maven plugin to replace the class of the standard product to obtain the 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 register, and instantiate the registered class in the class definition register to obtain the first non-intrusive modification result, so that non-intrusive modification can be achieved by adding annotations to the customized class, thereby improving the degree of decoupling and efficiency. At the same time, this embodiment can perform secondary development (project customization) for standard products without relying on standard product source code, and decouple the standard product Jar package and customized code. In addition, the combination of Spring extension and Maven plug-in can achieve rewriting of any method logic of any class of standard products (regardless of whether the class is managed by Spring IOC) to meet project requirements, and there is no need to change the standard product source code.
[0109] like Figure 4 As shown, an embodiment of the present invention further provides a standard product non-invasive modification device, including:
[0110] The first module 801 is used to initialize the customized engineering project;
[0111] The second module 802 is used to construct a control inversion replacement combination annotation in the custom engineering project, and the control inversion 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 construct a target scanning strategy;
[0114] The fifth module 805 is used to perform configuration modification processing on 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-intrusive 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, used 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, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, Figure 1 The method shown.
[0124] The contents of the above method embodiments are all applicable to the present storage medium embodiments. The functions specifically implemented by the present storage medium 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.
[0125] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights 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, construct 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 targeted scanning strategy; Performing configuration modification processing on the customized engineering project; In the customized engineering project after the configuration modification processing, the ordered component list is scanned and registered using the target scanning strategy to obtain a class definition register; The registered class in the class definition register is instantiated to obtain a first non-intrusive modification result.
2. The method according to claim 1, characterized in that The construction control inversion replacement combined 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 candidate component list is sorted to obtain an ordered component list, including: Judging each candidate component in the candidate component list; If the candidate component contains the inversion of control replacement combination annotation, the candidate component is used as the custom component; The storage position of the custom component is changed to the end of the position sequence of the candidate component list to obtain the ordered component list.
4. The method according to claim 1, characterized in that: The target scanning strategy is constructed, including: Get the native scanning strategy; The target scanning strategy is constructed according to the native scanning strategy and the de-conflict detection mechanism.
5. The method according to claim 1, characterized in that 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.
6. The method according to claim 1, characterized in that 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, wherein the target component includes the standard product component or the customized component.
7. The method according to claim 1, characterized in that The method further comprises: Use the preset installation plug-in to install standard product packages into the local project management repository; Construct the override class; After the custom engineering project adds a dependent package and configures a dependent plug-in, a packaging instruction is executed, wherein the packaging instruction is used to overwrite the class to be overwritten in the standard product software package according to the overwriting class to obtain a second non-intrusive modification result.
8. 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 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; The third module is used 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; The sixth module 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; The seventh module is used to instantiate the registered class in the class definition register to obtain a first non-intrusive modification result.
9. 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 7.
10. 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 7 is implemented.
Citation Information
Patent Citations
Spring-based non-intrusive modification standard product service system and method
CN112764723A
Method, system and equipment for generating automatic execution strategy, and storage medium
CN113204389A
Bytecode modification method and device
CN113791767A
Managing application customization
US20080066051A1
JMX bean custom service extension plugin agent for an application server
US20080127076A1