CN116541105A - Annotation-based component loading method, system, terminal and storage medium - Google Patents

Annotation-based component loading method, system, terminal and storage medium Download PDF

Info

Publication number
CN116541105A
CN116541105A CN202310820195.3A CN202310820195A CN116541105A CN 116541105 A CN116541105 A CN 116541105A CN 202310820195 A CN202310820195 A CN 202310820195A CN 116541105 A CN116541105 A CN 116541105A
Authority
CN
China
Prior art keywords
class
component
loading
annotation
abstract
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310820195.3A
Other languages
Chinese (zh)
Inventor
廖振伟
李国庆
左勇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Athena Eyes Co Ltd
Original Assignee
Athena Eyes Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Athena Eyes Co Ltd filed Critical Athena Eyes Co Ltd
Priority to CN202310820195.3A priority Critical patent/CN116541105A/en
Publication of CN116541105A publication Critical patent/CN116541105A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
    • G06F9/44526Plug-ins; Add-ons
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The application provides a component loading method, a system, a terminal and a storage medium based on annotation, which relate to the technical field of computers, in particular to a component loading method based on annotation, wherein the method comprises the following steps: obtaining a target class which is pre-created in the source code of the application program, wherein the target class comprises: the basic component loads abstract class, component realization class, self-defined annotation class of automatic loading component, automatic loading component class and loading component constant class; adding the automatic loading component class on the self-defined annotation class of the automatic loading component; acquiring an application starting class of the application program, and adding a custom annotation class of the automatic loading component on the application starting class, wherein the annotation value is a constant attribute field of a component configured in a constant class of the loading component; and when the application program is started, the application starting class is operated, and components required to be used are loaded through the target class. The method and the device can realize the on-demand loading of the components.

Description

Annotation-based component loading method, system, terminal and storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method, a system, a terminal, and a storage medium for loading components in annotation.
Background
With the development of internet technology, various basic technology iterations are continuously updated, and the operation of system service functions is not supported by some middleware. Hadoop (Hadoop is a distributed system infrastructure developed by the Apache foundation) components such as HDFS (Hadoop Distributed File System ), HIVE (HIVE is a data warehouse tool based on Hadoop), YARN (Yet Another Resource Negotiator, another resource coordinator is a new Hadoop resource manager) and the like are often used in big data systems.
In the prior art, in the big data system, the loading connection of the components is generally performed in a mode of configuration files, but in the big data system, the loading connection mode of the prior components is too complex because of too many loading components, and the configuration files cannot be dynamically changed, so that the configuration cannot be flexibly switched, and the components cannot be loaded according to requirements.
Therefore, how to implement on-demand loading of components is a technical problem to be solved by those skilled in the art.
Disclosure of Invention
In order to solve the technical problems, the application provides an annotation-based component loading method which can realize on-demand loading of components. The application also provides an annotation-based component loading system, a terminal and a storage medium, which have the same technical effects.
It is a first object of the present application to provide a method of annotation-based component loading.
The first object of the present application is achieved by the following technical solutions:
an annotation-based component loading method, comprising:
obtaining a target class which is pre-created in the source code of the application program, wherein the target class comprises: the basic component loads abstract class, component realization class, self-defined annotation class of automatic loading component, automatic loading component class and loading component constant class;
adding the automatic loading component class on the self-defined annotation class of the automatic loading component;
acquiring an application starting class of the application program, and adding a custom annotation class of the automatic loading component on the application starting class, wherein the annotation value is a constant attribute field of a component configured in a constant class of the loading component;
when the application program is started, the application starting class is operated, and components to be used are loaded through the target class;
the running the application starting class and loading the components to be used through the target class comprises the following steps:
running the application starting class, and configuring components to be used through the custom annotation class of the automatic loading component added on the application starting class and the components configured in the loading component constant class;
operating a method function in the automatic loading component class through the automatic loading component class added on the self-defined annotation class of the automatic loading component;
acquiring configuration data of a component required to be used by the custom annotation class of the automatic loading component;
acquiring a component realization class set inheriting the basic component loading abstract class;
and loading the corresponding component realization class in the component realization class set according to the configuration data so as to load the components required to be used.
Preferably, in the annotation-based component loading method, the method further includes:
when the application program is used, the abstract class is loaded through the basic component, so that the dynamic replacement of the component loading configuration file is realized.
Preferably, in the annotation-based component loading method, the dynamic replacement of the component loading configuration file is achieved by loading an abstract class through the base component, including:
and loading the loadFile method function of the abstract class through the basic component, and dynamically inquiring the data to realize the dynamic replacement of the component loading configuration file.
Preferably, in the annotation-based component loading method, the method further includes:
when the application program is used, abstract classes are loaded through the basic components, so that the unification of the loading and using modes of the components is realized.
Preferably, in the annotation-based component loading method, the abstract class is loaded through the base component to realize the unification of the component loading usage mode, which comprises the following steps:
and loading the load method function of the abstract class through the basic component, and using an abstract factory mode to realize the unification of the loading and using modes of the component.
Preferably, in the annotation-based component loading method, the component implementation class includes an HDFS loading class and a yan loading class, wherein:
the HDFS loading class inherits the basic component loading abstract class and is used for realizing load and getType method functions;
the YARN load class inherits the basic component load abstract class and is used for realizing load and getType method functions.
It is a second object of the present application to provide an annotation based component loading system.
The second object of the present application is achieved by the following technical solutions:
an annotation-based component loading system, comprising:
the acquisition unit is used for acquiring a target class which is created in advance in the source code of the application program, wherein the target class comprises: the basic component loads abstract class, component realization class, self-defined annotation class of automatic loading component, automatic loading component class and loading component constant class;
the first annotation unit is used for adding the automatic loading component class on the self-defined annotation class of the automatic loading component;
the second annotation unit is used for acquiring an application starting class of the application program, adding a custom annotation class of the automatic loading component on the application starting class, wherein the annotation value is a constant attribute field of a component configured in the constant class of the loading component;
the loading unit is used for running the application starting class when the application program is started, and loading components to be used through the target class;
the loading unit is specifically configured to, when executing the running application starting class and loading a component to be used through the target class, perform:
running the application starting class, and configuring components to be used through the custom annotation class of the automatic loading component added on the application starting class and the components configured in the loading component constant class;
operating a method function in the automatic loading component class through the automatic loading component class added on the self-defined annotation class of the automatic loading component;
acquiring configuration data of a component required to be used by the custom annotation class of the automatic loading component;
acquiring a component realization class set inheriting the basic component loading abstract class;
and loading the corresponding component realization class in the component realization class set according to the configuration data so as to load the components required to be used.
A third object of the present application is to provide an annotation based component loading terminal.
The third object of the present application is achieved by the following technical solutions:
an annotation-based component loading terminal, comprising: a storage medium and a processor;
computer-executable instructions are stored in the storage medium;
the processor executes computer-executable instructions stored on the storage medium to implement any of the methods described above for annotation-based component loading.
A fourth object of the present application is to provide a computer-readable storage medium.
The fourth object of the present application is achieved by the following technical solutions:
a computer readable storage medium having stored therein computer executable instructions for implementing any of the above-described annotation-based component loading methods when executed by a processor.
According to the technical scheme, the target class is created in the source code of the application program in advance, wherein the target class comprises: the basic component loads abstract class, component realization class, self-defined annotation class of automatic loading component, automatic loading component class and loading component constant class; adding an automatic loading component class on the custom annotation class of the automatic loading component; acquiring an application starting class of an application program, and adding a custom annotation class of an automatic loading component on the application starting class, wherein the annotation value is a constant attribute field of a component configured in a loading component constant class; when an application program is started, an application starting class is operated, and components to be used are loaded through a target class, wherein the specific steps include: running an application starting class, and configuring components to be used through the self-defined annotation class of the automatic loading component added on the application starting class and the components configured in the constant class of the loading component; operating a method function in the automatic loading component class through the automatic loading component class added on the self-defined annotation class of the automatic loading component; acquiring configuration data of a component required to be used by a custom annotation class of an automatic loading component; acquiring a component realization class set inheriting the basic component loading abstract class; and loading the corresponding component realization class in the component realization class set according to the configuration data so as to load the components required to be used.
The technical scheme supports the components used for loading according to the needs in use, and increases the selectivity of the system to the components. In summary, the above technical solution can realize the on-demand loading of the components.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings that are required to be used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments described in the present application, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow diagram of an annotation-based component loading method provided in an embodiment of the present application;
FIG. 2 is a schematic diagram of an annotation-based component loading system provided in an embodiment of the present application;
fig. 3 is a schematic structural diagram of an annotation-based component loading terminal according to an embodiment of the present application.
Detailed Description
In order to better understand the technical solutions in the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below, and it is obvious that the described embodiments are only some embodiments of the present application, not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure.
In the embodiments provided in the present application, it should be understood that the disclosed method and system may be implemented in other manners. The system embodiments described below are merely illustrative, and for example, the division of modules is merely a logical function division, and other divisions may be implemented in practice, such as: multiple modules or components may be combined, or may be integrated into another system, or some features may be omitted, or not performed. In addition, the various components shown or discussed may be coupled or directly coupled or communicatively coupled to each other via some interface, whether indirectly coupled or communicatively coupled to devices or modules, whether electrically, mechanically, or otherwise.
It should be appreciated that the terms "system," "apparatus," "unit," and/or "module," if used herein, are merely one method for distinguishing between different components, elements, parts, portions, or assemblies at different levels. However, if other words can achieve the same purpose, the word can be replaced by other expressions.
Furthermore, the terms "first," "second," and the like, are used for descriptive purposes only and are not to be construed as indicating or implying a relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include one or more such feature. In the description of the present application, the meaning of "a plurality" or "a number" is two or more, unless explicitly defined otherwise.
If a flowchart is used in the present application, the flowchart is used to describe the operations performed by the system according to embodiments of the present application. It should be appreciated that the preceding or following operations are not necessarily performed in order precisely. Rather, the steps may be processed in reverse order or simultaneously. Also, other operations may be added to or removed from these processes.
It should also be noted that, in this document, terms such as "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that an article or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such article or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in an article or apparatus that comprises such element.
The embodiment of the application is written in a progressive manner.
As shown in fig. 1, an embodiment of the present application provides an annotation-based component loading method, including:
s101, acquiring a target class which is created in advance in an application program source code, wherein the target class comprises: the basic component loads abstract class, component realization class, self-defined annotation class of automatic loading component, automatic loading component class and loading component constant class;
in S101, the application may be specifically implemented based on JAVA programming language and a Spring framework, which is a J2EE application framework with open source code. In JAVA, a class is a collection of entities with certain common characteristics, which is an abstract data type that is an abstraction of entities with the same characteristics, and in an object-oriented programming language, a class is an abstraction of the properties and behavior of a class of "things". A well-selected set of user-defined classes will make the program more compact, and in addition it will make the analysis of the code in various forms easier, and in particular it will make it possible for the compiler to check the object for illegal use. In some embodiments, the target methods in the target class may be obtained and used by JAVA mapping. The target class may also be obtained by other means, which is not limited in this application.
In a specific embodiment, a base component load abstract class may be created in advance [ BaseLoad ], and the following three method functions are defined in the [ BaseLoad ] class:
1. abstract method load, method return value type is org.apache.hadoop.conf.configuration class, and the main functions of the method are as follows: the configuration operation class available for assembling the specific component, loading configuration files, loading configuration parameters and the like.
2. The method loadFile, the method return value type is List < String >, the main function of the method is: and inquiring the corresponding file content and the file local address through the type inquiry database, generating a local file, and returning a new file address.
3. Abstract method getType, method return value type is String, and the main functions of the method are as follows: component encodings are defined, and classes can be found by corresponding encodings.
In JAVA, a generic class is a well-defined functional class, and can directly generate an instantiation object, and in the generic class, the contents such as a construction method, a generic method, a static method, constants, variables, and the like can be included. And abstract class refers to adding components of abstract methods inside the structure of common class. There is a "{ }" above all common methods, which means that the method body, the method with the method body, must be directly used by the object. The abstract method is a method without a method body, and the abstract method also needs to use a keyword abstract for modification. The class with the abstract method is an abstract class, and the abstract class is declared by using an abstract keyword. One of the greatest meanings of abstract class existence is inheritance, and when inherited, polymorphism can be realized by utilizing abstract class.
In a specific embodiment, a component implementation class inheriting a basic component loading abstract class [ BaseLoad ] may be created in advance, and the component implementation class may include an HDFS loading class [ HdfsLoad ] and a YARN loading class [ YarnLoad ], where:
HDFS load class [ HdfsLoad ], inheritance base component load abstract class [ BaseLoad ], for implementing load and getType method functions;
YARN loads class [ YarnLoad ] and inheritance base component loads abstract class [ BaseLoad ] for implementation of load and getType method functions.
In JAVA, the implementation class is the content agreed in the implementation interface, in which the specification is defined, and determines how the specification operates.
In a specific embodiment, a custom annotation class @ EnableHadoopoplad for the auto-load component may be pre-created, where:
the @ EnableHadoopopload has the following field properties: value, its type is String [ ];
and marking the following original notes on the @ EnableHadoopopload class:
@ Target ({ elementtype. Type }) (labeled class type);
@ Retention (Retention policy. RUNTIME) (labeled runtime).
In a programming language such as JAVA, annotation is a special modifier applied to classes, methods, parameters, variables, constructors, or package declarations, and is a tool used to describe metadata. Custom annotations are annotations written by the developer by itself with meta-annotations, except for built-in annotations in the system. In a specific application, the system provides the following four meta-notes:
documed-for determining if the defined annotation is to be contained in a JAVA document;
the @ Retention-is used to determine when to use a defined annotation;
@ Target-is used to determine where the annotation is to be used;
the @ Inherited-is used to determine whether to allow the subclass to inherit the defined annotation.
Note that the above-mentioned notes are completely different from the notes. In general, annotations are used to inform developers of the logic, description, characteristics, etc. of code, and can be written arbitrarily without limitation; at compile time, annotations may be ignored entirely by the compiler. Annotation is the notification of metadata of elements such as class, method, parameters, variables, constructors or packages to JAVA virtual machines by labeling these elements, which generally start with "@" and have strict restrictions on location, grammar, content, and if any error occurs, an exception will be displayed during compilation.
In a specific embodiment, an auto-load component class [ LoadImportSelector ] may be created in advance, and the auto-load component class [ LoadImportSelector ] is used to implement an ImportSelector interface, thereby implementing a method function selectImports;
the method function selectImports is specifically implemented as follows:
1. acquiring an attribute field value set of an @ EnableHadoop load annotation class through a method function annostationmetadata.
2. Judging whether the attribute field value set of the annotation class is empty, if so, returning new String [0], and if not, acquiring a value attribute field value through the attribute field value set of the annotation class;
3. and judging whether the value of the attribute field is empty, returning to new String [0] if the value of the attribute field is empty, and returning to the value of the attribute field if the value of the attribute field is not empty.
In particular embodiments, a load component constant class [ LoadConstant ] may be created in advance, defining the constant attribute fields and values that require the load component.
The following are examples:
public static final String HDFS = "[ HdfsLoad ] class packet name";
public static final String YARN = "[ YarnLoad ] class packet name.
The implementation of constant classes and constant methods in Java is done by key final. Generally, two cases are divided: 1. a constant that is immutable at compile time; 2. run-time initialization, but does not want the variable that was changed. The compiler can substitute its value into its place, i.e. the calculation formula is already executed at compile time, reducing the load at run time and optimizing the performance. These constants must be of a basic type in Java and must be assigned values.
S102, adding an automatic loading component class on the custom annotation class of the automatic loading component;
in S102, specifically, an @ report annotation may be added to an @ enablehadooplop load annotation class, where the value of the annotation is a @ LoadImportSelector "class, i.e., an auto-load component class, which functions as: the class is automatically loaded when the application is started through the @ report annotation, [ loadreport selector ], and specific method functions in the class are run.
S103, acquiring an application starting class of the application program, and adding a custom annotation class of the automatic loading component on the application starting class, wherein the annotation value is a constant attribute field of a component configured in a constant class of the loading component;
in S103, specifically, the application startup class may be created in advance in the application source code, and in this step, by adding @ enablehadoop load annotation to the application startup class, the value of the annotation is a constant attribute field of a specific component in the [ LoadConstant ] (i.e. loading component constant class): components that need to be loaded are introduced through the @ EnableHadoop load annotation configuration.
S104, when the application program is started, running an application starting class, and loading components to be used through a target class.
In S104, the specific implementation manner of this step includes: when an application program is started, an application starting class is operated, and components to be used are configured through the custom annotation class of the automatic loading component added on the application starting class and the components configured in the loading component constant class; operating a method function in the automatic loading component class through the automatic loading component class added on the self-defined annotation class of the automatic loading component; acquiring configuration data of a component required to be used by a custom annotation class of an automatic loading component; acquiring a component realization class set inheriting the basic component loading abstract class; and loading the corresponding component realization class in the component realization class set according to the configuration data so as to load the components required to be used. The on-demand loading of the components is realized, and the system selectivity to the components is increased.
In a specific embodiment, the components to be loaded can be configured by applying the @ EnableHadoop load annotation marked on the startup class and the components configured in the [ LoadConstat ] class; the method comprises the steps of loading a [ LoadImport selector ] class of a mark in an @ EnableHadoop load annotation, running a concrete method function in the [ LoadImport selector ] class, acquiring component configuration data required to be loaded by the @ EnableHadoop load annotation, and acquiring all component realization class sets inheriting a basic component loading abstract [ BaseLoad ] class. The corresponding component implementation class is found in the set of component implementation classes through the component configuration data (e.g., [ HdfsLoad ] class, [ YarnLoad ] class, etc. are component implementation classes).
In the prior art, in the big data system, the loading connection of the components is generally performed in a mode of configuration files, but in the big data system, the loading connection mode of the prior components is too complex because of too many loading components, and the configuration files cannot be dynamically changed, so that the configuration cannot be flexibly switched, and the components cannot be loaded according to requirements.
The above embodiment, the target class is created in advance in the source code of the application program, where the target class includes: the basic component loads abstract class, component realization class, self-defined annotation class of automatic loading component, automatic loading component class and loading component constant class; adding an automatic loading component class on the custom annotation class of the automatic loading component; acquiring an application starting class of an application program, and adding a custom annotation class of an automatic loading component on the application starting class, wherein the annotation value is a constant attribute field of a component configured in a loading component constant class; when an application program is started, an application starting class is operated, and components to be used are loaded through a target class, wherein the specific steps include: running an application starting class, and configuring components to be used through the self-defined annotation class of the automatic loading component added on the application starting class and the components configured in the constant class of the loading component; operating a method function in the automatic loading component class through the automatic loading component class added on the self-defined annotation class of the automatic loading component; acquiring configuration data of a component required to be used by a custom annotation class of an automatic loading component; acquiring a component realization class set inheriting the basic component loading abstract class; and loading the corresponding component realization class in the component realization class set according to the configuration data so as to load the components required to be used.
The above-described embodiments support components for loading on demand in use, increasing the system's options for components. In summary, the above embodiments can realize on-demand loading of components.
In other embodiments of the present application, the annotation-based component loading method further includes:
s201, when an application program is used, the abstract class is loaded through the basic component, so that dynamic replacement of the component loading configuration file is realized.
In S201, specifically, component configuration data may be queried from a database through coding of the component, a local configuration file is generated according to the component configuration data, and a local configuration file required by a specific component is added when loading connection, so as to realize dynamic replacement of the component loading configuration file. In some embodiments, one implementation manner of this step is specifically: the loadFile method function of the abstract class is loaded through the basic component, and the dynamic replacement of the component loading configuration file is realized through the dynamic query of data. The dynamic replacement of the component loading configuration file is realized by modifying the component configuration data in the database, dynamically inquiring the data and generating a local configuration file.
In the embodiment, the problem that the configuration cannot be flexibly switched due to the fact that the configuration file cannot be dynamically changed in a big data system is solved, the dynamic replacement of the configuration file through the components is achieved through loading abstract classes by the basic components, the risk of suspension of the system is reduced, and the flexibility of the system is improved.
In other embodiments of the present application, the annotation-based component loading method further includes:
s301, loading abstract classes through basic components when an application program is used, and realizing the unification of component loading and use modes.
In S301, specifically, one implementation manner of this step is specifically: the load method function of the abstract class is loaded through the basic component, and the abstract factory mode is used for realizing the unification of the component loading using mode. By using the abstract factory mode, all the component realization classes inherit the basic components to load abstract classes, and realize load method functions, and when the system loads the components, the load method functions are directly and uniformly called, so that the unification of the loading and using modes of the components is realized.
Wherein the abstract factory schema (Abstract Factory Pattern) is affiliated with a creation-type schema in the design schema for the construction of the product family. By using an abstract factory schema, concrete classes can be separated, customers manipulate instances through the abstract interface, class names for products are also separated in the implementation of the concrete factory, they do not appear in the customer code. The use of abstract factory patterns while allowing easy exchange of product families, a specific factory class appears only once at initialization, which makes it easy to change a specific factory of an application, and only changes specific factories can use different product configurations. Furthermore, using abstract factory patterns, which is important for product consistency, is easy to achieve by abstract factories when a series of product objects are designed to work together, one application can only use objects in the same series at a time.
In this embodiment, it is considered that the existing component loading connection mode is too complex and the usage mode is not uniform because of too many loading components in the big data system. The abstract class is loaded through the basic component, so that unified component loading processing can be realized, the working time for writing repeated codes by developers is shortened, the working efficiency is accelerated, and the developers can pay more attention to service development.
As shown in fig. 2, in another embodiment of the present application, there is also provided an annotation-based component loading system, comprising:
an obtaining unit 10, configured to obtain a target class created in advance in an application source code, where the target class includes: the basic component loads abstract class, component realization class, self-defined annotation class of automatic loading component, automatic loading component class and loading component constant class;
a first annotation unit 11, configured to add an auto-loading component class to a custom annotation class of the auto-loading component;
the second annotation unit 12 is configured to obtain an application startup class of the application program, and add a custom annotation class of the auto-load component to the application startup class, where the annotation value is a constant attribute field of a component configured in the constant class of the load component;
the loading unit 13 is used for running an application starting class when the application program is started, and loading components to be used through a target class;
the loading unit 13 is specifically configured to, when executing the running application startup class and loading the component to be used through the target class:
running an application starting class, and configuring components to be used through the self-defined annotation class of the automatic loading component added on the application starting class and the components configured in the constant class of the loading component;
operating a method function in the automatic loading component class through the automatic loading component class added on the self-defined annotation class of the automatic loading component;
acquiring configuration data of a component required to be used by a custom annotation class of an automatic loading component;
acquiring a component realization class set inheriting the basic component loading abstract class;
and loading the corresponding component realization class in the component realization class set according to the configuration data so as to load the components required to be used.
As shown in fig. 3, in another embodiment of the present application, there is also provided an annotation-based component loading terminal, including: a storage medium 20 and a processor 21;
computer-executable instructions are stored within the storage medium 20;
the processor 21 executes computer-executable instructions stored on the storage medium 20 to implement any of the methods described above for annotation-based component loading.
Wherein the processor 21 may comprise one or more processing cores. The processor 21 performs various functions of the present application and processes data by executing or executing instructions, programs, code sets, or instruction sets stored in the storage medium 20, invoking data stored in the storage medium 20. The processor 21 may be at least one of an application specific integrated circuit, a digital signal processor, a digital signal processing device, a programmable logic device, a field programmable gate array, a central processing unit, a controller, a microcontroller, and a microprocessor. It will be appreciated that the electronics for implementing the functions of the processor 21 described above may also be other for different devices.
Wherein the storage medium 20 may be used to store instructions, programs, code sets, or instruction sets. The storage medium 20 may include a storage program area and a storage data area, wherein the storage program area may store instructions for implementing an operating system, instructions for at least one function, instructions for implementing any of the annotation-based component loading methods described above, and the like; the store data area may store data or the like involved in any of the annotation-based component loading methods described above.
In another embodiment of the present application, there is also provided a computer-readable storage medium having stored therein computer-executable instructions for implementing any of the above-described annotation-based component loading methods when executed by a processor.
The computer readable storage medium may be various media capable of storing program codes, such as a usb disk, a removable hard disk, a read-only memory, a random access memory, or an optical disk.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (9)

1. An annotation-based component loading method, comprising:
obtaining a target class which is pre-created in the source code of the application program, wherein the target class comprises: the basic component loads abstract class, component realization class, self-defined annotation class of automatic loading component, automatic loading component class and loading component constant class;
adding the automatic loading component class on the self-defined annotation class of the automatic loading component;
acquiring an application starting class of the application program, and adding a custom annotation class of the automatic loading component on the application starting class, wherein the annotation value is a constant attribute field of a component configured in a constant class of the loading component;
when the application program is started, the application starting class is operated, and components to be used are loaded through the target class;
the running the application starting class and loading the components to be used through the target class comprises the following steps:
running the application starting class, and configuring components to be used through the custom annotation class of the automatic loading component added on the application starting class and the components configured in the loading component constant class;
operating a method function in the automatic loading component class through the automatic loading component class added on the self-defined annotation class of the automatic loading component;
acquiring configuration data of a component required to be used by the custom annotation class of the automatic loading component;
acquiring a component realization class set inheriting the basic component loading abstract class;
and loading the corresponding component realization class in the component realization class set according to the configuration data so as to load the components required to be used.
2. The method as recited in claim 1, further comprising:
when the application program is used, the abstract class is loaded through the basic component, so that the dynamic replacement of the component loading configuration file is realized.
3. The method of claim 2, wherein the dynamically changing component loading configuration files by loading abstract classes through the base component comprises:
and loading the loadFile method function of the abstract class through the basic component, and dynamically inquiring the data to realize the dynamic replacement of the component loading configuration file.
4. The method as recited in claim 1, further comprising:
when the application program is used, abstract classes are loaded through the basic components, so that the unification of the loading and using modes of the components is realized.
5. The method of claim 4, wherein loading abstract classes through the base component to achieve unification of component loading usage comprises:
and loading the load method function of the abstract class through the basic component, and using an abstract factory mode to realize the unification of the loading and using modes of the component.
6. The method of claim 1, wherein the component implementation classes comprise an HDFS load class and a YARN load class, wherein:
the HDFS loading class inherits the basic component loading abstract class and is used for realizing load and getType method functions;
the YARN load class inherits the basic component load abstract class and is used for realizing load and getType method functions.
7. An annotation-based component loading system, comprising:
the acquisition unit is used for acquiring a target class which is created in advance in the source code of the application program, wherein the target class comprises: the basic component loads abstract class, component realization class, self-defined annotation class of automatic loading component, automatic loading component class and loading component constant class;
the first annotation unit is used for adding the automatic loading component class on the self-defined annotation class of the automatic loading component;
the second annotation unit is used for acquiring an application starting class of the application program, adding a custom annotation class of the automatic loading component on the application starting class, wherein the annotation value is a constant attribute field of a component configured in the constant class of the loading component;
the loading unit is used for running the application starting class when the application program is started, and loading components to be used through the target class;
the loading unit is specifically configured to, when executing the running application starting class and loading a component to be used through the target class, perform:
running the application starting class, and configuring components to be used through the custom annotation class of the automatic loading component added on the application starting class and the components configured in the loading component constant class;
operating a method function in the automatic loading component class through the automatic loading component class added on the self-defined annotation class of the automatic loading component;
acquiring configuration data of a component required to be used by the custom annotation class of the automatic loading component;
acquiring a component realization class set inheriting the basic component loading abstract class;
and loading the corresponding component realization class in the component realization class set according to the configuration data so as to load the components required to be used.
8. An annotation-based component loading terminal, comprising: a storage medium and a processor;
computer-executable instructions are stored in the storage medium;
the processor executes computer-executable instructions stored on the storage medium to implement the method of any one of claims 1 to 6.
9. A computer readable storage medium having stored therein computer executable instructions which when executed by a processor are adapted to carry out the method of any one of claims 1 to 6.
CN202310820195.3A 2023-07-06 2023-07-06 Annotation-based component loading method, system, terminal and storage medium Pending CN116541105A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310820195.3A CN116541105A (en) 2023-07-06 2023-07-06 Annotation-based component loading method, system, terminal and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310820195.3A CN116541105A (en) 2023-07-06 2023-07-06 Annotation-based component loading method, system, terminal and storage medium

Publications (1)

Publication Number Publication Date
CN116541105A true CN116541105A (en) 2023-08-04

Family

ID=87445697

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310820195.3A Pending CN116541105A (en) 2023-07-06 2023-07-06 Annotation-based component loading method, system, terminal and storage medium

Country Status (1)

Country Link
CN (1) CN116541105A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117311799A (en) * 2023-11-30 2023-12-29 钱塘科技创新中心 Configuration method of software project page
CN117435512A (en) * 2023-12-21 2024-01-23 摩尔元数(福建)科技有限公司 Unit test method for automatically switching different database types based on Junit5

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107908442A (en) * 2017-12-07 2018-04-13 武汉斗鱼网络科技有限公司 Resource loading method, device, terminal device and computer-readable recording medium based on spring
CN111324333A (en) * 2018-12-17 2020-06-23 中移(杭州)信息技术有限公司 Software development method and device based on componentization
CN113778388A (en) * 2020-06-29 2021-12-10 北京京东拓先科技有限公司 Program development method and device
CN114217787A (en) * 2021-12-13 2022-03-22 网易(杭州)网络有限公司 Development method and device of modular application program and storage medium
CN115237631A (en) * 2022-07-29 2022-10-25 四川科瑞软件有限责任公司 Easily-extensible data sharing system and method based on data sharing plug-in
US20230089305A1 (en) * 2021-08-24 2023-03-23 Vmware, Inc. Automated naming of an application/tier in a virtual computing environment
US20230106435A1 (en) * 2020-04-30 2023-04-06 Huawei Technologies Co.,Ltd. Application processing method and apparatus, cloud environment, medium, and program product
CN116010038A (en) * 2023-02-09 2023-04-25 平安壹钱包电子商务有限公司 Bean object management method and device of Spring framework, electronic equipment and storage medium
CN116340269A (en) * 2023-03-29 2023-06-27 中电云数智科技有限公司 Method for acquiring and searching Flink task logs in real time based on elastic search

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107908442A (en) * 2017-12-07 2018-04-13 武汉斗鱼网络科技有限公司 Resource loading method, device, terminal device and computer-readable recording medium based on spring
CN111324333A (en) * 2018-12-17 2020-06-23 中移(杭州)信息技术有限公司 Software development method and device based on componentization
US20230106435A1 (en) * 2020-04-30 2023-04-06 Huawei Technologies Co.,Ltd. Application processing method and apparatus, cloud environment, medium, and program product
CN113778388A (en) * 2020-06-29 2021-12-10 北京京东拓先科技有限公司 Program development method and device
US20230089305A1 (en) * 2021-08-24 2023-03-23 Vmware, Inc. Automated naming of an application/tier in a virtual computing environment
CN114217787A (en) * 2021-12-13 2022-03-22 网易(杭州)网络有限公司 Development method and device of modular application program and storage medium
CN115237631A (en) * 2022-07-29 2022-10-25 四川科瑞软件有限责任公司 Easily-extensible data sharing system and method based on data sharing plug-in
CN116010038A (en) * 2023-02-09 2023-04-25 平安壹钱包电子商务有限公司 Bean object management method and device of Spring framework, electronic equipment and storage medium
CN116340269A (en) * 2023-03-29 2023-06-27 中电云数智科技有限公司 Method for acquiring and searching Flink task logs in real time based on elastic search

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
E_MLLS的博客-CSDN: "Spring项目中自定义注解的使用", Retrieved from the Internet <URL:https://blog.csdn.net/qq_37435078/article/details/90523309> *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117311799A (en) * 2023-11-30 2023-12-29 钱塘科技创新中心 Configuration method of software project page
CN117311799B (en) * 2023-11-30 2024-03-19 钱塘科技创新中心 Configuration method of software project page
CN117435512A (en) * 2023-12-21 2024-01-23 摩尔元数(福建)科技有限公司 Unit test method for automatically switching different database types based on Junit5
CN117435512B (en) * 2023-12-21 2024-03-08 摩尔元数(福建)科技有限公司 Unit test method for automatically switching different database types based on Junit5

Similar Documents

Publication Publication Date Title
KR101795844B1 (en) Runtime system
CN116541105A (en) Annotation-based component loading method, system, terminal and storage medium
JP6602283B2 (en) System and method for supporting object-oriented script tools
US8954939B2 (en) Extending a development environment
US7133874B2 (en) Prototyping model for components of a software program
US7484223B2 (en) System and method for building a run-time image from components of a software program
US7428559B2 (en) Versioning model for software program development
US20050149914A1 (en) Method of and system for sharing components between programming languages
US8141035B2 (en) Method for accessing internal states of objects in object oriented programming
US20090319554A1 (en) Unified metadata for external components
US20120331013A1 (en) Object-Relational Mapped Database Initialization
Alkhoun Language Specification
JP4806158B2 (en) System and method for declaratively defining and using subclasses in markup
US7421715B1 (en) System and method for dynamic late-binding of persistent object implementations in software-based systems
EP2380078B1 (en) Shared value resolution with multiple runtime containers
CN112631656A (en) Intelligent contract optimization method and device based on source code
CN115437619A (en) iOS classification attribute adding method and device, electronic device and storage medium
CN105393216B (en) Run-time memory is adjusted
Piumarta et al. Open, extensible object models
US20200241857A1 (en) Methods, systems, and computer program products for processing an excludable addressable entity
CN117234466B (en) Enterprise management software development method, system, equipment and storage medium
Sharan et al. Implementing Services
CN117348971A (en) Namespace class calling method, apparatus, device, storage medium and program product
US20160266879A1 (en) Methods, systems, and computer program products for processing an excludable addressable entity
DOES The active life is the life for me!

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination