Application server class loading resource isolation processing method, device, equipment and medium
By using the preset whitelist configuration label and the application layer class loader in the application server to determine resource matching, and isolating the service resource files of the application server layer and the application layer, the class loading conflict problem is solved, the operation and maintenance work is simplified, and the operation and maintenance work is improved. Application server compatibility and availability.
Patent Information
- Application Number
- CN202410191709.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-02-21
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2044-02-21
AI Technical Summary
In the application server, the application layer class loader also obtains the resource files of the application server layer during the process of searching for service resource files, resulting in class loading conflicts. The existing solution requires temporary annotation or deletion of the resource files of the application server layer, which affects many people. The normal operation of a WEB application and server is difficult to maintain.
By adding a preset whitelist configuration tag to the deployment description file of the target application, the application layer class loader is used to read the whitelist tag value to determine whether the resource to be found matches. If it matches, the service resource file is searched from the application server layer. Otherwise, search is prohibited to achieve isolation of application server layer and application layer service resource files.
It avoids class loading conflicts, simplifies operation and maintenance work, improves the compatibility and availability of application servers, reduces the workload of operation and maintenance personnel, and ensures the normal and stable operation of applications.
Smart Images

Figure CN118132166B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method, device, equipment and medium for isolating resource loading of an application server class. Background Art
[0002] For application servers, the importance of ensuring the normal operation of applications is self-evident. Being compatible with applications developed with various frameworks is the development trend of application servers. WEB applications may search for service resource files during the deployment and access stages. Different WEB applications may search for different service resource files.
[0003] However, since there are many jar files in the application server itself and there are also many jar files under the WEB application, during the deployment or access phase of the WEB application, some scenarios should only obtain the service resource files of the WEB application layer and only run the related programs of the application layer. However, when the application layer class loader searches for the service resource files, it also obtains the resource files of the application server layer and then executes the related programs of the application server layer, resulting in a series of class loading conflicts and abnormal application operation.
[0004] At present, in order to make the application layer class loader only find the service resource files of the application layer when searching for service resource files, it is necessary to temporarily comment or delete the corresponding service resource files in the application server layer to ensure the normal operation of the application. Since multiple WEB applications may be deployed in the application server, commenting or deleting the service resource files of the application server layer temporarily solves the class loading conflict problem of the current WEB application, but it may cause operation problems of other WEB applications and the application server itself. In addition, modifying the files at the application server layer is inconvenient for the subsequent operation and maintenance of the application server and WEB application, making the operation and maintenance work very difficult, cumbersome and redundant.
[0005] In summary, in the process of the application server searching for service resource files, how to isolate the service resource files of the application server layer and the application layer to avoid class loading conflicts in some scenarios is a problem that needs to be solved. Summary of the invention
[0006] The purpose of the present invention is to provide an application server class loading resource isolation processing method, device, equipment and medium, which can isolate the service resource files of the application server layer and the application layer during the process of the application server searching for service resource files, so as to avoid class loading conflicts in some scenarios. The specific scheme is as follows:
[0007] In a first aspect, the present application discloses a method for isolating application server class loading resources, comprising:
[0008] Deploy the target application to the application server; a deployment description file to which a preset whitelist configuration tag has been added is stored in the target directory of the target application;
[0009] Using the application layer class loader created by the application server for the target application to read the deployment description file to obtain the whitelist tag value of the preset whitelist configuration tag;
[0010] In the deployment phase and the access phase of the target application, according to the current resource to be found, the corresponding service resource file is searched from the application layer of the target application to obtain a first resource file set, and it is determined whether the current resource to be found matches the whitelist tag value;
[0011] If there is a match, the corresponding service resource file is searched from the application server layer based on the current resource to be searched to obtain the second resource file set. If there is no match, it is prohibited to search for the corresponding service resource file from the application server layer based on the current resource to be searched.
[0012] Optionally, after determining whether the current resource to be searched matches the whitelist tag value, the process further includes:
[0013] If they match, merging the first resource file set and the second resource file set to obtain a target file set, and returning the target file set to the target application;
[0014] If there is no match, only the first resource file set is returned to the target application.
[0015] Optionally, the using the application layer class loader created by the application server for the target application to read the deployment description file to obtain the whitelist tag value of the preset whitelist configuration tag includes:
[0016] Determining an application layer class loader created by the application server for the target application;
[0017] Parsing the deployment description file in the target application using the application layer class loader, and determining whether the preset whitelist configuration tag exists in the deployment description file;
[0018] If it exists, the whitelist tag value of the preset whitelist configuration tag is read, and the whitelist tag value is stored in the preset whitelist attribute of the application layer class loader.
[0019] Optionally, the determining whether the current resource to be searched matches the whitelist tag value includes:
[0020] Determine the resource name of the current resource to be searched;
[0021] Determine whether the header of the resource name includes the whitelist tag value;
[0022] If it is included, it is determined that the current resource to be searched matches the whitelist tag value; if it is not included, it is determined that the current resource to be searched does not match the whitelist tag value.
[0023] Optionally, the method further includes:
[0024] The whitelist tag value in the preset whitelist configuration tag is pre-set; wherein the whitelist tag value is a header name of a target resource file, and the target resource file is a resource file that the target application needs to search from the application layer and the application server layer.
[0025] Optionally, after determining whether the current resource to be searched matches the whitelist tag value, the process further includes:
[0026] If there is no match, monitor whether there is an error prompt at the moment;
[0027] If there is an error prompt, and the error prompt is used to indicate that the corresponding service resource file of the application server layer is missing, the preset whitelist configuration tag is adjusted based on the header name of the current resource to be found.
[0028] Optionally, adjusting the preset whitelist configuration tag based on the header name of the current resource to be searched includes:
[0029] If the target application is currently in the deployment phase, the header name of the current resource to be found is used as a new whitelist tag value in the preset whitelist configuration tag, and then the target application is redeployed;
[0030] If the target application is currently in the access phase, the target application is uninstalled, and the header name of the current resource to be found is used as the newly added whitelist tag value in the preset whitelist configuration tag, and then the target application is redeployed to the application server.
[0031] In a second aspect, the present application discloses an application server class loading resource isolation processing device, comprising:
[0032] An application deployment module, used to deploy a target application to an application server; a deployment description file to which a preset whitelist configuration tag has been added is stored under a target directory of the target application;
[0033] A tag value acquisition module, used to read the deployment description file using the application layer class loader created by the application server for the target application to obtain the whitelist tag value of the preset whitelist configuration tag;
[0034] A first file search module is used to search for corresponding service resource files from the application layer of the target application according to the current resource to be searched to obtain a first resource file set during the deployment phase and the access phase of the target application, and to determine whether the current resource to be searched matches the whitelist tag value;
[0035] The second file search module is used to search for corresponding service resource files from the application server layer based on the current resource to be searched to obtain a second resource file set if there is a match; if there is no match, it is prohibited to search for corresponding service resource files from the application server layer based on the current resource to be searched.
[0036] In a third aspect, the present application discloses an electronic device, comprising:
[0037] Memory, used to store computer programs;
[0038] The processor is used to execute the computer program to implement the steps of the aforementioned disclosed application server class loading resource isolation processing method.
[0039] In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the steps of the aforementioned disclosed application server class loading resource isolation processing method are implemented.
[0040] It can be seen that the present application deploys the target application to the application server; a deployment description file to which a preset whitelist configuration tag has been added is stored under the target directory of the target application; the deployment description file is read using the application layer class loader created by the application server for the target application to obtain the whitelist tag value of the preset whitelist configuration tag; during the deployment phase and access phase of the target application, the corresponding service resource file is searched from the application layer of the target application according to the current resource to be searched to obtain a first resource file set, and it is determined whether the current resource to be searched matches the whitelist tag value; if it matches, the corresponding service resource file is searched from the application server layer based on the current resource to be searched to obtain a second resource file set; if it does not match, it is prohibited to search for the corresponding service resource file from the application server layer based on the current resource to be searched.
[0041] It can be seen that this application needs to add a preset whitelist configuration tag in the deployment description file in advance, and place the deployment description file with the preset whitelist configuration tag added in the target directory of the target application to complete the configuration of the target application, and then deploy the configured target application to the application server. At the beginning of the deployment, the application server will create an application layer class loader for the target application to read the deployment description file through the application layer class loader to obtain the whitelist tag value of the preset whitelist configuration tag. In the deployment stage and access stage of the target application, first, according to the current resource to be found, the corresponding service resource file will be found from the application layer of the target application to obtain the first resource file set, and then further determine whether the current resource to be found matches the whitelist tag value to determine whether it is necessary to find the service resource file from the application server layer. Specifically, if the current resource to be found matches the whitelist tag value, it means that the current resource to be found is in the whitelist, and it is also necessary to find the service resource file from the application server layer; if the current resource to be found does not match the whitelist tag value, it means that the current resource to be found is not in the whitelist, and it is only necessary to find the service resource file from the application layer, and there is no need to find the corresponding service resource file from the application server layer. In this way, this application adds a preset whitelist configuration tag in the deployment description file in advance, and then further determines whether the resource currently to be found is in the whitelist to determine whether it is necessary to search for the service resource file in the application server layer. If it is not in the whitelist, there is no need to search from the application server layer, thereby isolating the service resource files of the application server layer and the application layer, and avoiding class loading conflicts in some scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0043] Figure 1 A flow chart of a resource isolation processing method for class loading of an application server disclosed in this application;
[0044] Figure 2 A flowchart of a specific application server class loading resource isolation processing method disclosed in this application;
[0045] Figure 3 A specific application server class loading resource isolation processing flow chart disclosed in this application;
[0046] Figure 4This is a schematic diagram of the structure of an application server class loading resource isolation processing device disclosed in this application;
[0047] Figure 5 This is a structural diagram of an electronic device disclosed in this application. DETAILED DESCRIPTION
[0048] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0049] At present, in order to make the application layer class loader only find the service resource files of the application layer during the process of searching for service resource files, it is necessary to temporarily annotate or delete the corresponding service resource files in the application server layer to ensure the normal operation of the application. Since multiple WEB applications may be deployed in the application server, although the class loading conflict problem of the current WEB application is temporarily solved by annotating or deleting the service resource files of the application server layer, it may cause operation problems of other WEB applications and the application server itself. And modifying the files of the application server layer is not convenient for the subsequent operation and maintenance of the application server and the WEB application, making the operation and maintenance work very difficult, cumbersome and redundant. To this end, the embodiment of the present application discloses an application server class loading resource isolation processing method, device, equipment and medium, which can isolate the service resource files of the application server layer and the application layer during the process of the application server searching for service resource files, so as to avoid class loading conflicts in some scenarios.
[0050] See also Figure 1 As shown, the embodiment of the present application discloses a method for isolating application server class loading resources, the method comprising:
[0051] Step S11: deploying the target application to the application server; a deployment description file to which a preset whitelist configuration tag has been added is stored in the target directory of the target application.
[0052] In this embodiment, it is necessary to add a preset whitelist configuration tag to the deployment description file in advance, and place the deployment description file with the preset whitelist configuration tag in the target directory of the target application to complete the configuration of the target application, and then deploy the configured target application to the application server.
[0053] It should be noted that the application server itself already includes the class loading whitelist function. You only need to enable this function in the configuration file. The operation is as follows: define the deployment description file: inforsuite-web.xml, and add the preset whitelist configuration tag for class loading to enable the class loading whitelist function. The tag format is <whitelist-package>< / whitelist-package> .
[0054] Specifically, the target directory refers to the WEB-INF directory of the target application. By placing the configured inforsuite-web.xml file in the WEB-INF directory of the target application, the application server can recognize this configuration during subsequent deployment. The WEB-INF directory is a standard folder under a WEB application.
[0055] Step S12: using the application layer class loader created by the application server for the target application to read the deployment description file to obtain the whitelist tag value of the preset whitelist configuration tag.
[0056] In this embodiment, at the beginning of deployment, the application server creates a corresponding application layer class loader WebappClassLoader for the target application, and reads the deployment description file through the application layer class loader to obtain the whitelist tag value of the preset whitelist configuration tag.
[0057] It should be pointed out that when the application is first deployed, the application server creates an independent application layer class loader WebappClassLoader for each application to load class classes or resource files.
[0058] Step S13: During the deployment and access phases of the target application, the corresponding service resource files are searched from the application layer of the target application according to the current resource to be found to obtain a first resource file set, and it is determined whether the current resource to be found matches the whitelist tag value.
[0059] In this embodiment, during the deployment phase and access phase of the target application, the corresponding service resource file is first searched from the application layer of the target application according to the current resource to be searched to obtain a first resource file set, and then it is further determined whether the current resource to be searched matches the whitelist tag value to determine whether it is necessary to search for the service resource file from the application server layer. The deployment phase refers to the process of deploying the target application to the application server; the access phase refers to the process of accessing the target application through a browser after the target application is deployed.
[0060] Specifically, the target application searches for service resource files by calling the getResources method of WebappClassLoader, first searches for service resource files at the application layer and records them in a collection object to obtain a first resource file collection. Wherein, getResources is a method for searching resource files in WebappClassLoader, which can search for resource files at both the application server layer and the application layer.
[0061] Then call the isWhitelistEnabled method of WebappClassLoader. Since the preset whitelist configuration tag has been configured, the isWhitelistEnabled method of WebappClassLoader will return true. It should be pointed out that isWhitelistEnabled is a method in WebappClassLoader to determine whether the class loading whitelist is enabled, and returns true or false. If inforsuite-web.xml exists <whitelist-package>Tag, that is, the class loading whitelist function is enabled and true is returned.
[0062] The isWhiteListed method of WebappClassLoader is further called to determine whether the current resource to be searched matches the whitelist tag value, that is, whether the current resource to be searched is in the whitelist. It should be pointed out that isWhiteListed is used by WebappClassLoader to determine whether the resource to be searched is in the configured whitelist. If it is, it returns true and searches for resource files at the application server layer at the same time; if not, it returns false and does not search for resource files at the application server layer.
[0063] Step S14: If there is a match, then based on the current resource to be found, the corresponding service resource file is searched from the application server layer to obtain a second resource file set; if there is no match, then it is prohibited to search for the corresponding service resource file from the application server layer based on the current resource to be found.
[0064] In this embodiment, as mentioned above, if the current resource to be searched matches the whitelist tag value, it means that the current resource to be searched is in the whitelist, and it is necessary to search the service resource file from the application server layer to obtain the second resource file set; if the current resource to be searched does not match the whitelist tag value, it means that the current resource to be searched is not in the whitelist, and it is only necessary to search the service resource file from the application layer, and there is no need to search for the corresponding service resource file from the application server layer. In this way, the present application adds a preset whitelist configuration tag to the deployment description file in advance, and then further determines whether the resource currently to be searched is in the whitelist to determine whether it is necessary to search for the service resource file in the application server layer. If it is not in the whitelist, there is no need to search from the application server layer, which realizes the isolation of the service resource files of the application server layer and the application layer, and avoids the class loading conflict problem in some scenarios.
[0065] In a specific implementation, after the above judgment of whether the current resource to be searched matches the whitelist tag value, it also includes: if it matches, then merging the first resource file set and the second resource file set to obtain a target file set, and returning the target file set to the target application; if it does not match, then only returning the first resource file set to the target application. That is, if the current resource to be searched matches the whitelist tag value, it means that the current resource to be searched is in the whitelist, then it is necessary to search the service resource file from the application server layer to obtain the second resource file set, and merge the first resource file set and the second resource file set to obtain the target file set, and then return the target file set to the target application. If the current resource to be searched does not match the whitelist tag value, that is, it means that the current resource to be searched is not in the whitelist, then the first resource file set of the application layer can be directly returned to the target application.
[0066] It can be seen that this application needs to add a preset whitelist configuration tag in the deployment description file in advance, and place the deployment description file with the preset whitelist configuration tag added in the target directory of the target application to complete the configuration of the target application, and then deploy the configured target application to the application server. At the beginning of the deployment, the application server will create an application layer class loader for the target application to read the deployment description file through the application layer class loader to obtain the whitelist tag value of the preset whitelist configuration tag. In the deployment stage and access stage of the target application, first, according to the current resource to be found, the corresponding service resource file will be found from the application layer of the target application to obtain the first resource file set, and then further determine whether the current resource to be found matches the whitelist tag value to determine whether it is necessary to find the service resource file from the application server layer. Specifically, if the current resource to be found matches the whitelist tag value, it means that the current resource to be found is in the whitelist, and it is also necessary to find the service resource file from the application server layer; if the current resource to be found does not match the whitelist tag value, it means that the current resource to be found is not in the whitelist, and it is only necessary to find the service resource file from the application layer, and there is no need to find the corresponding service resource file from the application server layer. In this way, this application adds a preset whitelist configuration tag in the deployment description file in advance, and then further determines whether the resource currently to be found is in the whitelist to determine whether it is necessary to search for the service resource file in the application server layer. If it is not in the whitelist, there is no need to search from the application server layer, thereby isolating the service resource files of the application server layer and the application layer, and avoiding class loading conflicts in some scenarios.
[0067] See also Figure 2 and Figure 3 As shown, the embodiment of the present application discloses a specific application server class loading resource isolation processing method. Compared with the previous embodiment, this embodiment further explains and optimizes the technical solution. Specifically, it includes:
[0068] Step S21: deploying the target application to the application server; a deployment description file to which a preset whitelist configuration tag has been added is stored in the target directory of the target application.
[0069] Step S22: Determine the application layer class loader created by the application server for the target application; use the application layer class loader to parse the deployment description file in the target application, and determine whether the preset whitelist configuration tag exists in the deployment description file.
[0070] In this embodiment, the application layer class loader WebappClassLoader created by the application server for the target application is determined, and the application layer class loader WebappClassLoader is used to parse the deployment descriptor file inforsuite-web.xml in the target application, and the isWhitelistEnabled method in WebappClassLoader is called to determine whether there is a preset whitelist configuration tag in the deployment descriptor file.
[0071] Step S23: If it exists, read the whitelist tag value of the preset whitelist configuration tag, and store the whitelist tag value in the preset whitelist attribute of the application layer class loader.
[0072] In this embodiment, since the whitelist-package tag has been configured in inforsuite-web.xml, the isWhitelistEnabled method of WebappClassLoader will return true, and then read the whitelist tag value of the preset whitelist configuration tag, and read all whitelist tag values into the preset whitelist attribute whitelistPackages of WebappClassLoader. Among them, the whitelistPackages attribute is a collection class of JDK (Java language software development kit) used to store the values of all configured whitelist tags.
[0073] Step S24: During the deployment phase and the access phase of the target application, the corresponding service resource files are searched from the application layer of the target application according to the current resources to be searched to obtain a first resource file set.
[0074] Step S25: Determine the resource name of the current resource to be searched, and judge whether the header of the resource name includes the whitelist tag value.
[0075] In this embodiment, the method for determining whether the current resource to be searched matches the whitelist tag value may specifically be: determining the resource name of the current resource to be searched, and determining whether the header of the resource name includes the whitelist tag value.
[0076] It should be noted that the above method further includes: presetting a whitelist tag value in the preset whitelist configuration tag; wherein the whitelist tag value is a header name of a target resource file, and the target resource file is a resource file that the target application needs to search from the application layer and the application server layer. For example, in a specific embodiment, the preset whitelist configuration tag is specifically set to <whitelist-package> META-INF / services / java.< / whitelist-package> , the content here is currently configured as "META-INF / services / java.", which can be adjusted according to actual needs. That is, when the application layer searches for service resource files, only those starting with this name will be searched at the application server layer at the same time, otherwise only the service resource files at the application layer will be searched. That is, this application sets the whitelist tag value to the header name of the target resource file that needs to be searched from both the application layer and the application server layer.
[0077] Step S26: If included, it is determined that the current resource to be searched matches the whitelist tag value; if not included, it is determined that the current resource to be searched does not match the whitelist tag value.
[0078] In this embodiment, if the resource name header of the current resource to be searched includes a whitelist tag value, it is determined that the current resource to be searched matches the whitelist tag value, otherwise it is determined that the current resource to be searched does not match the whitelist tag value.
[0079] Step S27: If there is a match, then based on the current resource to be found, the corresponding service resource file is searched from the application server layer to obtain a second resource file set; if there is no match, then it is prohibited to search for the corresponding service resource file from the application server layer based on the current resource to be found.
[0080] In this embodiment, when the current resource to be searched does not match the whitelist tag value, it is also necessary to monitor whether there is an error prompt; if there is an error prompt, and the error prompt is used to indicate the lack of the corresponding service resource file of the application server layer, the preset whitelist configuration tag is adjusted based on the header name of the current resource to be searched. It is understandable that in some scenarios, it is also necessary to search for the service resource file under the application server, and the class loading whitelist file may initially only be configured with <whitelist-package> META-INF / services / java.< / whitelist-package> That is, currently only service resource files starting with "META-INF / services / java." will be searched at the application server layer at the same time. However, in actual situations, files starting with "META-INF / services / javax." also need to be searched at the application server layer. Therefore, deployment failure may occur at this time, and there will be an error prompt indicating that the corresponding service resource file of the application server layer is missing. Therefore, at this time, it is necessary to readjust the class loading whitelist configuration based on the actual error prompt and the header name of the current resource to be searched, that is, adjust <whitelist-package>Tag configuration. Then redeploy the target application so that the target application can normally obtain the required service resource files.
[0081] In a specific implementation, the above-mentioned adjustment of the preset whitelist configuration tag based on the header name of the current resource to be searched includes: if the current stage is the deployment stage of the target application, the header name of the current resource to be searched is used as the newly added whitelist tag value in the preset whitelist configuration tag, and then the target application is redeployed; if the current stage is the access stage of the target application, the target application is uninstalled, and the header name of the current resource to be searched is used as the newly added whitelist tag value in the preset whitelist configuration tag, and then the target application is redeployed to the application server. That is, in the deployment stage and access stage of the target application, the way to adjust the preset whitelist configuration tag based on the header name of the current resource to be searched is different. If the current stage is the deployment stage of the target application, the header name of the current resource to be searched is used as the newly added whitelist tag value in the preset whitelist configuration tag, that is, a whitelist configuration tag is added on the basis of the original tag, which then includes <whitelist-package> META-INF / services / java.< / whitelist-package> and <whitelist-package> META-INF / services / javax.< / whitelist-package> Two whitelist configuration tags, and then redeploy the target application. If the current stage is the access stage of the target application, since the deployment of the target application has been completed at this time, you need to uninstall the target application first, and then use the header name of the current resource to be found as the new whitelist tag value in the preset whitelist configuration tag, and then redeploy the target application to the application server.
[0082] By continuously adjusting the configuration of the above whitelist and adapting to the problems of the target application, the target application is finally deployed successfully and accessed successfully.
[0083] For more specific processing procedures of the above steps S21 and S24, reference may be made to the corresponding contents disclosed in the above embodiments, which will not be described in detail here.
[0084] The above solution enhances the compatibility of the application server and ensures the normal and stable operation of the application program. It also enhances the availability of the application server, making the subsequent operation and maintenance of the application server and WEB application simple and easy, and reducing the workload of the operation and maintenance personnel.
[0085] It can be seen that the present application sets the whitelist tag value to the header name of the target resource file that needs to be searched from both the application layer and the application server layer. Therefore, the method for judging whether the current resource to be searched matches the whitelist tag value in the present application can be specifically as follows: determine the resource name of the current resource to be searched, and judge whether the header of the resource name includes the whitelist tag value. If the resource name header of the current resource to be searched includes the whitelist tag value, it is determined that the current resource to be searched matches the whitelist tag value, otherwise it is determined that the current resource to be searched does not match the whitelist tag value. In the case where the current resource to be searched does not match the whitelist tag value, if the error prompt is used to characterize the lack of the corresponding service resource file of the application server layer, the preset whitelist configuration tag is adjusted based on the header name of the current resource to be searched, and the adjustment method is different in the deployment stage and access stage of the target application. By continuously adjusting the configuration of the above whitelist, adapting to the problems of the target application, and finally making the target application deployed successfully and accessed successfully, the service resource files of the application server layer and the application layer are isolated, and the class loading conflict problem of some scenarios is avoided.
[0086] See also Figure 4 As shown, the embodiment of the present application discloses an application server class loading resource isolation processing device, the device comprising:
[0087] The application deployment module 11 is used to deploy the target application to the application server; the target directory of the target application stores a deployment description file to which a preset whitelist configuration tag has been added;
[0088] A tag value acquisition module 12 is used to read the deployment description file using the application layer class loader created by the application server for the target application to obtain the whitelist tag value of the preset whitelist configuration tag;
[0089] A first file search module 13 is used to search for corresponding service resource files from the application layer of the target application according to the current resource to be searched to obtain a first resource file set during the deployment phase and the access phase of the target application, and to determine whether the current resource to be searched matches the whitelist tag value;
[0090] The second file search module 14 is used to search for corresponding service resource files from the application server layer based on the current resource to be searched to obtain a second resource file set if there is a match, and to prohibit searching for corresponding service resource files from the application server layer based on the current resource to be searched if there is no match.
[0091] It can be seen that this application needs to add a preset whitelist configuration tag in the deployment description file in advance, and place the deployment description file with the preset whitelist configuration tag added in the target directory of the target application to complete the configuration of the target application, and then deploy the configured target application to the application server. At the beginning of the deployment, the application server will create an application layer class loader for the target application to read the deployment description file through the application layer class loader to obtain the whitelist tag value of the preset whitelist configuration tag. In the deployment stage and access stage of the target application, first, according to the current resource to be found, the corresponding service resource file will be found from the application layer of the target application to obtain the first resource file set, and then further determine whether the current resource to be found matches the whitelist tag value to determine whether it is necessary to find the service resource file from the application server layer. Specifically, if the current resource to be found matches the whitelist tag value, it means that the current resource to be found is in the whitelist, and it is also necessary to find the service resource file from the application server layer; if the current resource to be found does not match the whitelist tag value, it means that the current resource to be found is not in the whitelist, and it is only necessary to find the service resource file from the application layer, and there is no need to find the corresponding service resource file from the application server layer. In this way, this application adds a preset whitelist configuration tag in the deployment description file in advance, and then further determines whether the resource currently to be found is in the whitelist to determine whether it is necessary to search for the service resource file in the application server layer. If it is not in the whitelist, there is no need to search from the application server layer, thereby isolating the service resource files of the application server layer and the application layer, and avoiding class loading conflicts in some scenarios.
[0092] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Specifically, it may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. Among them, the memory 22 is used to store a computer program, and the computer program is loaded and executed by the processor 21 to implement the relevant steps in the application server class loading resource isolation processing method performed by the electronic device disclosed in any of the aforementioned embodiments.
[0093] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.
[0094] Among them, the processor 21 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 21 can be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 21 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 21 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 21 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.
[0095] In addition, the memory 22, as a carrier for storing resources, can be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon include an operating system 221, a computer program 222 and data 223, etc. The storage method can be temporary storage or permanent storage.
[0096] Among them, the operating system 221 is used to manage and control the hardware devices and computer programs 222 on the electronic device 20, so as to realize the operation and processing of the massive data 223 in the memory 22 by the processor 21, which can be Windows, Unix, Linux, etc. In addition to including a computer program that can be used to complete the application server class loading resource isolation processing method executed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include a computer program that can be used to complete other specific tasks. In addition to data transmitted from an external device received by the electronic device, the data 223 can also include data collected by its own input and output interface 25, etc.
[0097] Furthermore, an embodiment of the present application also discloses a computer-readable storage medium, in which a computer program is stored. When the computer program is loaded and executed by a processor, the steps of the application server class loading resource isolation processing method disclosed in any of the aforementioned embodiments are implemented.
[0098] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0099] Those skilled in the art may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented with electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0100] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a compact disc read-only memory (CD-ROM), or any other form of storage medium known in the art.
[0101] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprises a..." does not exclude the presence of other identical elements in the process, method, article or device including the element.
[0102] The above is a detailed introduction to the application server class loading resource isolation processing method, device, equipment and storage medium provided by the present invention. This article uses specific examples to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for general technical personnel in this field, according to the idea of the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A method for isolating application server class loading resources. It is characterized in that include: Deploy the target application to the application server; A deployment description file to which a preset whitelist configuration tag has been added is stored in the target directory of the target application; Using the application layer class loader created by the application server for the target application to read the deployment description file to obtain the whitelist tag value of the preset whitelist configuration tag; In the deployment phase and the access phase of the target application, according to the current resource to be found, the corresponding service resource file is searched from the application layer of the target application to obtain a first resource file set, and it is determined whether the current resource to be found matches the whitelist tag value; If there is a match, the corresponding service resource file is searched from the application server layer based on the current resource to be searched to obtain the second resource file set. If there is no match, it is prohibited to search for the corresponding service resource file from the application server layer based on the current resource to be searched.
2. The method for isolating application server class loading resources according to claim 1, It is characterized in that After determining whether the name of the current resource to be searched matches the whitelist tag value, the method further includes: If they match, merging the first resource file set and the second resource file set to obtain a target file set, and returning the target file set to the target application; If there is no match, only the first file set is returned to the target application.
3. The method for isolating application server class loading resources according to claim 1, It is characterized in that The step of using the application layer class loader created by the application server for the target application to read the deployment description file to obtain the whitelist tag value of the preset whitelist configuration tag includes: Determining an application layer class loader created by the application server for the target application; Parsing the deployment description file in the target application using the application layer class loader, and determining whether the preset whitelist configuration tag exists in the deployment description file; If it exists, the whitelist tag value of the preset whitelist configuration tag is read, and the whitelist tag value is stored in the preset whitelist attribute of the application layer class loader.
4. The method for isolating application server class loading resources according to claim 1, It is characterized in that The determining whether the current resource to be searched matches the whitelist tag value includes: Determine the resource name of the current resource to be searched; Determine whether the header of the resource name includes the whitelist tag value; If it is included, it is determined that the current resource to be searched matches the whitelist tag value; if it is not included, it is determined that the current resource to be searched does not match the whitelist tag value.
5. The method for isolating application server class loading resources according to claim 4, It is characterized in that Also includes: The whitelist tag value in the preset whitelist configuration tag is pre-set; wherein the whitelist tag value is a header name of a target resource file, and the target resource file is a resource file that the target application needs to search from the application layer and the application server layer.
6. The application server class loading resource isolation processing method according to claim 1, It is characterized in that After determining whether the current resource to be searched matches the whitelist tag value, the method further includes: If there is no match, monitor whether there is an error prompt at the moment; If there is an error prompt, and the error prompt is used to indicate that the corresponding service resource file of the application server layer is missing, the preset whitelist configuration tag is adjusted based on the header name of the current resource to be found.
7. The method for isolating application server class loading resources according to claim 6, It is characterized in that The adjusting the preset whitelist configuration tag based on the header name of the current resource to be searched includes: If the target application is currently in the deployment phase, the header name of the current resource to be found is used as a new whitelist tag value in the preset whitelist configuration tag, and then the target application is redeployed; If the target application is currently in the access phase, the target application is uninstalled, and the header name of the current resource to be found is used as the newly added whitelist tag value in the preset whitelist configuration tag, and then the target application is redeployed to the application server.
8. An application server class loading resource isolation processing device, It is characterized in that include: Application deployment module, used to deploy the target application to the application server; A deployment description file to which a preset whitelist configuration tag has been added is stored in the target directory of the target application; A tag value acquisition module, used to read the deployment description file using the application layer class loader created by the application server for the target application to obtain the whitelist tag value of the preset whitelist configuration tag; A first file search module is used to search for corresponding service resource files from the application layer of the target application according to the current resource to be searched to obtain a first resource file set during the deployment phase and the access phase of the target application, and to determine whether the current resource to be searched matches the whitelist tag value; The first file search module is used to search for corresponding service resource files from the application server layer based on the current resource to be searched to obtain a second resource file set if there is a match, and to prohibit searching for corresponding service resource files from the application server layer based on the current resource to be searched if there is no match.
9. An electronic device, It is characterized in that include: Memory, used to store computer programs; A processor is used to execute the computer program to implement the steps of the application server class loading resource isolation processing method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, It is characterized in that Used to store computer programs; wherein, when the computer program is executed by a processor, the steps of the application server class loading resource isolation processing method as described in any one of claims 1 to 7 are implemented.
