CN110704050B - Module initializing method and device, electronic equipment and computer readable storage medium - Google Patents

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

Info

Publication number
CN110704050B
CN110704050B CN201910959747.2A CN201910959747A CN110704050B CN 110704050 B CN110704050 B CN 110704050B CN 201910959747 A CN201910959747 A CN 201910959747A CN 110704050 B CN110704050 B CN 110704050B
Authority
CN
China
Prior art keywords
module
modules
dependency relationship
initializing
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.)
Active
Application number
CN201910959747.2A
Other languages
Chinese (zh)
Other versions
CN110704050A (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 Youzhuju Network 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 Youzhuju Network Technology Co Ltd filed Critical Beijing Youzhuju Network 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

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, a module initialization device, electronic equipment and a computer readable storage medium. The method comprises the following steps: when compiling a program, acquiring user-defined notes of a first module to be initialized in the program, wherein the user-defined notes declare a second module to be called by the first module; the first module and the second module are initialized. In the method, when the first module is loaded, user-defined annotation of the first module is obtained, and the user-defined annotation states that the second module required to be called by the first module is required, so that the initialization of the first module and the second module is completed. The initialization of the module to be called is finished in advance, so that the normal call of the module can be ensured, and the normal use of software is further ensured.

Description

Module initializing method and 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, a module initialization device, an electronic device, and a computer readable storage medium.
Background
In the development of software, different services are split into different modules, and the modules are isolated from each other and do not depend directly, so that the coupling degree between the services and codes is reduced, and the maintainability of the 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 the condition that the module needing to be called is not initialized may occur, and the normal call of the module may be affected, thereby affecting 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 method for initializing a module, including:
when compiling a program, acquiring user-defined notes of a first module to be initialized in the program, wherein the user-defined notes declare a second module to be called by the first module;
the first module and the second module are initialized.
In a second aspect, embodiments of the present disclosure provide a module initializing device, including:
the annotation acquisition module is used for acquiring user-defined annotations of the first module to be initialized in the program when compiling the program, and the user-defined annotations declare a 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.
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, embodiments of the present disclosure provide a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the method of module initialization shown in the first aspect of the present disclosure.
The technical scheme provided by the embodiment of the disclosure has the beneficial effects that:
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 required to be called by the first module is required, so that the initialization of the first module and the second module is completed. The initialization of the module to be called is finished in advance, so that the normal call of the module can be ensured, and the normal use of software is further ensured.
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.
In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure, the drawings that are required to be used in the description of the embodiments of the present disclosure will be briefly introduced below.
Fig. 1 is a flow chart of a module initializing method according to an embodiment of the disclosure;
FIG. 2 is a directed graph of the dependency structure between modules B, C and D;
FIG. 3 is a directed graph of the dependency relationships among module E, module F, module G, module H, and module I;
fig. 4 is a schematic structural diagram of a module initializing device according to an embodiment of the 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 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 a different order and/or performed 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 used merely to distinguish one device, module, or unit from another device, module, or unit, and are not intended to limit the order or interdependence of the functions performed by the devices, modules, or units.
It should be noted that references to "one", "a plurality" and "a plurality" 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 understood 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.
In the prior art, the module initialization scheme generally does not initialize the module to be called in advance, and initializes the module to be called when the module is called, which results in that whether the module to be called is initialized or not needs to be judged when the module is called each time, and the processing efficiency is affected.
In the prior art, when module call is performed, a processing mode is also available, wherein the module call is performed in a host module in a hard coding mode, the host module can contain codes corresponding to each module when the module call is performed, so that the codes are coupled, and the mode needs to write the codes respectively for each call, so that the code writing is complex.
The embodiment of the disclosure provides a module initializing method, a device, an electronic apparatus and a computer readable storage medium, which aim 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 the technical solutions of the present disclosure solve the above technical problems in detail with specific embodiments. The following embodiments may be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments. Embodiments of the present disclosure will be described below with reference to the accompanying drawings.
Fig. 1 shows a flow chart of a module initializing method according to an embodiment of the disclosure, as shown in fig. 1, the method may mainly include:
step S110: when compiling a program, acquiring user-defined notes of a first module to be initialized in the program, wherein the user-defined notes declare a second module to be called by the first module;
step S120: the first module and the second module are initialized.
In the embodiment of the disclosure, the second module required to be invoked can be declared through user-defined annotations added to the first module. The number of the second modules can be multiple, and corresponding user-defined annotations are respectively added to the multiple second modules.
For example: the module A is a first module, and a second module required to be called by the module A comprises: module B, module C, and module D may be declared by user-defined annotations, respectively.
When the first module is loaded, the custom annotation of the first module can be obtained, so that the second module is determined based on the custom annotation of the first module, and the first module and the second module can be respectively initialized. When the first module is calling the second module, the second module has completed initialization 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 declares that the first module needs to call the second module, so that the first module and the second module are initialized. The initialization of the module to be called is finished in advance, so that the normal call of the module can be ensured, and the normal use of software is further ensured.
In an optional manner of the embodiment of the disclosure, if the number of the second modules is at least two, and the dependency relationship between the at least two second modules is declared in the user-defined annotation, initializing the second modules includes:
based on the dependency, determining an initialization sequence of a second module with the dependency;
and initializing the second modules with the dependency relationships sequentially based on the initialization sequence.
In the embodiment of the present disclosure, when there are at least two second modules to be called by the first module, there may be a dependency relationship between the at least two second modules, for example, there is a dependency relationship between the module B and the module C, for example, the module B depends on the module C, where 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 the 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, so that the dependent modules are ensured to be initialized before the dependent modules, and the initialization operation of the modules can be ensured to be normally performed.
In practice, the dependency between at least two second modules may be defined by means of a dependendson annotation.
In an optional manner of the embodiment of the disclosure, if the dependency relationship between at least two second modules is not a ring-shaped dependency relationship, determining, based on the dependency relationship, an initialization order of the second modules having the dependency relationship includes:
and carrying out topological ordering on the second modules with the dependency relationship based on the dependency relationship, and determining the initialization sequence of the second modules with the dependency relationship.
In the presently disclosed embodiments, as one 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 the moment, the module B, the module C and the module D form annular dependency relations, in the initialization process, the initialization of the module B depends on the initialization of the module C, the initialization of the module C depends on the initialization of the module D, and the initialization of the module D depends on the initialization of the module B, at the moment, the initialization sequence cannot be determined, and the initialization operation of the module is influenced.
Fig. 2 shows a directed graph composed of the dependency relationships among the modules B, C, and D, and as shown in fig. 2, the node B in the graph represents the module B, the node C represents the module C, and the node D represents the module D.
The nodes at two ends of the directed edge in the graph have a dependency relationship, the node pointed by the arrow of the directed edge is a dependent module, the directed edge from the node B to the node C in the graph represents the module B to depend on the module C, the directed edge from the node C to the node D represents the module C to depend on the module D, and the directed edge from the node D to the node B represents the module D to depend on the module B.
When there is a ring dependency relationship between at least two second modules, there is a ring formed by directed edges in the directed graph formed based on the dependency relationship, as in fig. 2, the directed edges from node B to node C, the directed edges from node C to node D, and the directed edges from node D to node B form a ring.
When at least two second modules have annular dependency, the prompting information of the annular dependency can be output, and the related information of each second module having the annular dependency can be output so as to process the annular dependency.
When at least two second modules do not have annular dependency relationships, the topology ordering of the second modules with the dependency relationships can be determined, and then the initialization sequence is determined according to the topology ordering.
In actual use, when at least two second modules do not have annular dependency relationships, the directed acyclic graph can be determined based on the dependency relationships, and the initialization sequence is determined by performing topological ordering on the directed acyclic graph. In particular, topological ordering may be implemented based on the kahn algorithm.
As one example, the dependency relationship 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 composed of dependency relationships among a module E, a module F, a module G, a module H, and a module I, and as shown in fig. 3, a node E in the graph represents a module E, a node F represents a module F, a node G represents a module G, a node H represents a module H, and a node I represents a module I.
The nodes at two ends of the directed edge in the graph have a dependency relationship, the node pointed by the arrow of the directed edge is a dependent module, the directed edge from the node E to the node F in the graph represents the module E to depend on the module F, the directed edge from the node E to the node I in the graph represents the module E to depend on the module I, the directed edge from the node F to the node G in the graph represents the module F to depend on the module G, and the directed edge from the node G to the node H in the graph represents the module G to depend on the module H.
The specific process of topologically ordering the directed graph based on the kahn algorithm may be:
step one: selecting a node which is not pointed to by a directed edge (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 the directed graph deletes all nodes in the directed graph.
Step four: and reversing the deleting order of the nodes in the directed graph to be used as an initialization order.
Taking the directed graph in fig. 3 as an example, the order of node deletion in the directed graph in fig. 3 may be: E. i, F, G, H, the initialization sequence obtained after reverse sequence is: H. g, F, I, E, the initialization is performed in the initialization order, that is, H, G, F, I and E are sequentially initialized.
In an alternative manner of embodiments of the present disclosure, the user-defined annotation declares the second module that the first module needs to invoke by:
and establishing a corresponding relation between the custom annotation and the entry class of the second module.
In the embodiment of the disclosure, the second module may be declared by annotating an entry class of the second module, where the annotated entry class may be a subclass, and when the entry class is called, a parent class corresponding to the entry class is found based on a java polymorphic mechanism, 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 relies on module B and module C, and the annotation of the entry class for module a may be: @ ModuleEntry (dependendsOn= { "B", "C" }.
In an alternative manner of an embodiment of the disclosure, initializing the second module includes:
generating a routing table of the ingress class of the second module based on the user-defined annotation;
and calling an entry class of the second module based on the routing table, and initializing the second module.
In the embodiment of the disclosure, the user-defined annotation can be processed through the annotation processing tool (Annotatino Processing Tool, APT), the routing table of the entry class of the second module is automatically generated, the code is relatively simple to write, and the user-defined annotation of each module is in the code of each module, not in the host module, so that the coupling of the codes can be avoided.
When the entry class of the second module is called based on the routing table, the entry class of the corresponding second module can be sequentially called for initialization according to the determined initialization sequence.
In actual use, there may be a case where a parent class corresponding to an ingress class cannot be found, at this time, initialization of the module may not be achieved, and the routing information of the ingress 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 initializing device provided by an embodiment of the present disclosure, and as shown in fig. 4, the module initializing device 20 may include:
the annotation obtaining module 210 is configured to obtain a user-defined annotation of a first module to be initialized in the program when compiling the program, where the user-defined annotation declares a second module that the first module needs to be invoked;
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 declares that the first module needs to call the second module, so that the first module and the second module are initialized. The initialization of the module to be called is finished in advance, so that the normal call of the module can be ensured, and the normal use of software is further ensured.
Optionally, if the number of the second modules is at least two and the user-defined annotation declares a dependency relationship between the at least two second modules, the initializing module is specifically configured to, when initializing the second modules:
based on the dependency, determining an initialization sequence of a second module with the dependency;
and initializing the second modules with the dependency relationships sequentially based on the initialization sequence.
Optionally, if the dependency relationship between the at least two second modules is not a ring-shaped dependency relationship, the initialization module is specifically configured to:
and carrying out topological ordering on the second modules with the dependency relationship based on the dependency relationship, and determining the initialization sequence of the second modules with the dependency relationship.
Optionally, if at least two second modules have a ring dependency relationship, the module initializing device further includes:
the prompting module is used for outputting prompting information of the annular dependency relationship of at least two second modules and outputting related information of each second module with the 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 custom annotation and the entry class of the second module.
Optionally, the initialization module, when used for initializing the second module, is specifically configured to:
generating a routing table of the ingress class of the second module based on the user-defined annotation;
and calling an entry class of the second module based on the routing table, and initializing the second module.
Referring now to fig. 5, there is illustrated a schematic diagram of an architecture of an electronic device (e.g., a terminal device or server performing the method illustrated in fig. 1) 600 suitable for use in implementing embodiments of the present disclosure. 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. 5 is merely an example and should not be construed to limit the functionality and scope of use of the disclosed embodiments.
An electronic device includes: a memory and a processor, where the processor may be referred to as a processing device 601 described below, 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 described below, as follows:
as shown in fig. 5, the electronic device 600 may include a processing means (e.g., a central processing unit, a graphics processor, etc.) 601, which may perform various appropriate actions and processes according to 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 required 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 through a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
In general, the following devices may be connected to the I/O interface 605: input devices 606 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, and the like; an output device 607 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 608 including, for example, magnetic 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 shows an electronic device 600 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 non-transitory computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via communication means 609, or from storage means 608, or from ROM 602. 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 601.
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: when compiling a program, acquiring user-defined notes of a first module to be initialized in the program, wherein the user-defined notes declare 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 of the present disclosure may be written in 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 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 modules or units involved in the embodiments of the present disclosure may be implemented by means of software, or may be implemented by means of hardware. Where the name of the module or unit does not in some way constitute a limitation of the unit itself, for example, the hint may also be described as an "information output module".
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, the present disclosure provides a module initialization method comprising:
when compiling a program, acquiring user-defined notes of a first module to be initialized in the program, wherein the user-defined notes declare a second module to be called by the first module;
the first module and the second module are initialized.
According to the above module initializing method provided by the present disclosure, if there are at least two second modules and a dependency relationship between the at least two second modules is declared in the user-defined annotation, initializing the second modules includes:
based on the dependency, determining an initialization sequence of a second module with the dependency;
and initializing the second modules with the dependency relationships sequentially based on the initialization sequence.
According to the above module initializing method provided by the present disclosure, if the dependency relationship between at least two second modules is not a ring-shaped dependency relationship, determining, based on the dependency relationship, an initializing order of the second modules having the dependency relationship includes:
and carrying out topological ordering on the second modules with the dependency relationship based on the dependency relationship, and determining the initialization sequence of the second modules with the dependency relationship.
According to the above module initializing method provided by the present disclosure, if at least two second modules have a ring-shaped dependency relationship, the method further includes:
and outputting prompt information of the annular dependency relationship of at least two second modules, and outputting relevant information of each second module with the annular dependency relationship.
According to the above module initializing method provided by the present disclosure, the user-defined annotation declares the second module that the first module needs to call by:
and establishing a corresponding relation between the custom annotation and the entry class of the second module.
According to the above module initializing method provided by the present disclosure, initializing a second module includes:
generating a routing table of the ingress class of the second module based on the user-defined annotation;
and calling an entry class of the second module based on the routing table, and initializing the second module.
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 (7)

1. A method of initializing a module, comprising:
when compiling a program, acquiring user-defined notes of a first module to be initialized in the program, wherein the user-defined notes declare a second module to be called by the first module;
initializing the first module and the second module, wherein when the first module calls the second module, the second module has completed initialization;
if the number of the second modules is at least two and the dependency relationship between the at least two second modules is declared in the user-defined annotation, initializing the second modules, including:
if the dependency relationship between at least two second modules is not a ring-shaped dependency relationship, determining a directed acyclic graph based on the dependency relationship, performing topological ordering on the directed acyclic graph based on a kahn algorithm, and determining an initialization sequence of the second modules with the dependency relationship;
and initializing the second modules with the dependency relationships sequentially based on the initialization sequence.
2. The method of claim 1, wherein if there is a ring dependency relationship between at least two of the second modules, the method further comprises:
and outputting prompt information of the annular dependency relationship of the at least two second modules, and outputting related information of each second module with the annular dependency relationship.
3. The method of any of claims 1-2, wherein the user-defined annotation declares the second module that the first module needs to invoke by:
and establishing a corresponding relation between the custom annotation and the entry class of the second module.
4. A method according to claim 3, wherein initializing the second module comprises:
generating a routing table of an ingress class of the second module based on the user-defined annotation;
and calling an entry class of the second module based on the routing table, and initializing the second module.
5. A module initializing device, comprising:
the annotation acquisition module is used for acquiring user-defined annotations of the first module to be initialized in the program when compiling the program, wherein the user-defined annotations declare the second module to be called by the first module;
the initialization module is used for initializing the first module and the second module, and when the first module calls the second module, the second module has completed initialization;
if the number of the second modules is at least two and the dependency relationship between the at least two second modules is declared in the user-defined annotation, initializing the second modules, including:
if the dependency relationship between at least two second modules is not a ring-shaped dependency relationship, determining a directed acyclic graph based on the dependency relationship, performing topological ordering on the directed acyclic graph based on a kahn algorithm, and determining an initialization sequence of the second modules with the dependency relationship;
and initializing the second modules with the dependency relationships sequentially based on the initialization sequence.
6. An electronic device comprising a processor and a memory;
the memory is used for storing a computer program;
the processor being adapted to perform the method of any of claims 1-4 by invoking the computer program.
7. A computer readable storage medium, characterized in that the storage medium has stored thereon a computer program which, when executed by a processor, implements the method of any of claims 1-4.
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 CN110704050A (en) 2020-01-17
CN110704050B true 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)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
GB2377283B (en) * 2001-04-10 2004-12-01 Discreet Logic Inc Initialising modules

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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
Spring 中如何控制2个bean中的初始化顺序?;Chown;《https://zhuanlan.zhihu.com/p/30112785》;20171017;第1-10页 *

Also Published As

Publication number Publication date
CN110704050A (en) 2020-01-17

Similar Documents

Publication Publication Date Title
CN109523187B (en) Task scheduling method, device and equipment
CN112214408B (en) Dependency conflict detection method, dependency conflict detection device, electronic equipment and computer readable medium
CN113835992B (en) Memory leakage processing method and device, electronic equipment and computer storage medium
CN111857720B (en) User interface state information generation method and device, electronic equipment and medium
CN111625422B (en) Thread monitoring method, thread monitoring device, electronic equipment and computer readable storage medium
CN111309304B (en) Method, device, medium and electronic equipment for generating IDL file
CN110704050B (en) Module initializing method and device, electronic equipment and computer readable storage medium
CN114035879A (en) Page theme color changing method and device, electronic equipment and computer readable medium
CN113407165B (en) SDK generation and self-upgrade method, device, readable medium and equipment
CN112416303B (en) Software development kit hot repair method and device and electronic equipment
CN113220281A (en) Information generation method and device, terminal equipment and storage medium
CN113391860B (en) Service request processing method and device, electronic equipment and computer storage medium
CN110489219B (en) Method, device, medium and electronic equipment for scheduling functional objects
CN111752644A (en) Interface simulation method, device, equipment and storage medium
CN113391811A (en) Function compiling method and device, electronic equipment and computer readable storage medium
CN111240801A (en) Method, device, medium and electronic equipment for generating heap memory snapshot file
CN112965713B (en) Development method, device, equipment and storage medium of visual editor
CN111258582B (en) Window rendering method and device, computer equipment and storage medium
CN111399902B (en) Client source file processing method and device, readable medium and electronic equipment
CN111258786A (en) Decoupling method and device in layered architecture, terminal and storage medium
CN111309323A (en) Parameter initialization method and device and electronic equipment
CN111209042B (en) Method, device, medium and electronic equipment for establishing function stack
CN111221513B (en) Method, device, medium and electronic equipment for adjusting cascading style sheet
CN114647472B (en) Picture processing method, apparatus, device, storage medium, and program product
CN111240738B (en) File processing method, device, equipment and medium

Legal Events

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

Effective date of registration: 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