Method and apparatus for component configuration
By obtaining the identifier and application level information of the target component, obtaining configuration rules from the configuration file and instantiating the components, the problem of complex component configuration is solved, and flexible and efficient component configuration is achieved.
Patent Information
- Application Number
- CN202011593725.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-29
- Publication Date
- 2025-06-27
- Estimated Expiration
- 2040-12-29
AI Technical Summary
With the enrichment of application functions and the increase in the number of components, component configurations become complex and difficult to maintain, and traditional configuration delivery logic is complex and inflexible.
By obtaining the identifier of the target component and the hierarchical information of the application, the associated configuration rules are obtained from the configuration file and instantiating the components based on these rules.
Using hierarchical information to parse configuration files improves the flexibility and efficiency of component configuration and reduces the labor and time costs of developers.
Smart Images

Figure CN114756292B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present disclosure relate to the field of computers, and more particularly, to methods, apparatuses, devices, computer storage media, and computer program products for component configuration. Background Art
[0002] In the process of software development, especially in the process of front-end development, for the sake of flexibility in development and maintenance, developers generally encapsulate a set of display elements, element styles, and element interaction logics corresponding to a human-computer interaction interface into a component. A complete web page or software interface is usually formed by combining and nesting multiple components.
[0003] During the development process, the software needs to define corresponding configurations for multiple components in the application. As the functions of the application become more and more abundant, the number of components it contains is increasing and the nesting relationship is becoming more and more complex. How to effectively configure components has become the current focus of attention. Summary of the Invention
[0004] Embodiments of the present disclosure provide a solution for component configuration.
[0005] According to a first aspect of the present disclosure, a method for component configuration is proposed. The method includes: in response to an instantiation request for a target component in an application, obtaining an identifier of the target component, where the identifier is used to uniquely identify the target component in the application; based on the identifier and the hierarchical information of the application, obtaining at least one configuration rule associated with the target component from the configuration file of the application, where the hierarchical information includes relationship information between multiple components in the application and description information of the multiple components; and instantiating the component based on the at least one configuration rule.
[0006] According to a second aspect of the present disclosure, an apparatus for component configuration is proposed. The apparatus includes: an identifier obtaining module configured to obtain an identifier of a target component in response to an instantiation request for the target component in an application, where the identifier is used to uniquely identify the target component in the application; a rule obtaining module configured to obtain at least one configuration rule associated with the target component from the configuration file of the application based on the identifier and the hierarchical information of the application, where the hierarchical information includes relationship information between multiple components in the application and description information of the multiple components; and an instantiation module configured to instantiate the component based on the at least one configuration rule.
[0007] According to a third aspect of the present disclosure, an electronic device is provided. The device includes: at least one processing unit; and at least one memory coupled to the at least one processing unit and storing instructions for execution by the at least one processing unit, which when executed by the at least one processing unit, cause the device to perform any of the steps of the method described in the first aspect of the present disclosure.
[0008] In a fourth aspect of the present disclosure, a computer-readable storage medium is provided. A computer program is stored on the computer-readable storage medium, which when executed by a processor, causes the processor to perform any of the steps of the method described in the first aspect of the present disclosure.
[0009] In a fifth aspect of the present disclosure, a computer program product is provided. The computer program product includes a computer program, which when executed by a processor, causes the processor to perform any of the steps of the method described in the first aspect of the present disclosure.
[0010] The Summary of the Invention is provided to introduce a selection of concepts in a simplified form, which will be further described in the Detailed Description below. The Summary of the Invention is not intended to identify the key features or essential features of the present disclosure, nor is it intended to limit the scope of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] By describing the exemplary embodiments of the present disclosure in more detail in conjunction with the accompanying drawings, the above and other objects, features, and advantages of the present disclosure will become more apparent, wherein in the exemplary embodiments of the present disclosure, the same reference numerals generally represent the same components.
[0012] Figure 1 A schematic diagram illustrating multiple components of an example application according to an embodiment of the present disclosure;
[0013] Figure 2 A schematic diagram illustrating an example environment in which embodiments of the present disclosure can be implemented;
[0014] Figure 3 A flowchart illustrating a process of component configuration according to an embodiment of the present disclosure;
[0015] Figures 4A - 4C A schematic diagram illustrating an example configuration file according to an embodiment of the present disclosure;
[0016] Figure 5 A schematic block diagram illustrating an example device according to an embodiment of the present disclosure; and
[0017] Figure 6 A schematic block diagram illustrating an example device that can be used to implement embodiments of the present disclosure. Detailed Implementation Modes
[0018] Preferred embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the preferred embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to make the present disclosure more thorough and complete, and to fully convey the scope of the present disclosure to those skilled in the art.
[0019] As used herein, the term "including" and its variants mean open inclusion, that is, "including but not limited to". Unless otherwise stated, the term "or" means "and / or". The term "based on" means "at least partially based on". The terms "an exemplary embodiment" and "an embodiment" mean "at least one exemplary embodiment". The term "another embodiment" means "at least one additional embodiment". The terms "first", "second", etc. may refer to different or the same objects. There may also be other explicit and implicit definitions hereinafter.
[0020] As discussed above, as the functions of an application (such as a web page or software) become more and more complex, the number of components it includes may increase, and the nesting relationships of the components may also become more complex.
[0021] In some cases, considering code reusability, developers can, for example, develop some basic components that can be included in upper-level components associated with different businesses as needed. Such basic components can be some general components, such as buttons, dialog boxes, input boxes, audio players, video players, credit card payments, or maps. For example, developers can encapsulate payment-related code into an independent payment component and include it in different upper-level components, such as a physical goods settlement component or a virtual goods settlement component.
[0022] Exemplarily, Figure 1 A schematic diagram showing multiple components of an exemplary application 100 according to an embodiment of the present disclosure is illustrated. As shown in 1, the application 100 may include a root component 110, and the root component nests two second-level components 120 and 130. Exemplarily, the second-level components 120 and 130 may correspond to a physical goods settlement component and a virtual goods settlement component, respectively.
[0023] In addition, as Figure 1 shown, the second-level component 120 further includes a third-level component 140, and the second-level component 130 further includes a third-level component 150. Exemplarily, the third-level components 140 and 150 may both be payment components to support payments under physical goods settlement and payments under virtual goods settlement, respectively.
[0024] During the development process, the configuration of components is one of the core issues that developers need to pay attention to. Even for components of the same type, they may have different configurations under different business models. Taking the payment component as an example, in the scenario of physical goods settlement, the payment component can, for example, allow credit card payment, while in the scenario of virtual goods settlement, the payment component cannot use credit card payment according to regulatory requirements.
[0025] Some traditional methods configure components in different levels by passing configurations. For example, developers can first define a configuration in the root component 110, define the logic for passing the configuration, and pass the configuration to the secondary component 120, and further define the logic for passing the configuration in the secondary component 120 to pass the configuration to the tertiary component 140. In this case, developers not only need to pay attention to how to configure each component in each scenario, but also need to write code related to the logic of passing configurations. As the functions of the application become more and more abundant, the nesting relationship of components will become more and more complex, which will make the logic of passing configurations become complex and difficult to maintain.
[0026] According to an embodiment of the present disclosure, a component configuration solution is provided. In this solution, first, according to an instantiation request for a target component in an application, an identifier for uniquely identifying the target component in the application is obtained for the target component. Subsequently, based on the identifier and the hierarchical information of the application, at least one configuration rule associated with the target component is obtained from the configuration file of the application, where the hierarchical information includes relationship information between multiple components in the application and description information of the multiple components. Subsequently, based on the at least one obtained configuration rule, the component is instantiated.
[0027] Based on such a method, the embodiments of the present disclosure can utilize the hierarchical information of components in the application to parse the configuration file, which will allow developers to define the configuration file more flexibly and conveniently according to development needs. This can reduce the labor cost and time cost of developers and improve the efficiency of component configuration.
[0028] The following further describes various example implementations of this solution in detail with reference to the accompanying drawings.
[0029] First, refer to Figure 2 , which schematically shows a schematic diagram of an environment 200 in which an exemplary implementation manner according to the present disclosure can be implemented. As Figure 2 shown, the environment 200 includes a computing device 220. The computing device 220 is configured to receive a component 210 and a configuration file 230.
[0030] In some implementations, component 210 can be, for example, a piece of code written by a developer that provides encapsulation of display elements, element styles, and / or interaction logic. In some examples, component 210 can include embedded sub-components. Alternatively, component 210 can also be embedded in other components.
[0031] In some implementations, configuration file 230 can be a configuration written by a developer for multiple components in an application. Different from traditional ways, by separating configuration file 230 from the development code, the efficiency of maintaining configuration file 230 can be improved.
[0032] In some implementations, configuration file 230 can configure parameters associated with component 210 in the form of variable definitions. For example, configuration file 230 can define whether the payment component supports credit card payments by assigning a value to the parameter "creditcard" in the payment component.
[0033] In some implementations, computing device 220 can also generate and / or obtain hierarchical information 240 of the application to be configured. Taking Figure 1 the example application 100 as an example, hierarchical information 240 can be used to describe the hierarchical structure of components in application 100. For example, hierarchical information 240 can include root node 260 corresponding to root component 110, nodes 262 and 265 corresponding to secondary components 120 and 130, and nodes 266 and 268 corresponding to tertiary components 140 and 150.
[0034] In some implementations, hierarchical information 240 can also include description information of the nodes. Exemplarily, hierarchical information 240 can include the identifier, name, type, instantiation order, etc. of node 260.
[0035] Based on hierarchical information 240, computing device 220 can determine the corresponding configuration for component 210 to be instantiated from configuration file 230, and instantiate component 210 based on this configuration to obtain instantiated component 250. The generation process of hierarchical information 240 and the determination process of the configuration of component 210 will be described in detail below.
[0036] The following will refer to Figure 3 FIG. 4 to describe the process of component configuration according to an embodiment of the present disclosure. Figure 3 FIG. 3 shows a flowchart of a process 300 for component configuration according to some embodiments of the present disclosure. Process 300 can be implemented, for example, by Figure 2 the computing device 220 shown in
[0037] At block 302, in response to an instantiation request for the target component 210 in the application, the computing device 220 obtains an identifier of the target component 210, where the identifier is used to uniquely identify the target component 210 in the application.
[0038] In some implementations, the computing device 220 may instantiate the target component 210 according to the specification of a user (e.g., a developer). Alternatively, the computing device 220 may also automatically perform instantiation on a set of components in a predetermined order.
[0039] In some implementations, a developer may define a component name for the target component. However, as the functions of the application become more and more complex, the component name may not be able to uniquely identify the target component. For example, in Figure 1 the example of, both component 140 and component 150 may be named "pay", which causes this name to not be able to uniquely identify the corresponding component.
[0040] In some implementations, in order to uniquely correspond to the target component 210, during the instantiation process, the computing device 220 may first allocate an identifier that can uniquely identify the target component 210 in the application to the target component 210. Exemplarily, the computing device 220 may set up a component registration module for allocating an identifier to the target component 210 according to relevant information of the target component 210.
[0041] In some implementations, the identifier includes any appropriate representation. Examples thereof include, but are not limited to: numbers, strings, or combinations thereof. For example, taking component 140 as an example of the target component 210, its identifier may be "3001" to indicate that it is the first component in the third layer. Alternatively, its identifier may also be "pay0" to indicate that it is the first payment component in the application. It should be understood that such identifiers are merely illustrative, and any other appropriate identifier may also be used to uniquely identify the target component.
[0042] In some implementations, the process of allocating the identifier of the target component 210 may be performed before the instantiation process. Exemplarily, when deploying the code of the target component 210, an appropriate module may allocate an identifier to the target component 210 based on the above rules.
[0043] At block 304, based on the identifier and the hierarchical information of the application, the computing device 220 obtains at least one configuration rule associated with the target component 210 from the configuration file 230 of the application, where the hierarchical information 240 includes relationship information between multiple components in the application and description information of the multiple components.
[0044] In some implementations, computing device 220 may also maintain hierarchical information 240 associated with an application. For example, computing device 220 may update existing hierarchical information after receiving an instantiation request for target component 210.
[0045] Specifically, computing device 220 may obtain existing hierarchical information (also referred to as second-level hierarchical information) of the application, where the second-level hierarchical information includes nodes (also referred to as first nodes) associated with the parent component of target component 210.
[0046] Taking Figure 1 component 150 in as an example of target component 210, for example, before component 150 is instantiated, components 110, 120, 130, and 140 have requested to be instantiated. Correspondingly, computing device 220 may have correspondingly generated second-level hierarchical information. This second-level hierarchical information may include, for example, nodes 260, 262, 264, and 266 corresponding to components 110 - 140, where each node corresponds to the corresponding component.
[0047] In some implementations, the parent-child relationship between nodes 260, 262, 264, and 266 may be used to indicate the nesting relationship between the corresponding components. For example, node 262 is a child node of component 260, which indicates that the corresponding component 120 is a lower-level component of component 110.
[0048] After obtaining the second-level hierarchical information, computing device 220 may also add a second node, which is a child node of the first node, to the second-level hierarchical information based on the attributes of target component 210. The second node includes description information of the target component.
[0049] In some implementations, as discussed above, the information related to target component 210 obtained by the component registry may include the attributes of target component 210. In some examples, the attributes of target component 210 may include the type of target component 210. Exemplarily, the type of target component 210 may be represented by a string, such as "pay", to indicate that the type of target component 210 is a "payment component".
[0050] In another example, the attributes of target component 210 may also include the name of target component 210. Exemplarily, the name of target component 210 may be represented by a string, such as "cart_pay".
[0051] In yet another example, the attributes of target component 210 may also include the identifier of the parent component. Exemplarily, taking component 150 as an example of target component 210, the parent component of target component 210 is component 130, and its identifier may be, for example, "2002".
[0052] It should be understood that the attributes of the target component 210 may also include other appropriate types of information, or combinations of the above multiple example information, or combinations between the above example information and other appropriate information.
[0053] Accordingly, based on the description information of the target component 210, the computing device 220 may add a new node 268 corresponding to the target component 210 in the second-level information. The node 268 is a child node of the node 264 corresponding to the component 130.
[0054] Additionally, the computing device 220 may also store relevant information of the target component 210 in the node 268. Examples include but are not limited to: the identifier of the target component 210 (e.g., 3002), type (e.g., "pay"), name (e.g., "cart_pay"), instantiation order (e.g., "5"), or other information related to the target component 210.
[0055] In some implementations, the instantiation order of the target component 210 may also be indicated by the position of the corresponding node 268 in the hierarchical structure. For example, the node 268 is the first child node of the node 264, which may indicate that the component 210 is the first component to be instantiated among its superior components.
[0056] After completing the addition of the node 268 corresponding to the target component 210 in the second-level information, the computing device 220 may use the updated second-level information as the new hierarchical information 240 (also referred to as the first-level information). Based on this approach, the computing device 220 can dynamically maintain the hierarchical information associated with the application, thereby being able to effectively locate one or more components in the application.
[0057] After obtaining the hierarchical information 240 corresponding to the application, the computing device 220 may determine at least one configuration rule associated with the target component 210 from the configuration file according to the identifier of the component 210 and the hierarchical information 240.
[0058] As discussed above, the configuration file 230 may be configuration rules defined by the developer for one or more components in the application. Since the present disclosure uses the hierarchical information 240 to parse the configuration file 230, the developer can define the configuration rules in the configuration file 230 in a more flexible manner.
[0059] Figures 4A - 4C A schematic diagram of an example configuration file according to an embodiment of the present disclosure is shown. As Figure 4AAs shown, the configuration file 400A may include multiple configuration entries. The first configuration entry is for the "pay" component in ".shopping_cart[0]", and the second configuration entry is for the "pay" component in ".shopping_cart[1]".
[0060] Specifically, the first configuration entry in the configuration file 400A includes a component description part 410-1 and a rule description part 420-1. The component description part 410-1 is used to indicate the set of components targeted by the first configuration entry. In this example, the description part 410-1 is defined by the instantiation order of the parent component and the type of the target component.
[0061] For example, ".shopping_cart[0]" in the component description part 410-1 represents the first instantiated component of type ".shopping_cart" in the application, and ".pay" represents the component of type "pay" within that component. The rule description part 420-1 "creditcard: true" is used to indicate that the specific rule applied to the corresponding component is "credit card payment is supported".
[0062] Similarly, the description part 410-2 included in the second configuration entry represents the component of type "pay" in the second instantiated component of type ".shopping_cart". The rule description part 420-2 "creditcard: false" is used to indicate that the specific rule applied to the corresponding component is "credit card payment is not supported".
[0063] In this example, taking component 150 as an example of the target component 210, the computing device 220 can determine, based on the hierarchical information 240, that the node corresponding to the set of components corresponding to the component description part 410-1 is node 266, which, for example, corresponds to the component with the identifier 3001. Similarly, the computing device 220 can determine that the node corresponding to the set of components corresponding to the component description part 410-2 is node 268, which, for example, corresponds to the component with the identifier 3002.
[0064] Additionally, if the identifier of the target component 210 (e.g., "3002") matches the set of identifiers corresponding to the component description part 410-2, the computing device 220 can determine the rule description part 420-2 "creditcard: false" as the rule corresponding to the target component 210.
[0065] Figure 4B Another example configuration file 400B is shown. As Figure 4BAs shown, the configuration file 400B may include multiple configuration entries. The first configuration entry is for the "pay" component in "#entity_cart", and the second configuration entry is for the "pay" component in "#virtual_cart".
[0066] Specifically, the first configuration entry in the configuration file 400B includes a component description part 430-1 and a rule description part 440-1. The component description part 430-1 is used to indicate the set of components targeted by the first configuration entry. For example, "#entity_cart" in the component description part 430-1 represents the component named "entity_cart" in the application, and ".pay" represents the component of type "pay" in that component. The rule description part 440 "creditcard: true" is used to indicate that the specific rule applied to the corresponding component is "credit card payment is supported".
[0067] Similarly, the description part 430-2 included in the second configuration entry represents the component of type "pay" in the component named "virtual_cart" in the application. The rule description part 440-2 "creditcard: false" is used to indicate that the specific rule applied to the corresponding component is "credit card payment is not supported".
[0068] In this example, taking component 150 as an example of the target component 210, the computing device 220 can determine, based on the hierarchical information 240, that the node corresponding to the set of components corresponding to the component description part 430-1 is node 266, which, for example, corresponds to the component with the identifier 3001. Similarly, the computing device 220 can determine that the node corresponding to the set of components corresponding to the component description part 430-2 is node 268, which, for example, corresponds to the component with the identifier 3002.
[0069] Additionally, if the identifier of the target component 210 (e.g., "3002") matches the set of identifiers corresponding to the component description part 430-2, the computing device 220 can determine the rule description part 440-2 "creditcard: false" as the rule corresponding to the target component 210.
[0070] Figure 4C Shows another example configuration file 400C. As Figure 4C shown, the configuration file 400C may include multiple configuration entries. The first configuration entry is for ".A.B.C", and the second configuration entry is for ".A.B.C.#C1".
[0071] Specifically, the first configuration entry in the configuration file 400C includes a component description section 450-1 and a rule description section 460-1. The component description section 450-1 is used to indicate the set of components targeted by the first configuration entry. For example, the component description section 450-1 ".A.B.C" indicates that this configuration entry will be used for the C-category components included in the B-category components included in the A-category components in the application. The rule description section 460-1 "creditcard: true" is used to indicate that the specific rule applied to the corresponding component is "support credit card payment".
[0072] Similarly, the second configuration entry in the configuration file 400C includes a component description section 450-2 and a rule description section 460-2. The component description section 450-2 is used to indicate the set of components targeted by the first configuration entry. For example, the component description section 450-2 ".A.B.C.#C1" indicates that this configuration entry will be used for the component named "C1" among the C-category components included in the B-category components included in the A-category components in the application. The rule description section 460-2 "creditcard: false" is used to indicate that the specific rule applied to the corresponding component is "do not support credit card payment".
[0073] In this example, taking component 150 as an example of the target component 210, the type of the root component 110 is "A", the types of components 120 and 130 are "B", the types of components 140 and 150 are "C", and the name of component 140 is "C0", and the name of component 140 is "C1".
[0074] The computing device 220 can determine, according to the hierarchical information 240, that the set of components corresponding to the component description section 450-1 is all the C-category components in the B-category components in the A-category components, and the corresponding nodes are node 266 and node 268, which, for example, correspond to the components with identifiers 3001 and identifier 3002. Similarly, the computing device 220 can determine that the node corresponding to the set of components corresponding to the component description section 450-2 is node 268, which, for example, corresponds to the component with identifier 3002.
[0075] Additionally, the computing device 220 can determine that the identifier of the target component 210 (e.g., "3002") matches the set of identifiers corresponding to the component description section 450-1 and also matches the set of identifiers corresponding to the component description section 450-2. Accordingly, the computing device 220 can determine both the rule description section 460-1 "creditcard: true" and the rule description section 460-2 "creditcard: false" as the rules corresponding to the target component 210.
[0076] The possible definition methods of the configuration file 230 are described above in combination with different examples. It should be understood that the above specific definition methods are only illustrative. In addition, the specific programming languages in the above example configuration files are also only illustrative, and the configuration files can be written using any appropriate programming language according to needs. On the other hand, the specific syntax formats in the above configuration files are also only illustrative, and any appropriate syntax parsing method can be defined according to needs. For example, "#" can be used to indicate that the connected syntax element is the name of a component, and "." can indicate that the connected syntax element is the type of a component, etc.
[0077] In addition, since the hierarchical structure 240 includes component-related information and relationship information between components, the implementation manner of the present disclosure can allow developers to specify one or more components by component type, component name, component instantiation order, superior information of the component, or other appropriate component information. This enables developers to conveniently define the configuration of components and build personalized component configurations with different granularities.
[0078] Continuing to refer to Figure 3 , at block 306, the computing device 220 instantiates the target component 210 based on at least one configuration rule. In some implementations, if the determined at least one configuration rule includes only one configuration rule or includes multiple non-conflicting configuration rules, the computing device 220 can directly apply the determined configuration rule to the target component 210 and perform the instantiation of the target component 210 to obtain the instantiated component 250.
[0079] Taking the configuration files 400A and 400B as examples, the computing device 220 can determine that the configuration rule corresponding to the target component 210 is "creditcard: false" and instantiate the target component 210 based on this configuration rule to disallow credit card payments.
[0080] In other implementations, the computing device 220 can determine that the at least one configuration rule associated with the target component 210 includes multiple configuration rules with different priorities. Accordingly, the computing device 220 can determine the priorities corresponding to the multiple configuration rules.
[0081] Taking the configuration file 400C as an example, the computing device 220 can determine that the at least one configuration rule associated with the target component 210 includes: the rule "creditcard: true" indicated by the rule description part 460-1 and "creditcard: false" indicated by the rule description part 460-2.
[0082] Considering that the rule description part 460-1 is a description for the whole type, it can be set with a lower priority. On the contrary, the rule description part 460-2 is a description for a single component, and it can be set with a higher priority.
[0083] Additionally, the computing device 220 can merge multiple configuration rules based on the priorities. Continuing with the example of the configuration file 400C, the computing device 220 can determine that there is a conflict between the rule "creditcard: true" indicated by the rule description part 460-1 and the rule "creditcard: false" indicated by the rule description part 460-2, and the rule "creditcard: false" has a higher priority. Accordingly, the computing device 220 can determine that the merged rule is the rule "creditcard: false" with a higher priority.
[0084] Accordingly, the computing device 220 can instantiate the target component 210 based on the merged multiple configuration rules. Continuing with the example of the configuration file 400C, the computing device 220 can instantiate the target component 210 based on the rule "creditcard: false" to not allow credit card payments.
[0085] Based on the component configuration method described in the present disclosure, the embodiments of the present disclosure enable developers to more conveniently define the configuration rules for one or more components. In addition, by using the hierarchical information to parse the configuration file, the embodiments of the present disclosure also allow developers to define configuration rules with different granularities in an appropriate manner, thereby improving the flexibility of development.
[0086] The embodiments of the present disclosure also provide corresponding devices for implementing the above methods or processes. Figure 5 A schematic structural block diagram of a device 500 for component configuration according to some embodiments of the present disclosure is shown.
[0087] As Figure 5 shown, the device 500 includes an identifier acquisition module 510 configured to acquire an identifier of a target component in response to an instantiation request for the target component in an application, where the identifier is used to uniquely identify the target component in the application. The device 500 further includes a rule acquisition module 520 configured to acquire at least one configuration rule associated with the target component from a configuration file of the application based on the identifier and the hierarchical information of the application, where the hierarchical information includes relationship information between multiple components in the application and description information of the multiple components. Additionally, the device 500 further includes a configuration module 530 configured to instantiate a component based on the at least one configuration rule.
[0088] In some implementations, the hierarchical information is the first-level hierarchical information, and the apparatus 500 further includes: an information acquisition module configured to acquire second-level information of an application, where the second-level information includes a first node associated with a parent component of a target component; an adding module configured to add, based on an attribute of the target component, a second node that is a child node of the first node to the second-level information, where the second node includes description information of the target component; and an updating module configured to use the updated second-level information as the first-level hierarchical information.
[0089] In some implementations, the attribute of the target component includes at least one of the following: the type of the target component, the name of the target component, or an identifier of the parent component.
[0090] In some implementations, the hierarchical information further describes the order in which the target node is instantiated.
[0091] In some implementations, the configuration file includes at least one configuration entry, and the configuration entry includes a component description part and a rule description part. The component description part indicates a set of components targeted by the configuration entry. The rule acquisition module 520 includes: a parsing module configured to determine, based on the hierarchical information, a set of identifiers of the set of components corresponding to the description part; and a matching module configured to, if the identifier of the target component matches the set of identifiers, determine the rule description part as a configuration rule associated with the target component.
[0092] In some implementations, the component description part indicates at least one of the following: the type of the components in the set of components, the name of the components in the set of components, the parent information of the components in the set of components, or the instantiation order of the components in the set of components.
[0093] In some implementations, the at least one configuration rule includes multiple configuration rules, and the configuration module 530 includes: a priority module configured to determine priorities corresponding to the multiple configuration rules; a merging module configured to merge the multiple configuration rules based on the priorities; and a rule application module configured to instantiate the target component based on the merged multiple configuration rules.
[0094] In some implementations, the at least one configuration rule is used to configure at least one parameter associated with the target component.
[0095] The units included in apparatus 500 can be implemented in various ways, including software, hardware, firmware, or any combination thereof. In some embodiments, one or more units can be implemented using software and / or firmware, such as machine-executable instructions stored on a storage medium. In addition to or instead of the machine-executable instructions, some or all of the units in apparatus 500 can be implemented at least partially by one or more hardware logic components. By way of example and not limitation, exemplary types of hardware logic components that can 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.
[0096] Figure 6 FIG. shows a schematic block diagram of an example device 600 that can be used to implement embodiments of the present disclosure. For example, a backup system and / or a recovery system according to an embodiment of the present disclosure can be implemented by device 600. As shown, device 600 includes a central processing unit (CPU) 601 that can perform various appropriate actions and processes according to computer program instructions stored in a read only memory (ROM) 602 or computer program instructions loaded from a storage unit 608 into a random access memory (RAM) 603. In RAM 603, various programs and data required for the operation of device 600 can also be stored. The CPU 601, ROM 602, and RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0097] A plurality of components in device 600 are connected to the I / O interface 605, including: an input unit 606, such as a keyboard, a mouse, etc.; an output unit 607, such as various types of displays, speakers, etc.; a storage unit 608, such as a magnetic disk, an optical disk, etc.; and a communication unit 609, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 609 allows device 600 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0098] The various processes and treatments described above, such as process 300, can be executed by the processing unit 601. For example, in some embodiments, process 300 can be implemented as a computer software program that is tangibly contained in a machine-readable medium, such as storage unit 608. In some embodiments, part or all of the computer program can be loaded and / or installed onto device 600 via the ROM 602 and / or the communication unit 609. When the computer program is loaded into the RAM 603 and executed by the CPU 601, one or more actions of process 300 described above can be performed.
[0099] The present disclosure may be a method, an apparatus, a system, and / or a computer program product. The computer program product may include a computer-readable storage medium having thereon computer-readable program instructions for performing various aspects of the present disclosure.
[0100] A computer-readable storage medium may be a tangible device that can retain and store instructions for use by an instruction execution device. A computer-readable storage medium may be, for example, but is not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of the computer-readable storage medium include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), a static random access memory (SRAM), a portable compact disc read-only memory (CD-ROM), a digital versatile disc (DVD), a memory stick, a floppy disk, a mechanically encoded device such as a punch card or raised structures in grooves having instructions stored thereon, and any suitable combination of the foregoing. The computer-readable storage medium as used herein is not construed to be a transitory signal per se, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., a light pulse through an optical fiber cable), or an electrical signal transmitted through a wire.
[0101] The computer-readable program instructions described herein may be downloaded from a computer-readable storage medium to a respective computing / processing device, or may be downloaded to an external computer or an external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network may include a copper transmission cable, an optical fiber transmission, a wireless transmission, a router, a firewall, a switch, a gateway computer, and / or an edge server. A network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in a computer-readable storage medium in each computing / processing device.
[0102] The computer program instructions for performing the operations of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine - related instructions, microcode, firmware instructions, state - setting data, or source code or object code written in any combination of one or more programming languages, including object - oriented programming languages such as Smalltalk, C++, etc., and conventional procedural programming languages such as the "C" language or similar programming languages. The computer - readable program instructions may be executed entirely on the user's computer, partially on the user's computer, executed as a stand - alone software package, partially on the user's computer and partially on a remote computer, or entirely on a 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, alternatively, may be connected to an external computer (e.g., via an Internet service provider through the Internet). In some embodiments, by using the state information of the computer - readable program instructions to customize an electronic circuit, such as a programmable logic circuit, a field - programmable gate array (FPGA), or a programmable logic array (PLA), the electronic circuit can execute the computer - readable program instructions to implement various aspects of the present disclosure.
[0103] Aspects of the present disclosure are described herein with reference to the flowcharts and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the present disclosure. It should be understood that each block of the flowcharts and / or block diagrams, and combinations of blocks in the flowcharts and / or block diagrams, can be implemented by computer - readable program instructions.
[0104] These computer - readable program instructions can be provided to a processing unit of a general - purpose computer, a special - purpose computer, or other programmable data - processing apparatus to produce a machine such that, when the instructions are executed by the processing unit of the computer or other programmable data - processing apparatus, a device is produced that implements the functions / actions specified in one or more blocks of the flowchart and / or block diagram. These computer - readable program instructions can also be stored in a computer - readable storage medium, which causes a computer, a programmable data - processing apparatus, and / or other devices to operate in a particular manner, so that the computer - readable medium storing the instructions includes a manufacture that includes instructions for implementing various aspects of the functions / actions specified in one or more blocks of the flowchart and / or block diagram.
[0105] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device, causing a series of operational steps to be performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process such that the instructions executed on the computer, other programmable data processing apparatus, or other device implement the functions / acts specified in one or more boxes of the flowchart and / or block diagram.
[0106] 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 diagram may represent a module, a segment of code, or a portion of an instruction, which contains one or more executable instructions for implementing the specified logical function. In some alternative implementations, the functions noted in the blocks may occur out of the order noted in the figures. For example, two consecutive blocks may in fact be executed substantially in parallel, or they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block of the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented by a dedicated hardware-based system that performs the specified functions or acts, or by a combination of dedicated hardware and computer instructions.
[0107] The various embodiments of the present disclosure have been described above. The above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The choice of terms used herein is intended to best explain the principles of the embodiments, the practical application, or improvements made to the technology in the market, or to enable other ordinary skilled persons in the art to understand the embodiments disclosed herein.
Claims
1. A method for component configuration, comprising: In response to an instantiation request for a target component in an application, obtaining an identifier of the target component, where the identifier is used to uniquely identify the target component in the application; Based on the identifier and the hierarchical information of the application, obtaining at least one configuration rule associated with the target component from a configuration file of the application, where the hierarchical information includes relationship information between multiple components in the application and description information of the multiple components; and Based on the at least one configuration rule, instantiating the target component, where the configuration file includes at least one configuration entry, and the configuration entry includes a component description part and a rule description part, the component description part indicating a set of components targeted by the configuration entry, and where obtaining the at least one configuration rule associated with the target component includes: Based on the hierarchical information, determining a set of identifiers of a set of components corresponding to the component description part; And If the identifier of the target component matches the set of identifiers, determining the rule description part as the configuration rule associated with the target component.
2. The method according to claim 1, where the hierarchical information is first-level hierarchical information, and the method further includes: Obtaining second-level hierarchical information of the application, where the second-level hierarchical information includes a first node associated with a parent component of the target component; Based on an attribute of the target component, adding a second node as a child node of the first node in the second-level hierarchical information, where the second node includes description information of the target component; And Using the updated second-level hierarchical information as the first-level hierarchical information.
3. The method according to claim 2, where the attribute of the target component includes at least one of the following: The type of the target component, The name of the target component, or The identifier of the parent component.
4. The method according to claim 1, where the hierarchical information further describes an order in which a target node is instantiated.
5. The method according to claim 1, where the component description part indicates at least one of the following: The type of components in the set of components, The name of components in the set of components, The parent information of components in the set of components, or The instantiation order of components in the set of components.
6. The method according to claim 1, where the at least one configuration rule includes multiple configuration rules, and where instantiating the target component based on the at least one configuration rule includes: Determining a priority corresponding to the multiple configuration rules; Based on the priority, merging the multiple configuration rules; And Based on the merged multiple configuration rules, instantiating the target component.
7. The method according to claim 1, where the at least one configuration rule is used to configure at least one parameter associated with the target component.
8. A device for component configuration, comprising: An identifier acquisition module, configured to acquire an identifier of the target component in response to an instantiation request for the target component in the application, where the identifier is used to uniquely identify the target component in the application; A rule acquisition module, configured to acquire at least one configuration rule associated with the target component from a configuration file of the application based on the identifier and hierarchical information of the application, where the hierarchical information includes relationship information between multiple components in the application and description information of the multiple components; And A configuration module, configured to instantiate the target component based on the at least one configuration rule, where the configuration file includes at least one configuration entry, the configuration entry includes a component description part and a rule description part, the component description part indicates a set of components targeted by the configuration entry, and the rule acquisition module includes: A parsing module, configured to determine a set of identifiers of the set of components corresponding to the component description part based on the hierarchical information; And A matching module, configured to determine the rule description part as a configuration rule associated with the target component if the identifier of the target component matches the set of identifiers.
9. The apparatus according to claim 8, wherein the hierarchical information is first-level hierarchical information, and the apparatus further includes: An information acquisition module, configured to acquire second-level hierarchical information of the application, where the second-level hierarchical information includes a first node associated with a parent component of the target component; An adding module, configured to add, based on an attribute of the target component, a second node as a child node of the first node in the second-level hierarchical information, where the second node includes description information of the target component; And An updating module, configured to use the updated second-level hierarchical information as the first-level hierarchical information.
10. The apparatus according to claim 9, wherein the attribute of the target component includes at least one of the following: The type of the target component, The name of the target component, or The identifier of the parent component.
11. The apparatus according to claim 8, wherein the hierarchical information further describes the order in which the target node is instantiated.
12. The apparatus according to claim 8, wherein the component description part indicates at least one of the following: The type of the components in the set of components, The name of the components in the set of components, The parent information of the components in the set of components, or The instantiation order of the components in the set of components.
13. The apparatus according to claim 8, wherein the at least one configuration rule includes multiple configuration rules, and the configuration module includes: A priority module, configured to determine priorities corresponding to the multiple configuration rules; A merging module, configured to merge the multiple configuration rules based on the priorities; And A rule application module, configured to instantiate the target component based on the merged multiple configuration rules.
14. The apparatus according to claim 8, wherein the at least one configuration rule is used to configure at least one parameter associated with the target component.
15. An electronic device, comprising: At least one processing unit; And At least one memory coupled to the at least one processing unit and storing instructions for execution by the at least one processing unit, which when executed by the at least one processing unit cause the device to perform the method according to any one of claims 1-7.
16. A computer-readable storage medium having stored thereon a computer program, which when executed by a processor causes the processor to perform the method according to any one of claims 1-7.
17. A computer program product comprising a computer program, which when executed by a processor causes the processor to perform the method according to any one of claims 1-7.
Citation Information
Patent Citations
Module expansion method and device thereof
CN102216901A
Component-based page rendering method and device, computer equipment and storage medium
CN111443912A