Application processing method and device, electronic equipment, storage medium and program product
By performing coding verification on the first component and the second component it calls in the Spring framework application, the problem that static verification cannot check the calling relationship between components is solved, improving the accuracy and maintainability of application coding and ensuring that components The rationality of the calling relationship between them.
Patent Information
- Application Number
- CN202410353514.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-26
- Publication Date
- 2024-09-17
AI Technical Summary
In existing technology, in applications developed based on the Spring framework, static verification during the coding phase cannot accurately check the calling relationships between components, which may lead to problems such as unreasonable layering of calls and network calls between components, affecting the reliability of coding. Maintainability and scalability.
When the target application responds to the startup operation, by determining the first component and performing coding verification on it, including checking the first component and the second component it calls, ensuring that the calling relationship between the components complies with the preset coding rules, so as to The application startup result is determined during application startup processing.
It achieves accurate and comprehensive coding verification of target application components, standardizes the calling relationship between components, improves the accuracy and maintainability of application coding, and avoids application startup failures.
Smart Images

Figure CN118656137A
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to an application processing method and device, an electronic device, a storage medium, and a program product. Background Art
[0002] At present, for applications developed based on the Spring framework, in order to ensure the standardization and scalability of application coding, static verification is usually adopted in the coding stage, that is, the application coding is verified manually or by writing scripts, which is not convenient and accurate enough. Summary of the invention
[0003] The present disclosure provides an application processing method and device, an electronic device, a storage medium, and a program product.
[0004] In a first aspect, the present disclosure provides an application processing method, the application processing method comprising:
[0005] In response to a start operation on a target application, determining a first component of the target application, the first component being a component loaded by the target application after executing component loading processing in response to the start operation, the first component being used to receive a client request and respond;
[0006] Performing a first verification on the first component to obtain a first verification result, wherein the first verification is used to perform coding verification on the first component and a second component called by the first component during the startup process of the target application;
[0007] A startup result of the target application is determined according to the first verification result, wherein the startup result indicates whether the target application is successfully started.
[0008] In a second aspect, the present disclosure provides an application processing device, the application processing device comprising:
[0009] a component determination unit, configured to determine a first component of the target application in response to a startup operation on the target application, the first component being a component loaded by the target application after the component loading process is performed in response to the startup operation, and the first component being configured to receive a client request and respond;
[0010] a verification unit, configured to perform a first verification on the first component to obtain a first verification result, wherein the first verification is used to perform coding verification on the first component and a second component called by the first component during the startup process of the target application;
[0011] The result determination unit is used to determine the startup result of the target application according to the first verification result, wherein the startup result indicates whether the target application is successfully started.
[0012] In a third aspect, the present disclosure provides an electronic device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores one or more computer programs executable by the at least one processor, and one or more of the computer programs are executed by the at least one processor so that the at least one processor can execute the application processing method of the first aspect above.
[0013] In a fourth aspect, the present disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the application processing method of the first aspect.
[0014] In a fifth aspect, the present disclosure provides a computer program product, characterized in that it includes a computer-readable code, or a non-volatile computer-readable storage medium carrying a computer-readable code, and when the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the application processing method of the first aspect mentioned above.
[0015] The embodiments provided by the present disclosure take into account that when the target application's code is statically verified during the coding phase, since the components in the target application are not actually constructed and assembled during the coding phase, the verification method during the coding phase is usually to simply verify the naming of the components in the code, the number of coding lines in the component implementation class, the parameter names, the number of parameters, etc., but cannot verify the calling relationship between components, which may lead to the problem of unreasonable calling hierarchy between components in the application coding. To this end, the present disclosure, after the target application responds to the startup operation, completes the construction, packaging and other loading processes of the component after executing the component loading process, considering that the component at the first level of the component call in the application is usually the first component for receiving the client request and responding, therefore, by determining the first component of the target application, and taking the first component as the initial component for coding verification of the component in the application, the first component and the second component called by the first component are first verified, and the startup result of the application is determined based on the first verification; on the one hand, the effect of accurate and comprehensive coding verification of the components in the target application can be achieved; on the other hand, since the components in the application startup process have been truly built and packaged, the effect of verifying the calling relationship between the components in the application can also be achieved in the first verification process; on the other hand, by performing the first verification in the application startup process, and determining the startup result of the target application based on the first verification, it can also further constrain the developer to better comply with the coding specifications of the components and component calls to avoid application startup failure. That is, based on the embodiment of the present disclosure, the components of the target application and the calling relationship between the components can be conveniently and accurately verified, and the accuracy of the application coding verification can be improved.
[0016] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The accompanying drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the embodiments of the present disclosure, they are used to explain the present disclosure and do not constitute a limitation of the present disclosure. The above and other features and advantages will become more apparent to those skilled in the art by describing detailed example embodiments with reference to the accompanying drawings, in which:
[0018] Figure 1 A flowchart of an application processing method provided by an embodiment of the present disclosure;
[0019] Figure 2 A flowchart of an application processing method provided by an embodiment of the present disclosure;
[0020] Figure 3A block diagram of an application processing device provided in an embodiment of the present disclosure;
[0021] Figure 4 A block diagram of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0022] In order to enable those skilled in the art to better understand the technical solutions of the present disclosure, the exemplary embodiments of the present disclosure are described below in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0023] In the absence of conflict, the various embodiments of the present disclosure and the various features therein may be combined with each other.
[0024] As used herein, the term "and / or" includes any and all combinations of one or more of the associated listed items.
[0025] The terms used herein are only used to describe specific embodiments and are not intended to limit the present disclosure. As used herein, the singular forms "a" and "the" are also intended to include plural forms, unless the context clearly indicates otherwise. It will also be understood that when the terms "including" and / or "made of" are used in this specification, the presence of the features, wholes, steps, operations, elements and / or components is specified, but the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or groups thereof is not excluded. "Connected" or "connected" and similar words are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect.
[0026] It should be noted that all actions of acquiring signals, information or data in this application are carried out in compliance with the relevant data protection laws and policies of the country where they are located, and with the authorization given by the owner of the corresponding device.
[0027] Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by those of ordinary skill in the art. It will also be understood that terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and the present disclosure, and will not be interpreted as having an idealized or overly formal meaning unless explicitly defined as such herein.
[0028] For ease of understanding, the following professional terms are explained here and will not be repeated later.
[0029] The Spring development framework is an open source J2EE application framework that is a lightweight container that manages the life cycle of components.
[0030] Components, in the embodiments of the present disclosure, refer to spring beans used in the process of coding development based on the spring development framework, or they can also be called bean objects, which are essentially ordinary java objects. Such objects are created and managed by spring. In the coding stage, developers only need to define the metadata information of the components to be created in the configuration file. The application creates a spring container in the startup stage and builds and assembles these components according to the metadata information of the configured components. Components can include control layer components (controller components), service layer components (service components), executor components (IExecutor components), and collaborator components (ICollavorator components).
[0031] The spring container is a container with dependency injection function. It is responsible for the instantiation of objects, the configuration of dependencies between objects, the destruction of objects, and the search of objects provided to the outside world. The entire life cycle of objects is controlled by the spring container. All objects that the application needs to use are managed by the spring container. There is no need to manually create objects through the new method. The spring container directly helps the application assemble them. When the application needs to use them, it can directly obtain them from the spring container.
[0032] In the related art, for applications developed based on the spring framework, a static verification method is generally adopted, which is to verify the application code manually or through scripts. In this verification method, since the components in the application are not actually built and assembled during the coding stage, this verification method generally performs simple verification on the naming of components in the coding, the number of coding lines in the component implementation class, parameter names, the number of parameters, etc., but cannot verify the calling relationship between components, resulting in unreasonable calling layering between components in the application coding, and even mesh calling problems; wherein, mesh calling refers to the situation where there may be nested calls of components at the same level in the application coding. For example, for the service component, the application coding may have an unordered mesh calling problem in which the serverA component calls the serverB component, and the serverB component calls the serviceC component at the same level. This calling method causes the coding to have poor scalability and maintainability.
[0033] In view of this, in the embodiment of the present disclosure, when the target application responds to the startup operation, after the component loading process is executed and the component construction, packaging and other loading processes are completed, considering that the component at the first level of component call in the application is usually the first component for receiving client requests and responding, therefore, by determining the first component of the target application, and taking the first component as the initial component for coding verification of the components in the application, the first component and the second component called by the first component are first verified, and the startup result of the application is determined based on the first verification; on the one hand, the effect of accurate and comprehensive coding verification of the components in the target application can be achieved; on the other hand, since the components in the application startup process have been truly built and packaged, the effect of verifying the calling relationship between the components in the application can also be achieved in the first verification process; on the other hand, by performing the first verification in the application startup process and determining the startup result of the target application based on the first verification, the developer can be further constrained to better comply with the coding specifications of the components and component calls to avoid application startup failure. That is, based on the embodiment of the present disclosure, the components of the target application and the calling relationship between the components can be conveniently and accurately verified, and the accuracy of the application coding verification can be improved.
[0034] Please see Figure 1 , which is a flow chart of an application processing method provided by an embodiment of the present disclosure. The method can be applied to an electronic device, which can be a server or a terminal device, and is not particularly limited here.
[0035] like Figure 1 As shown, the application processing method provided by the embodiment of the present disclosure may include the following steps S101-S103, which are described in detail below.
[0036] Step S101, in response to a start operation for a target application, determining a first component of the target application, the first component being a component loaded after the target application performs component loading processing in response to the start operation, and the first component is used to receive a client request and respond.
[0037] In the embodiments of the present disclosure, the target application may be any application developed based on a preset development framework, and the coding of the target application includes multiple components, namely, metadata information of beans; wherein the preset development framework may be a spring development framework, or may be other development frameworks that build and assemble components in the application startup process based on metadata information of components configured in the coding stage, and no special limitation is made here.
[0038] The first component may be a component at the first level of component calling in the application, for example, a component in the application for receiving client requests and responding, and the first component may be a controller component, for example.
[0039] In actual implementation, when the first component is a controller component, the first component can be determined by identifying whether the component name of the application contains the keyword "controller"; or, the component type of the component in the application can be obtained and the first component can be determined according to the component type. Of course, in actual implementation, when the first component is other components, the first component can also be determined by other methods as needed, which is not specifically limited here.
[0040] Step S102, performing a first verification on the first component to obtain a first verification result, wherein the first verification is used to perform coding verification on the first component and a second component called by the first component during the startup process of the target application;
[0041] Step S103: determining a startup result of the target application according to the first verification result, wherein the startup result indicates whether the target application is successfully started.
[0042] Specifically, in the embodiments of the present disclosure, encoding verification can be performed on the first component and the second component called by the first component based on preset encoding rules to standardize the calling hierarchy between components in the encoding, that is, beans, which can include 4 layers, specifically including: Level 1: first component, Level 2: second component; Level 3: third component; Level 4: fifth component; wherein the calling relationship between components in each level can be: 1. Level 1 calls level 2 downward; 2. Level 2 calls level 3 downward, but cannot make upward or same-level calls; 3. Level 3 calls level 4 downward, but cannot make upward or same-level calls; 5. Level 4 can make one same-level call, but cannot make an upward call. For example, taking the fifth component including component 51 and component 52 as an example, component 51 can call component 52, but component 52 can no longer call other components at the same level.
[0043] In the embodiment of the present disclosure, the first component may be a component of a first preset type, which may be, for example, a control layer type; the first component may be, for example, a bean definition object whose component name contains the keyword "controller", i.e., a control bean.
[0044] The second component refers to a component of a second preset type. The second component can be a component for processing at least one business logic in the application. The second preset type can be, for example, a service layer type, that is, the second component can be a bean definition object defined as an interface type Interface, that is, a service bean.
[0045] The third component refers to a component of the third preset type. The third component can be a component used to implement a business logic in the application. For example, if a second component needs to implement two business logics, two third components can be used to implement each business logic, and the second component can call the two third components for encoding. The third preset type can be an executor type. The third component can be a bean definition object of an implementation class of the executor IExecutor type, that is, an execution bean.
[0046] The fifth component refers to a component of the fourth preset type. The fifth component can be a component used to implement a common logic in the application; the fourth preset type can be a collaborator type; the fifth component can be, for example, a bean definition object of an implementation class of the collaborator ICollavorator type, that is, a collaborative bean.
[0047] In the related art, when the code is verified by static verification, since only the metadata information of each component is configured in the code, and the components are not actually constructed and assembled, the calling relationship between the components is often not accurately obtained, and thus the calling relationship between the components is not verified. In the application startup process, the related art often determines that the application startup is successful after the spring container is initialized and loaded with all components. However, the application coding is usually completed by different developers in multiple stages such as the coding stage, the testing stage, and the iterative upgrade stage when the application is put into production operation. This makes it possible that different developers follow different coding specifications, and then various arbitrary calls may be made to the components in the coding, resulting in extremely complex mesh calls in the component coding and the calling coding between components in the coding due to such arbitrary calls. For example, for convenience, one or more layers of same-layer calls may be made in the service layer, that is, layer 2, resulting in multiple nested calls in the service layer call, so that when a component code is updated or deleted, the code of other components that reference the component needs to be synchronously maintained, resulting in poor maintainability and scalability of the code.
[0048] In the embodiment of the present disclosure, considering that no matter which development framework is used to develop the target application, there will be a first component in the target application at the first level for receiving client requests and responding, therefore, the first component in the target application can be determined, and the first component can be used as the initial component for coding verification of the components in the application, based on the above-mentioned preset coding rules, the first component and the second component called by the first component are first verified, and the startup result of the target application is determined based on the first verification result; on the one hand, the effect of accurate and comprehensive coding verification of the components in the target application can be achieved; on the other hand, since the components in the application startup process have been truly constructed and encapsulated, the above-mentioned first verification can achieve the effect of standardizing the calling relationship between components in the target application, avoid the occurrence of mesh calls, make the calling relationship between components clearer, and improve the maintainability and scalability of the coding; on the other hand, by performing the first verification during the application startup process and determining the startup result of the target application based on the first verification, it can also further constrain the developer to better comply with the coding specifications of the components and component calls to avoid application startup failure. That is, based on the embodiment of the present disclosure, the components of the target application and the calling relationship between components can be accurately verified, and the accuracy of application coding verification can be improved.
[0049] In addition, it should be noted that, in actual implementation, the method can be implemented in the testing phase, that is, after the coding of the target application is completed, the standardization and scalability of the coding in the target application can be guaranteed based on the method when the functional testing of the target application is performed; and when the target application is deployed to the production environment, in order to ensure the startup speed of the target application, the verification processing of the target application based on the method can be stopped during the startup process. For example, the corresponding fields can be configured in the configuration file to determine whether to perform the verification processing on the target application during the application startup process, so as to improve the flexibility of implementing the method.
[0050] In some embodiments, in step S101, determining the first component of the target application may include: determining a component corresponding to a first component name containing a first keyword in a component name set as the first component, wherein the first keyword is used to identify a component of a first preset type.
[0051] The component name set may be a set including component names defined for all components.
[0052] The first keyword may be, for example, "controller", or may be set as required, and is not specifically limited here.
[0053] Specifically, in the embodiments of the present disclosure, the target application may be an application that is coded and developed based on a preset development framework, which may be, for example, a spring development framework; in this case, in the process of the target application responding to a startup operation to perform component loading processing, each component in the application will usually be loaded into a spring container, and therefore, the first component can be determined by obtaining the component names of the components of the target application from the spring container through a first keyword corresponding to the first component.
[0054] In actual implementation, when the target application is coded and developed based on the spring development framework, the component name set can be obtained from the application run detection object, where the application run detection object is used to receive event notifications at different execution points in the application startup process. The application run detection object can be, for example, SpringApplicationRunListener.
[0055] For example, the component name set can be implemented by the finished(ConfigurableApplicationContext context,Throwable exception) method function in SpringApplicationRunListener, and then the processing in this method function will be triggered after the context refresh is completed. In this method function, for example, the component name set can be obtained through the statement "String[]definitionNames=context.getBeanDefinitionNames()".
[0056] After obtaining the component name set, the set can be traversed to filter out component names containing the first keyword "controller" as target component names, and the component corresponding to the target component name is determined as the first component.
[0057] It can be seen that based on the method provided by the embodiment of the present disclosure, during the application startup process, after the target application executes the component loading process, it is possible to accurately determine the first component in the target application for receiving client requests and responding by screening from the component name set based on the first keyword, and based on the first component as the initial component for coding verification, it is possible to achieve the effect of layer-by-layer verification of all components in the target application, thereby improving the accuracy of application coding verification.
[0058] In some embodiments, in step S102, the first component is subjected to a first verification to obtain a first verification result, including: verifying whether the first attribute set of the first component includes a second component name of a second component of a second preset type, wherein the second component includes a component for processing at least one business logic in the application; if the first attribute set includes the second component name, a second verification is performed on the second component represented by the second component name to obtain a second verification result; and determining the first verification result based on the second verification result.
[0059] The first attribute set may be a set of member variables defined in the first component.
[0060] With reference to the above description, it can be known that the second component may be, for example, a service bean, that is, may be a service component of a service layer type.
[0061] The second check may be used to check whether the second component has made an upward call and / or a same-layer call.
[0062] Specifically, for the first component at level 1, considering that after receiving the call request from the client, the first component generally distributes the call request to the second component in the service layer for processing the business logic in response to the call request, therefore, after determining the first component in the target application, the first attribute set of the first component can be obtained to verify whether the attribute set contains the second component name of the second component. If it does, it means that the current call of the first component is reasonable. If it does not, it means that the first component may be an invalid component, or the code for executing the business logic is directly implemented in the first component, that is, the first component at the control layer does what the second component in the service layer should do. Business logic, this situation usually indicates that the encoding of the first component is relatively arbitrary and does not comply with the above-mentioned preset encoding rules. In this case, the first verification result can be set to verification failure; otherwise, if the first attribute set includes the second component name, the second component represented by the second component name can be subjected to a second verification, for example, to verify whether the second component has made upward calls and same-layer calls; after obtaining the second verification result, the first verification result can be determined based on the second verification result. For example, if the second verification result is verification success, the first verification result can be determined to be verification success; otherwise, if the second verification result is verification failure, the first verification result can be determined to be verification failure.
[0063] In actual implementation, the verification of whether the first attribute set of the first component includes the second component name of the second component of the second preset type can be to verify whether the component name included in the first attribute set contains a component name whose definition type is an interface type, i.e., Interface. If it is included, it means that the component represented by the component name is the second component.
[0064] For example, for the serviceCls object defined in "Class serviceCls", the Boolean flag result can be obtained through "booleanflag=serviceCls.isInterface()". If the flag is equal to true, it means that the component represented by the serviceCls object is the second component. Otherwise, the first verification result can be set to verification failure.
[0065] In some embodiments, the second verification is performed on the second component represented by the second component name to obtain a second verification result, including: verifying whether the second attribute set of the second component includes a third component name of a third component of a third preset type, wherein the third component includes a component used to implement a business logic in an application; if the second attribute set includes the third component name, performing a third verification on the third component represented by the third component name to obtain a third verification result; and determining the second verification result based on the third verification result.
[0066] As can be seen from the above description, the third component can be, for example, an executor component, that is, an execution bean, which can be used to implement a business logic in an application. In actual implementation, the following code can be used to verify whether a component is a third component:
[0067] Class executorCls;
[0068] boolean flag=IExecutor.class.isAssignableFrom(executorCls).
[0069] The third verification can be used to verify whether the fifth component is called in the third component, and no other execution components are called and no service components are called upward, that is, the fourth component is not called. The fourth component can be other third components at the same layer as the third component, or it can also be the first component at level 1 or the second component at level 2.
[0070] In the spring development framework, ConfigurableListableBeanFactory provides the parsing and registration functions of beanDefinition. In actual implementation, the second attribute set can be obtained by instantiating the class and calling the corresponding method function provided by the class.
[0071] For example, any attribute clazz in the second attribute set can be obtained by the following encoding:
[0072] ConfigurableListableBeanFactory configurableListableBeanFactory=context.getBeanFactory();
[0073] RootBeanDefinition beanDefinition=(RootBeanDefinition)configurableListableBeanFactory.getMergedBeanDefinition(beanName);
[0074] Class clazz=beanDefinition.getBeanClass();
[0075] Of course, this is just an illustrative explanation and the detailed processing process will not be repeated here.
[0076] In addition, in some embodiments, the method may also include: obtaining a first number of interfaces defined in the second component, and a second number of interfaces coded and implemented in the second component; if the first number is greater than a first preset threshold, or the first number and the second number do not match, setting the second verification result to verification failure.
[0077] The first preset threshold value may be, for example, 30, or may be set as required, and is not specifically limited here.
[0078] That is, when performing the second verification on the second component, it is also possible to verify whether the number of methods defined in the second component are all implemented in the implementation subclass. If the subclass is not fully implemented, the verification result can be set to verification failure.
[0079] Taking the second component as serviceCls as an example, the first number can be obtained through serviceCls.getMethods().length, and the second number can be obtained by instantiating RootBeanDefinition, for example, instantiating a serviceBeanDef, and obtaining it through serviceBeanDef.getBeanClass().getDeclaredMethods().length.
[0080] The process of checking whether the first number is greater than the first preset threshold value is not described here. In actual implementation, the matching process of the first number and the second number can be implemented by the following coding:
[0081] Class serviceCls;
[0082] RootBeanDefinition serviceBeanDef;
[0083] boolean flag=serviceCls.getMethods().length! =serviceBeanDef.getBeanClass().getDeclaredMethods().length.
[0084] In actual implementation, when the flag is equal to true, it can be determined that the first quantity and the second quantity match, and when it is false, it can be determined that the two do not match, and the second verification result is set to verification failure.
[0085] Of course, in some embodiments, the checking whether the second attribute set of the second component includes the third component name of the third component of the third preset type may include: obtaining a first number of interfaces defined in the second component, and a second number of interfaces coded and implemented in the second component; if the first number is less than or equal to a first preset threshold, and the first number and the second number match, then checking whether the second attribute set of the second component includes the third component name of the third component of the third preset type.
[0086] That is, in actual implementation, the verification process of whether the first quantity and the second quantity match and whether the first quantity is greater than the first preset threshold can be performed before or after the step of whether the second attribute set includes the name of the third component, or it can be processed together in this step, and there is no special limitation here.
[0087] In some embodiments, the performing a third check on the third component represented by the third component name to obtain a third check result includes: checking whether the third attribute set of the third component includes a fourth component name of a fourth component, and whether the third attribute set includes a fifth component name of a fifth component of a fourth preset type, the fifth component includes a component for implementing a common logic in an application, and the fourth component includes a first component, a second component and a third component; if the third attribute set does not include the fourth component name, and the third attribute set includes the fifth component name, performing a fourth check on the fifth component represented by the fifth component name to obtain a fourth check result; and determining the third check result based on the fourth check result.
[0088] Referring to the above description, it can be known that the fifth component can be a component for implementing a common logic. In actual implementation, whether a component is the fifth component can be checked by the following code: Class CollavoratorCls; boolean flag = ICollavorator.class.isAssignableFrom(CollavoratorCls).
[0089] Regarding how to obtain the attribute value in the third attribute set, please refer to the description of the second attribute set above, and the detailed processing process will not be repeated here.
[0090] The fourth check can be used to check whether only a preset number of same-level calls have been made in the fifth component, and can also be used to check whether it has not called other components.
[0091] It should be noted that in actual implementation, the third component may also be named and verified. For example, the following code may be used to verify whether the execution component name ends with CmdExe. If not, the third verification result may be set to verification failure:
[0092] Class executorCls;
[0093] boolean flag=StringUtils.endsWith(executorCls.getName(),"CmdExe").
[0094] In actual implementation, if the third attribute set of the third component does not include the fourth component name of the fourth component, that is, it does not include the first component name of the first component, the second component name of the second component and the component names of other third components, it means that the third component has not called the upward component or other execution components in the same level, avoiding the mesh call, and also called the fifth component downward, then the verification processing of the fifth component can continue to be executed, and if the above conditions are not met, the third verification result can be set to verification failure.
[0095] In some embodiments, the method may further include: obtaining a parameter type of a parameter included in the third component; if the parameter type is not a preset type, setting the third verification result to verification failure.
[0096] That is, in actual implementation, the method parameters of the third component, such as the IExecutor component, can also be checked to verify whether the method parameters in the component are all subclasses of the custom common component. If not, the third check result can be set to check failure, and its code can be, for example:
[0097] Class executorCls;
[0098] Method[]methods=executorCls.getDeclaredMethods();
[0099] Class[]parameterTypes=methods.getParameterTypes();
[0100] boolean flag=Command.class.isAssignableFrom(parameterType).
[0101] In some embodiments, the fourth verification is performed on the fifth component represented by the fifth component name to obtain a fourth verification result, including: determining the calling level of the fifth component calling the sixth component, wherein the sixth component is a component other than the fifth component; if the calling level is less than or equal to a preset level threshold, setting the fourth verification result to verification success; otherwise, setting the fourth verification result to verification failure.
[0102] In the embodiment of the present disclosure, the preset level threshold can be 1, that is, a first-fifth component is allowed to make a same-level call once and call a second-fifth component once, but the second-fifth component is not allowed to call the third-fifth component again. The first-fifth component, the second-fifth component and the third-fifth component are different fifth components.
[0103] In addition, in some embodiments, the method may further include: verifying whether the fourth attribute set of the fifth component includes the fourth component name of the fourth component; if the fourth attribute set includes the fourth component name, setting the fourth verification result to verification failure.
[0104] For how to obtain the fourth attribute set, please refer to the relevant description of the second attribute set, which will not be repeated here.
[0105] In this implementation, it is possible to determine whether the fifth component has made an upward call by checking whether the fourth attribute set of the fifth component includes the fourth component, that is, whether it includes the component names of the first component, the second component, and the third component, so as to avoid mesh calls in the coding and improve the maintainability and scalability of the coding.
[0106] In addition, it should be noted that in actual implementation, when performing the fourth check on the fifth component, the data type of the member variables defined in the fifth component and the number of member variables defined therein can also be checked, and the detailed processing process will not be repeated here.
[0107] Please see Figure 2, which is a flowchart of the application processing method provided by the embodiment of the present disclosure. Figure 2 The application processing method provided by the embodiment of the present disclosure is schematically described. Figure 2 In the figure, the target application is an application developed by coding based on the spring development framework, and the first component is the controller component, the second component is the service component, the third component is the IExecutor component, and the fifth component is the ICollavorator component.
[0108] like Figure 2 As shown, first, the target application may receive a start operation, and the start operation may be, for example, a click operation of the user on the target application.
[0109] After the target application receives the startup operation, in response to the startup operation, step S21 is executed to perform bean component loading processing; that is, in step S21, the target application can build and assemble each bean component and initialize and load the bean component into the spring container.
[0110] Step S22, determine the controller component in the target application; that is, the keyword "controller" corresponding to the controller component can be used to filter component name 1 containing the keyword from the component name set of the target application, and the component corresponding to the component name 1 is determined as the controller component.
[0111] See also Figure 2 In step S22, each component name in the component name set may be judged in a loop. If the current component name contains the keyword, step S23 may be executed to perform a first check on the current controller component; if the current component name does not contain the keyword, the next component name may be read and judged.
[0112] During the execution of step S23, step S31 can be executed to check whether the attribute set 1 of the controller component includes the component name 2 of the service component; if not, the first verification result can be set to verification failure, thereby determining that the target application failed to start; if included: step S32 is executed to perform a second verification on the service component represented by component name 2, and determine the first verification result based on the second verification result obtained.
[0113] During the execution of step S32, step S41 can be executed to check whether the attribute set 2 of the service component includes the component name 3 of the IExecutor component; if not, the second verification result can be set to verification failure; if included, step S42 is executed to perform a third verification on the IExecutor component represented by the component name 3, and determine the second verification result based on the third verification result obtained.
[0114] During the execution of step S42, step S51 can be executed to check whether the property set 3 of the IExecutor component does not include the component name 4 of the fourth component, and includes the component name 5 of the ICollavorator component; wherein the fourth component can be a controller component, a service component, or another IExecutor component; if this condition is met, step S52 is executed to perform a fourth check on the ICollavorator component represented by the component name 5, and determine the third check result based on the fourth check result obtained; if this condition is not met, it means that the IExecutor component may have made a same-layer call or an upward call, or did not call the common logic, and the third check result can be set to a check failure.
[0115] During the execution of step S52, step S61 may be executed to determine the call level of the ICollavorator component; step S62 determines whether the call level is less than or equal to 1; if so, the fourth verification result is set to verification success; if not, the fourth verification result is set to verification failure.
[0116] Of course, in the process of executing step S32, the number of interfaces defined in the service component and the number of implemented interfaces can also be verified; and, in the process of executing step S42, the IExecutor component can also be named and / or the parameter type of the IExecutor component can be verified; and, in the process of executing step S52, it can also be verified whether the attribute set 4 of the ICollavorator component contains the component name of the controller component, service component or IExecutor component to verify whether the ICollavorator component has an upward call, which will not be repeated here.
[0117] It is understandable that, in the above application processing, if the first verification result of any controller component is a verification failure, it can be determined that the first verification result is a verification failure, and further it can be determined that the application startup fails.
[0118] It can be understood that the above-mentioned various method embodiments mentioned in the present disclosure can be combined with each other to form a combined embodiment without violating the principle logic. Due to space limitations, the present disclosure will not repeat them. It can be understood by those skilled in the art that in the above-mentioned method of the specific implementation method, the specific execution order of each step should be determined according to its function and possible internal logic.
[0119] In addition, the present disclosure also provides an application processing device, an electronic device, a computer-readable storage medium, and a computer program product, all of which can be used to implement any application processing method provided by the present disclosure. The corresponding technical solutions and descriptions are referred to the corresponding records in the method part and will not be repeated here.
[0120] Figure 3 A block diagram of an application processing device provided in an embodiment of the present disclosure.
[0121] Reference Figure 3 The embodiment of the present disclosure provides an application processing device that can be applied to an electronic device. The application processing device 300 includes: a component determination unit 301, a verification unit 302 and a result determination unit 303.
[0122] The component determination unit 301 is used to determine a first component of the target application in response to a startup operation on the target application, the first component being a component loaded after the target application performs component loading processing in response to the startup operation, and the first component is used to receive a client request and respond;
[0123] The verification unit 302 is used to perform a first verification on the first component to obtain a first verification result, wherein the first verification is used to perform coding verification on the first component and the second component called by the first component during the startup process of the target application;
[0124] The result determination unit 303 is used to determine a startup result of the target application according to the first verification result, wherein the startup result indicates whether the target application is successfully started.
[0125] In some embodiments, when determining the first component of the target application, the component determination unit 301 can be used to: obtain a component name set corresponding to the target application, wherein the component name set includes component names of components in the target application; determine the component corresponding to the first component name containing a first keyword in the component name set as the first component, wherein the first keyword is used to identify a component of a first preset type.
[0126] In some embodiments, when the verification unit 302 performs a first verification on the first component and obtains a first verification result, it can be used to: verify whether the first attribute set of the first component includes a second component name of a second component of a second preset type, wherein the second component includes a component for processing at least one business logic in the application; if the first attribute set includes the second component name, perform a second verification on the second component represented by the second component name to obtain a second verification result; and determine the first verification result based on the second verification result.
[0127] In some embodiments, when the verification unit 302 performs a second verification on the second component represented by the second component name and obtains a second verification result, it can be used to: verify whether the second attribute set of the second component includes a third component name of a third component of a third preset type, wherein the third component includes a component used to implement a business logic in an application; if the second attribute set includes the third component name, perform a third verification on the third component represented by the third component name to obtain a third verification result; and determine the second verification result based on the third verification result.
[0128] In some embodiments, the verification unit 302 can also be used to: obtain a first number of interfaces defined in the second component, and a second number of interfaces coded and implemented in the second component; if the first number is greater than a first preset threshold, or the first number and the second number do not match, then set the second verification result to verification failure.
[0129] In some embodiments, when the verification unit 302 performs a third verification on the third component represented by the third component name and obtains a third verification result, it can be used to: verify whether the third attribute set of the third component includes the fourth component name of the fourth component, and whether the third attribute set includes the fifth component name of the fifth component of the fourth preset type, the fifth component includes a component for implementing a common logic in the application, and the fourth component includes the first component, the second component and the third component; if the third attribute set does not include the fourth component name, and the third attribute set includes the fifth component name, then perform a fourth verification on the fifth component represented by the fifth component name to obtain a fourth verification result; and determine the third verification result based on the fourth verification result.
[0130] In some embodiments, when the verification unit 302 performs a fourth verification on the fifth component represented by the fifth component name and obtains a fourth verification result, it can be used to: determine the calling level of the fifth component calling the sixth component, where the sixth component is a component other than the fifth component; if the calling level is less than or equal to a preset level threshold, set the fourth verification result to verification success; otherwise, set the fourth verification result to verification failure.
[0131] It can be seen that, based on the application processing device provided by the embodiment of the present disclosure, when the target application responds to the startup operation, after executing the component loading process and completing the loading process such as building and packaging of the component, by determining the first component of the target application, and taking the first component as the initial component for coding verification of the components in the application, the first component and the second component called by the first component are first verified, and the startup result of the application is determined based on the first verification; on the one hand, the effect of accurate and comprehensive coding verification of the components in the target application can be achieved; on the other hand, since the components in the application startup processing process have been truly built and packaged, the effect of verifying the calling relationship between the components in the application during the first verification process can also be achieved; on the other hand, by performing the first verification during the application startup processing process and determining the startup result of the target application based on the first verification, the developer can be further constrained to better comply with the coding specifications of the components and component calls to avoid application startup failure. That is, based on the application processing device provided by the embodiment of the present disclosure, the components of the target application and the calling relationship between the components can be accurately verified, and the accuracy of the application coding verification can be improved.
[0132] It should be noted that each module in the above application processing device can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0133] Figure 4 A block diagram of an electronic device provided in an embodiment of the present disclosure.
[0134] Reference Figure 4 An embodiment of the present disclosure provides an electronic device, which includes: at least one processor 401; at least one memory 402, and one or more I / O interfaces 403, connected between the processor 401 and the memory 402; wherein the memory 402 stores one or more computer programs that can be executed by the at least one processor 401, and the one or more computer programs are executed by the at least one processor 401 so that the at least one processor 401 can execute the above-mentioned application processing method.
[0135] The present disclosure also provides a computer-readable storage medium on which a computer program is stored, wherein the computer program implements the above-mentioned application processing method when executed by a processor. The computer-readable storage medium may be a volatile or non-volatile computer-readable storage medium.
[0136] The embodiments of the present disclosure also provide a computer program product, including a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the above-mentioned application processing method.
[0137] It will be appreciated by those skilled in the art that all or some of the steps, systems, and functional modules / units in the methods disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In a hardware implementation, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or may be implemented as hardware, or may be implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable storage medium, which may include a computer storage medium (or a non-transitory medium) and a communication medium (or a temporary medium).
[0138] As is known to those of ordinary skill in the art, the term computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable program instructions, data structures, program modules or other data). Computer storage media include, but are not limited to, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), static random access memory (SRAM), flash memory or other memory technology, portable compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and can be accessed by a computer. In addition, it is known to those of ordinary skill in the art that communication media typically contain computer-readable program instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transmission mechanism, and may include any information delivery medium.
[0139] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or 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 can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The 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 the computer-readable storage medium in each computing / processing device.
[0140] The computer program instructions for performing the operation 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 "C" language or similar programming languages. Computer-readable program instructions may be executed completely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be customized by utilizing the state information of the computer-readable program instructions, and the electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the present disclosure.
[0141] The computer program product described herein may be implemented in hardware, software, or a combination thereof. In one optional embodiment, the computer program product is embodied as a computer storage medium, and in another optional embodiment, the computer program product is embodied as a software product, such as a software development kit (SDK), etc.
[0142] Various aspects of the present disclosure are described herein with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer-readable program instructions.
[0143] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0144] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0145] The flow chart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to multiple embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a part of a module, program segment or instruction, and a part of the module, program segment or instruction includes one or more executable instructions for realizing the specified logical function. In some alternative implementations, the function marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous square boxes can actually be executed substantially in parallel, and they can sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or action, or can be implemented with a combination of special hardware and computer instructions.
[0146] Example embodiments have been disclosed herein, and although specific terms are employed, they are used and should be interpreted only in a general illustrative sense and not for limiting purposes. In some instances, it will be apparent to those skilled in the art that, unless otherwise expressly noted, features, characteristics, and / or elements described in conjunction with a particular embodiment may be used alone or in combination with features, characteristics, and / or elements described in conjunction with other embodiments. Therefore, those skilled in the art will appreciate that various changes in form and detail may be made without departing from the scope of the present disclosure as set forth in the appended claims.
Claims
1. An application processing method, characterized in that: The method comprises: In response to a start operation on a target application, determining a first component of the target application, the first component being a component loaded by the target application after executing component loading processing in response to the start operation, the first component being used to receive a client request and respond; Performing a first verification on the first component to obtain a first verification result, wherein the first verification is used to perform coding verification on the first component and a second component called by the first component during the startup process of the target application; A startup result of the target application is determined according to the first verification result, wherein the startup result indicates whether the target application is successfully started.
2. The method according to claim 1, characterized in that The determining the first component of the target application includes: Acquire a component name set corresponding to the target application, wherein the component name set includes component names of components in the target application; A component corresponding to a first component name containing a first keyword in the component name set is determined as the first component, wherein the first keyword is used to identify a component of a first preset type.
3. The method according to claim 1, characterized in that: The performing a first verification on the first component to obtain a first verification result includes: Verify whether the first attribute set of the first component includes a second component name of a second component of a second preset type, wherein the second component includes a component for processing at least one business logic in the application; If the first attribute set includes a second component name, performing a second verification on the second component represented by the second component name to obtain a second verification result; The first verification result is determined according to the second verification result.
4. The method according to claim 3, characterized in that The performing a second verification on the second component represented by the second component name to obtain a second verification result includes: Verify whether the second attribute set of the second component includes a third component name of a third component of a third preset type, wherein the third component includes a component for implementing a business logic in the application; If the second attribute set includes a third component name, performing a third verification on the third component represented by the third component name to obtain a third verification result; The second verification result is determined according to the third verification result.
5. The method according to claim 4, characterized in that The method further comprises: Obtaining a first number of interfaces defined in the second component and a second number of interfaces implemented by coding in the second component; If the first number is greater than a first preset threshold, or the first number does not match the second number, the second verification result is set to verification failure.
6. The method according to claim 4, characterized in that The performing a third verification on the third component represented by the third component name to obtain a third verification result includes: Verify whether the third attribute set of the third component includes a fourth component name of a fourth component, and whether the third attribute set includes a fifth component name of a fifth component of a fourth preset type, wherein the fifth component includes a component for implementing a common logic in an application, and the fourth component includes the first component, the second component, and the third component; If the third attribute set does not include the fourth component name, and the third attribute set includes the fifth component name, performing a fourth verification on the fifth component represented by the fifth component name to obtain a fourth verification result; The third verification result is determined according to the fourth verification result.
7. The method according to claim 6, characterized in that The performing a fourth verification on the fifth component represented by the fifth component name to obtain a fourth verification result includes: Determine a calling hierarchy of the fifth component calling a sixth component, wherein the sixth component is a component other than the fifth component; If the call level is less than or equal to a preset level threshold, the fourth verification result is set to verification success; otherwise, the fourth verification result is set to verification failure.
8. An application processing device, characterized in that: include: a component determination unit, configured to determine a first component of the target application in response to a startup operation on the target application, the first component being a component loaded by the target application after the component loading process is performed in response to the startup operation, and the first component being configured to receive a client request and respond; a verification unit, configured to perform a first verification on the first component to obtain a first verification result, wherein the first verification is used to perform coding verification on the first component and a second component called by the first component during the startup process of the target application; The result determination unit is used to determine the startup result of the target application according to the first verification result, wherein the startup result indicates whether the target application is successfully started.
9. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores one or more computer programs executable by the at least one processor, and the one or more computer programs are executed by the at least one processor to enable the at least one processor to execute the application processing method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the computer program implements the application processing method according to any one of claims 1 to 7.
11. A computer program product, characterized in that The invention comprises a computer-readable code or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the application processing method as described in any one of claims 1 to 7.
