CN110704050A - Module initialization method, device, electronic equipment and computer readable storage medium - Google Patents

Module initialization method, device, electronic equipment and computer readable storage medium Download PDF

Info

Publication number
CN110704050A
CN110704050A CN201910959747.2A CN201910959747A CN110704050A CN 110704050 A CN110704050 A CN 110704050A CN 201910959747 A CN201910959747 A CN 201910959747A CN 110704050 A CN110704050 A CN 110704050A
Authority
CN
China
Prior art keywords
module
modules
dependency relationship
initialization
user
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.)
Granted
Application number
CN201910959747.2A
Other languages
Chinese (zh)
Other versions
CN110704050B (en
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.)
Beijing Youzhuju Network Technology Co Ltd
Original Assignee
Beijing Infinite Light Field 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 Beijing Infinite Light Field Technology Co Ltd filed Critical Beijing Infinite Light Field Technology Co Ltd
Priority to CN201910959747.2A priority Critical patent/CN110704050B/en
Publication of CN110704050A publication Critical patent/CN110704050A/en
Application granted granted Critical
Publication of CN110704050B publication Critical patent/CN110704050B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/35Creation or generation of source code model driven
    • 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)
  • Stored Programmes (AREA)

Abstract

The embodiment of the disclosure provides a module initialization method and device, electronic equipment and a computer-readable storage medium. The method comprises the following steps: when a program is compiled, user-defined notes of a first module to be initialized in the program are obtained, and the user-defined notes declare a second module to be called by the first module; the method includes initializing a first module and a second module. According to the method and the device, the user-defined annotation of the first module is obtained when the first module is loaded, and the user-defined annotation states that the second module which needs to be called by the first module is provided, so that the first module and the second module are initialized. Because the initialization of the module to be called is completed in advance, the normal calling of the module can be ensured, and the normal use of the software is further ensured.

Description

Module initialization method, device, electronic equipment and computer readable storage medium
Technical Field
The present disclosure relates to the field of software development technologies, and in particular, to a module initialization method and apparatus, an electronic device, and a computer-readable storage medium.
Background
In software development, different services are mostly split into different modules, and the modules are isolated from each other and do not depend on each other directly, so that the coupling degree between the services and codes is reduced, and the maintainability of a project is improved.
The initialization of each module in the software is performed separately, and in actual use, the module in the software may need to call other modules, and a situation that the module to be called is not initialized may occur, which may affect the normal call of the module, and further affect the use of the software.
Disclosure of Invention
This summary is provided to introduce a selection of concepts in a simplified form that are further described below in the detailed description. This summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used to limit the scope of the claimed subject matter.
In a first aspect, an embodiment of the present disclosure provides a module initialization method, where the method includes:
when a program is compiled, user-defined notes of a first module to be initialized in the program are obtained, and the user-defined notes declare a second module to be called by the first module;
the method includes initializing a first module and a second module.
In a second aspect, an embodiment of the present disclosure provides a module initialization apparatus, including:
the system comprises an annotation acquisition module, a first module and a second module, wherein the annotation acquisition module is used for acquiring a user-defined annotation of the first module to be initialized in a program when the program is compiled, and the user-defined annotation declares the second module to be called by the first module;
and the initialization module is used for initializing the first module and the second module.
In a third aspect, an embodiment of the present disclosure provides an electronic device, including: a processor and a memory;
a memory for storing a computer program;
a processor for executing the module initialization method as shown in the first aspect of the present disclosure by calling a computer program.
In a fourth aspect, the embodiments of the present disclosure provide a computer-readable storage medium, on which a computer program is stored, which when executed by a processor, implements the module initialization method shown in the first aspect of the present disclosure.
The technical scheme provided by the embodiment of the disclosure has the following beneficial effects:
according to the scheme provided by the embodiment of the disclosure, when the first module is loaded, the user-defined annotation of the first module is obtained, and the user-defined annotation states that the second module which needs to be called by the first module is provided, so that the initialization of the first module and the second module is completed. Because the initialization of the module to be called is completed in advance, the normal calling of the module can be ensured, and the normal use of the software is further ensured.
Drawings
The above and other features, advantages and aspects of various embodiments of the present disclosure will become more apparent by referring to the following detailed description when taken in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numbers refer to the same or similar elements. It should be understood that the drawings are schematic and that elements and features are not necessarily drawn to scale.
In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure, the drawings used in the description of the embodiments of the present disclosure will be briefly described below.
Fig. 1 is a schematic flowchart of a module initialization method according to an embodiment of the present disclosure;
FIG. 2 is a directed graph formed by dependencies among modules B, C, and D;
FIG. 3 is a directed graph formed by dependencies among module E, module F, module G, module H, and module I;
fig. 4 is a schematic structural diagram of a module initialization apparatus according to an embodiment of the present disclosure;
fig. 5 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 are shown in the 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 rather are provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the disclosure are for illustration purposes only and are not intended to limit the scope of the disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in a different order, and/or performed in parallel. Moreover, 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 "include" and variations thereof as used herein are 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". Relevant definitions for other terms will be given in the following description.
It should be noted that the terms "first", "second", and the like in the present disclosure are only used for distinguishing the devices, modules or units, and are not used for limiting the devices, modules or units to be different devices, modules or units, and also for limiting the sequence or interdependence relationship of the functions executed by the devices, modules or units.
It is noted that references to "a", "an", and "the" modifications in this disclosure are intended to be illustrative rather than limiting, and that those skilled in the art will recognize that "one or more" may be used unless the context clearly dictates otherwise.
The names of messages or information exchanged between devices in the embodiments of the present disclosure are for illustrative purposes only, and are not intended to limit the scope of the messages or information.
In a module initialization scheme in the prior art, generally, a module to be called is not initialized in advance, and the module to be called is initialized during calling, which may cause that whether the module to be called is initialized or not needs to be judged every time the module is called, thereby affecting processing efficiency.
In the prior art, a processing mode also exists when a module is called, the module is called in a host module in a hard coding mode, the host module can contain codes corresponding to the modules when the modules are called, so that the codes are coupled, and the mode needs to respectively write the codes for each calling, so that the codes are more complicated to write.
The module initialization method, device, electronic device and computer-readable storage medium provided by the embodiments of the present disclosure are intended to solve at least one of the above technical problems in the prior art.
The following describes the technical solutions of the present disclosure and how to solve the above technical problems in specific embodiments. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments. Embodiments of the present disclosure will be described below with reference to the accompanying drawings.
Fig. 1 shows a schematic flowchart of a module initialization method provided in an embodiment of the present disclosure, and as shown in fig. 1, the method mainly includes:
step S110: when a program is compiled, user-defined notes of a first module to be initialized in the program are obtained, and the user-defined notes declare a second module to be called by the first module;
step S120: the method includes initializing a first module and a second module.
In the embodiment of the disclosure, the second module required to be called can be declared through the user-defined annotation added to the first module. The number of the second modules can be multiple, and corresponding user-defined annotations are added to the multiple second modules respectively.
For example: the module A is a first module, and a second module required to be called by the module A comprises: and the module B, the module C and the module D can be declared through user-defined notes.
When the first module is loaded, the user-defined annotation of the first module can be obtained, so that the second module is determined based on the user-defined annotation of the first module, and the first module and the second module can be respectively initialized. When the first module calls the second module, the second module has already finished initializing, so that the first module can normally call the second module.
According to the method provided by the embodiment of the disclosure, when the first module is loaded, the user-defined annotation of the first module is obtained, and the user-defined annotation states that the second module which needs to be called by the first module is provided, so that the initialization of the first module and the second module is completed. Because the initialization of the module to be called is completed in advance, the normal calling of the module can be ensured, and the normal use of the software is further ensured.
In an optional manner of the embodiment of the present disclosure, if there are at least two second modules and a user-defined annotation states a dependency relationship between the at least two second modules, initializing the second modules includes:
determining the initialization sequence of the second modules with the dependency relationship based on the dependency relationship;
and sequentially initializing the second modules with the dependency relationship based on the initialization sequence.
In the embodiment of the present disclosure, when the number of the second modules that the first module needs to call is at least two, a dependency relationship may exist between the at least two second modules, as an example, a dependency relationship exists between the module B and the module C, for example, the module B depends on the module C, at this time, the module B is a dependent module, the module C is a dependent module, and the initialization of the module B needs to depend on the initialized module C, so that the module B needs to be initialized after the module C is initialized.
Because of the possible dependency relationship between at least two second modules, the initialization sequence of the second modules with the dependency relationship needs to be determined according to the dependency relationship, and the initialization operation of the modules is performed according to the initialization sequence to ensure that the dependent modules are initialized before the dependent modules, thereby ensuring that the initialization operation of the modules can be performed normally.
In practice, the dependency between at least two second modules may be defined by means of the dependedson annotation.
In an optional manner of the embodiment of the present disclosure, if the dependency relationship between at least two second modules is not an annular dependency relationship, determining, based on the dependency relationship, an initialization sequence of the second modules having the dependency relationship, includes:
and carrying out topological sequencing on the second modules with the dependency relationships based on the dependency relationships, and determining the initialization sequence of the second modules with the dependency relationships.
In the embodiments of the present disclosure, as an example: the module B depends on the module C, the module C depends on the module D, the module D depends on the module B, and at this time, the module B, the module C, and the module D form a ring-shaped dependency relationship, and in the initialization process, the initialization of the module B needs to depend on the initialization of the module C, the initialization of the module C needs to depend on the initialization of the module D, and the initialization of the module D depends on the initialization of the module B, and at this time, the initialization sequence cannot be determined, which may affect the initialization operation of the module.
Fig. 2 shows a directed graph formed by dependencies among modules B, C and D, where node B represents module B, node C represents module C, and node D represents module D, as shown in fig. 2.
Nodes at two ends of a directed edge in the graph have a dependency relationship, a node pointed by an arrow of the directed edge is a depended module, a directed edge from a node B to a node C in the graph represents that a module B depends on the module C, a directed edge from the node C to a node D represents that a module C depends on the module D, and a directed edge from the node D to the node B represents that a module D depends on the module B.
When the at least two second modules have a ring-shaped dependency relationship, a ring formed by directed edges exists in the directed graph formed based on the dependency relationship, and as in fig. 2, a ring is formed by directed edges from node B to node C, directed edges from node C to node D, and directed edges from node D to node B.
When at least two second modules have a ring dependency relationship, prompt information indicating the existence of the ring dependency relationship can be output, and relevant information of each second module having the ring dependency relationship can be output so as to process the ring dependency relationship.
When the at least two second modules do not have the annular dependency relationship, the topological ordering of the second modules with the dependency relationship can be determined, and then the initialization sequence is determined according to the topological ordering.
In practical use, when the at least two second modules do not have a ring dependency relationship, the directed acyclic graph can be determined based on the dependency relationship, and the initialization sequence is determined by performing topological sorting on the directed acyclic graph. In particular, the topological sort can be implemented based on kahn's algorithm.
As an example, the dependency is: module E depends on module F, which depends on module G, which depends on module H, and module I.
Fig. 3 shows a directed graph formed by dependencies among modules E, F, G, H and I, where, as shown in fig. 3, node E in the graph represents module E, node F represents module F, node G represents module G, node H represents module H, and node I represents module I.
The method comprises the steps that nodes at two ends of a directed edge in a graph have a dependency relationship, nodes pointed by arrows of the directed edge are depended modules, a directed edge from a node E to a node F in the graph represents that a module E depends on the module F, a directed edge from the node E to the node I in the graph represents that a module E depends on the module I, a directed edge from the node F to a node G in the graph represents that a module F depends on the module G, and a directed edge from the node G to a node H in the graph represents that a module G depends on the module H.
The specific process of performing topology ranking on the directed graph based on the kahn algorithm may be as follows:
the method comprises the following steps: selecting a node without directed edge pointing (namely, the degree of entry is 0) from the directed graph;
step two: deleting the node selected in the step one from the directed graph, and deleting all directed edges sent from the node;
step three: and repeatedly executing the first step and the second step until all nodes in the directed graph are deleted.
Step four: and performing reverse order on the deleting sequence of the nodes in the directed graph to be used as an initialization sequence.
Taking the directed graph in fig. 3 as an example, the order of deleting nodes in the directed graph in fig. 3 may be: E. i, F, G, H, the initialization sequence obtained by reversing the sequence is: H. g, F, I, E, initialize H, G, F, I and E in turn according to the initialization order.
In an optional manner of the embodiment of the present disclosure, the user-defined annotation declares the second module that needs to be called by the first module in the following manner:
and establishing a corresponding relation between the self-defined annotation and the entry class of the second module.
In the embodiment of the disclosure, the second module may be declared by annotating the entry class of the second module, the annotated entry class may be a subclass, and based on a java polymorphic mechanism, when the entry class is called, a parent class corresponding to the entry class is found, and initialization of the second module is achieved by calling the parent class corresponding to the entry class.
In actual use, the dependency relationship between at least two second modules may be defined by means of a ModuleEntry annotation. For example, module A depends on module B and module C, and the annotation to module A's entry class may be: @ ModuleEntry (dependsOn { "B", "C" }.
In an optional mode of the embodiment of the present disclosure, initializing the second module includes:
generating a routing table of an entry class of the second module based on the user-defined annotation;
and calling the entry class of the second module based on the routing table, and initializing the second module.
In the embodiment of the present disclosure, the user-defined comment may be processed by an Annotation Processing Tool (APT), and the routing table of the entry class of the second module is automatically generated, the code is written easily, and the user-defined comment of each module is in the code of each module, but not in the host module, so that the coupling of the code can be avoided.
When the entry class of the second module is called based on the routing table, the entry classes of the corresponding second modules can be called in sequence for initialization according to the determined initialization sequence.
In actual use, there may be a case that the parent class corresponding to the entry class cannot be found, and at this time, the initialization of the module may not be implemented, and the routing information of the entry class may be discarded in the routing table.
Based on the same principle as the method shown in fig. 1, fig. 4 shows a schematic structural diagram of a module initialization apparatus provided by an embodiment of the present disclosure, and as shown in fig. 4, the module initialization apparatus 20 may include:
the annotation acquisition module 210 is configured to acquire a user-defined annotation of a first module to be initialized in a program when the program is compiled, where the user-defined annotation declares a second module that needs to be called by the first module;
the initialization module 220 is configured to initialize the first module and the second module.
According to the device provided by the embodiment of the disclosure, when the first module is loaded, the user-defined annotation of the first module is obtained, and the user-defined annotation states that the second module which needs to be called by the first module is provided, so that the initialization of the first module and the initialization of the second module are completed. Because the initialization of the module to be called is completed in advance, the normal calling of the module can be ensured, and the normal use of the software is further ensured.
Optionally, if the number of the second modules is at least two, and the user-defined annotation states a dependency relationship between the at least two second modules, the initialization module is specifically configured to, when initializing the second modules:
determining the initialization sequence of the second modules with the dependency relationship based on the dependency relationship;
and sequentially initializing the second modules with the dependency relationship based on the initialization sequence.
Optionally, if the dependency relationship between the at least two second modules is not a ring dependency relationship, when the initialization module determines the initialization sequence of the second modules having the dependency relationship based on the dependency relationship, the initialization module is specifically configured to:
and carrying out topological sequencing on the second modules with the dependency relationships based on the dependency relationships, and determining the initialization sequence of the second modules with the dependency relationships.
Optionally, if at least two second modules have a ring dependency relationship, the module initialization apparatus further includes:
and the prompting module is used for outputting prompting information that at least two second modules have annular dependency relationship and outputting related information of each second module having annular dependency relationship.
Optionally, the user-defined annotation declares the second module that the first module needs to invoke by:
and establishing a corresponding relation between the self-defined annotation and the entry class of the second module.
Optionally, when the initialization module is configured to initialize the second module, the initialization module is specifically configured to:
generating a routing table of an entry class of the second module based on the user-defined annotation;
and calling the entry class of the second module based on the routing table, and initializing the second module.
Referring now to fig. 5, shown is a schematic diagram of an electronic device (e.g., a terminal device or server that performs the method shown in fig. 1) 600 suitable for use in implementing embodiments of the present disclosure. The terminal device in the embodiments of the present disclosure may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle terminal (e.g., a car navigation terminal), and the like, and a stationary terminal such as a digital TV, a desktop computer, and the like. The electronic device shown in fig. 5 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
The electronic device includes: a memory and a processor, wherein the processor may be referred to as a processing device 601 described below, and the memory may include at least one of a Read Only Memory (ROM)602, a Random Access Memory (RAM)603, and a storage device 608, which are described below:
as shown in fig. 5, electronic device 600 may include a processing means (e.g., central processing unit, graphics processor, etc.) 601 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)602 or a program loaded from a storage means 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data necessary for the operation of the electronic apparatus 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
Generally, the following devices may be connected to the I/O interface 605: input devices 606 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 607 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 608 including, for example, tape, hard disk, etc.; and a communication device 609. The communication means 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. While fig. 5 illustrates an electronic device 600 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a non-transitory computer readable medium, the computer program containing program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication means 609, or may be installed from the storage means 608, or may be installed from the ROM 602. The computer program, when executed by the processing device 601, performs the above-described functions defined in the methods of the embodiments of the present disclosure.
It should be noted that the computer readable medium in the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination 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 present 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 contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. 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, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
In some embodiments, 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 communications 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 network.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled 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: when a program is compiled, obtaining a user-defined note of a first module to be initialized in the program, wherein the user-defined note states a second module to be called by the first module; initializing the first module and the second module.
Computer program code for carrying out operations for the present disclosure may be written in any combination of one or more programming languages, including but not limited to 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 type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart 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 modules or units described in the embodiments of the present disclosure may be implemented by software or hardware. Where the name of a module or unit does not in some cases constitute a limitation on the unit itself, for example, a prompt may also be described as an "information output module".
The functions described herein above 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: field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), systems on a chip (SOCs), Complex Programmable Logic Devices (CPLDs), 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. A 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 module initialization method including:
when a program is compiled, user-defined notes of a first module to be initialized in the program are obtained, and the user-defined notes declare a second module to be called by the first module;
the method includes initializing a first module and a second module.
According to the above module initialization method provided by the present disclosure, if there are at least two second modules and the user-defined annotation states the dependency relationship between the at least two second modules, initializing the second modules includes:
determining the initialization sequence of the second modules with the dependency relationship based on the dependency relationship;
and sequentially initializing the second modules with the dependency relationship based on the initialization sequence.
According to the module initialization method provided by the present disclosure, if the dependency relationship between at least two second modules is not a ring dependency relationship, determining the initialization sequence of the second modules having the dependency relationship based on the dependency relationship, includes:
and carrying out topological sequencing on the second modules with the dependency relationships based on the dependency relationships, and determining the initialization sequence of the second modules with the dependency relationships.
According to the module initialization method provided by the present disclosure, if at least two second modules have a ring dependency relationship, the method further includes:
and outputting prompt information that at least two second modules have annular dependency relationship, and outputting related information of each second module having annular dependency relationship.
According to the module initialization method provided by the disclosure, the user-defined annotation declares the second module to be called by the first module in the following way:
and establishing a corresponding relation between the self-defined annotation and the entry class of the second module.
According to the module initialization method provided by the present disclosure, initializing the second module includes:
generating a routing table of an entry class of the second module based on the user-defined annotation;
and calling the entry class of the second module based on the routing table, and initializing the second module.
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the disclosure herein is not limited to the particular combination of features described above, but also encompasses other embodiments in which any combination of the features described above or their equivalents does not depart from the spirit of the disclosure. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.
Further, while 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. Under 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 limitations on the scope of the 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 disclosed as example forms of implementing the claims.

Claims (10)

1. A method for initializing a module, comprising:
when a program is compiled, obtaining a user-defined note of a first module to be initialized in the program, wherein the user-defined note states a second module to be called by the first module;
initializing the first module and the second module.
2. The method of claim 1, wherein initializing the second module if the second module is at least two and a dependency relationship between at least two of the second modules is declared in the user-customized annotation comprises:
determining an initialization order of the second modules with the dependency relationship based on the dependency relationship;
and sequentially initializing the second modules with the dependency relationship based on the initialization sequence.
3. The method according to claim 2, wherein if the dependency relationship between at least two of the second modules is not a ring dependency relationship, the determining the initialization order of the second modules having the dependency relationship based on the dependency relationship comprises:
and performing topological sorting on the second modules with the dependency relationships based on the dependency relationships, and determining the initialization sequence of the second modules with the dependency relationships.
4. The method of claim 2, wherein if at least two of the second modules have a ring dependency, the method further comprises:
and outputting prompt information that the at least two second modules have the annular dependency relationship, and outputting related information of each second module having the annular dependency relationship.
5. The method of any of claims 1-4, wherein the user-customized annotation declares a second module that the first module needs to invoke by:
and establishing a corresponding relation between the self-defined annotation and the entry class of the second module.
6. The method of claim 5, wherein initializing the second module comprises:
generating a routing table of the entry class of the second module based on the user-defined annotation;
and calling the entry class of the second module based on the routing table, and initializing the second module.
7. A module initialization apparatus, comprising:
the system comprises an annotation acquisition module, a first module and a second module, wherein the annotation acquisition module is used for acquiring a user-defined annotation of the first module to be initialized in a program when the program is compiled, and the user-defined annotation declares the second module which needs to be called by the first module;
and the initialization module is used for initializing the first module and the second module.
8. The apparatus according to claim 7, wherein if there are at least two of the second modules and a dependency relationship between at least two of the second modules is stated in the user-defined annotation, the initialization module, when initializing the second modules, is specifically configured to:
determining an initialization order of the second modules with the dependency relationship based on the dependency relationship;
and sequentially initializing the second modules with the dependency relationship based on the initialization sequence.
9. An electronic device comprising a processor and a memory;
the memory for storing a computer program;
the processor configured to execute the method of any one of claims 1-6 by invoking the computer program.
10. A computer-readable storage medium, characterized in that the storage medium has stored thereon a computer program which, when being executed by a processor, carries out the method of any one of claims 1-6.
CN201910959747.2A 2019-10-10 2019-10-10 Module initializing method and device, electronic equipment and computer readable storage medium Active CN110704050B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910959747.2A CN110704050B (en) 2019-10-10 2019-10-10 Module initializing method and device, electronic equipment and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910959747.2A CN110704050B (en) 2019-10-10 2019-10-10 Module initializing method and device, electronic equipment and computer readable storage medium

Publications (2)

Publication Number Publication Date
CN110704050A true CN110704050A (en) 2020-01-17
CN110704050B CN110704050B (en) 2023-10-03

Family

ID=69200153

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910959747.2A Active CN110704050B (en) 2019-10-10 2019-10-10 Module initializing method and device, electronic equipment and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN110704050B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112783568A (en) * 2021-01-12 2021-05-11 网易(杭州)网络有限公司 Initialization method, device, equipment and storage medium of application program
CN113778568A (en) * 2021-09-09 2021-12-10 网易(杭州)网络有限公司 Service control method and device

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020147903A1 (en) * 2001-04-10 2002-10-10 Discreet Logic Inc. Initialising modules
CN106528261A (en) * 2016-12-02 2017-03-22 武汉斗鱼网络科技有限公司 Application page initialization compiling and controlling device and method
CN106598573A (en) * 2016-11-11 2017-04-26 武汉斗鱼网络科技有限公司 Method and device for simplifying application program language
CN107391218A (en) * 2017-07-07 2017-11-24 北京小米移动软件有限公司 Compilation Method and device, electronic equipment and computer-readable recording medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020147903A1 (en) * 2001-04-10 2002-10-10 Discreet Logic Inc. Initialising modules
CN106598573A (en) * 2016-11-11 2017-04-26 武汉斗鱼网络科技有限公司 Method and device for simplifying application program language
CN106528261A (en) * 2016-12-02 2017-03-22 武汉斗鱼网络科技有限公司 Application page initialization compiling and controlling device and method
CN107391218A (en) * 2017-07-07 2017-11-24 北京小米移动软件有限公司 Compilation Method and device, electronic equipment and computer-readable recording medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
CHOWN: "Spring 中如何控制2个bean中的初始化顺序?", 《HTTPS://ZHUANLAN.ZHIHU.COM/P/30112785》 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112783568A (en) * 2021-01-12 2021-05-11 网易(杭州)网络有限公司 Initialization method, device, equipment and storage medium of application program
CN112783568B (en) * 2021-01-12 2022-12-06 网易(杭州)网络有限公司 Initialization method, device, equipment and storage medium of application program
CN113778568A (en) * 2021-09-09 2021-12-10 网易(杭州)网络有限公司 Service control method and device

Also Published As

Publication number Publication date
CN110704050B (en) 2023-10-03

Similar Documents

Publication Publication Date Title
CN109523187B (en) Task scheduling method, device and equipment
CN111858518B (en) Method and device for updating reference document, electronic equipment and storage medium
CN111968648B (en) Voice recognition method and device, readable medium and electronic equipment
CN112214408A (en) Dependency conflict detection method and device, electronic equipment and computer readable medium
CN113835992A (en) Memory leak processing method and device, electronic equipment and computer storage medium
CN110704050B (en) Module initializing method and device, electronic equipment and computer readable storage medium
CN111857720A (en) Method and device for generating user interface state information, electronic equipment and medium
CN111309304A (en) Method, device, medium and electronic equipment for generating IDL file
CN113220281A (en) Information generation method and device, terminal equipment and storage medium
CN110489219B (en) Method, device, medium and electronic equipment for scheduling functional objects
CN111262778B (en) Invitation link information processing method and device, electronic equipment and readable medium
CN111752644A (en) Interface simulation method, device, equipment and storage medium
CN113391860A (en) Service request processing method and device, electronic equipment and computer storage medium
CN111124541A (en) Configuration file generation method, device, equipment and medium
CN111240801A (en) Method, device, medium and electronic equipment for generating heap memory snapshot file
CN111399902B (en) Client source file processing method and device, readable medium and electronic equipment
CN111367527B (en) Language processing method, device, medium and electronic equipment
CN113032046A (en) Method, device and equipment for repairing so file and storage medium
CN112230986A (en) Project file generation method and device, electronic equipment and computer readable medium
CN111258786A (en) Decoupling method and device in layered architecture, terminal and storage medium
CN111538577A (en) Program execution control device and method, terminal and storage medium
CN111209042B (en) Method, device, medium and electronic equipment for establishing function stack
CN112437013B (en) Path acquisition method in network diagram and maintenance method of routing networking
CN111221513B (en) Method, device, medium and electronic equipment for adjusting cascading style sheet
CN115994120B (en) Data file merging method, device, electronic equipment and computer readable medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20230428

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.

GR01 Patent grant
GR01 Patent grant