CN115129298A - Service instance injection method and related equipment - Google Patents

Service instance injection method and related equipment Download PDF

Info

Publication number
CN115129298A
CN115129298A CN202210647672.6A CN202210647672A CN115129298A CN 115129298 A CN115129298 A CN 115129298A CN 202210647672 A CN202210647672 A CN 202210647672A CN 115129298 A CN115129298 A CN 115129298A
Authority
CN
China
Prior art keywords
interface
target
service
annotation
variable information
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
CN202210647672.6A
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.)
Shenzhen Big Head Brothers Technology Co Ltd
Original Assignee
Shenzhen Big Head Brothers Technology 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 Shenzhen Big Head Brothers Technology Co Ltd filed Critical Shenzhen Big Head Brothers Technology Co Ltd
Priority to CN202210647672.6A priority Critical patent/CN115129298A/en
Publication of CN115129298A publication Critical patent/CN115129298A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/20Software design
    • G06F8/24Object-oriented
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

The invention discloses a service instance injection method and related equipment, wherein the method comprises the steps of obtaining a byte code file; aiming at each variable information in the byte code file, determining whether a target interface corresponding to the variable information exists in the marking interface according to the interface type corresponding to the variable information; if a target interface corresponding to the variable information exists, determining a target service in the service information according to the target interface; and instantiating the target service to obtain a service instance corresponding to the target interface. The invention can freely adjust the interface, the service and the variable through annotating the file without manually mapping the interface and realizing the relationship, thereby reducing the difficulty of parallel development of a plurality of engineering projects.

Description

Service instance injection method and related equipment
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a service instance injection method and related devices.
Background
A Java Virtual Machine (JVM) is a specification for a computing device, which is a fictitious computer and implements the running of programs by simulating various computer functions on a real computer. For a large function based on the JVM, multi-user, multi-module, and multi-component parallel development is often adopted, so that there is interaction between each module and component, and in order to reduce coupling and ensure that the parallel development is not affected, the interaction mode is usually realized by using a call interface. Since each service providing module may be independent and there are multiple multiplexing situations, and there are different types of input sources, instantiation of the service is required at the interface variables.
In order to implement service instantiation, manual mapping is generally established for an interface layer, a service layer and a service layer, and all mappings need to be established during initialization, so that the scheme is relatively rough. Registration and mapping can also be done via a library through auto-service or Dagger, but they only support service collection at the source code level and rely on runtime reflection.
Disclosure of Invention
The technical problem to be solved by the present invention is to provide a service instance injection method and related device, aiming at the deficiencies of the prior art.
In order to solve the technical problems, the technical scheme adopted by the invention is as follows:
a method of injection of a service instance, the method comprising:
acquiring a bytecode file, wherein the bytecode file comprises a first annotation file, a second annotation file and a third annotation file, the first annotation file comprises a plurality of tag interfaces, the second annotation file comprises a plurality of service information, and the third annotation file comprises a plurality of variable information;
for each piece of variable information, determining whether a target interface corresponding to the variable information exists in the marked interface or not according to the interface type corresponding to the variable information;
if a target interface corresponding to the variable information exists, determining a target service in the service information according to the target interface;
and instantiating the target service to obtain a service instance corresponding to the target interface.
The injection method of the service instance, wherein the second annotation file further comprises an annotation interface file and a fourth annotation file, wherein the annotation interface file comprises an annotation interface and an object type corresponding to the annotation interface, and the fourth annotation file comprises a plurality of implementation classes and implementation numbers corresponding to each implementation class.
The injection method of the service instance, wherein the third annotation file further comprises a variable number corresponding to each piece of variable information; before the determining, for each piece of the variable information, whether a target interface corresponding to the variable information exists in the marked interface according to the interface type corresponding to the variable information, the method includes:
for each piece of variable information, according to the variable number of the variable information, determining a target interface corresponding to the variable information in the annotation interface file and a target implementation class corresponding to the variable information in the fourth annotation file;
judging whether the first generic type of the target interface belongs to the interface type of the first annotation file;
and if so, instantiating the object of the target implementation class to obtain the target service corresponding to the variable information.
The service instance injection method, wherein the determining, for each piece of the variable information, a target interface corresponding to the variable information in the annotation interface file and a target implementation class corresponding to the variable information in the fourth annotation file according to the variable number of the variable information includes:
judging whether the variable number is equal to a preset default number value or not;
if the variable number is not equal to the default number value, determining a candidate implementation class corresponding to the variable information in the fourth annotation file according to the variable number and the implementation number;
and determining a target interface and a target implementation class corresponding to the variable information according to the annotation interface in the annotation interface file.
The service instance injection method, wherein the determining, according to the annotation interface in the annotation interface file, the target interface and the target implementation class corresponding to the variable information includes:
taking an annotation interface corresponding to a candidate implementation class in an annotation interface file as a comparison interface, and judging whether the interface type of the comparison interface is the same as the interface type of the variable information or not;
and if the candidate implementation classes are the same as the target implementation classes, taking the candidate implementation classes as target implementation classes, and taking the comparison interfaces as target interfaces.
The method for injecting the service instance, wherein the determining the target service in the service information according to the target interface includes:
determining service data corresponding to the variable information in the service information according to the target interface;
when the number of the service data is equal to one, determining the service data as a target service;
and when the quantity of the service data is not equal to one, determining the target service corresponding to the target interface according to the service quantity corresponding to the target interface.
The service instance injection method, wherein the determining, according to the service quantity corresponding to the target interface, the target service corresponding to the target interface includes:
and when the service quantity corresponding to the target interface is zero, taking a preset default service as the target service corresponding to the target interface.
A service instance injection apparatus, the apparatus comprising:
the system comprises an acquisition module, a storage module and a processing module, wherein the acquisition module is used for acquiring byte code files, the byte code files comprise a first annotation file, a second annotation file and a third annotation file, the first annotation file comprises a plurality of mark interfaces, the second annotation file comprises a plurality of service information, and the third annotation file comprises a plurality of variable information;
a first determining module, configured to determine, for each piece of variable information, whether a target interface corresponding to the variable information exists in the marked interface according to an interface type corresponding to the variable information;
a second determining module, configured to determine, if a target interface corresponding to the variable information exists, a target service in the service information according to the target interface;
and the instance module is used for instantiating the target service to obtain the service instance corresponding to the target interface.
A computer readable storage medium storing one or more programs, the one or more programs being executable by one or more processors to implement steps in a method of injection of a service instance as described in any above.
A terminal device, comprising: a processor, a memory, and a communication bus; the memory has stored thereon a computer readable program executable by the processor;
the communication bus realizes connection communication between the processor and the memory;
the processor, when executing the computer readable program, implements the steps in the method for injecting a service instance as described in any one of the above.
Has the advantages that: the invention provides a service instance injection method and related equipment. And traversing the variable information in the third annotation file, and searching a target interface corresponding to the variable information in the mark interface for each piece of traversed variable information according to the interface type of the variable information. And after the target interface is obtained, searching the corresponding target service from the service information, and finally instantiating the target service to obtain the service instance corresponding to the variable information. In the process, a third-party library is not needed, no requirement is made on an input source, and only a mark interface, service information and variable information are added into a corresponding annotation file, so that the method is simple and convenient, and the calling stack is not influenced by loss in operation. In addition, manual de-mapping of interfaces and implemented relationships is not required, and initialization of the framework is not required. The requirement of the whole operation process on the coupling degree is low, the dependence of the user of the interface and the realization party of the interface on the interface is low, and the parallel development of multiple modules and multiple components becomes possible conveniently.
Drawings
Fig. 1 is a flowchart of a conventional interface layer, a basic service layer, and a business layer.
Fig. 2 is a flowchart of a service instance injection method provided by the present invention.
Fig. 3 is an exemplary diagram of codes for determining a target service according to a first annotation file and a second annotation file in the service instance injection method provided by the present invention.
Fig. 4 is another exemplary diagram of codes for determining a target service according to a first annotation file and a second annotation file in the injection method of the service instance provided by the present invention.
Fig. 5 is a first flowchart of determining a target service in the method for injecting the service instance provided by the present invention.
Fig. 6 is a second flowchart of determining a target service in a service instance provided by the present invention in the injection method of the service instance provided by the present invention.
FIG. 7 is a schematic diagram of an injection device for an example of the service provided by the present invention.
Fig. 8 is a schematic structural diagram of a terminal device according to the present invention.
Detailed Description
The present invention provides a method for injecting a service instance, and in order to make the objects, technical solutions, and effects of the present invention clearer and clearer, the present invention is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are merely illustrative of the invention and do not limit the invention.
As used herein, the singular forms "a", "an", "the" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises" and/or "comprising," when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof. It will be understood that when an element is referred to as being "connected" or "coupled" to another element, it can be directly connected or coupled to the other element or intervening elements may also be present. Further, "connected" or "coupled" as used herein may include wirelessly connected or wirelessly coupled. As used herein, the term "and/or" includes all or any element and all combinations of one or more of the associated listed items.
It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. It will be further understood that terms, such as those defined in commonly used dictionaries, should be interpreted as having a meaning that is consistent with their meaning in the context of the prior art and will not be interpreted in an idealized or overly formal sense unless expressly so defined herein.
As shown in fig. 2, for convenience of description, the present embodiment provides a service instance injection method, which is described by using a common server as an execution subject, where the server may be replaced by a tablet, a computer, or other devices with a data processing function, and the service instance injection method includes the following steps:
and S10, acquiring the byte code file.
Specifically, a bytecode file, which is an execution file of a JVM processed by a compiler, is first acquired. Among these bytecode files, a first annotation file (class a), a second annotation file (class B), and a third annotation file (class C) are included.
As shown in fig. 3, the first annotation file is used to record and tag the interface, and the interface tagged by the first annotation file is therefore referred to as the tag interface. The second annotation file is used to tag the implementation of the interface, i.e. the specific service information. The third annotation file is used for marking variables, namely variable information, which need to be injected. It should be noted that the annotation file herein includes not only the content of the annotation itself, but also the object pointed by each annotation content, so as to facilitate the subsequent direct determination of the corresponding relationship according to the annotation.
When a project is compiled, all source codes exist in the project, and all the source codes are finally compiled into a byte code file under the JVM environment, so that the byte codes can be analyzed and modified at the end of the compilation of the whole project, and extra steps are not needed in the previous compiling process. The filtering can be realized in a directory (directory) where each bytecode file is located, files (inclusions) required to be contained are designated, files (excesses) required to be excluded are designated, and the filtering of all bytecode files can be realized based on storage paths, file names and the like of the first annotation file, the second annotation file and the third annotation file by a user, so that the first annotation file, the second annotation file and the third annotation file are obtained.
Further, since the bytecode file can be compiled from a plurality of languages, the obtained bytecode file includes files of other types and roles in addition to the first annotation file, the second annotation file, and the third annotation file. After the bytecode file is obtained, filtering may be performed to obtain a first annotation file, a second annotation file, and a third annotation file.
And S20, determining whether a target interface corresponding to the variable information exists in the mark interface or not according to the interface type corresponding to the variable information aiming at each variable information.
Specifically, the third annotation file includes a plurality of variable information to be injected, and for each variable information, a corresponding service instance needs to be determined. In the embodiment, a mode of circularly traversing the variable information is adopted to avoid parallel processing, and the accuracy of subsequent steps is improved until all the variable information is traversed and processed. In the traversal process, if abnormal conditions such as the loss or error report of the variable information exist, the variable information can be skipped over, and the next variable information is processed.
For example, for the nth (N is a positive integer) variable information, each variable information is preset with a corresponding interface type, and in this embodiment, the interface type is named as an interface type. In contrast, the first annotation file comprises a tag interface, and whether a target interface corresponding to the variable information exists in the tag interface can be determined according to whether the interface type of the tag interface is the same as the interface type. The target interface refers to a mark interface corresponding to the variable information in the mark interface.
If the target interface does not exist in the first annotation file, directly judging that no service capable of corresponding to the variable exists, directly sending preset error reporting information, jumping to the (N + 1) th variable information, and judging again.
The error information can be sent to the project personnel through various communication software or methods such as mails, telephones, short messages and the like, so that the project personnel can quickly correct the first annotation file or the second annotation file.
Further, multiple parameters may be required in the service creation process, for example, a service instance needs to be singleton, and the service creation mode is relatively single. Therefore, in this embodiment, the bytecode file further includes an annotation interface file and a fourth annotation file, where the annotation interface file includes an annotation interface for describing an object type, a creation mode, and/or a destruction mode of the annotation interface.
The fourth annotation file is used for marking a plurality of implementation classes of the annotation interface in the fourth annotation and the implementation number corresponding to each implementation class.
And relative to the fourth annotation file, the third annotation file comprises a variable number corresponding to each variable information. Therefore, for each variable information, a target interface corresponding to the variable information in the annotation interface file and a target implementation class corresponding to the variable information in the fourth annotation file are determined.
And judging whether the variable number corresponding to the variable information is a preset default number value, wherein the default number value is not equal to the implementation number. As shown in fig. 3 and 4, the default number is-1, so that it is determined whether the variable number is-1. If they are equal, it is only necessary to process the variable information according to the conventional flow, that is, the target interface is determined directly according to the variable information as described above. And if the number of the variable is not equal to the number of the implementation number, comparing the variable number with the implementation number to determine whether the implementation number equal to the variable exists. If yes, determining the implementation class corresponding to the implementation number in the fourth annotation file by using the equal implementation number, and taking the implementation class as a candidate implementation class corresponding to the variable information; and if not, sending preset error reporting information to a manager in the mode of the mail and the like.
In the first implementation manner, after the candidate implementation class is obtained, since the fourth annotation file is for the annotation interface file, the candidate implementation class corresponds to an interface in the annotation interface file, that is, the annotation interface corresponding to the variable information is determined and is used as the target interface, and the candidate implementation class is used as the target implementation class.
In another implementation, the implementation class corresponding to the variable information may be determined even according to the variable number and the implementation number of the variable information. However, the fourth annotation file is for an annotation interface file, and therefore it is not always necessary whether the annotation interface in the fourth annotation file can be used for the variable information, and therefore, as shown in fig. 5, the implementation class corresponding to the variable information is taken as a candidate implementation class, the interface type of the annotation interface corresponding to the candidate implementation class in the annotation interface file is compared with the interface type of the variable information, and if the candidate implementation class is the same as the candidate implementation class, the candidate implementation class is taken as a target implementation class; and if not, sending preset error reporting information.
After the target implementation class and the target interface are obtained, whether the first generic type of the target interface belongs to the interface type of the first annotation file is judged, that is, whether the first generic type of the target interface is included in the interface types in the first annotation file is judged. And if so, instantiating the object of the target implementation class to obtain the target service corresponding to the variable information.
By the method, only the service related to the business itself needs to be compiled in the development process, and other business services do not need to be adjusted, so that the code amount needing to be compiled in the whole development process is reduced, and the compiling and debugging speed in the development process is obviously improved. In addition, the service providing mode can be highly customized, and the supporting scenes are more.
And S30, if the target interface corresponding to the variable information exists, determining the target service in the service information according to the target interface.
Specifically, if there is a target interface corresponding to the variable information, it is necessary to further determine whether there is a service corresponding to the target interface in the bytecode file of the virtual machine.
And the service information is stored in the third annotation file, and after the target interface is obtained, whether the service information corresponding to the target interface, namely the target service exists in the third annotation file is determined according to parameters such as the function of the target interface.
In general, there should be a unique object to implement for one variable information and one target interface, so in conventional selection, the target interface to the first annotation is implemented as a decision as to whether there is a unique object in the third annotation file.
First, according to the target interface, it may be determined whether service data corresponding to the variable information exists in the second annotation file. And if the number of the service data corresponding to the variable information is one, directly taking the uniquely corresponding service data as the target service. If the number of the service data corresponding to the variable information is not equal to one, it indicates that a plurality of service information corresponding to the target interface exist or service information corresponding to the target interface does not exist. At this time, a preset error message may be displayed, and the error message may be sent to the manager by means of the above-mentioned e-mail or the like.
Further, in the actual business development process, if the service is under development, there may be a situation that the service cannot be accessed to the project and packaged together, so that the flexibility of other business debugging is affected to a certain extent. To solve the problem, parameters of engineering construction needing service participation can be added in the first annotation file, and a dynamic agent is matched when the parameters are called. The engineering construction parameters may include the number of services corresponding to each markup interface, where the number of services refers to the number of service implementations that can be subsequently connected and invoked by the markup interface.
Therefore, a preset null value may be set in the service number, as shown in fig. 6, the null value, i.e. representing the target interface, may not need to obtain the service information from the second annotation file. Therefore, when the number of the service data is not equal to one, a dynamic proxy inside the framework is called, a proxy default implementation of the target interface is created, and the preset default service is used as the target service corresponding to the target interface. The target service is preset internally, and in the process of modifying, developing or packaging the service information corresponding to the target interface, the preset default service can temporarily replace the service information to provide certain service so as to avoid the condition that the service cannot be used for the current variable information service. In addition, when the number of services is a positive integer greater than one, for example, 2, it indicates that the target interface may select 2 pieces of service information from the corresponding service information as objects to be instantiated subsequently, and may select the service information randomly or filter the service information according to the size, role, or other information of the service information, so as to obtain the target service.
And S40, instantiating the target service to obtain a service instance corresponding to the target interface.
Specifically, after the target service is determined, the target service is instantiated, and then the instantiated target service is assigned to the variable annotated by the target interface, so that the service instance of the currently traversed variable information is obtained. Because the target interface corresponds to the currently traversed variable information, the service instance obtained after instantiation of the target service can provide service for the variable information when the variable information is injected through the target interface.
Based on the injection method of the service instance, the present invention further provides an injection device of the service instance, as shown in fig. 7, the device includes:
the byte code file comprises a first annotation file, a second annotation file and a third annotation file, wherein the first annotation file comprises a plurality of mark interfaces, the second annotation file comprises a plurality of service information, and the third annotation file comprises a plurality of variable information;
a first determining module, configured to determine, for each piece of variable information, whether a target interface corresponding to the variable information exists in the marked interface according to an interface type corresponding to the variable information;
a second determining module, configured to determine, if a target interface corresponding to the variable information exists, a target service in the service information according to the target interface;
and the instance module is used for instantiating the target service to obtain the service instance corresponding to the target interface.
The second annotation file further comprises an annotation interface file and a fourth annotation file, wherein the annotation interface file comprises an annotation interface and an object type corresponding to the annotation interface, and the fourth annotation file comprises a plurality of implementation classes and implementation numbers corresponding to the implementation classes.
Wherein the injection device of the service instance further comprises a service modification module, and the service modification module comprises:
a first determining unit, configured to determine, for each piece of variable information, a target interface corresponding to the variable information in the annotation interface file and a target implementation class corresponding to the variable information in the fourth annotation file according to a variable number of the variable information;
the judging unit is used for judging whether the first generic type of the target interface belongs to the interface type of the first annotation file;
and the instance unit is used for instantiating the object of the target implementation class if the object of the target implementation class is the target service corresponding to the variable information.
Wherein the determining unit includes:
the judging subunit is used for judging whether the variable number is equal to a preset default number value or not;
a first determining subunit, configured to determine, according to the variable number and the implementation number, a candidate implementation class corresponding to the variable information in the fourth annotation file if the variable number is not equal to the default number value;
and the second determining subunit is used for determining a target interface and a target implementation class corresponding to the variable information according to the annotation interface in the annotation interface file.
Wherein the second determining subunit is specifically configured to:
taking an annotation interface corresponding to a candidate implementation class in an annotation interface file as a comparison interface, and judging whether the interface type of the comparison interface is the same as the interface type of the variable information or not;
if the candidate implementation class is the same as the target implementation class, the candidate implementation class is used as a target implementation class, and the comparison interface is used as a target interface.
Wherein the determining module comprises:
determining service data corresponding to the variable information in the service information according to the target interface;
a second determining unit, configured to determine that the service data is a target service when the number of the service data is equal to one;
a third determining unit, configured to determine, according to the service quantity corresponding to the target interface, a target service corresponding to the target interface when the quantity of the service data is not equal to one.
Wherein the third determining unit is specifically configured to:
and when the service quantity corresponding to the target interface is zero, taking a preset default service as the target service corresponding to the target interface.
Based on the injection method of the service instance, the present invention further provides a terminal device, as shown in fig. 8, which includes at least one processor (processor) 20; a display screen 21; and a memory (memory)22, and may further include a communication Interface (Communications Interface)23 and a bus 24. The processor 20, the display 21, the memory 22 and the communication interface 23 can communicate with each other through the bus 24. The display screen 21 is configured to display a user guidance interface preset in the initial setting mode. The communication interface 23 may transmit information. The processor 20 may call logical commands in the memory 22 to perform the methods in the above embodiments.
In addition, the logic commands in the memory 22 can be implemented in the form of software functional units and stored in a computer readable storage medium when the logic commands are sold or used as independent products.
The memory 22, which is a computer-readable storage medium, may be configured to store a software program, a computer-executable program, such as program commands or modules corresponding to the methods in the embodiments of the present disclosure. The processor 20 executes functional applications and data processing by executing software programs, commands or modules stored in the memory 22, i.e. implements the method in the above-described embodiments.
The memory 22 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created according to the use of the terminal device, and the like. Further, the memory 22 may include a high speed random access memory and may also include a non-volatile memory. For example, a variety of media that can store program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk, may also be used as the transient computer readable storage medium.
In addition, the specific processes loaded and executed by the computer readable storage medium and the plurality of command processors in the terminal device are described in detail in the method, and are not stated herein.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (10)

1. A method for injecting a service instance, the method comprising:
acquiring a bytecode file, wherein the bytecode file comprises a first annotation file, a second annotation file and a third annotation file, the first annotation file comprises a plurality of tag interfaces, the second annotation file comprises a plurality of service information, and the third annotation file comprises a plurality of variable information;
for each piece of variable information, determining whether a target interface corresponding to the variable information exists in the mark interface according to the interface type corresponding to the variable information;
if a target interface corresponding to the variable information exists, determining a target service in the service information according to the target interface;
and instantiating the target service to obtain a service instance corresponding to the target interface.
2. The method for injecting the service instance according to claim 1, wherein the bytecode file further includes an annotation interface file and a fourth annotation file, wherein the annotation interface file includes a plurality of annotation interfaces and object types corresponding to the annotation interfaces, and the fourth annotation file includes a plurality of implementation classes and implementation numbers corresponding to each implementation class.
3. The method for injecting service instances according to claim 2, wherein the third annotation file further includes a variable number corresponding to each of the variable information; before the determining, for each piece of the variable information, whether a target interface corresponding to the variable information exists in the marked interface according to the interface type corresponding to the variable information, the method includes:
for each piece of variable information, according to the variable number of the variable information, determining a target interface corresponding to the variable information in the annotation interface file and a target implementation class corresponding to the variable information in the fourth annotation file;
judging whether the first generic type of the target interface belongs to the interface type of the first annotation file;
and if so, instantiating the object of the target implementation class to obtain the target service corresponding to the variable information.
4. The method according to claim 3, wherein the determining, for each piece of the variable information and according to the variable number of the variable information, the target interface corresponding to the variable information in the annotation interface file and the target implementation class corresponding to the variable information in the fourth annotation file comprises:
judging whether the variable number is equal to a preset default number value or not;
if the variable number is not equal to the default number value, determining a candidate implementation class corresponding to the variable information in the fourth annotation file according to the variable number and the implementation number;
and determining a target interface and a target implementation class corresponding to the variable information according to the annotation interface in the annotation interface file.
5. The method according to claim 4, wherein the determining, according to the annotation interface in the annotation interface file, the target interface and the target implementation class corresponding to the variable information comprises:
taking an annotation interface corresponding to a candidate implementation class in an annotation interface file as a comparison interface, and judging whether the interface type of the comparison interface is the same as the interface type of the variable information or not;
and if the candidate implementation classes are the same as the target implementation classes, taking the candidate implementation classes as target implementation classes, and taking the comparison interfaces as target interfaces.
6. The method for injecting the service instance according to any one of claims 1 to 5, wherein the determining the target service in the service information according to the target interface includes:
determining service data corresponding to the variable information in the service information according to the target interface;
when the number of the service data is equal to one, determining the service data as a target service;
and when the quantity of the service data is not equal to one, determining the target service corresponding to the target interface according to the service quantity corresponding to the target interface.
7. The method for injecting the service instance as claimed in claim 6, wherein the determining the target service corresponding to the target interface according to the number of services corresponding to the target interface comprises:
and when the service quantity corresponding to the target interface is zero, taking a preset default service as the target service corresponding to the target interface.
8. An injection apparatus for a service instance, the apparatus comprising:
the system comprises an acquisition module, a storage module and a processing module, wherein the acquisition module is used for acquiring byte code files, the byte code files comprise a first annotation file, a second annotation file and a third annotation file, the first annotation file comprises a plurality of mark interfaces, the second annotation file comprises a plurality of service information, and the third annotation file comprises a plurality of variable information;
a first determining module, configured to determine, for each piece of variable information, according to an interface type corresponding to the variable information, whether a target interface corresponding to the variable information exists in the marked interface;
a second determining module, configured to determine, if a target interface corresponding to the variable information exists, a target service in the service information according to the target interface;
and the instance module is used for instantiating the target service to obtain a service instance corresponding to the target interface.
9. A computer-readable storage medium, storing one or more programs, which are executable by one or more processors, for performing the steps in the method for injecting the service instance as claimed in any one of claims 1 to 7.
10. A terminal device, comprising: a processor, a memory, and a communication bus; the memory has stored thereon a computer readable program executable by the processor;
the communication bus realizes connection communication between the processor and the memory;
the processor, when executing the computer readable program, implements the steps in the method for injecting a service instance according to any of claims 1 to 7.
CN202210647672.6A 2022-06-08 2022-06-08 Service instance injection method and related equipment Pending CN115129298A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210647672.6A CN115129298A (en) 2022-06-08 2022-06-08 Service instance injection method and related equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210647672.6A CN115129298A (en) 2022-06-08 2022-06-08 Service instance injection method and related equipment

Publications (1)

Publication Number Publication Date
CN115129298A true CN115129298A (en) 2022-09-30

Family

ID=83378510

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210647672.6A Pending CN115129298A (en) 2022-06-08 2022-06-08 Service instance injection method and related equipment

Country Status (1)

Country Link
CN (1) CN115129298A (en)

Similar Documents

Publication Publication Date Title
CN110096338B (en) Intelligent contract execution method, device, equipment and medium
CN109976761B (en) Software development kit generation method and device and terminal equipment
US9274768B2 (en) Runtime code hooking for print driver and functionality testing
US6745385B1 (en) Fixing incompatible applications by providing stubs for APIs
US8458681B1 (en) Method and system for optimizing the object code of a program
US7739698B2 (en) Multiplatform API usage tool
US8429632B1 (en) Method and system for debugging merged functions within a program
US9104804B2 (en) Method and system for invoking just-in-time debugger
CN111158741B (en) Method and device for monitoring dependency relationship change of service module on third party class library
CN103970659A (en) Android application software automation testing method based on pile pitching technology
CN110058860A (en) A kind of automatic delivery method of code, device, equipment and computer storage medium
CN112769706B (en) Componentized routing method and system
EP3504617A1 (en) Hybrid deoptimization mechanism for class hierarchy analysis
CA3167549A1 (en) Method and apparatus for authority control, computer device and storage medium
CN106796521B (en) API version control independent of product release
CN114691188A (en) Compatibility evaluation method, device, equipment and storage medium
US20130212598A1 (en) Dependency informer
CN108228266B (en) Method and device for starting Fragment component between different plug-ins under Android plug-in framework
CN111352631B (en) Interface compatibility detection method and device
CN106775916B (en) Method and device for reducing application installation packages and electronic equipment
CN111625225A (en) Program specified data output method and device
CN112445706A (en) Program abnormal code acquisition method and device, electronic equipment and storage medium
CN115129298A (en) Service instance injection method and related equipment
EP2756396B1 (en) Simulation of static members and parameterized constructors on an interface-based api
CN109947407B (en) Data acquisition method and device

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
CB02 Change of applicant information
CB02 Change of applicant information

Address after: 518000 Building 1901, 1902, 1903, Qianhai Kexing Science Park, Labor Community, Xixiang Street, Bao'an District, Shenzhen, Guangdong Province

Applicant after: Shenzhen Flash Scissor Intelligent Technology Co.,Ltd.

Address before: 518000 Unit 9ABCDE, Building 2, Haihong Industrial Plant Phase II, Haihong Industrial Plant, West Side of Xixiang Avenue, Labor Community, Xixiang Street, Bao'an District, Shenzhen, Guangdong

Applicant before: Shenzhen big brother Technology Co.,Ltd.