CN112612477B - Service implementation method, device, equipment and storage medium - Google Patents
Service implementation method, device, equipment and storage medium Download PDFInfo
- Publication number
- CN112612477B CN112612477B CN202011607944.7A CN202011607944A CN112612477B CN 112612477 B CN112612477 B CN 112612477B CN 202011607944 A CN202011607944 A CN 202011607944A CN 112612477 B CN112612477 B CN 112612477B
- Authority
- CN
- China
- Prior art keywords
- source code
- original
- code file
- file
- service
- 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.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 47
- 238000013507 mapping Methods 0.000 claims abstract description 156
- 238000004590 computer program Methods 0.000 claims description 14
- 230000001960 triggered effect Effects 0.000 claims description 9
- 238000012545 processing Methods 0.000 abstract description 5
- 238000010586 diagram Methods 0.000 description 8
- 238000005516 engineering process Methods 0.000 description 3
- 230000003068 static effect Effects 0.000 description 2
- 238000011161 development Methods 0.000 description 1
- 238000001914 filtration Methods 0.000 description 1
- 230000006870 function Effects 0.000 description 1
- 230000009545 invasion Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/73—Program documentation
Landscapes
- Engineering & Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Library & Information Science (AREA)
- Stored Programmes (AREA)
- Devices For Executing Special Programs (AREA)
Abstract
The application relates to the technical field of computer processing, and provides a service implementation method, a device, computer equipment and a storage medium. Specifically, the method annotates in a compiling mode to obtain the extension source code file of the specified class, the code is not required to be modified, the extension source code file corresponding to the specified class is loaded based on the mapping relation between the specified class and the extension source code file, and then the original service and the extension service are executed through the extension source code file, so that the invasiveness to the original code is reduced while the extension service is realized on the basis of the original service. In addition, before the appointed class is used, the application compiles and forms the expansion source code file corresponding to the appointed class, when the appointed class is used, the corresponding expansion source code file is directly loaded to execute the expansion service, belongs to non-dynamic real-time annotation, and has lower performance loss compared with the dynamic real-time annotation mode of the container.
Description
Technical Field
The present application relates to the field of computer processing technologies, and in particular, to a service implementation method, a device, a computer device, and a storage medium.
Background
With the development of computer processing technology, a technology for realizing a service based on computer code has emerged. After the computer code is set, the computer device executes the set computer code, so that the corresponding service can be realized. In implementing a service, it is often necessary to do so by class.
In some scenarios, after the computer code is set, the service needs to be expanded, and if the original class cannot meet the expanded service, the annotated class needs to meet the expanded service in an annotation mode.
In the processing mode provided by the traditional scheme, annotation is generally carried out based on a container, and the class obtained after annotation can meet the expanded service, but the container mode needs to modify the set computer code, so that the invasiveness is high.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a service implementation method, apparatus, computer device, and storage medium.
A method of service implementation, the method comprising:
acquiring notes configured for a specified class;
Compiling an original source code file by using the annotation to obtain an extended source code file, and generating a second mapping relation between the extended source code file and the appointed class; the original source code file and the appointed class have a first mapping relation, and the original source code file is a source code file for executing original service;
And loading the extension source code file based on the second mapping relation and the specified class so as to execute the original service and the extension service aiming at the original service by utilizing the extension source code file.
In one embodiment, the loading the extension source code file based on the second mapping relation and the specified class to execute the original service and the extension service for the original service by using the extension source code file includes:
If the original service is triggered and started, determining the sequence of the first mapping relation in a plurality of mapping relations; the plurality of mapping relations are mapping relations between other classes of the original service and corresponding source code files, and the first mapping relation and the plurality of mapping relations are registered to a naming space;
Registering the second mapping relationship to the namespace based on an ordering of the first mapping relationship among the plurality of mapping relationships; wherein the ordering of the second mapping relationship in the plurality of mapping relationships is prior to the ordering of the first mapping relationship in the plurality of mapping relationships;
and if the specified class is read, loading the extended source code file corresponding to the second mapping relation according to the sequence of the first mapping relation and the second mapping relation in the name space so as to execute the original service and the extended service aiming at the original service by utilizing the extended source code file.
In one embodiment, the method further comprises:
And if the second mapping relation is deleted after being registered in the name space, loading the original source code file corresponding to the first mapping relation according to the first mapping relation in the name space when the specified class is read, so as to execute the original service by utilizing the original source code file.
In one embodiment, compiling the original source code file with the annotation to obtain the extended source code file includes:
Analyzing a source code structure of the original source code file;
If the source code structure of the original source code file does not accord with the annotation source code structure, formatting the source code structure of the original source code file into the annotation source code structure to obtain a formatted original source code file; the annotation source code structure is the source code structure required by the annotation;
And compiling the formatted original source code file and the annotation to obtain the extended source code file.
In one embodiment, compiling the formatted original source code file and the annotation to obtain the extended source code file includes:
compiling the formatted original source code file and the annotation to obtain an initial extension source code file;
and formatting the source code structure of the initial extended source code file from the annotation source code structure to the source code structure of the original source code file to obtain the extended source code file.
In one embodiment, before parsing the source code structure of the original source code file, the method further comprises:
Acquiring a plurality of candidate original source code files corresponding to the specified class;
Scanning source code file types corresponding to the candidate original source code files;
and determining a candidate original source code file with the source code file type consistent with the annotation source code type from a plurality of candidate original source code files, and taking the determined candidate original source code file as an original source code file to be analyzed.
In one embodiment, the obtaining a plurality of candidate native source code files corresponding to the specified class includes:
Acquiring a project file aiming at the original service; the project file comprises candidate original source code files of each class, and the candidate original source code files of the same class are belonged to the same catalog of the project file;
Reading a catalog to be scanned in the configuration file;
and scanning the candidate original source code files under the project file to-be-scanned directory to obtain a plurality of candidate original source code files corresponding to the specified class.
A service implementation apparatus, the apparatus comprising:
the annotation acquisition module is used for acquiring the annotation configured for the specified class;
the file compiling module is used for compiling the original source code file by utilizing the annotation to obtain an extended source code file and generating a second mapping relation between the extended source code file and the appointed class; the original source code file and the appointed class have a first mapping relation, and the original source code file is a source code file for executing original service;
And the file loading module is used for loading the extension source code file based on the second mapping relation and the appointed class so as to execute the original service and the extension service aiming at the original service by utilizing the extension source code file.
A computer device comprising a memory storing a computer program and a processor implementing the method described above when executing the computer program.
A computer readable storage medium having stored thereon a computer program which when executed by a processor implements the method described above.
The service implementation method, the device, the computer equipment and the storage medium, wherein the computer equipment acquires notes configured for a specified class; compiling an original source code file by using the annotation to obtain an extended source code file, and generating a second mapping relation between the extended source code file and the appointed class; the original source code file and the appointed class have a first mapping relation, and the original source code file is a source code file for executing original service; and loading the extension source code file based on the second mapping relation and the specified class so as to execute the original service and the extension service aiming at the original service by utilizing the extension source code file. Therefore, in the above manner, the computer device annotates the original service and the extended service through the extended source code file to obtain the extended source code file of the specified class in a compiling manner, the code is not required to be modified, the extended source code file corresponding to the specified class is loaded based on the mapping relation between the specified class and the extended source code file, and further the original service and the extended service are executed through the extended source code file, so that the invasiveness to the original code is reduced while the extended service is realized on the basis of realizing the original service. In addition, the traditional annotation mode based on the container is only generated when the container is called when the new class is obtained by decorating the class through the container, belongs to dynamic real-time annotation and has performance loss; compared with a container mode, the method and the device have the advantages that before the appointed class is used, the extended source code file corresponding to the appointed class is compiled, when the appointed class is used, the extended service can be executed by directly loading the corresponding extended source code file, the method and the device belong to non-dynamic real-time annotation, and the performance loss is lower.
Drawings
FIG. 1 is an internal block diagram of a computer device in one embodiment;
FIG. 2 is a flow diagram of a method of implementing services in one embodiment;
FIG. 3 is a namespace diagram of one embodiment having multiple mappings registered;
FIG. 4 is a flow diagram of a method of implementing services in one embodiment;
FIG. 5 is a flow diagram of a method of implementing services in one embodiment;
fig. 6 is a block diagram of a service implementation apparatus in one embodiment.
Detailed Description
The present application will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present application more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application.
Reference in the specification to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the application. The appearances of such phrases in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. Those of skill in the art will explicitly and implicitly appreciate that the described embodiments of the application may be combined with other embodiments.
The service implementation method provided by the application can be applied to computer equipment, and the internal structure diagram of the service implementation method can be shown in figure 1. The computer device includes a processor, a memory, and a network interface connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database of the computer device is for storing business implementation data. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a service implementation method.
It will be appreciated by those skilled in the art that the architecture shown in fig. 1 is merely a block diagram of some of the architecture relevant to the present inventive arrangements and is not limiting as to the computer device to which the present inventive arrangements may be implemented, as a particular computer device may include more or less components than those shown, or may be combined with some components, or may have a different arrangement of components.
In one embodiment, as shown in fig. 2, a service implementation method is provided, and the method is applied to a computer device for illustration, and includes the following steps:
Step S201, the computer equipment acquires the notes configured for the specified class;
wherein the computer device may read the configuration file with a code scanner (scanner) to obtain annotations configured for the specified class.
Step S202, the computer equipment compiles the original source code file by using the annotation to obtain an extended source code file, and generates a second mapping relation between the extended source code file and the appointed class; the original source code file has a first mapping relation with the appointed class, and the original source code file is a source code file for executing the original service;
in step S203, the computer device loads the extension source code file based on the second mapping relation and the specified class, so as to execute the original service and the extension service for the original service by using the extension source code file.
In the service implementation method, the computer equipment annotates the code to obtain the extension source code file of the specified class in a compiling mode, the code is not required to be modified, the extension source code file corresponding to the specified class is loaded based on the mapping relation between the specified class and the extension source code file, and then the original service and the extension service are executed through the extension source code file, so that the invasiveness to the original code is reduced while the original service is realized on the basis of realizing the original service. And, based on the way that the container annotates, when the container decorates the class to obtain a new class, only happens when the container is called, and the method belongs to dynamic real-time annotation and has performance loss; before the appointed class is used, the application compiles and forms the extension source code file corresponding to the appointed class, when the appointed class is used, the corresponding extension source code file is directly loaded to execute the extension service, and the application belongs to non-dynamic real-time annotation, and compared with the dynamic real-time annotation mode of the container, the application has lower performance loss.
In one embodiment, the computer device may specifically perform the following steps when performing step S203: if the original service is triggered and started, determining the sequence of the first mapping relation in a plurality of mapping relations; the plurality of mapping relations are mapping relations between other classes of the original service and corresponding source code files, and the first mapping relation and the plurality of mapping relations are registered to the name space; registering the second mapping relationship to the namespace based on ordering of the first mapping relationship in the plurality of mapping relationships; wherein the ordering of the second mapping relationship in the plurality of mapping relationships precedes the ordering of the first mapping relationship in the plurality of mapping relationships; if the specified class is read, loading an extension source code file corresponding to the second mapping relation according to the ordering sequence of the first mapping relation and the second mapping relation in the naming space so as to execute the original service and the extension service aiming at the original service by utilizing the extension source code file.
As shown in fig. 3, the namespace registers a mapping relationship (i.e., a first mapping relationship) between class 1 and the original source code file, and a mapping relationship between class 2 and the source code file; wherein, class 1 and class 2 are both classes for the original service, and if class 1 is a designated class, class 2 can be regarded as other classes. When the original service is triggered and started, the computer equipment registers the mapping relation (namely the second mapping relation) between the class 1 and the extension source code file into the name space, and after the registration is completed, the mapping relation between the class 1 and the extension source code file is before the mapping relation between the class 1 and the original source code file, so when the appointed class is used, the computer equipment can load the extension source code file according to the mapping relation between the ordered prior class 1 and the extension source code file, and execute the original service and the extension service based on the original service by utilizing the extension source code file.
It can be seen that in the above embodiment, by ordering the mapping relationships registered to the namespaces, when the computer device uses the specified class, the extension source code file of the class 1 may be loaded first, instead of the original source code file of the class 1, so as to ensure the execution of the extension service.
Further, the computer device may also perform the steps of: if the second mapping relation is deleted after being registered in the name space, when the appointed class is read, loading an original source code file corresponding to the first mapping relation according to the first mapping relation in the name space so as to execute the original service by utilizing the original source code file.
That is, if the second mapping relationship is deleted from the namespace, when the computer device uses the class 1, the mapping relationship between the class 1 and the original source code file can be used to load the original source code file of the class 1, so that the original service is restored to be executed, the code does not need to be modified, and the service processing efficiency is improved while the invasiveness is reduced.
In one embodiment, when the computer device performs step S202, the following steps may be specifically performed: analyzing a source code structure of an original source code file; if the source code structure of the original source code file does not accord with the annotation source code structure, formatting the source code structure of the original source code file into the annotation source code structure to obtain a formatted original source code file; annotating the source code structure to be the source code structure required for the annotation; and compiling the formatted original source code file and annotation to obtain an extended source code file.
That is, if the source code structure of the original source code file of the specified class does not conform to the source code structure required for annotation (i.e., annotate the source code structure), formatting of the source code structure is performed first, and then compiling is performed, so that the correctness of compiling is ensured.
Further, when the computer device compiles the formatted original source code file and the annotation to obtain the extended source code file, the computer device may further execute the following steps: compiling the formatted original source code file and annotation to obtain an initial extension source code file; and formatting the source code structure of the initial extended source code file from the annotation source code structure to the source code structure of the original source code file to obtain the extended source code file.
Therefore, the source code structure of the extended source code file obtained after the source code structure is formatted is the source code structure required by the annotation, so that further formatting is needed, the source code structure of the extended source code file is formatted from the annotation source code structure to the source code structure of the original source code file, and the loaded extended source code file can be ensured to be normally used for executing the extended service.
Further, before executing the parsing of the source code structure of the original source code file, the computer device may further execute the following steps: acquiring a plurality of candidate original source code files corresponding to the specified class; scanning source code file types corresponding to the candidate original source code files; and determining a candidate original source code file with the source code file type consistent with the annotation source code type from a plurality of candidate original source code files, and taking the determined candidate original source code file as an original source code file to be analyzed.
The source code file types may include c++, php, json, etc., among others. For class 1, the source code file corresponding to class 1 may include types of c++, php, json, etc. as described above; if the annotation is for php, the computer device may first filter out the c++ and json type source code files in class 1, preserve the php type source code files, and parse the php type source code files.
Therefore, the computer equipment takes the candidate original source code file of the source code file type consistent with the annotation source code type as the original source code file to be analyzed, and does not compile the source code file which does not accord with the annotation source code type, so that the annotation efficiency can be improved while ensuring the annotation mode with low invasiveness.
Still further, the computer device may perform the following steps when acquiring a plurality of candidate native source code files corresponding to the specified class: acquiring a project file aiming at the original service; the project file comprises candidate original source code files of each class, and the candidate original source code files of the same class are belonged to the same catalog of the project file; reading a catalog to be scanned in the configuration file; and scanning the candidate original source code files under the project file to-be-scanned directory to obtain a plurality of candidate original source code files corresponding to the specified class.
The computer device may further use the code scanner to read the configuration file to obtain a directory to be scanned, an annotation for a specified class, an ignore source code file type (e.g. the annotation is for php type, then c++ and json type are ignore source code file types), and an ignore directory (e.g. the annotation is for class 1, then class 2 directory is ignore directory), so as to improve annotation efficiency while ensuring a low invasive annotation mode.
As shown in fig. 4, the present application provides a service implementation method, which specifically includes:
Step S401, obtaining project files aiming at original business; the project file comprises candidate original source code files of each class, and the candidate original source code files of the same class are belonged to the same catalog of the project file;
step S402, reading a catalog to be scanned and notes configured for a specified class in a configuration file;
step S403, scanning candidate original source code files under the project file to-be-scanned directory to obtain a plurality of candidate original source code files corresponding to the specified class;
Step S404, scanning source code file types corresponding to the candidate original source code files;
Step S405, determining a candidate original source code file with a source code file type consistent with the annotation source code type from a plurality of candidate original source code files, and taking the determined candidate original source code file as an original source code file to be analyzed;
Step S406, analyzing the source code structure of the original source code file;
Step S407, if the source code structure of the original source code file does not accord with the annotation source code structure of the annotation, formatting the source code structure of the original source code file into the annotation source code structure to obtain the formatted original source code file;
Step S408, compiling the formatted original source code file and annotation to obtain an initial extended source code file;
step S409, the source code structure of the original extended source code file is formatted from the annotation source code structure to the source code structure of the original source code file, and the extended source code file is obtained;
step S410, generating a second mapping relation between the extended source code file and the appointed class;
Step S411, if the original service is triggered and started, determining the sequence of the first mapping relation in the plurality of mapping relations; the first mapping relationship and the plurality of mapping relationships are registered to the namespace;
Step S412, registering the second mapping relationship to the namespace based on the ordering of the first mapping relationship among the plurality of mapping relationships; wherein the ordering of the second mapping relationship in the plurality of mapping relationships precedes the ordering of the first mapping relationship in the plurality of mapping relationships;
step S413, if the specified class is read, loading the extension source code file corresponding to the second mapping relation according to the sequence of the first mapping relation and the second mapping relation in the naming space, so as to execute the original service and the extension service aiming at the original service by utilizing the extension source code file.
It can be seen that, in the above embodiment, the computer device annotates by a compiling manner to obtain the extension source code file of the specified class, and based on the mapping relationship between the specified class and the extension source code file, loads the extension source code file corresponding to the specified class, so as to execute the original service and the extension service through the extension source code file, and reduce the invasiveness to the original code while realizing the extension service on the basis of realizing the original service. In addition, the traditional annotation mode based on the container is only generated when the container is called when the new class is obtained by decorating the class through the container, belongs to dynamic real-time annotation and has performance loss; compared with a container mode, the method and the device have the advantages that before the appointed class is used, the extended source code file corresponding to the appointed class is compiled, when the appointed class is used, the extended service can be executed by directly loading the corresponding extended source code file, the method and the device belong to non-dynamic real-time annotation, and the performance loss is lower.
For a better understanding of the above method, an application example of the service implementation method of the present application is described in detail below with reference to fig. 5. The annotation for this application instance is for a php type source code file.
During compilation, code units utilized by a computer device may include a code scanner, a file manager (finder), a code parser (PHP PARSER), and a compiler (compiler); after the original service is triggered to start, the code unit utilized by the computer device may include an auto loader (annotation loader).
Firstly, introducing the functions executed by the code units in the compiling process:
① The code scanner is responsible for reading the configuration file, obtaining the catalog to be scanned, the user-defined annotation aiming at the specified class, ignoring the source code file type and ignoring the catalog, and delivering the annotation and the source code file of the scanned specified class to the file manager, the code parser and the compiler.
② The file manager is responsible for filtering, determining a php type source code file from the source code files of the specified class, and delivering the php type source code file to the code analyzer;
③ The code analyzer analyzes the acquired php type source code file, determines the source code structure of the source code file, formats the source code structure, analyzes the annotated content to determine the source code structure conforming to the annotation.
④ The compiler compiles the formatted source code file and annotation to obtain an initial compiled file (equivalent to an initial extended source code file), and formats the source code structure of the initial compiled file to obtain a final compiled file (equivalent to an extended source code file).
The computer equipment obtains a final compiling file by utilizing the code unit and then generates a mapping relation between the final compiling file and the appointed class; when the original service is triggered and started, the computer equipment registers the mapping relation in a name space (namespace), if the appointed class is used, the computer equipment can determine that the mapping relation is preferentially the mapping relation between the appointed class and the source code file in the mapping relation between the appointed class and the source code file and the mapping relation between the appointed class and the final compiled file by utilizing the automatic loader, and then the final compiled file is preferentially loaded, and the original service and the extended service are executed by utilizing the final compiled file.
In the embodiment, the catalog scanning and the custom mapping annotation are carried out through the configuration file, and the final compiling file is obtained through compiling, so that zero invasion is realized; and the pseudo compiling mode is realized through the independent program, so that the performance is free from loss during the running process.
It should be understood that, although the steps in the flowcharts of fig. 2 to 5 are sequentially shown as indicated by arrows, these steps are not necessarily sequentially performed in the order indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least a portion of the steps of fig. 2-5 may include steps or stages that are not necessarily performed at the same time, but may be performed at different times, nor does the order in which the steps or stages are performed necessarily occur sequentially, but may be performed alternately or alternately with other steps or at least a portion of the steps or stages in other steps.
In one embodiment, as shown in fig. 6, there is provided a service implementation apparatus, including:
An annotation acquisition module 601, configured to acquire annotations configured for a specified class;
The file compiling module 602 is configured to compile an original source code file using the annotation to obtain an extended source code file, and generate a second mapping relationship between the extended source code file and the specified class; the original source code file and the appointed class have a first mapping relation, and the original source code file is a source code file for executing original service;
And a file loading module 603, configured to load the extension source code file based on the second mapping relationship and the specified class, so as to execute the original service and the extension service for the original service by using the extension source code file.
In one embodiment, the file loading module 603 is further configured to determine an ordering of the first mapping relationship in a plurality of mapping relationships if the original service is triggered to be started; the plurality of mapping relations are mapping relations between other classes of the original service and corresponding source code files, and the first mapping relation and the plurality of mapping relations are registered to a naming space; registering the second mapping relationship to the namespace based on an ordering of the first mapping relationship among the plurality of mapping relationships; wherein the ordering of the second mapping relationship in the plurality of mapping relationships is prior to the ordering of the first mapping relationship in the plurality of mapping relationships; and if the specified class is read, loading the extended source code file corresponding to the second mapping relation according to the sequence of the first mapping relation and the second mapping relation in the name space so as to execute the original service and the extended service aiming at the original service by utilizing the extended source code file.
In one embodiment, the device further includes a service restoration module, configured to load, when the specified class is read if the second mapping relationship is deleted after being registered in the namespace, the original source code file corresponding to the first mapping relationship according to the first mapping relationship in the namespace, so as to execute the original service by using the original source code file.
In one embodiment, the file compiling module 602 is further configured to parse a source code structure of the original source code file; if the source code structure of the original source code file does not accord with the annotation source code structure, formatting the source code structure of the original source code file into the annotation source code structure to obtain a formatted original source code file; the annotation source code structure is the source code structure required by the annotation; and compiling the formatted original source code file and the annotation to obtain the extended source code file.
In one embodiment, the file compiling module 602 is further configured to compile the formatted original source code file and the annotation to obtain an initial extended source code file; and formatting the source code structure of the initial extended source code file from the annotation source code structure to the source code structure of the original source code file to obtain the extended source code file.
In one embodiment, the file compiling module 602 is further configured to obtain a plurality of candidate original source code files corresponding to the specified class; scanning source code file types corresponding to the candidate original source code files; and determining a candidate original source code file with the source code file type consistent with the annotation source code type from a plurality of candidate original source code files, and taking the determined candidate original source code file as an original source code file to be analyzed.
In one embodiment, the file compiling module 602 is further configured to obtain a project file for the original service; the project file comprises candidate original source code files of each class, and the candidate original source code files of the same class are belonged to the same catalog of the project file; reading a catalog to be scanned in the configuration file; and scanning the candidate original source code files under the project file to-be-scanned directory to obtain a plurality of candidate original source code files corresponding to the specified class.
For specific limitations of the service implementation apparatus, reference may be made to the above limitation of the service implementation method, which is not repeated here. The modules in the service implementation apparatus may be implemented in whole or in part by software, hardware, or a combination thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one embodiment, a computer device is provided, comprising a memory storing a computer program and a processor implementing the steps of the method embodiments described above when the processor executes the computer program.
In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored which, when executed by a processor, carries out the steps of the respective method embodiments described above.
Those skilled in the art will appreciate that implementing all or part of the above-described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed may comprise the steps of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, or the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory. By way of illustration, and not limitation, RAM can be in various forms such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), etc.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The foregoing examples illustrate only a few embodiments of the application, which are described in detail and are not to be construed as limiting the scope of the application. It should be noted that it will be apparent to those skilled in the art that several variations and modifications can be made without departing from the spirit of the application, which are all within the scope of the application. Accordingly, the scope of protection of the present application is to be determined by the appended claims.
Claims (10)
1. A method for implementing a service, the method comprising:
acquiring notes configured for a specified class;
analyzing a source code structure of an original source code file;
If the source code structure of the original source code file does not accord with the annotation source code structure, formatting the source code structure of the original source code file into the annotation source code structure to obtain a formatted original source code file; the annotation source code structure is the source code structure required by the annotation;
compiling the formatted original source code file and the annotation to obtain an initial extension source code file;
Formatting the source code structure of the initial extended source code file from the annotation source code structure to the source code structure of the original source code file to obtain the extended source code file;
Generating a second mapping relation between the extension source code file and the appointed class; the original source code file and the appointed class have a first mapping relation, and the original source code file is a source code file for executing original service;
And loading the extension source code file based on the second mapping relation and the specified class so as to execute the original service and the extension service aiming at the original service by utilizing the extension source code file.
2. The method of claim 1, wherein loading the extended source code file based on the second mapping relationship and the specified class to execute the original service and an extended service for the original service using the extended source code file comprises:
If the original service is triggered and started, determining the sequence of the first mapping relation in a plurality of mapping relations; the plurality of mapping relations are mapping relations between other classes of the original service and corresponding source code files, and the first mapping relation and the plurality of mapping relations are registered to a naming space;
Registering the second mapping relationship to the namespace based on an ordering of the first mapping relationship among the plurality of mapping relationships; wherein the ordering of the second mapping relationship in the plurality of mapping relationships is prior to the ordering of the first mapping relationship in the plurality of mapping relationships;
and if the specified class is read, loading the extended source code file corresponding to the second mapping relation according to the sequence of the first mapping relation and the second mapping relation in the name space so as to execute the original service and the extended service aiming at the original service by utilizing the extended source code file.
3. The method according to claim 2, wherein the method further comprises:
And if the second mapping relation is deleted after being registered in the name space, loading the original source code file corresponding to the first mapping relation according to the first mapping relation in the name space when the specified class is read, so as to execute the original service by utilizing the original source code file.
4. The method of claim 1, wherein prior to parsing the source code structure of the native source code file, the method further comprises:
Acquiring a plurality of candidate original source code files corresponding to the specified class;
Scanning source code file types corresponding to the candidate original source code files;
And determining a candidate original source code file with the source code file type consistent with the annotation source code type from the plurality of candidate original source code files, and taking the determined candidate original source code file as an original source code file to be analyzed.
5. The method of claim 4, wherein the obtaining a plurality of candidate native source code files corresponding to the specified class comprises:
Acquiring a project file aiming at the original service; the project file comprises candidate original source code files of each class, and the candidate original source code files of the same class are belonged to the same catalog of the project file;
Reading a catalog to be scanned in the configuration file;
and scanning the candidate original source code files under the project file to-be-scanned directory to obtain a plurality of candidate original source code files corresponding to the specified class.
6. A service implementation apparatus, the apparatus comprising:
the annotation acquisition module is used for acquiring the annotation configured for the specified class;
The file compiling module is used for analyzing the source code structure of the original source code file; if the source code structure of the original source code file does not accord with the annotation source code structure, formatting the source code structure of the original source code file into the annotation source code structure to obtain a formatted original source code file; the annotation source code structure is the source code structure required by the annotation; compiling the formatted original source code file and the annotation to obtain an initial extension source code file; formatting the source code structure of the initial extended source code file from the annotation source code structure to the source code structure of the original source code file to obtain the extended source code file;
The file compiling module is also used for generating a second mapping relation between the extension source code file and the appointed class; the original source code file and the appointed class have a first mapping relation, and the original source code file is a source code file for executing original service;
And the file loading module is used for loading the extension source code file based on the second mapping relation and the appointed class so as to execute the original service and the extension service aiming at the original service by utilizing the extension source code file.
7. The apparatus of claim 6, wherein the file loading module is further configured to:
If the original service is triggered and started, determining the sequence of the first mapping relation in a plurality of mapping relations; the plurality of mapping relations are mapping relations between other classes of the original service and corresponding source code files, and the first mapping relation and the plurality of mapping relations are registered to a naming space;
Registering the second mapping relationship to the namespace based on an ordering of the first mapping relationship among the plurality of mapping relationships; wherein the ordering of the second mapping relationship in the plurality of mapping relationships is prior to the ordering of the first mapping relationship in the plurality of mapping relationships;
and if the specified class is read, loading the extended source code file corresponding to the second mapping relation according to the sequence of the first mapping relation and the second mapping relation in the name space so as to execute the original service and the extended service aiming at the original service by utilizing the extended source code file.
8. The apparatus of claim 7, further comprising a service restoration module configured to:
And if the second mapping relation is deleted after being registered in the name space, loading the original source code file corresponding to the first mapping relation according to the first mapping relation in the name space when the specified class is read, so as to execute the original service by utilizing the original source code file.
9. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the method of any one of claims 1 to 5 when executing the computer program.
10. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the method of any one of claims 1 to 5.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011607944.7A CN112612477B (en) | 2020-12-29 | 2020-12-29 | Service implementation method, device, equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011607944.7A CN112612477B (en) | 2020-12-29 | 2020-12-29 | Service implementation method, device, equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112612477A CN112612477A (en) | 2021-04-06 |
CN112612477B true CN112612477B (en) | 2024-05-24 |
Family
ID=75249583
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011607944.7A Active CN112612477B (en) | 2020-12-29 | 2020-12-29 | Service implementation method, device, equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112612477B (en) |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1782992A (en) * | 2004-12-02 | 2006-06-07 | 国际商业机器公司 | Method and apparatus for incrementally processing program annotations |
US10303466B1 (en) * | 2016-09-07 | 2019-05-28 | Amazon Technologies, Inc. | Semantic annotations in source code |
CN112083930A (en) * | 2020-09-14 | 2020-12-15 | 华帝股份有限公司 | Optimization method for android project compiling process |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20060277456A1 (en) * | 2005-06-07 | 2006-12-07 | International Business Machines Corporation | Method for handling annotations |
US8214811B2 (en) * | 2006-10-23 | 2012-07-03 | International Business Machines Corporation | Instantiating an interface or abstract class in application code |
-
2020
- 2020-12-29 CN CN202011607944.7A patent/CN112612477B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1782992A (en) * | 2004-12-02 | 2006-06-07 | 国际商业机器公司 | Method and apparatus for incrementally processing program annotations |
US10303466B1 (en) * | 2016-09-07 | 2019-05-28 | Amazon Technologies, Inc. | Semantic annotations in source code |
CN112083930A (en) * | 2020-09-14 | 2020-12-15 | 华帝股份有限公司 | Optimization method for android project compiling process |
Non-Patent Citations (1)
Title |
---|
统一数据服务层框架缓存模块的设计与实现;詹道楠;《中国优秀硕士学位论文全文数据库 信息科技辑》;20141215;第I138-203页 * |
Also Published As
Publication number | Publication date |
---|---|
CN112612477A (en) | 2021-04-06 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109710428B (en) | Dynamic calling method and device for implementation class | |
US8458681B1 (en) | Method and system for optimizing the object code of a program | |
CN109032631B (en) | Application program patch package obtaining method and device, computer equipment and storage medium | |
US8429632B1 (en) | Method and system for debugging merged functions within a program | |
JP2019053729A (en) | Test method and test apparatus of smart contract | |
CN111158741B (en) | Method and device for monitoring dependency relationship change of service module on third party class library | |
CN108614702B (en) | Byte code optimization method and device | |
CN109815141B (en) | Test method and device | |
CN112769706B (en) | Componentized routing method and system | |
CN111124872A (en) | Branch detection method and device based on difference code analysis and storage medium | |
CN110059002B (en) | Test data generation method, test equipment, storage medium and device | |
JPH11212837A (en) | Method and device for language processing and storage medium recording language processing program | |
CN110968296B (en) | Data acquisition method, device, equipment and readable storage medium | |
CN113094252B (en) | Test case generation method and device, computer equipment and storage medium | |
CN110457013B (en) | Program component configuration device and method | |
CN107450909A (en) | The treating method and apparatus of validity check is integrated for SDK | |
US7406681B1 (en) | Automatic conversion of source code from 32-bit to 64-bit | |
CN112612477B (en) | Service implementation method, device, equipment and storage medium | |
US10642714B2 (en) | Mapping dynamic analysis data to source code | |
CN111158665B (en) | Code generation method and device, electronic equipment and storage medium | |
CN117149209A (en) | Code increment compiling method and device, computer equipment and storage medium | |
CN111475150A (en) | Cross-language binding method, device, equipment and storage medium | |
CN111625225A (en) | Program specified data output method and device | |
CN111488144A (en) | Data processing method and equipment | |
CN114661298A (en) | Automatic public method generation method, system, device and medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
TA01 | Transfer of patent application right | ||
TA01 | Transfer of patent application right |
Effective date of registration: 20230524 Address after: Room 101, No. 227 Gaotang Road, Tianhe District, Guangzhou City, Guangdong Province, 510665 (Location: Room 601) Applicant after: Yamei Zhilian Data Technology Co.,Ltd. Address before: Room 201, No.1 Hanjing Road, Tianhe District, Guangzhou City, Guangdong Province Applicant before: GUANGZHOU YAME INFORMATION TECHNOLOGY Co.,Ltd. |
|
GR01 | Patent grant | ||
GR01 | Patent grant |