Application server-based external class library loading method, device, equipment and medium

By configuring external classpath attributes and parsing the class loader in the initial standard deployment description file, and splitting and traversing the external classpath elements, the problem of increased maintenance workload and cumbersome configuration file operations caused by placing JAR files in external directories in web applications is solved, thus achieving simplified maintenance and ease of use of application servers.

CN119557013BActive Publication Date: 2025-11-07SHANDONG CVICSE MIDDLEWARE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

In existing technologies, all JAR files of a web application are moved to a standard JAR file library, which makes the subsequent operation and maintenance of the application server and web application difficult and cumbersome, and increases the workload of operation and maintenance and the complexity of configuration file operations.

Method used

By configuring the external classpath attribute in the initial standard deployment description file, the class loader parses the preset application, segments and traverses the external classpath elements, and adds the external package files to the preset classpath of the class loader in turn, thereby loading the external class library.

Benefits of technology

It reduces the workload of developers and operations personnel, simplifies the operation and maintenance of application servers and web applications, and makes them more available and easier to implement.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119557013B_ABST
    Figure CN119557013B_ABST
Patent Text Reader

Abstract

The application discloses an application server-based external class library loading method and device, equipment and medium, and relates to the technical field of Internet, which 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 an attribute of an absolute path of an external class library directory or an external software package file; the external class library directory comprises the external software package file; the preset application program is parsed, and a standard directory class library and a standard software package file class library obtained are added to a first preset class path; the target standard deployment description file is read, and an external class path string is segmented; each external class path element is traversed, and external software package files are sequentially added to a second preset class path based on a judgment result of whether the external class path element is an external class library directory, so as to load a target software package file. The operation and maintenance work becomes simple and easy.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

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

[0002] At present, in order to facilitate the deployment and adaptation of WEB application (a kind of software application program), reduce the workload of developers and operation and maintenance personnel, facilitate the management of configuration files, it is necessary to temporarily move all external jar (a kind of software package file format) files to WEB application standard jar file library, that is, all jar files required by WEB application are placed in standard jar file library, in this way, the structure of WEB application is adjusted, the size of WEB application is increased, which is not convenient for the subsequent operation and maintenance of application server and WEB application, and makes the operation and maintenance work very difficult, tedious and redundant.

[0003] From the above, how to avoid the increase of operation and maintenance workload and the tedious operation of configuration file caused by placing part of the jar files of WEB application in an external directory is a problem to be solved at present. SUMMARY

[0004] Therefore, the purpose of the present application is to provide an external class library loading method and device based on an application server, which can avoid the increase of operation and maintenance workload and the tedious operation of configuration file caused by placing part of the jar files of WEB application in an external directory. 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] An initial standard deployment description file is configured with an external class path attribute to obtain a target standard deployment description file, and the target standard deployment description file is placed in a preset application program; 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] A class loader is used to parse the preset application program to obtain a standard directory class library, a standard software package file library and the target standard deployment description file of the preset application program, and a first preset adding class library strategy is used to add the standard directory class library and the standard software package file library to a first preset class path of the class loader in sequence;

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

[0009] splitting the external class path string to obtain an external class path element, and storing the external class path element 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 adding the external software package file to a second preset class path of the class loader in sequence by using a second preset class library adding strategy;

[0011] In the preset application running process, a corresponding target software package file is loaded from the first preset class path and the second preset class path by using a preset class loading strategy.

[0012] Optionally, the initial standard deployment description file is configured with an external class path attribute to obtain a target standard deployment description file, and the target standard deployment description file is placed into a preset application, which comprises:

[0013] The absolute path of the external class library directory or the absolute path of the external software package file is configured by using the class loading tag to obtain a configured target class loading tag, and the target class loading tag is added to the initial standard deployment description file to obtain the target standard deployment description file.

[0014] The target standard deployment description file is placed into a standard folder of the preset application.

[0015] Optionally, the preset application is parsed by using the 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, which comprises:

[0016] The preset application is deployed to an application server, and the class loader corresponding to the preset application is created by using the application server;

[0017] The preset application is parsed based on the 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;

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

[0019] Optionally, the external class path string is split to obtain an external class path element, and the external class path element is stored into an external class path element array, which comprises:

[0020] The external class path string is segmented according to a preset string segmentation policy of a software development kit to obtain corresponding external class path elements.

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

[0022] Optionally, the external class path elements in the external class path element array are iterated, and the external software package files are obtained based on a judgment result of whether the iterated external class path elements are the external class library directories, and the external software package files are sequentially added to a second preset class path of the class loader by using a second preset class library adding policy, including:

[0023] The external class path elements in the external class path element array are iterated by using a preset loop iteration policy.

[0024] A corresponding file class is created by using a preset keyword, and a preset directory judgment mode of the file class is used to judge whether the iterated external class path elements are the external class library directories.

[0025] The external software package files are obtained based on the judgment result, and the external software package files are sequentially added to the second preset class path of the class loader by using the second preset class library adding policy.

[0026] Optionally, the external software package files are obtained based on the judgment result, and the external software package files are sequentially added to the second preset class path of the class loader by using the second preset class library adding policy, including:

[0027] If the external class path element is the external class library directory, file reading is performed from the external class library directory based on a preset file listing policy to obtain each external software package file, each external software package file is iterated, and the external software package file is added to the second preset class path of the class loader by using an adding class library mode of the class loader.

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

[0029] Optionally, during the preset application program running process, corresponding target software package files are loaded from the first preset class path and the second preset class path by using a preset class loading policy, including:

[0030] In a running process of the preset application, a loading class method of the class loader is called to load corresponding target software package files from the standard directory class library, the standard software package file library and the external software package file in the second preset class path in sequence.

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

[0032] A target file configuration module is configured to configure an external class path attribute of an 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 comprises the external software package file;

[0033] An application program parsing module is configured to parse the preset application by using a class loader to obtain a standard directory class library, a standard software package file library and the target standard deployment description file of the preset application, and add the standard directory class library and the standard software package file library to a first preset class path of the class loader in sequence by using a first preset class library adding strategy;

[0034] A target file reading module is configured 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 to an external class path string;

[0035] A string segmentation module is configured to segment the external class path string to obtain an external class path element, and store the external class path element to an external class path element array;

[0036] A path element traversal module is configured to traverse the external class path element 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 add the external software package file to a second preset class path of the class loader in sequence by using a second preset class library adding strategy;

[0037] A class file loading module is configured to load corresponding target software package files from the first preset class path and the second preset class path in a running process of the preset application by using a preset loading class strategy.

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

[0039] A memory is configured to save a computer program;

[0040] a processor for executing the computer program to implement the foregoing application server-based external class library loading method.

[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 foregoing application server-based external class library loading method.

[0042] The application first configures an external class path attribute to an initial standard deployment description file to obtain a target standard deployment description file, and puts 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; a class loader is used 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, and a first preset adding class library strategy is used to add the standard directory class library and the standard software package file class library to a first preset class path of the class loader in sequence; the target standard deployment description file is read based on the class loader to obtain a path value corresponding to the external class path attribute, and the path value is stored to an external class path string; the external class path string is segmented to obtain an external class path element, and the external class path element is stored to an external class path element array; the external class path elements in the external class path element array are traversed, the external software package file is obtained based on a judgment result of whether the traversed external class path element is the external class library directory, and a second preset adding class library strategy is used to add the external software package file to a second preset class path of the class loader in sequence; in a running process of the preset application, a preset loading class strategy is used to load a corresponding target software package file from the first preset class path and the second preset class path.

[0043] From the above, the application puts the target standard deployment description file including the external class library directory into a preset application, then parses the preset application by using a class loader to obtain a path value corresponding to the external class path attribute, stores the path value into an external class path string, splits the external class path string to obtain an external class path element, and stores the external class path element into an external class path element array; then traverses the external class path element in the external class path element array, 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 into a 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 the absolute path of the external software package file under the external class library directory does not need to be configured in sequence, thereby enhancing the usability of the application server, making the subsequent operation and maintenance of the application server and the WEB application simple and easy to implement, and reducing the workload of the developers and the operation and maintenance personnel. BRIEF DESCRIPTION OF DRAWINGS

[0044] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or the prior art description. Obviously, the drawings in the following description only constitute a part of the embodiments of the present application, and for those skilled in the art, other drawings can be obtained without creative labor based on the provided drawings.

[0045] Figure 1 A flow chart of an external class library loading method based on an application server is disclosed in the present application.

[0046] Figure 2 A flow chart of a specific external class library loading method based on an application server is provided in the present application.

[0047] Figure 3 A structural schematic diagram of an external class library loading device based on an application server is disclosed in the present application.

[0048] Figure 4 A structural diagram of an electronic device is disclosed in the present application. DETAILED DESCRIPTION

[0049] The technical solutions in the embodiments of the present application will be described clearly and completely in the following with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments only constitute a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the protection scope of the present application.

[0050] At present, in order to reduce the workload of developers and operation and maintenance personnel, facilitate the management of configuration files, all jar files required by the WEB application are placed in the standard jar file library, the structure of the WEB application is adjusted, the size of the WEB application is increased, and the operation and maintenance work becomes very difficult, tedious and redundant. Therefore, the application provides an external class library loading method based on an application server, avoids placing part of the jar files of the WEB application in an external directory, and increases the operation and maintenance workload and the tedious configuration file operation.

[0051] Referring to Figure 1 The embodiment of the application discloses an external class library loading method based on an application server, which comprises the following steps:

[0052] In step S11, the initial standard deployment description file is configured with an external class path attribute to obtain a target standard deployment description file, and the target standard deployment description file is placed in a preset application program; 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 comprises the external software package file.

[0053] In this embodiment, a class loading tag is added to the initial standard deployment description file, and an attribute of an absolute path of an external class library directory or an attribute of an absolute path of an external software package file is configured in the class loading tag to obtain a target class loading tag, 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 program. Specifically, the initial standard deployment description file is configured with an external class path attribute to obtain a target standard deployment description file, and the target standard deployment description file is placed in a preset application program, comprising: 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; and placing the target standard deployment description file in a standard folder of the preset application program.

[0054] In a specific embodiment, the external class path attribute extra-class-path is configured in the class loading tag, 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. Part of the jar files of the WEB application is placed in the / opt / extraRepository directory, and can be configured as follows: <class-loader extra-class-path=" / opt / extraRepository" / >; and placing the configured inforsuite-web.xml (i.e. target standard deployment description file) into the WEB-INF (i.e. standard folder) directory of the WEB application (i.e. preset application).

[0055] In step S12, the preset application is parsed by using the class loader to obtain the standard directory class library, the standard software package file library and the target standard deployment description file of the preset application, and the standard directory class library and the standard software package file library are added to the first preset class path of the class loader in sequence by using the first preset adding class library strategy.

[0056] In the embodiment, the preset application is parsed by using the class loader created by the application server to obtain the standard directory class library, the standard software package file library and the target standard deployment description file of the preset application, and the standard directory class library is placed into the file array and the standard software package file library is placed into the software package file array. Specifically, the preset application is deployed to the application server, and the class loader corresponding to the preset application is created by using the application server; the preset application is parsed based on the class loader to obtain the standard directory class library, the standard software package file library and the target standard deployment description file of the preset application; and the standard directory class library and the standard software package file library are respectively stored into the file array and the software package file array.

[0057] It can be understood that the configured WEB application is deployed to the application server, and at the beginning of the deployment, the application server first creates the corresponding WebappClassLoader (i.e. class loader) for the WEB application. The WebappClassLoader first parses the deployed application, reads the standard directory class library and the standard jar file library (i.e. standard software package file library) of the WEB application. The standard directory class library (generally only one, i.e. WEB-INF / classes directory) of the WEB application is stored in the file array; the standard jar file library of the WEB application is stored in the jar file array, and then the standard directory class library and the standard jar file library are added to the class path of the WebappClassLoader in sequence by calling the adding class library method of the WebappClassLoader.

[0058] Step S13, 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 into an external class path string.

[0059] In this embodiment, the class loader of the application server parses the target standard deployment description file to obtain the class loading tag, reads the class loading tag to obtain a path value corresponding to an external class path attribute, and stores the path value into an 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, the 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, splitting the external class path string to obtain an external class path element, and storing the external class path element into an external class path element array.

[0061] In this embodiment, the external class path string is split by a semicolon using a preset string splitting strategy of a software development kit to obtain an external class path element, and the external class path element is stored into an external class path element array. Specifically, the splitting of the external class path string to obtain an external class path element and storing the external class path element into an external class path element array includes: splitting the external class path string using a preset string splitting strategy of a software development kit according to a preset string splitting rule to obtain a corresponding external class path element; and storing the external class path element into an external class path element array.

[0062] It can be understood that after obtaining the external class path string, a string splitting method of a JDK (i.e., a software development kit) can be called to split the external class path string into multiple external class path elements by a semicolon, and the external class path elements are stored in an external class path element array. At this point, the external class path configured by the extra-class-path attribute has been completely parsed and stored in the external class path element array.

[0063] Step S15, traversing the external class path elements in the external class path element array, obtaining 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 adding the external software package file to a second preset class path of the class loader in sequence using a second preset class library adding strategy.

[0064] In the embodiment, the external class path elements in the external class path element array are traversed, and it is determined whether the traversed external class path element is the external class library directory by using a preset directory judgment method of a file class, so as to obtain the external software package file based on the determination result, and the external software package file is sequentially added to the second preset class path of the class loader by using a second preset class library adding strategy. Specifically, the traversal of the external class path elements in the external class path element array, the obtaining of the external software package file based on the determination result of whether the traversed external class path element is the external class library directory, and the sequential addition of the external software package file to the second preset class path of the class loader by using the second preset class library adding strategy include: the external class path elements in the external class path element array are traversed by using a preset loop traversal strategy; it is determined whether the traversed external class path element is the external class library directory by using a preset directory judgment method of a file class; the external software package file is obtained based on the determination result, and the external software package file is sequentially added to the second preset class path of the class loader by using a second preset class library adding strategy.

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

[0066] Further, it is judged whether the external class path element is the external class library directory through the preset directory judgment mode of the file type. If the external class path element is the external class library directory, the external software package file is obtained by reading the external class library directory. If the external class path element is not the external class library directory, the external class path element is determined as 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 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 by using the second preset adding class library strategy. If the external class path element is the external class library directory, the file reading is performed from the external class library directory based on a preset file listing strategy to obtain each external software package file. Each external software package file is traversed and added to the second preset class path of the class loader by using the adding class library mode of the class loader. If the external class path element is not the external class library directory, the external class path element is determined as the external software package file, and the external software package file is added to the second preset class path of the class loader by using the adding class library mode of the class loader.

[0067] It can be further understood that it is judged 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 file listing method of the file type is called to read all external jar files under the external class library directory, and then all external jar files are traversed and added to the class path of the WebappClassLoader by calling the adding class library method of the WebappClassLoader. If the external class path element is not the external class library directory, i.e., the external jar file, the adding class library method of the WebappClassLoader is directly called to add the external jar file to the class path of the WebappClassLoader.

[0068] In step S16, 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 during the running of the preset application program.

[0069] In the embodiment, 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 calling the class loading method of the class loader. Specifically, 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 a preset class loading strategy, including: 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 library and the external software package file in the second preset class path by calling the class loading method of the class loader.

[0070] It can be understood that during the running of the WEB application, the class file is searched from the class path by calling the class loading method of the WebappClassLoader, that is, the required class file is searched from the standard directory class library, the standard jar file 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 target standard deployment description file including the external class library directory is put into the preset application, and then the preset application is parsed by using the class loader to obtain the path value corresponding to the external class path attribute, and the path value is stored to the external class path string. The external class path string is segmented to obtain the external class path element, and the external class path element is stored to the external class path element array. Then, the external class path elements in the external class path element array are 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. The external software package file is sequentially added to the second preset class path of the class loader. In this way, during the running of the preset application, the corresponding target software package file can be loaded based on the second preset class path, without the need to sequentially configure the absolute paths of the external software package files under the external class library directory, thereby enhancing the usability of the application server, making the subsequent operation and maintenance of the application server and the WEB application simple and easy to implement, and reducing the workload of the developers and the operation and maintenance personnel.

[0072] As can be seen from the above embodiment, the target standard deployment description file and the created class loader are configured to implement the search of the external class file, and therefore, the process of searching the class file from the 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 for the embodiment includes:

[0074] First, the initial standard deployment description file is configured to obtain a target standard deployment description file. Specifically, a class loading tag is added in the initial standard deployment description file, and an external class path attribute is configured based on the class loading tag, that is, a path attribute of an absolute path of an external class library directory or a path attribute of an absolute path of an external software package file is configured in the class loading tag to obtain a target class loading tag. The target class loading tag is added to the initial standard deployment description file to obtain a configured target standard deployment description file, and the target standard deployment description file is put into a preset application. The preset application is deployed to an application server, and a class loader corresponding to the preset application is created based on the application server. The class loader is used to read a 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 a first preset class path of the class loader.

[0075] Then, the preset application is parsed by the class loader to obtain a target standard deployment description file, a path value corresponding to an external class path attribute is obtained by reading the target standard deployment description file, the path value is stored in an external class path string, the external class path string is segmented to obtain an external class path element, and the external class path element is stored in an external class path element array. Then, the external class path elements in the external class path element array are traversed, and the external software package file is obtained based on a judgment result of whether the traversed external class path element is the external class library directory. The external software package file is sequentially added to a second preset class path of the class loader. In this way, during the running of the preset application, the absolute path of the external software package file under the external class library directory does not need to be sequentially configured, and the target software package file can be loaded based on the second preset class path. This not only enhances the usability of the application server, but also makes the subsequent operation and maintenance of the application server and the WEB application simple and easy, thereby reducing the workload of the developers and the operation and maintenance personnel.

[0076] Correspondingly, referring to Figure 3 The application also provides an external class library loading device based on an application server, which comprises:

[0077] A target file configuration module 11 is configured to configure an external class path attribute of an 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 comprises the external software package file.

[0078] The application program parsing module 12 is configured to parse the preset application program by using the class loader to obtain a standard directory class library, a standard software package file library and the target standard deployment description file of the preset application program, and add the standard directory class library and the standard software package file library to a first preset class path of the class loader in sequence by using a first preset adding class library strategy.

[0079] The target file reading module 13 is configured to 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 to an external class path string.

[0080] The string segmentation module 14 is configured to segment the external class path string to obtain an external class path element, and store the external class path element to an external class path element array.

[0081] The path element traversal module 15 is configured to traverse the external class path element 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 add the external software package file to a second preset class path of the class loader in sequence by using a second preset adding class library strategy.

[0082] The class file loading module 16 is configured to load a 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 running of the preset application program.

[0083] As can be seen from the above, the target standard deployment description file including the external class library directory is put into the preset application program, and then the preset application program is parsed by using the class loader to obtain a path value corresponding to the external class path attribute, and store the path value to an external class path string. The external class path string is segmented to obtain an external class path element, and the external class path element is stored to an 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 a judgment result of whether the traversed external class path element is the external class library directory. The external software package file is added to the second preset class path of the class loader in sequence. In this way, during running of the preset application program, the corresponding target software package file can be loaded based on the second preset class path, without the need to configure the absolute paths of the external software package files under the external class library directory in sequence, thereby enhancing the usability of the application server, making the subsequent operation and maintenance of the application server and the WEB application simple and easy to implement, and reducing the workload of the developers and the operation and maintenance personnel.

[0084] In some embodiments, the target file configuration module 11 can specifically include:

[0085] a label configuration unit, configured to configure an absolute path of the external class library directory or an absolute path of the external software package file by using 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] a file storage unit, configured to store the target standard deployment description file in a standard folder of a preset application program.

[0087] In some embodiments, the application program parsing module 12 can specifically include:

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

[0089] a program parsing completion unit, configured to parse the preset application program 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 program;

[0090] a class library storage unit, configured to respectively store the standard directory class library and the standard software package file class library into a file array and a software package file array.

[0091] In some embodiments, the string segmentation module 14 can specifically include:

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

[0093] a path element storage unit, configured to store the external class path elements into an external class path element array.

[0094] In some embodiments, the path element traversal module 15 can specifically include:

[0095] an element traversal unit, configured to traverse the external class path elements in the external class path element array by using a preset loop traversal strategy;

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

[0097] a file adding unit, configured to obtain the external software package file based on the judgment result, and add the external software package file to the second preset class path of the class loader in sequence by using a second preset adding class library strategy.

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

[0099] a file reading unit, configured to, if the external class path element is the external class library directory, perform file reading from the external class library directory based on a preset listing file strategy to obtain each external software package file, and perform traversal on each external software package file and add the external software package file to the second preset class path of the class loader by using an adding class library manner of the class loader.

[0100] a file determining unit, configured to, if the external class path element is not the external class library directory, determine the external class path element as the external software package file, and add the external software package file to the second preset class path of the class loader by using an adding class library manner of the class loader.

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

[0102] a file loading unit, configured to, in the preset application running process, load a 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 a loading class method of the class loader.

[0103] Further, the application also discloses an electronic device, Figure 4 is an electronic device 20 structure diagram shown according to an exemplary embodiment, the content in the figure cannot be considered as any limitation on the use range of the application. The electronic device 20, specifically can include: at least one processor 21, at least one memory 22, power supply 23, communication interface 24, input output interface 25 and communication bus 26. Wherein, the memory 22 is used for storing computer program, the computer program is loaded and executed by the processor 21, to realize the related steps in the foregoing any embodiment disclosed a kind of based on application server's external class library loading method. In addition, the electronic device 20 in the embodiment specifically can be electronic computer.

[0104] In this embodiment, the power supply 23 is configured to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 is configured to create a data transmission channel between the electronic device 20 and external devices, and the communication protocol followed by the communication interface 24 can be any communication protocol applicable to the technical solution of the present application, which will not be specifically limited herein; the input / output interface 25 is configured to obtain external input data or output data to the outside, and the specific interface type can be selected according to the specific application needs, which will not be specifically limited herein.

[0105] In addition, the memory 22 as a carrier of resource storage can be a read-only memory, a random access memory, a magnetic disk or an optical disk, etc., and the resources stored thereon can include an operating system 221, a computer program 222, etc., and the storage mode can be temporary storage or permanent storage.

[0106] The operating system 221 is configured to manage and control each hardware device on the electronic device 20 and the computer program 222, and can be Windows Server, Netware, Unix, Linux, etc. In addition to the computer program capable of completing the foregoing any embodiment disclosed by the electronic device 20 to execute an application server-based external class library loading method, the computer program 222 can further include a computer program capable of completing other specific work.

[0107] Further, the present application further discloses a computer readable storage medium for storing a computer program; wherein the computer program is executed by a processor to implement the foregoing disclosed application server-based external class library loading method. For the specific steps of the method, please refer to the corresponding content disclosed in the foregoing embodiments, which will not be described here.

[0108] The embodiments in the specification are described in a progressive manner, and each embodiment focuses on the difference from other embodiments. The same or similar parts of each embodiment can be referred to each other. For the device disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple, and the related parts can be referred to the method part.

[0109] The skilled person can further realize that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be realized by electronic hardware, computer software or combination of the two. In order to clearly show the interchangeability of hardware and software, the components and steps of each example have been described in general in the above description. Whether the functions are realized by hardware or software depends on the specific application and design constraints of the technical solution. The skilled person can use different methods to realize the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.

[0110] The steps of a method or algorithm described in connection with the embodiments disclosed herein can be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module can reside in RAM, flash memory, ROM, electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art. The

[0111] Finally, it should be noted that the terms "first", "second", and the like, herein do not denote any order, quantity, combination, or importance, but rather are used to distinguish one element from another, and do not imply or require any such actual relationship or order. Moreover, the terms "include", "contain", or any other variant thereof are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that includes a list of elements does not include only those elements recited, but can also include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without more limitations, an element defined by the phrase "comprising a" does not exclude the existence of additional identical elements in the process, method, article, or apparatus that includes the element.

[0112] The above provides a detailed description of the technical solutions of the present application. The principles and implementation modes of the present application are described by applying specific examples. The above description of the embodiments is only to help understand the method and its core idea of the present application; at the same time, for those skilled in the art, according to the idea of the present application, the specific implementation mode and application range will be changed; in summary, the content of the specification should not be understood as a limitation of the present application.

Claims

1. An application server-based external class library loading method, characterized by, The application comprises the following steps: An initial standard deployment description file is configured with an external class path attribute to obtain a target standard deployment description file, and the target standard deployment description file is put into a preset application program; 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, and the external class library directory comprises the external software package file; A class loader is used to parse the preset application program 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 program, and a first preset class library adding strategy is used to add the standard directory class library and the standard software package file class library to a first preset class path of the class loader in sequence; The target standard deployment description file is read based on the class loader to obtain a path value corresponding to the external class path attribute, and the path value is stored in an external class path string; The external class path string is segmented to obtain an external class path element, and the external class path element is stored in an external class path element array; The external class path elements in the external class path element array are traversed, and the external software package file is obtained based on a judgment result of whether the traversed external class path element is the external class library directory, and a second preset class library adding strategy is used to add the external software package file to a second preset class path of the class loader in sequence; During running of the preset application program, a preset class loading strategy is used to load corresponding target software package files from the first preset class path and the second preset class path.

2. The application server based external class library loading method according to claim 1, wherein, The application comprises the following steps: An absolute path of the external class library directory or an absolute path of the external software package file is configured by using a class loading tag to obtain a configured target class loading tag, the target class loading tag is added to an initial standard deployment description file to obtain a target standard deployment description file, and the target standard deployment description file is put into a standard folder of a preset application program. The application comprises the following steps:

3. The application server based foreign class library loading method according to claim 1, wherein, The preset application program is deployed to an application server, and a class loader corresponding to the preset application program is created by using the application server; The preset application program is parsed 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 program; The standard directory class library and the standard software package file class library are respectively stored in a file array and a software package file array. The application comprises the following steps:

4. The application server based foreign class library loading method according to claim 1, wherein, ​ The external class path string is segmented according to a preset string segmentation strategy of a software development kit to obtain corresponding external class path elements; The external class path elements are stored in an external class path element array.

5. The application server based foreign class library loading method according to claim 1, wherein, The external class path elements in the external class path element array are traversed, and the external software package files are obtained based on a judgment result of whether the traversed external class path elements are the external class library directories, and the external software package files are sequentially added to the second preset class path of the class loader by using a second preset class library adding strategy, including: The external class path elements in the external class path element array are traversed by using a preset loop traversal strategy; A corresponding file class is created by using a preset keyword, and it is judged by using a preset directory judgment method of the file class whether the traversed external class path elements are the external class library directories; The external software package files are obtained based on the judgment result, and the external software package files are sequentially added to the second preset class path of the class loader by using a second preset class library adding strategy.

6. The application server based external class library loading method according to claim 5, wherein, The external class path elements in the external class path element array are traversed by using a preset loop traversal strategy; If the external class path element is the external class library directory, file reading is performed from the external class library directory based on a preset file listing strategy to obtain each external software package file, each external software package file is traversed, and the external software package file is added to the second preset class path of the class loader by using a class library adding method of the class loader; If the external class path element is not the external class library directory, the external class path element is determined as the external software package file, and the external software package file is added to the second preset class path of the class loader by using a class library adding method of the class loader.

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

8. An external class library loading device based on an application server, characterized in that, Including: A target file configuration module is configured to configure an external class path attribute of an initial standard deployment description file to obtain a target standard deployment description file, and to 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; and the external class library directory includes the external software package file. The application program parsing module is configured to parse the preset application program by using the class loader to obtain a standard directory class library, a standard software package file library, and the target standard deployment description file of the preset application program, and add the standard directory class library and the standard software package file library to a first preset class path of the class loader in sequence by using a first preset adding class library strategy; The target file reading module is configured to 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 in an external class path string; The string segmentation module is configured to segment the external class path string to obtain an external class path element, and store the external class path element in an external class path element array; The path element traversal module is configured to traverse the external class path element 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 add the external software package file to a second preset class path of the class loader in sequence by using a second preset adding class library strategy; The class file loading module is configured to load a 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 running of the preset application program.

9. An electronic device, comprising: The application server-based external class library loading method comprises the following steps: A memory is configured to save a computer program; A processor is configured to execute the computer program to implement the application server-based external class library loading method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, A computer program is configured to be executed by a processor to implement the application server-based external class library loading method according to any one of claims 1 to 7.

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