CN111324336B - Method, device, terminal and storage medium for implementing dependency injection - Google Patents
Method, device, terminal and storage medium for implementing dependency injection Download PDFInfo
- Publication number
- CN111324336B CN111324336B CN202010066483.0A CN202010066483A CN111324336B CN 111324336 B CN111324336 B CN 111324336B CN 202010066483 A CN202010066483 A CN 202010066483A CN 111324336 B CN111324336 B CN 111324336B
- Authority
- CN
- China
- Prior art keywords
- component
- class
- protocol
- attribute
- class set
- 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 52
- 238000002347 injection Methods 0.000 title claims abstract description 21
- 239000007924 injection Substances 0.000 title claims abstract description 21
- 238000013507 mapping Methods 0.000 claims abstract description 31
- 230000001419 dependent effect Effects 0.000 claims abstract description 17
- 230000006870 function Effects 0.000 claims description 17
- 238000004378 air conditioning Methods 0.000 claims description 6
- 238000010586 diagram Methods 0.000 description 12
- 238000004590 computer program Methods 0.000 description 7
- 238000004891 communication Methods 0.000 description 6
- 238000012546 transfer Methods 0.000 description 6
- 230000003287 optical effect Effects 0.000 description 5
- 230000008569 process Effects 0.000 description 5
- 238000002513 implantation Methods 0.000 description 4
- 238000012545 processing Methods 0.000 description 4
- 235000006719 Cassia obtusifolia Nutrition 0.000 description 2
- 235000014552 Cassia tora Nutrition 0.000 description 2
- 244000201986 Cassia tora Species 0.000 description 2
- 230000008901 benefit Effects 0.000 description 2
- 230000000694 effects Effects 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 239000013307 optical fiber Substances 0.000 description 2
- 230000000644 propagated effect Effects 0.000 description 2
- 239000004065 semiconductor Substances 0.000 description 2
- 239000000243 solution Substances 0.000 description 2
- 238000013459 approach Methods 0.000 description 1
- 239000000470 constituent Substances 0.000 description 1
- 239000000835 fiber Substances 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification 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/20—Software design
- G06F8/24—Object-oriented
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/31—Programming languages or programming paradigms
- G06F8/315—Object-oriented languages
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/448—Execution paradigms, e.g. implementations of programming paradigms
- G06F9/4488—Object-oriented
- G06F9/449—Object-oriented method invocation or resolution
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computing Systems (AREA)
- Stored Programmes (AREA)
Abstract
The disclosure provides a method and device for realizing dependent injection, a terminal and a storage medium. The method for realizing the dependent injection comprises the following steps: acquiring a first component; the first component comprises a first class set, wherein the first class set corresponds to a first attribute, and the first attribute comprises a first protocol set; acquiring a second component; wherein the second component comprises a first sub-component and a second sub-component; acquiring a second class set contained in the first sub-assembly; wherein the second class set corresponds to a second attribute, and the second attribute comprises a second protocol set; establishing a mapping relation between the class in the corresponding first class set and the class in the second class set according to the same protocol in the first protocol set and the second protocol set; acquiring a third class set used for realizing the first protocol set in the second sub-assembly; and initializing the third class set, and assigning the initialized third class set to the first attribute. The method of the present disclosure may facilitate the implementation of a handoff.
Description
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a method and apparatus for implementing dependency injection, a terminal, and a storage medium.
Background
Dependency injection means that the component does not make a location query, and only provides a common Java method to let the container determine the dependency relationship. The container is responsible for the assembly of components that will pass the dependency-compliant objects to the desired objects through the java bean attributes or constructors. Injecting the dependency relationship through the JavaBean attribute is called value setting method injection; the approach of entering dependencies as constructor parameters is called constructor injection.
Disclosure of Invention
In order to solve the existing problems, the disclosure provides a method and device for realizing dependent injection, a terminal and a storage medium.
The present disclosure adopts the following technical solutions.
In some embodiments, the present disclosure provides a method of implementing dependent injection, comprising:
acquiring a first component; the first component comprises a first class set, wherein the first class set corresponds to a first attribute, and the first attribute comprises a first protocol set;
acquiring a second component; wherein the second component comprises a first sub-component and a second sub-component;
acquiring a second class set contained in the first sub-assembly; wherein the second class set corresponds to a second attribute, and the second attribute comprises a second protocol set;
establishing a mapping relation between the class in the corresponding first class set and the class in the second class set according to the same protocol in the first protocol set and the second protocol set;
acquiring a third class set used for realizing the first protocol set in the second sub-assembly; a kind of electronic device with high-pressure air-conditioning system
Initializing the third class set, and assigning the initialized third class set to the first attribute.
In some embodiments, the present disclosure provides an apparatus for implementing dependent injection, comprising:
the device comprises an acquisition module, a first component, a second collection in a first sub-component included in the second component, and a third collection in a second sub-component included in the second component, wherein the acquisition module is used for acquiring the first component, the second collection in the first sub-component included in the second component, and the third collection in the second sub-component included in the second component;
the establishing module is used for establishing a mapping relation between the first class set and the second class set;
the initialization module is used for initializing the third class set; a kind of electronic device with high-pressure air-conditioning system
And the assignment module is used for assigning the initialized third class set to the first attribute corresponding to the first class set.
In some embodiments, the present disclosure provides a terminal comprising: at least one memory and at least one processor;
the memory is used for storing program codes, and the processor is used for calling the program codes stored in the memory to execute the method.
In some embodiments, the present disclosure provides a storage medium for storing program code for performing the above-described method.
The method for realizing the dependency injection provided by the embodiment of the disclosure can transfer the call directed to the basic component to different service components by establishing the mapping relation, thereby being capable of providing convenience for switching between different implementations.
Drawings
The above and other features, advantages, and aspects of embodiments of the present disclosure will become more apparent by reference to the following detailed description when taken in conjunction with the accompanying drawings. The same or similar reference numbers will be used throughout the drawings to refer to the same or like elements. It should be understood that the figures are schematic and that elements and components are not necessarily drawn to scale.
FIG. 1 is a flow chart of an implementation dependent implantation method of an embodiment of the present disclosure.
Fig. 2 is a schematic diagram of establishing a mapping relationship according to an embodiment of the present disclosure.
Fig. 3 is a schematic diagram of an assignment process of an embodiment of the present disclosure.
Fig. 4 is an effect schematic of an implementation-dependent implantation method of an embodiment of the present disclosure.
Fig. 5 is a schematic structural diagram of an implementation-dependent injection device of an embodiment of the present disclosure.
Fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure.
Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure have been shown in the accompanying drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustration purposes only and are not intended to limit the scope of the present disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in and/or in parallel. Furthermore, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
The term "including" and variations thereof as used herein are intended to be open-ended, i.e., including, but not limited to. The term "based on" is based at least in part on. The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments. Related definitions of other terms will be given in the description below.
It should be noted that the terms "first," "second," and the like in this disclosure are merely used to distinguish between different devices, modules, or units and are not used to define an order or interdependence of functions performed by the devices, modules, or units.
It should be noted that references to "a" and "an" in this disclosure are intended to be illustrative rather than limiting, and those of ordinary skill in the art will appreciate that "one or more" is intended to be construed as "one or more" unless the context clearly indicates otherwise.
The names of messages or information interacted between the various devices in the embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.
The following describes in detail the scheme provided by the embodiment of the present application with reference to the accompanying drawings.
As shown in fig. 1, fig. 1 is a flowchart of an implementation-dependent implantation method of an embodiment of the present disclosure, including the following steps.
S100, acquiring a first component; the first component comprises a first class set, wherein the first class set corresponds to a first attribute, and the first attribute comprises a first protocol set.
Wherein, the first component in the embodiment of the disclosure may be a binary format file. A component's constituent unit is a class, and a component may be composed of several classes, where each class may correspond to an attribute, referred to as a global variable or member variable of the class, in which the attribute may include a protocol, and in the embodiment of the present disclosure, the first attribute may be an interface class attribute. Accordingly, a set of classes may be referred to as a first set of classes, and a set of different protocols included in the attributes may be referred to as a first set of protocols. Furthermore, the first component may be a base component that only declares the protocol and does not implement the protocol, in other words, invokes the base component for the purpose of implementation.
S200, acquiring a second component; wherein the second assembly comprises a first subassembly and a second subassembly.
With the above, the base component can only declare the protocol, and its implementation needs to invoke an upper layer component, such as a business component. Specifically, in addition to acquiring the base component, the embodiments of the present disclosure may acquire a service component capable of implementing a base component protocol, and the service component may be multiple.
S300, obtaining a second class set contained in the first sub-assembly; wherein the second class set corresponds to a second attribute, and the second attribute includes a second protocol set.
In particular, embodiments of the present disclosure may obtain a class in one of two business components. As above, the business component may also be in binary format; the service component can also comprise a plurality of classes, each class can correspond to an attribute, and the attribute can comprise a protocol; the second attribute may also be an interface class attribute; accordingly, a collection of classes may be referred to as a class set, as distinguished from the class set described above, and may be referred to herein as a second class set; similarly, the set of different protocols included in the attribute may be referred to as a second protocol set.
S400, according to the same protocol in the first protocol set and the second protocol set, a mapping relation is established between the corresponding class in the first class set and the class in the second class set.
In the embodiment of the disclosure, the first protocol set and the second protocol set may include the same protocol, where the difference is that the protocol in the first protocol set is a declaration protocol, and the protocol in the second protocol set may achieve the purpose of implementation. In other words, the classes in the first class set and the classes in the second class set may be associated classes. As shown in fig. 2, fig. 2 is a schematic diagram of establishing a mapping relationship according to an embodiment of the present disclosure. In fig. 2, component a may be a base component and component B may be a business component. Wherein, the component a may include a plurality of classes, the embodiments of the disclosure take class 1 and class 2 as examples, wherein the attribute of class 1 may include protocol 1, and the attribute of class 2 may include protocol 2. Correspondingly, in service component B, the attribute of class 3 includes protocol 1 and the attribute of class 4 includes protocol 2. In component a, protocol 1 and protocol 2 may be just declarative protocols; in component B, protocol 1 and protocol 2 may be implementation protocols. At this time, a mapping relationship is established between classes having the same protocol, that is, class 1 corresponds to class 3 and class 2 corresponds to class 4, so that a mapping relationship between classes having the same protocol in the component a and the component B can be established. It is understood that this embodiment is for illustrative purposes only and that the number of classes may vary in other embodiments of the present disclosure, and the present disclosure is not limited in this regard. In addition, embodiments of the present disclosure may create a sub-data segment in a data (data) segment in a binary format file for recording a mapping relationship, which may be, for example, in the form of a binary format, which is advantageous in that security is high. In another embodiment of the present disclosure, the mapping relationship may also be recorded in a configuration table in a plaintext form, and the advantage of using the plaintext form is that it is convenient for a developer to understand; furthermore, since plaintext is modifiable, the configuration table may be updated or pruned as desired, unlike binary formatted files. The mapping in the above embodiment is preferably directed to the service component unidirectionally from the base component, but it is understood that the mapping in the embodiment of the disclosure may also be directed unidirectionally, which may also achieve the call transfer of the disclosure.
S500, a third collection used for realizing the first protocol collection in the second sub-assembly is obtained.
Specifically, the embodiment of the present disclosure may further obtain a service component, where the service component also includes a protocol existing in the base component, and the remaining aspects are similar to step S300, and are not repeated herein.
S600, initializing the third class set, and assigning the initialized third class set to the first attribute.
Specifically, embodiments of the present disclosure may create objects; and according to the mapping relation, transferring the first class corresponding to the same protocol in the first class set pointed by the third class set to a function set determined according to the assignment in the second class corresponding to the same protocol in the second class set. Taking fig. 3 as an example, fig. 3 is a schematic diagram of an assignment process according to an embodiment of the present disclosure. In fig. 3, a business component C is acquired; multiple classes, such as class 5 and class 6, may be included in component C, where the attributes of class 5 include protocol 1 and the attributes of class 6 include protocol 2. When the business component C calls the basic component A, according to the mapping relation, the calling object is transferred to the class with the same protocol in the component B. The call relationship changes from dotted line in fig. 3 to broken line, i.e. class 5 goes from class 1 in call component a to a corresponding set of functions, e.g. set of functions 2, in class 3 in call component B according to the assignment, class 6 goes from class 2 in call component a to, e.g. set of functions 4, in class 4 in call component B according to the assignment. It is understood that each class of the present embodiment includes only two function sets by way of example, but in other embodiments of the present disclosure, the number of function sets is not limited to two, which is not a limitation of the present disclosure. In addition, the embodiment takes the acquisition of a component C as an example, but in other embodiments, the acquired component is not limited to the component C, and other cases such as the component D, the component E, and more are also included in the scope of the present disclosure.
Referring to fig. 4, fig. 4 is an effect schematic diagram of the implementation-dependent implantation method according to the embodiment of the disclosure. As can be seen from fig. 4, the implementation-dependent injection method proposed by the embodiment of the present disclosure may provide convenience for function switching. In particular, component 1 may be a base component, and components 2, 3, 4, and 5 may be business modules, including different implementations. If it is desired to switch from the implementation of the component 2 to the implementation of the component 3, only the mapping relation pointing is selected, i.e. the short-line arrow in fig. 4 is changed to a dotted-line arrow. Further, the method of implementing dependent injection provided by the embodiments of the present disclosure can also simplify the modification process. For example, component 3 and component 4 in FIG. 4 correspond to the same implementation, except that component 4 is an optimized version of component 3, so that the updating of the component does not require repositioning of the original code, and this implementation can be upgraded by changing the mapping to point to component 4, especially when the amount of source code is large. In addition, the embodiment of the disclosure can also quickly position the error reporting module according to the direction when reporting errors. It will be appreciated that while five components are illustrated in fig. 4, the present disclosure may also include a greater or lesser number of components.
As shown in fig. 5, the embodiment of the present disclosure further provides an apparatus 10 for implementing dependency injection, including an acquisition module 30, a setup module 50, an initialization module 70, and a valuation module 90. Wherein the obtaining module 30 may be configured to obtain the first component, the second set of categories in the first sub-component included in the second component, and the third set of categories in the second sub-component included in the second component. The establishing module 50 may be configured to establish a mapping relationship between the first class set and the second class set. The initialization module 70 may be used to initialize the third set of categories. The assignment module 90 may be configured to assign the initialized third class set to a first attribute corresponding to the first class set. In other embodiments of the present disclosure, a transfer module (not shown) may be further included, and the transfer module may be configured to transfer, according to the mapping relationship, a first class corresponding to the same protocol in the first class set to which the third class set points to a function set determined according to the assignment in a second class corresponding to the same protocol in the second class set.
For embodiments of the device, reference is made to the description of method embodiments for the relevant points, since they essentially correspond to the method embodiments. The apparatus embodiments described above are merely illustrative, wherein the modules illustrated as separate modules may or may not be separate. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art will understand and implement the present application without undue burden.
The above, the method and apparatus for implementing dependent injection of the present disclosure is described based on the embodiments and applications. In addition, the present disclosure also provides a terminal and a storage medium, which are described below.
Referring now to fig. 6, a schematic diagram of an electronic device (e.g., a terminal device or server) 800 suitable for use in implementing embodiments of the present disclosure is shown. The terminal devices in the embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and the like, and stationary terminals such as digital TVs, desktop computers, and the like. The electronic device shown in fig. 6 is merely an example and should not be construed to limit the functionality and scope of use of the disclosed embodiments.
As shown in fig. 6, the electronic device 800 may include a processing means (e.g., a central processor, a graphics processor, etc.) 801, which may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 802 or a program loaded from a storage means 808 into a Random Access Memory (RAM) 803. In the RAM803, various programs and data required for the operation of the electronic device 800 are also stored. The processing device 801, the ROM 802, and the RAM803 are connected to each other by a bus 804. An input/output (I/O) interface 805 is also connected to the bus 804.
In general, the following devices may be connected to the I/O interface 805: input devices 806 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, and the like; an output device 807 including, for example, a Liquid Crystal Display (LCD), speakers, vibrators, etc.; storage 808 including, for example, magnetic tape, hard disk, etc.; communication means 809. The communication means 809 may allow the electronic device 800 to communicate wirelessly or by wire with other devices to exchange data. While fig. 6 shows an electronic device 800 having various means, it is to be understood that not all of the illustrated means are required to be implemented or provided. More or fewer devices may be implemented or provided instead.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from a network via communication device 809, or installed from storage device 808, or installed from ROM 802. The above-described functions defined in the methods of the embodiments of the present disclosure are performed when the computer program is executed by the processing device 801.
It should be noted that the computer readable medium described in the present disclosure may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this disclosure, a computer-readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present disclosure, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, fiber optic cables, RF (radio frequency), and the like, or any suitable combination of the foregoing.
In some implementations, the clients, servers may communicate using any currently known or future developed network protocol, such as HTTP (HyperText Transfer Protocol ), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the internet (e.g., the internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed networks.
The computer readable medium may be contained in the electronic device; or may exist alone without being incorporated into the electronic device.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to perform the methods of the present disclosure described above.
Computer program code for carrying out operations of the present disclosure may be written in one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units involved in the embodiments of the present disclosure may be implemented by means of software, or may be implemented by means of hardware. Wherein the names of the units do not constitute a limitation of the units themselves in some cases.
The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: a Field Programmable Gate Array (FPGA), an Application Specific Integrated Circuit (ASIC), an Application Specific Standard Product (ASSP), a system on a chip (SOC), a Complex Programmable Logic Device (CPLD), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
In accordance with one or more embodiments of the present disclosure, there is provided a method of implementing dependent injection, comprising:
acquiring a first component; the first component comprises a first class set, wherein the first class set corresponds to a first attribute, and the first attribute comprises a first protocol set;
acquiring a second component; wherein the second component comprises a first sub-component and a second sub-component;
acquiring a second class set contained in the first sub-assembly; wherein the second class set corresponds to a second attribute, and the second attribute comprises a second protocol set;
establishing a mapping relation between the class in the corresponding first class set and the class in the second class set according to the same protocol in the first protocol set and the second protocol set;
acquiring a third class set used for realizing the first protocol set in the second sub-assembly; a kind of electronic device with high-pressure air-conditioning system
Initializing the third class set, and assigning the initialized third class set to the first attribute.
According to one or more embodiments of the present disclosure, there is provided a method, wherein the step of assigning the initialized third class set to the first attribute includes:
and according to the mapping relation, transferring the first class corresponding to the same protocol in the first class set pointed by the third class set to a function set determined according to the assignment in the second class corresponding to the same protocol in the second class set.
According to one or more embodiments of the present disclosure, there is provided a method, wherein the first component is a base component and the second component is a business component.
According to one or more embodiments of the present disclosure, there is provided a method, wherein the first component and the second component are both binary format files.
According to one or more embodiments of the present disclosure, there is provided a method, wherein the mapping relation is recorded in a sub-data section of a data section in the binary format file in a binary format.
According to one or more embodiments of the present disclosure, there is provided a method, wherein the mapping relation is recorded in a plain text form in a configuration table.
According to one or more embodiments of the present disclosure, there is provided a method, wherein the first attribute and the second attribute are both interface class attributes.
According to one or more embodiments of the present disclosure, there is provided a method, wherein the mapping relationship is a unidirectional pointing relationship from a class in the first class set to a class in the second class set.
According to one or more embodiments of the present disclosure, there is provided an apparatus for implementing dependent injection, comprising:
the device comprises an acquisition module, a first component, a second collection in a first sub-component included in the second component, and a third collection in a second sub-component included in the second component, wherein the acquisition module is used for acquiring the first component, the second collection in the first sub-component included in the second component, and the third collection in the second sub-component included in the second component;
the establishing module is used for establishing a mapping relation between the first class set and the second class set;
the initialization module is used for initializing the third class set; a kind of electronic device with high-pressure air-conditioning system
And the assignment module is used for assigning the initialized third class set to the first attribute corresponding to the first class set.
According to one or more embodiments of the present disclosure, there is provided a terminal including: at least one memory and at least one processor;
wherein the at least one memory is configured to store program code, and the at least one processor is configured to invoke the program code stored by the at least one memory to perform any of the methods described above.
According to one or more embodiments of the present disclosure, there is provided a storage medium for storing program code for performing the above-described method.
The foregoing description is only of the preferred embodiments of the present disclosure and description of the principles of the technology being employed. It will be appreciated by persons skilled in the art that the scope of the disclosure referred to in this disclosure is not limited to the specific combinations of features described above, but also covers other embodiments which may be formed by any combination of features described above or equivalents thereof without departing from the spirit of the disclosure. Such as those described above, are mutually substituted with the technical features having similar functions disclosed in the present disclosure (but not limited thereto).
Moreover, although operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. In certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the present disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are example forms of implementing the claims.
Claims (10)
1. A method of implementing dependent injection, comprising:
acquiring a first component; the first component comprises a first class set, wherein the first class set corresponds to a first attribute, and the first attribute comprises a first protocol set;
acquiring a second component; wherein the second component comprises a first sub-component and a second sub-component;
acquiring a second class set contained in the first sub-assembly; wherein the second class set corresponds to a second attribute, and the second attribute comprises a second protocol set;
establishing a mapping relation between the class in the corresponding first class set and the class in the second class set according to the same protocol in the first protocol set and the second protocol set;
acquiring a third class set used for realizing the first protocol set in the second sub-assembly; a kind of electronic device with high-pressure air-conditioning system
Initializing the third class set, and assigning the initialized third class set to the first attribute;
the first component is a base component, the second component is a service component, the first protocol set comprises a declaration protocol, and the second protocol set comprises an implementation protocol.
2. The method of claim 1, wherein assigning the initialized third set of categories to the first attribute comprises:
and according to the mapping relation, transferring the first class corresponding to the same protocol in the first class set pointed by the third class set to a function set determined according to the assignment in the second class corresponding to the same protocol in the second class set.
3. The method of claim 1, wherein the first component and the second component are both binary format files.
4. A method according to claim 3, wherein the mapping relationship is recorded in a binary format in a sub-data section of a data section in the binary format file.
5. A method according to claim 1 or 3, characterized in that the mapping is recorded in plain text in a configuration table.
6. The method of claim 1, wherein the first attribute and the second attribute are both interface class attributes.
7. The method of claim 1, wherein the mapping relationship is a unidirectional pointing relationship from a class in the first class set to a class in the second class set.
8. An apparatus that implements dependent injection, comprising:
the device comprises an acquisition module, a first component, a second class set in a first sub-component included in the second component, and a third class set in a second sub-component included in the second component, wherein the first component comprises a first class set corresponding to a first attribute, the first attribute comprises a first protocol set, the second class set corresponds to a second attribute, and the second attribute comprises a second protocol set;
the establishing module is used for establishing a mapping relation between the first class set and the second class set;
the initialization module is used for initializing the third class set; a kind of electronic device with high-pressure air-conditioning system
The assignment module is used for assigning the initialized third class set to the first attribute corresponding to the first class set;
the first component is a base component, the second component is a service component, the first protocol set comprises a declaration protocol, and the second protocol set comprises an implementation protocol.
9. A terminal, comprising:
at least one memory and at least one processor;
wherein the at least one memory is configured to store program code, and the at least one processor is configured to invoke the program code stored by the at least one memory to perform the method of any of claims 1 to 7.
10. A storage medium for storing program code for performing the method of any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010066483.0A CN111324336B (en) | 2020-01-20 | 2020-01-20 | Method, device, terminal and storage medium for implementing dependency injection |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010066483.0A CN111324336B (en) | 2020-01-20 | 2020-01-20 | Method, device, terminal and storage medium for implementing dependency injection |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111324336A CN111324336A (en) | 2020-06-23 |
CN111324336B true CN111324336B (en) | 2023-12-12 |
Family
ID=71167012
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010066483.0A Active CN111324336B (en) | 2020-01-20 | 2020-01-20 | Method, device, terminal and storage medium for implementing dependency injection |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111324336B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113407163A (en) * | 2021-05-18 | 2021-09-17 | 中广核工程有限公司 | Module association assignment method and device, computer equipment and readable storage medium |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6832369B1 (en) * | 2000-08-01 | 2004-12-14 | International Business Machines Corporation | Object oriented method and apparatus for class variable initialization |
CN104407843A (en) * | 2014-10-22 | 2015-03-11 | 浪潮软件集团有限公司 | Dependency inversion optimization method for decoupling high-low layer modules |
CN106569835A (en) * | 2016-11-14 | 2017-04-19 | 济南浪潮高新科技投资发展有限公司 | Realization method for inversion-of-control assembly based on go language |
CN108762728A (en) * | 2018-04-13 | 2018-11-06 | 杭州朗和科技有限公司 | By integrated method, medium, device and the computing device in the application of communication function |
CN109669679A (en) * | 2018-12-28 | 2019-04-23 | 北京微播视界科技有限公司 | Service detection and processing method, device and electronic equipment |
CA3047939A1 (en) * | 2018-06-25 | 2019-12-25 | Tata Consultancy Services Limited | Automated extraction of rules embedded in software application code using machine learning |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US10268549B2 (en) * | 2016-03-03 | 2019-04-23 | International Business Machines Corporation | Heuristic process for inferring resource dependencies for recovery planning |
US10839011B2 (en) * | 2018-04-18 | 2020-11-17 | International Business Machines Corporation | Application programing interface document generator |
-
2020
- 2020-01-20 CN CN202010066483.0A patent/CN111324336B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6832369B1 (en) * | 2000-08-01 | 2004-12-14 | International Business Machines Corporation | Object oriented method and apparatus for class variable initialization |
CN104407843A (en) * | 2014-10-22 | 2015-03-11 | 浪潮软件集团有限公司 | Dependency inversion optimization method for decoupling high-low layer modules |
CN106569835A (en) * | 2016-11-14 | 2017-04-19 | 济南浪潮高新科技投资发展有限公司 | Realization method for inversion-of-control assembly based on go language |
CN108762728A (en) * | 2018-04-13 | 2018-11-06 | 杭州朗和科技有限公司 | By integrated method, medium, device and the computing device in the application of communication function |
CA3047939A1 (en) * | 2018-06-25 | 2019-12-25 | Tata Consultancy Services Limited | Automated extraction of rules embedded in software application code using machine learning |
CN109669679A (en) * | 2018-12-28 | 2019-04-23 | 北京微播视界科技有限公司 | Service detection and processing method, device and electronic equipment |
Non-Patent Citations (3)
Title |
---|
Dependency Injection Refined by Extra-functional Properties;Jezek, K;IEEE;第2012卷;pp.255-256 * |
Model-to-model transformation in approach by modeling: From UML model to Model-View-Presenter and Dependency Injection patterns;Redouane Esbai;IEEE;第2015卷;正文1-5页 * |
基于机器学习识别SQL注入攻击设计与实现;王誉东;《中国优秀硕士学位论文全文数据库》;第2018年第12期卷;正文第7-48页 * |
Also Published As
Publication number | Publication date |
---|---|
CN111324336A (en) | 2020-06-23 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110851139B (en) | Method and device for checking codes and electronic equipment | |
CN112965761B (en) | Data processing method, system, electronic equipment and storage medium | |
CN111309304B (en) | Method, device, medium and electronic equipment for generating IDL file | |
CN111400068B (en) | Interface control method and device, readable medium and electronic equipment | |
CN111324376B (en) | Function configuration method, device, electronic equipment and computer readable medium | |
CN114595065A (en) | Data acquisition method and device, storage medium and electronic equipment | |
CN113407165B (en) | SDK generation and self-upgrade method, device, readable medium and equipment | |
CN111324336B (en) | Method, device, terminal and storage medium for implementing dependency injection | |
CN111414152B (en) | Method, system, readable medium and electronic device for realizing business logic | |
CN110704050B (en) | Module initializing method and device, electronic equipment and computer readable storage medium | |
CN111752644A (en) | Interface simulation method, device, equipment and storage medium | |
CN112965713B (en) | Development method, device, equipment and storage medium of visual editor | |
CN113391860B (en) | Service request processing method and device, electronic equipment and computer storage medium | |
CN111240738B (en) | File processing method, device, equipment and medium | |
CN111290812B (en) | Display method, device, terminal and storage medium of application control | |
CN111258786B (en) | Decoupling method, device, terminal and storage medium in layered architecture | |
CN111782895B (en) | Retrieval processing method and device, readable medium and electronic equipment | |
CN111309323A (en) | Parameter initialization method and device and electronic equipment | |
CN111240657A (en) | Method and device for generating SDK and electronic equipment | |
CN113448550B (en) | Method and device for realizing collection management of classes, electronic equipment and computer medium | |
CN111399902B (en) | Client source file processing method and device, readable medium and electronic equipment | |
CN116820354B (en) | Data storage method, data storage device and data storage system | |
CN111581305B (en) | Feature processing method, device, electronic equipment and medium | |
CN110086880B (en) | Method and apparatus for creating instances of network requests | |
CN111381898B (en) | Interface calling method and device, mobile terminal and storage 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 |
Effective date of registration: 20230406 Address after: Room 802, Information Building, 13 Linyin North Street, Pinggu District, Beijing, 101299 Applicant after: Beijing youzhuju Network Technology Co.,Ltd. Address before: No. 715, 7th floor, building 3, 52 Zhongguancun South Street, Haidian District, Beijing 100081 Applicant before: Beijing infinite light field technology Co.,Ltd. |
|
TA01 | Transfer of patent application right | ||
GR01 | Patent grant | ||
GR01 | Patent grant |