External class library loading method and device based on application server, equipment and medium

By configuring external classpath attributes and class loader parsing the initial standard deployment description file, the cumbersome operation and maintenance problems caused by the placement of external jar files in WEB applications are solved, and the effect of simplifying operation and maintenance and improving application server availability is achieved.

CN119557013AActive Publication Date: 2025-03-04SHANDONG CVICSE MIDDLEWARE CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411698276.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-26
Publication Date
2025-03-04
Estimated Expiration
2044-11-26

AI Technical Summary

Technical Problem

In the prior art, some jar files used in WEB need to be placed in external directories, resulting in increased operation and maintenance workload and complicated configuration file operations.

Method used

By configuring the initial standard deployment profile external classpath attributes, the target standard deployment profile is generated and placed in a preset application. Use the class loader to parse preset applications, add standard directory class libraries and package file class libraries to the class path, read external class path properties, divide and traverse class path elements, and add external package files to the second preset class path of the class loader.

Benefits of technology

It avoids the problem of placing external jar files in external directories, simplifies operation and maintenance work, reduces the workload of development and operation and maintenance personnel, and improves the availability of application servers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119557013A_ABST
    Figure CN119557013A_ABST
Patent Text Reader

Abstract

The invention discloses an external class library loading method and device based on an application server, equipment and a medium, and relates to the technical field of the Internet, the external class library loading method comprises the following steps: performing external class path attribute configuration on an initial standard deployment description file, and putting a target standard deployment description file into a preset application program; the external class path attribute is the attribute of an absolute path of an external class library directory or an external software package file; the external class library directory comprises an external software package file; analyzing the preset application program, and adding the obtained standard directory class library and the standard software package file class library to a first preset class path; reading the target standard deployment description file and segmenting the external class path character string; and traversing the external class path elements, and sequentially adding the external software package files to a second preset class path based on a judgment result of whether the external class path elements are the external class library directory or not, so as to load the target software package file. And the operation and maintenance work becomes simple and feasible.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of Internet technology, and in particular to an external class library loading method, device, equipment and medium based on an application server. Background Art

[0002] At present, in order to facilitate the deployment and adaptation of WEB applications (a kind of software application), reduce the workload of developers and operation and maintenance personnel, and facilitate the management of configuration files, it is necessary to temporarily move all external jar (a kind of software package file format) files to the WEB application standard jar file class library, that is, all jar files required by the WEB application are placed in the standard jar file class library. In this way, the structure of the WEB application is adjusted, the size of the WEB application is increased, and it is inconvenient 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.

[0003] As can be seen from the above, how to avoid placing some jar files of WEB applications in an external directory, which increases the operation and maintenance workload and makes configuration file operations complicated, is an urgent problem to be solved. Summary of the invention

[0004] In view of this, the purpose of the present invention is to provide an external class library loading method, device, equipment and medium based on an application server, which can avoid placing some jar files of a WEB application in an external directory, which increases the operation and maintenance workload and makes configuration file operations complicated. The specific scheme is as follows:

[0005] In a first aspect, the present application provides an external class library loading method based on an application server, comprising:

[0006] Performing external class path attribute configuration on the initial standard deployment description file to obtain a target standard deployment description file, and placing the target standard deployment description file into a preset application; the external class path attribute is an attribute of an absolute path of an external class library directory or an absolute path of an external software package file; the external class library directory includes the external software package file;

[0007] Parsing the preset application using a class loader to obtain a standard directory class library, a standard software package file class library, and the target standard deployment description file of the preset application, and sequentially adding the standard directory class library and the standard software package file class library to a first preset class path of the class loader using a first preset class library addition strategy;

[0008] Reading the target standard deployment description file based on the class loader to obtain a path value corresponding to an external class path attribute, and storing the path value in an external class path string;

[0009] Splitting the external class path character string to obtain external class path elements, and storing the external class path elements into an external class path element array;

[0010] Traversing the external class path elements in the external class path element array, obtaining the external software package file based on a judgment result of whether the traversed external class path element is the external class library directory, and sequentially adding the external software package files to the second preset class path of the class loader using a second preset class library adding strategy;

[0011] During the running of the preset application, the corresponding target software package file is loaded from the first preset class path and the second preset class path through the preset loading class strategy.

[0012] Optionally, configuring the external class path property of the initial standard deployment description file to obtain a target standard deployment description file, and placing the target standard deployment description file into a preset application program, includes:

[0013] Configure the absolute path of the external class library directory or the absolute path of the external software package file through the class loading tag to obtain a configured target class loading tag, and add the target class loading tag to the initial standard deployment description file to obtain a target standard deployment description file;

[0014] Place the target standard deployment descriptor file into the standard folder of the preset application.

[0015] Optionally, the using a class loader to parse the preset application to obtain a standard directory class library, a standard software package file class library and the target standard deployment description file of the preset application includes:

[0016] Deploy the preset application to an application server, and use the application server to create a class loader corresponding to the preset application;

[0017] Parsing the preset application based on the class loader to obtain a standard directory class library, a standard software package file class library and the target standard deployment description file of the preset application;

[0018] The standard directory class library and the standard software package file class library are stored in the file array and the software package file array respectively.

[0019] Optionally, the step of segmenting the external class path character string to obtain external class path elements and storing the external class path elements in an external class path element array includes:

[0020] Using a preset string segmentation strategy of a software development kit and according to a preset string segmentation rule, the external class path string is segmented to obtain corresponding external class path elements;

[0021] The external class path element is stored in an external class path element array.

[0022] Optionally, traversing the external class path elements in the external class path element array, obtaining the external software package file based on a judgment result of whether the traversed external class path element is the external class library directory, and sequentially adding the external software package file to the second preset class path of the class loader by using a second preset class library addition strategy, includes:

[0023] Traversing the external class path elements in the external class path element array by using a preset loop traversal strategy;

[0024] Create a corresponding file class using a preset keyword, and determine whether the traversed external class path element is the external class library directory through a preset directory determination method of the file class;

[0025] The external software package file is obtained based on the judgment result, and the external software package file is sequentially added to the second preset class path of the class loader using the second preset class library addition strategy.

[0026] Optionally, obtaining the external software package file based on the judgment result, and sequentially adding the external software package file to the second preset class path of the class loader using a second preset class library adding strategy includes:

[0027] If the external class path element is the external class library directory, then based on a preset file listing strategy, files are read from the external class library directory to obtain each of the external software package files, each of the external software package files is traversed and the external software package files are added to the second preset class path of the class loader by using the class loader's adding class library method;

[0028] If the external class path element is not the external class library directory, the external class path element is determined to be the external software package file, and the external software package file is added to the second preset class path of the class loader using the class library adding method of the class loader.

[0029] Optionally, during the running of the preset application, loading the corresponding target software package file from the first preset class path and the second preset class path by using a preset loading class strategy includes:

[0030] During the running of the preset application, the corresponding target software package file is loaded from the standard directory class library in the first preset class path, the standard software package file class library and the external software package file in the second preset class path in sequence by calling the load class method of the class loader.

[0031] In a second aspect, the present application provides an external class library loading device based on an application server, comprising:

[0032] The target file configuration module is used to configure the external class path attribute of the initial standard deployment description file to obtain a target standard deployment description file, and put the target standard deployment description file into the preset application; the external class path attribute is the attribute of the absolute path of the external class library directory or the absolute path of the external software package file; the external class library directory includes the external software package file;

[0033] an application parsing module, configured to parse the preset application using a class loader to obtain a standard directory class library, a standard software package file class library, and the target standard deployment description file of the preset application, and sequentially add the standard directory class library and the standard software package file class library to a first preset class path of the class loader using a first preset class library addition strategy;

[0034] A target file reading module, used for reading the target standard deployment description file based on the class loader to obtain a path value corresponding to the external class path attribute, and storing the path value in an external class path string;

[0035] A string segmentation module, used for segmenting the external class path string to obtain external class path elements, and storing the external class path elements into an external class path element array;

[0036] a path element traversal module, configured to traverse the external class path elements in the external class path element array, obtain the external software package file based on a judgment result of whether the traversed external class path element is the external class library directory, and sequentially add the external software package files to the second preset class path of the class loader using a second preset class library addition strategy;

[0037] The class file loading module is used to load the corresponding target software package file from the first preset class path and the second preset class path through a preset loading class strategy during the running process of the preset application program.

[0038] In a third aspect, the present application provides an electronic device, including:

[0039] Memory, used to store computer programs;

[0040] The processor is used to execute the computer program to implement the aforementioned external class library loading method based on the application server.

[0041] In a fourth aspect, the present application provides a computer-readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the aforementioned application server-based external class library loading method.

[0042] The present application first configures the external class path attribute of the initial standard deployment description file to obtain the target standard deployment description file, and puts the target standard deployment description file into a preset application; the external class path attribute is the attribute of the absolute path of the external class library directory or the absolute path of the external software package file; the external class library directory includes the external software package file; the preset application is parsed by a class loader to obtain the standard directory class library, the standard software package file class library and the target standard deployment description file of the preset application, and the first preset class library addition strategy is used to sequentially add the standard directory class library and the standard software package file class library to the first preset class path of the class loader; based on the class loader, the target standard deployment description file is parsed by a class loader to obtain the standard directory class library, the standard software package file class library and the target standard deployment description file; The method comprises the steps of: reading to obtain a path value corresponding to an external class path attribute, and storing the path value in an external class path character string; segmenting the external class path character string to obtain external class path elements, and storing the external class path elements in an external class path element array; traversing the external class path elements in the external class path element array, obtaining the external software package file based on a judgment result of whether the traversed external class path element is the external class library directory, and sequentially adding the external software package file to a second preset class path of the class loader by using a second preset adding class library strategy; and loading corresponding target software package files from the first preset class path and the second preset class path by using a preset loading class strategy during the running of the preset application.

[0043] As can be seen from the above, the present application puts the target standard deployment description file including the external class library directory into the preset application, and then uses the class loader to parse the preset application to obtain the path value corresponding to the external class path attribute, and stores the path value into the external class path string, divides the external class path string to obtain the external class path element, and stores the external class path element into the external class path element array; then traverses the external class path element in the external class path element array, and obtains the external software package file based on the judgment result of whether the traversed external class path element is the external class library directory, and adds the external software package file to the second preset class path of the class loader in sequence. In this way, the corresponding target software package file can be loaded based on the second preset class path during the running process of the preset application, and there is no need to configure the absolute path of the external software package file under the external class library directory in sequence, which enhances the availability of the application server, makes the subsequent operation and maintenance of the application server and WEB application simple and easy, and reduces the workload of developers and operation and maintenance personnel. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the embodiments of the present invention 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.

[0045] Figure 1 A flow chart of an external class library loading method based on an application server disclosed in this application;

[0046] Figure 2 A specific flow chart of an external class library loading method based on an application server provided in this application;

[0047] Figure 3 This is a schematic diagram of the structure of an external class library loading device based on an application server disclosed in this application;

[0048] Figure 4 This is a structural diagram of an electronic device disclosed in this application. DETAILED DESCRIPTION

[0049] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. 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 creative work are within the scope of protection of the present invention.

[0050] At present, in order to reduce the workload of developers and operation and maintenance personnel and facilitate the management of configuration files, all jar files required by WEB applications are placed in the standard jar file class library, and the structure of the WEB application is adjusted, which increases the size of the WEB application and makes the operation and maintenance work very difficult, cumbersome, and redundant. To this end, the present application provides an external class library loading method based on an application server, which avoids the increase in operation and maintenance workload and cumbersome configuration file operations caused by placing some jar files of the WEB application in an external directory.

[0051] See also Figure 1 As shown, the embodiment of the present invention discloses a method for loading an external class library based on an application server, comprising:

[0052] Step S11, configuring the external class path attribute of the initial standard deployment description file to obtain a target standard deployment description file, and placing the target standard deployment description file into a preset application; the external class path attribute is an attribute of an absolute path of an external class library directory or an absolute path of an external software package file; the external class library directory includes the external software package file.

[0053] In this embodiment, a class loading tag is added to the initial standard deployment description file, and the attribute of the absolute path of the external class library directory or the attribute of the absolute path of the external software package file is configured in the class loading tag to obtain a target class loading tag, and the target class loading tag is added to the initial standard deployment description file to obtain a target standard deployment description file, and the target standard deployment description file is placed in a preset application. Specifically, the configuration of the external class path attribute of the initial standard deployment description file to obtain a target standard deployment description file and placing the target standard deployment description file in the preset application includes: configuring the absolute path of the external class library directory or the absolute path of the external software package file through the class loading tag to obtain a configured target class loading tag, and adding the target class loading tag to the initial standard deployment description file to obtain a target standard deployment description file; placing the target standard deployment description file in a standard folder of the preset application.

[0054] In a specific implementation, the external class path attribute extra-class-path is configured in the class loading tag, and the absolute path of the external class library directory or the absolute path of the external jar file is configured based on the external class path attribute, and multiple directory paths or multiple jar file paths are separated by semicolons. Some jar files of the WEB application are placed in the / opt / extraRepository directory, which can be configured as follows: <class-loader extra-class-path=" / opt / extraRepository" / >;Put the configured inforsuite-web.xml (i.e. the target standard deployment description file) into the WEB-INF (i.e. the standard folder) directory of the WEB application (i.e. the preset application).

[0055] Step S12: parse the preset application using a class loader to obtain a standard directory class library, a standard software package file class library, and the target standard deployment description file of the preset application, and sequentially add the standard directory class library and the standard software package file class library to the first preset class path of the class loader using a first preset class library addition strategy.

[0056] In this embodiment, the class loader created by the application server is used to parse the preset application to obtain the standard directory class library, standard software package file class library and the target standard deployment description file of the preset application, and the standard directory class library is placed in the file array, and the standard software package file class library is placed in the software package file array. Specifically, the class loader is used to parse the preset application to obtain the standard directory class library, standard software package file class library and the target standard deployment description file of the preset application, including: deploying the preset application to the application server, and using the application server to create a class loader corresponding to the preset application; parsing the preset application based on the class loader to obtain the standard directory class library, standard software package file class library and the target standard deployment description file of the preset application; and storing the standard directory class library and the standard software package file class library in the file array and the software package file array respectively.

[0057] It is understandable that when deploying a configured WEB application to an application server, at the very beginning of the deployment, the application server will first create a corresponding WebappClassLoader (i.e., class loader) for this WEB application. The WebappClassLoader will first parse the deployed application and read the standard directory class library and standard jar file class library (i.e., standard package file class library) of the WEB application. Among them, the standard directory class library of the WEB application (usually only one, i.e., the WEB-INF / classes directory) is stored in the file array; the standard jar file class library of the WEB application is stored in the jar file array, and then by calling the add class library method of the WebappClassLoader, the standard directory class library and the standard jar file class library are added to the class path of the WebappClassLoader in turn.

[0058] Step S13: Read the target standard deployment description file based on the class loader to obtain a path value corresponding to an external class path attribute, and store the path value into an external class path character string.

[0059] In this embodiment, the target standard deployment description file is parsed by the class loader of the application server to obtain the class loading tag, and the class loading tag is read to obtain the path value corresponding to the external class path attribute, and the path value is stored in the external class path string. In a specific implementation, after the application server reads the standard directory class library and the standard jar file class library, WebappClassLoader parses the inforsuite-web.xml file to read the class loading tag, reads the value of the external class path configured by the extra-class-path attribute, and stores it in the external class path string.

[0060] Step S14: Segment the external class path character string to obtain external class path elements, and store the external class path elements into an external class path element array.

[0061] In this embodiment, the external class path string is segmented with semicolons using the preset string segmentation strategy of the software development kit to obtain external class path elements, and the external class path elements are stored in the external class path element array. Specifically, the segmentation of the external class path string to obtain external class path elements and the storage of the external class path elements in the external class path element array includes: using the preset string segmentation strategy of the software development kit and segmenting the external class path string according to the preset string segmentation rules to obtain corresponding external class path elements; storing the external class path elements in the external class path element array.

[0062] It is understandable that after obtaining the external class path string, the string splitting method of JDK (Software Development Kit) can be called to split the external class path string into multiple external class path elements with semicolons, and store the external class path elements in the external class path element array. At this point, the external class path configured by the extra-class-path attribute has been fully parsed and stored in the external class path element array.

[0063] Step S15: traverse the external class path elements in the external class path element array, obtain the external software package file based on a judgment result of whether the traversed external class path element is the external class library directory, and use the second preset class library addition strategy to sequentially add the external software package files to the second preset class path of the class loader.

[0064] In this embodiment, the external class path elements in the external class path element array are traversed, and a preset directory judgment method of the file class is used to judge whether the traversed external class path element is the external class library directory, so as to obtain the external software package file based on the judgment result, and the external software package file is sequentially added to the second preset class path of the class loader by using the second preset class library addition strategy. Specifically, traversing the external class path elements in the external class path element array, obtaining the external software package file based on a judgment result of whether the traversed external class path element is the external class library directory, and sequentially adding the external software package file to the second preset class path of the class loader using a second preset adding class library strategy includes: traversing the external class path elements in the external class path element array using a preset loop traversal strategy; creating a corresponding file class using a preset keyword, and judging whether the traversed external class path element is the external class library directory using a preset directory judgment method of the file class; obtaining the external software package file based on the judgment result, and sequentially adding the external software package file to the second preset class path of the class loader using the second preset adding class library strategy.

[0065] It can be understood that the JDK loop traversal method can be used to traverse all external class path elements in the external class path element array, and for each external class path element, the new keyword is first used to create a JDK file class, and then the directory judgment method of the file class is called to determine whether the traversed external class path element is the external class library directory, and the external software package files obtained based on the judgment result are added to the second preset class path of the class loader in sequence.

[0066] Furthermore, it is determined whether the traversed external class path element is the external class library directory through the preset directory judgment method of the file class; if the external class path element is the external class library directory, the external class library directory is read to obtain the external software package file; if the external class path element is not the external class library directory, the external class path element is determined to be the external software package file, and the obtained external software package file is added to the second preset class path of the class loader. Specifically, the obtaining the external software package file based on the judgment result, and sequentially adding the external software package file to the second preset class path of the class loader by using the second preset adding class library strategy, includes: if the external class path element is the external class library directory, reading files from the external class library directory based on the preset listing file strategy to obtain each of the external software package files, traversing each of the external software package files and adding the external software package file to the second preset class path of the class loader by using the adding class library method of the class loader; if the external class path element is not the external class library directory, determining the external class path element as the external software package file, and adding the external software package file to the second preset class path of the class loader by using the adding class library method of the class loader.

[0067] It can be further understood that, it is determined whether the external class path element is the external class library directory. If the external class path element is the external class library directory, the list file method of the file class is called to read all external jar files under the external class library directory, and then all external jar files are looped through, and all external jar files are added to the class path of WebappClassLoader in turn by calling the add class library method of WebappClassLoader; if the external class path element is not the external class library directory, that is, it is an external jar file, the add class library method of WebappClassLoader is directly called to add the external jar file directly to the class path of WebappClassLoader.

[0068] Step S16: During the running of the preset application, the corresponding target software package file is loaded from the first preset class path and the second preset class path by using a preset loading class strategy.

[0069] In this embodiment, during the running of the preset application, the corresponding target software package files are loaded from the first preset class path and the second preset class path by calling the load class method of the class loader. Specifically, during the running of the preset application, the corresponding target software package files are loaded from the first preset class path and the second preset class path by using the preset load class strategy, including: during the running of the preset application, by calling the load class method of the class loader, the corresponding target software package files are loaded from the standard directory class library in the first preset class path, the standard software package file class library and the external software package file in the second preset class path in sequence.

[0070] It is understandable that during the operation of a WEB application, the class loading method of WebappClassLoader is called to search for class files from the class path, that is, to search for required class files from the standard directory class library, the standard jar file class library, and the external class library in sequence. The external class library includes all external software package files.

[0071] As can be seen from the above, the present application puts the target standard deployment description file including the external class library directory into the preset application, and then uses the class loader to parse the preset application to obtain the path value corresponding to the external class path attribute, and stores the path value into the external class path string, divides the external class path string to obtain the external class path element, and stores the external class path element into the external class path element array; then traverses the external class path element in the external class path element array, and obtains the external software package file based on the judgment result of whether the traversed external class path element is the external class library directory, and adds the external software package file to the second preset class path of the class loader in sequence. In this way, the corresponding target software package file can be loaded based on the second preset class path during the running process of the preset application, and there is no need to configure the absolute path of the external software package file under the external class library directory in sequence, which enhances the availability of the application server, makes the subsequent operation and maintenance of the application server and WEB application simple and easy, and reduces the workload of developers and operation and maintenance personnel.

[0072] It can be seen from the above embodiments that the present application realizes the search for external class files based on the configured target standard deployment description file and the created class loader. Therefore, the process of searching for class files from an external class library based on the target standard deployment description file and the class loader is described.

[0073] Figure 2 A specific external class library loading method based on an application server provided in this embodiment includes:

[0074] First, the initial standard deployment description file is configured to obtain the target standard deployment description file. Specifically, a class loading tag is added to the initial standard deployment description file, and the external class path attribute is configured based on the class loading tag, that is, the path attribute of the absolute path of the external class library directory or the path attribute of the absolute path of the external software package file is configured in the class loading tag to obtain the configured target class loading tag, and the target class loading tag is added to the initial standard deployment description file to obtain the configured target standard deployment description file, and the target standard deployment description file is placed in the preset application. The preset application is deployed to the application server, and a class loader corresponding to the preset application is created based on the application server, and the class loader is used to read the standard class library of the preset application, the standard class library includes a standard directory class library and a standard software package file class library, and the standard directory class library and the standard software package file class library are added to the first preset class path of the class loader.

[0075] Then, the class loader is used to parse the preset application to obtain the target standard deployment description file, and the target standard deployment description file is read to obtain the path value corresponding to the external class path attribute, and the path value is stored in the external class path string, and the external class path string is segmented to obtain the external class path element, and the external class path element is stored in the external class path element array; then, the external class path element in the external class path element array is traversed, and the external software package file is obtained based on the judgment result of whether the traversed external class path element is the external class library directory, and the external software package file is sequentially added to the second preset class path of the class loader. In this way, during the operation of the preset application, the target software package file can be loaded based on the second preset class path without sequentially configuring the absolute path of the external software package file under the external class library directory, which not only enhances the availability of the application server, but also makes the subsequent operation and maintenance of the application server and WEB application simple and easy, thereby reducing the workload of developers and operation and maintenance personnel.

[0076] Accordingly, see Figure 3 As shown, the present application also provides an external class library loading device based on an application server, comprising:

[0077] The target file configuration module 11 is used to configure the external class path attribute of the initial standard deployment description file to obtain a target standard deployment description file, and put the target standard deployment description file into the preset application; the external class path attribute is the attribute of the absolute path of the external class library directory or the absolute path of the external software package file; the external class library directory includes the external software package file;

[0078] The application parsing module 12 is used to parse the preset application using a class loader to obtain a standard directory class library, a standard software package file class library and the target standard deployment description file of the preset application, and sequentially add the standard directory class library and the standard software package file class library to a first preset class path of the class loader using a first preset class library addition strategy;

[0079] A target file reading module 13 is used to read the target standard deployment description file based on the class loader to obtain a path value corresponding to the external class path attribute, and store the path value in an external class path string;

[0080] A string segmentation module 14 is used to segment the external class path string to obtain external class path elements, and store the external class path elements into an external class path element array;

[0081] A path element traversal module 15 is used to traverse the external class path elements in the external class path element array, obtain the external software package file based on the judgment result of whether the traversed external class path element is the external class library directory, and use the second preset class library addition strategy to sequentially add the external software package files to the second preset class path of the class loader;

[0082] The class file loading module 16 is used to load the corresponding target software package file from the first preset class path and the second preset class path according to the preset loading class strategy during the running process of the preset application program.

[0083] As can be seen from the above, the present application puts the target standard deployment description file including the external class library directory into the preset application, and then uses the class loader to parse the preset application to obtain the path value corresponding to the external class path attribute, and stores the path value into the external class path string, divides the external class path string to obtain the external class path element, and stores the external class path element into the external class path element array; then traverses the external class path element in the external class path element array, and obtains the external software package file based on the judgment result of whether the traversed external class path element is the external class library directory, and adds the external software package file to the second preset class path of the class loader in sequence. In this way, the corresponding target software package file can be loaded based on the second preset class path during the running process of the preset application, and there is no need to configure the absolute path of the external software package file under the external class library directory in sequence, which enhances the availability of the application server, makes the subsequent operation and maintenance of the application server and WEB application simple and easy, and reduces the workload of developers and operation and maintenance personnel.

[0084] In some specific implementations, the target file configuration module 11 may specifically include:

[0085] A label configuration unit, configured to configure the absolute path of the external class library directory or the absolute path of the external software package file through the class loading label to obtain a configured target class loading label, and add the target class loading label to an initial standard deployment description file to obtain a target standard deployment description file;

[0086] The file storage unit is used to place the target standard deployment description file into a standard folder of a preset application program.

[0087] In some specific implementations, the application parsing module 12 may specifically include:

[0088] A class loader creation unit, configured to deploy the preset application to an application server, and use the application server to create a class loader corresponding to the preset application;

[0089] A program parsing completion unit, configured to parse the preset application based on the class loader to obtain a standard directory class library, a standard software package file class library and a target standard deployment description file of the preset application;

[0090] The class library storage unit is used to store the standard directory class library and the standard software package file class library into the file array and the software package file array respectively.

[0091] In some specific implementations, the string segmentation module 14 may specifically include:

[0092] A string segmentation completion unit, used to segment the external class path string using a preset string segmentation strategy of the software development kit and according to a preset string segmentation rule to obtain corresponding external class path elements;

[0093] The path element storage unit is used to store the external class path element into the external class path element array.

[0094] In some specific implementations, the path element traversal module 15 may specifically include:

[0095] An element traversal unit, used for traversing the external class path elements in the external class path element array by using a preset loop traversal strategy;

[0096] A directory judgment unit, used to create a corresponding file class using a preset keyword, and judge whether the traversed external class path element is the external class library directory through a preset directory judgment method of the file class;

[0097] The file adding unit is used to obtain the external software package file based on the judgment result, and sequentially add the external software package file to the second preset class path of the class loader by using the second preset class library adding strategy.

[0098] In some specific implementations, the path element traversal module 15 may specifically include:

[0099] A file reading unit is used for, if the external class path element is the external class library directory, reading files from the external class library directory based on a preset file listing strategy to obtain each of the external software package files, traversing each of the external software package files and adding the external software package files to a second preset class path of the class loader by using a class library adding method of the class loader;

[0100] The file determination unit is used to determine the external class path element as the external software package file if the external class path element is not the external class library directory, and add the external software package file to the second preset class path of the class loader by using the class library adding method of the class loader.

[0101] In some specific implementations, the class file loading module 16 may specifically include:

[0102] The file loading unit is used to load the corresponding target software package file from the standard directory class library in the first preset class path, the standard software package file class library and the external software package file in the second preset class path in sequence by calling the loading class method of the class loader during the running of the preset application.

[0103] Furthermore, the present application also discloses an electronic device. Figure 4 It is a structural diagram of an electronic device 20 shown according to an exemplary embodiment, and the content in the figure cannot be regarded as any limitation on the scope of use of this application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input and 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 an external class library loading method based on an application server disclosed in any of the aforementioned embodiments. In addition, the electronic device 20 in this embodiment may specifically be an electronic computer.

[0104] 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.

[0105] In addition, the memory 22 as a carrier for storing resources may be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon may include an operating system 221, a computer program 222, etc., and the storage method may be temporary storage or permanent storage.

[0106] The operating system 221 is used to manage and control the hardware devices and computer program 222 on the electronic device 20, and can be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program that can be used to complete an external class library loading method based on an application server 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.

[0107] Furthermore, the present application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the aforementioned disclosed external class library loading method based on an application server is implemented. The specific steps of the method can refer to the corresponding contents disclosed in the aforementioned embodiment, and will not be repeated here.

[0108] 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.

[0109] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in 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 the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians 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.

[0110] 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 CD-ROM, or any other form of storage medium known in the art.

[0111] 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 "include", "comprise" 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, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0112] The technical solution provided by the present application is introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for general technicians in this field, according to the idea of ​​the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A method for loading an external class library based on an application server, characterized in that: include: Performing external class path attribute configuration on the initial standard deployment description file to obtain a target standard deployment description file, and placing the target standard deployment description file into a preset application; The external class path attribute is an attribute of an absolute path of an external class library directory or an absolute path of an external software package file; the external class library directory includes the external software package file; Parsing the preset application using a class loader to obtain a standard directory class library, a standard software package file class library, and the target standard deployment description file of the preset application, and sequentially adding the standard directory class library and the standard software package file class library to a first preset class path of the class loader using a first preset class library addition strategy; Reading the target standard deployment description file based on the class loader to obtain a path value corresponding to an external class path attribute, and storing the path value in an external class path string; Splitting the external class path character string to obtain external class path elements, and storing the external class path elements into an external class path element array; Traversing the external class path elements in the external class path element array, obtaining the external software package file based on a judgment result of whether the traversed external class path element is the external class library directory, and sequentially adding the external software package files to the second preset class path of the class loader using a second preset class library adding strategy; During the running of the preset application, the corresponding target software package file is loaded from the first preset class path and the second preset class path through the preset loading class strategy.

2. The external class library loading method based on the application server according to claim 1 is characterized in that: The external class path attribute configuration of the initial standard deployment description file to obtain a target standard deployment description file, and placing the target standard deployment description file into a preset application program includes: Configure the absolute path of the external class library directory or the absolute path of the external software package file through the class loading tag to obtain a configured target class loading tag, and add the target class loading tag to the initial standard deployment description file to obtain a target standard deployment description file; Place the target standard deployment descriptor file into the standard folder of the preset application.

3. The external class library loading method based on the application server according to claim 1 is characterized in that: The method of parsing the preset application using a class loader to obtain a standard directory class library, a standard software package file class library and a target standard deployment description file of the preset application includes: Deploy the preset application to an application server, and use the application server to create a class loader corresponding to the preset application; Parsing the preset application based on the class loader to obtain a standard directory class library, a standard software package file class library and the target standard deployment description file of the preset application; The standard directory class library and the standard software package file class library are stored in the file array and the software package file array respectively.

4. The external class library loading method based on the application server according to claim 1 is characterized in that: The step of segmenting the external class path character string to obtain external class path elements and storing the external class path elements into an external class path element array includes: Using a preset string segmentation strategy of a software development kit and according to a preset string segmentation rule, the external class path string is segmented to obtain corresponding external class path elements; The external class path element is stored in an external class path element array.

5. The external class library loading method based on the application server according to claim 1 is characterized in that: The traversing the external class path elements in the external class path element array, obtaining the external software package file based on a judgment result of whether the traversed external class path element is the external class library directory, and sequentially adding the external software package files to the second preset class path of the class loader using a second preset class library adding strategy, includes: Traversing the external class path elements in the external class path element array by using a preset loop traversal strategy; Create a corresponding file class using a preset keyword, and determine whether the traversed external class path element is the external class library directory through a preset directory determination method of the file class; The external software package file is obtained based on the judgment result, and the external software package file is sequentially added to the second preset class path of the class loader using the second preset class library addition strategy.

6. The external class library loading method based on the application server according to claim 5 is characterized in that: The step of obtaining the external software package file based on the judgment result and sequentially adding the external software package file to the second preset class path of the class loader using the second preset class library adding strategy includes: If the external class path element is the external class library directory, then based on a preset file listing strategy, files are read from the external class library directory to obtain each of the external software package files, each of the external software package files is traversed and the external software package files are added to the second preset class path of the class loader by using the class loader's adding class library method; If the external class path element is not the external class library directory, the external class path element is determined to be the external software package file, and the external software package file is added to the second preset class path of the class loader using the class library adding method of the class loader.

7. The external class library loading method based on the application server according to any one of claims 1 to 6, characterized in that: The method of loading the corresponding target software package file from the first preset class path and the second preset class path by using a preset loading class strategy during the running of the preset application program includes: During the running of the preset application, the corresponding target software package file is loaded from the standard directory class library in the first preset class path, the standard software package file class library and the external software package file in the second preset class path in sequence by calling the load class method of the class loader.

8. An external class library loading device based on an application server, characterized in that: include: A target file configuration module is used to configure the external class path attribute of the initial standard deployment description file to obtain a target standard deployment description file, and put the target standard deployment description file into a preset application; The external class path attribute is an attribute of an absolute path of an external class library directory or an absolute path of an external software package file; the external class library directory includes the external software package file; an application parsing module, configured to parse the preset application using a class loader to obtain a standard directory class library, a standard software package file class library, and the target standard deployment description file of the preset application, and sequentially add the standard directory class library and the standard software package file class library to a first preset class path of the class loader using a first preset class library addition strategy; A target file reading module, used for reading the target standard deployment description file based on the class loader to obtain a path value corresponding to the external class path attribute, and storing the path value in an external class path string; A string segmentation module, used for segmenting the external class path string to obtain external class path elements, and storing the external class path elements into an external class path element array; a path element traversal module, configured to traverse the external class path elements in the external class path element array, obtain the external software package file based on a judgment result of whether the traversed external class path element is the external class library directory, and sequentially add the external software package files to the second preset class path of the class loader using a second preset class library addition strategy; The class file loading module is used to load the corresponding target software package file from the first preset class path and the second preset class path through a preset loading class strategy during the running process of the preset application program.

9. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor is used to execute the computer program to implement the external class library loading method based on the application server as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: Used to store a computer program, wherein when the computer program is executed by a processor, the external class library loading method based on an application server as described in any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Method and device for introducing external database into HTML5 application

    CN103473311A

  • Method for configuring spring data source through property file in dynamic path

    CN104021000A

  • External class loading method and device, medium, equipment and program product

    CN113377456A

  • Class loading method and device in page compiling stage, equipment and storage medium

    CN118192984A

  • Method for packaging driver kernel module, electronic device and storage medium

    US20240168768A1