Disclosure of Invention
In view of this, embodiments of the present invention provide a method and an apparatus for deploying and calling a web service based on a multi-tenant technology, which can deploy multiple service systems on the same web service platform in a tenant manner to implement service isolation, so that a cross-domain remote procedure call can be converted into a local call, thereby saving network communication, interaction, and the like, and improving response efficiency.
To achieve the above object, according to an aspect of the embodiments of the present invention, a method for deploying a web service based on a multi-tenant technology is provided.
A method for deploying web services based on multi-tenant technology, which deploys at least one business system to a web service platform in a tenant mode, comprises the following steps: acquiring a tenant registration request of a service system, wherein the tenant registration request comprises a configuration file and an executable file of the service system; analyzing the configuration file, generating an authority verification rule for a private method in the configuration file, and loading the executable file; and allocating ports for the business system and publishing the ports as web services.
Optionally, if the private method has a dependent method, adding the permission check rule to an annotation of the dependent method.
Optionally, after acquiring the tenant registration request of the service system, the method further includes: marking the declared executable class files of the service system which need to use a coroutine processing method, and updating the executable class files of the service system into marked class files.
Optionally, loading the executable class file includes: and analyzing the executable class file, and weaving an intervention code into the marked method to realize the pause and the awakening of the general thread.
Optionally, after acquiring the tenant registration request of the service system, the method further includes: and storing the executable class file into a database or a disk after serialization and compression processing.
Optionally, if the compression processing is saved in the database, the compression processing includes: performing byte processing on the serialized executable class file to convert the executable class file into byte codes; encoding the byte codes based on a Base64 encoding mode; cutting off the first two bits of the 8-bit binary code corresponding to each byte code, and splicing the binary codes of all the byte codes; and segmenting the binary code obtained after splicing into a section according to each 8 bits, and converting each segmented binary code into bytes after decimal transformation for compression processing.
Optionally, if the data is saved in the disk, the compressing includes: establishing a coordinate axis with a longitudinal axis of 54 and a transverse axis of 20, and representing a Chinese character symbol by the intersection point of each unit transverse axis and each unit longitudinal axis; performing byte processing on the serialized executable class file to convert the executable class file into byte codes, and encoding the byte codes based on a Base64 encoding mode; according to the corresponding relation between the preset code and the coordinate values on the coordinate axis, acquiring the horizontal coordinate value and the vertical coordinate value corresponding to the code, and taking the Chinese character symbol of the corresponding intersection point of the vertical axis and the horizontal axis as a compressed file.
According to another aspect of the embodiment of the invention, a device for deploying a web service based on a multi-tenant technology is provided.
A deployment device of web services based on multi-tenant technology, which deploys not less than one business system to a web service platform in a tenant form, the device comprising: the system comprises a request acquisition module, a service system and a service management module, wherein the request acquisition module is used for acquiring a tenant registration request of the service system, and the tenant registration request comprises a configuration file and an executable file of the service system; the analysis loading module is used for analyzing the configuration file, generating an authority verification rule for a private method in the configuration file and loading the executable file; and the service publishing module is used for distributing a port for the service system and publishing the port as the web service.
Optionally, if the private method has a dependent method, adding the permission check rule to an annotation of the dependent method.
Optionally, the system further comprises a marking module for: after acquiring a tenant registration request of a service system, marking the declared executable class files of the service system which need to be processed by using a coroutine processing method, and updating the executable class files of the service system into marked class files.
Optionally, the parsing loading module is further configured to: and analyzing the executable class file, and weaving an intervention code into the marked method to realize the pause and the awakening of the general thread.
Optionally, the system further comprises a file saving module, configured to: after acquiring a tenant registration request of a service system, storing the executable class file into a database or a disk after serialization and compression processing.
Optionally, if the compression processing is saved in the database, the compression processing includes: performing byte processing on the serialized executable class file to convert the executable class file into byte codes; encoding the byte codes based on a Base64 encoding mode; cutting off the first two bits of the 8-bit binary code corresponding to each byte code, and splicing the binary codes of all the byte codes; and segmenting the binary code obtained after splicing into a section according to each 8 bits, and converting each segmented binary code into bytes after decimal transformation for compression processing.
Optionally, if the data is saved in the disk, the compressing includes: establishing a coordinate axis with a longitudinal axis of 54 and a transverse axis of 20, and representing a Chinese character symbol by the intersection point of each unit transverse axis and each unit longitudinal axis; performing byte processing on the serialized executable class file to convert the executable class file into byte codes, and encoding the byte codes based on a Base64 encoding mode; according to the corresponding relation between the preset code and the coordinate values on the coordinate axis, acquiring the horizontal coordinate value and the vertical coordinate value corresponding to the code, and taking the Chinese character symbol of the corresponding intersection point of the vertical axis and the horizontal axis as a compressed file.
According to another aspect of the embodiment of the invention, a method for calling a web service based on a multi-tenant technology is provided.
A method for calling a web service based on a multi-tenant technology, wherein the web service is deployed according to a method for deploying the web service based on the multi-tenant technology provided by the embodiment of the invention, and the method for calling the web service comprises the following steps: acquiring a request type of a web service calling request initiated by a user; when the request type is a private request, performing authority verification on the user; and when the permission check is passed, responding to the web service calling request.
Optionally, the performing the authority check on the user includes: acquiring a private method corresponding to the private request; and carrying out authority verification on the user according to the authority verification rule of the private method.
Optionally, the performing the authority check on the user includes: acquiring a private method corresponding to the private request; if the private method has a dependent method, acquiring the authority verification rule from the annotation of the dependent method; and carrying out authority verification on the user according to the authority verification rule.
According to another aspect of the embodiment of the invention, a device for calling the web service based on the multi-tenant technology is provided.
An invoking device of a web service based on multi-tenant technology, the web service being deployed according to a deployment method of the web service based on multi-tenant technology provided by an embodiment of the present invention, the invoking device comprising: the type obtaining module is used for obtaining the request type of the web service calling request initiated by the user; the authority verification module is used for verifying the authority of the user when the request type is a private request; and the request response module is used for responding to the web service calling request when the permission verification passes.
Optionally, the permission verification module is further configured to: acquiring a private method corresponding to the private request; and carrying out authority verification on the user according to the authority verification rule of the private method.
Optionally, the permission verification module is further configured to: acquiring a private method corresponding to the private request; if the private method has a dependent method, acquiring the authority verification rule from the annotation of the dependent method; and carrying out authority verification on the user according to the authority verification rule.
According to yet another aspect of an embodiment of the present invention, an electronic device is provided.
An electronic device, comprising: one or more processors; the storage device is used for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement the method for deploying and calling the web service based on the multi-tenant technology provided by the embodiment of the invention.
According to yet another aspect of embodiments of the present invention, a computer-readable medium is provided.
A computer readable medium, on which a computer program is stored, when being executed by a processor, implements a method for deploying and calling a web service based on multi-tenant technology, provided by an embodiment of the present invention.
One embodiment of the above invention has the following advantages or benefits: the method for deploying the web service based on the multi-tenant technology is realized by acquiring a tenant registration request of a service system, analyzing a configuration file of the service system to generate an authority check rule for a private method, loading an executable class file of the service system, allocating a port for the service system and issuing the web service, and deploying a plurality of service systems on the same web service platform in a tenant mode to realize service isolation based on the multi-tenant technology theory. In addition, the invention can also use the way of coordinating the journey to carry on the business processing, the coordinating journey is relative to thread, its switching mode is more flexible, and can save the establishment of the thread, maintain the expenses, improve the throughput under the distributed high concurrency; meanwhile, the executable class files of the business system can be stored in a database or a disk corresponding to the working space of the web service platform instead of being directly loaded into the JVM, the class files can be dynamically loaded and executed only when the business system is called, and resources are released after business processing is finished, so that the dynamic loading and unloading of the class are realized, and the effective utilization rate of the JVM is improved.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Most of the existing multi-tenant systems implement data and configuration isolation by virtually partitioning data and configuration of service instances supporting multi-tenant technology, but service isolation cannot be achieved, so that the problem of network overhead exists when cross-domain access occurs. In order to solve the technical problem, the invention provides a deployment method of web services, and based on a multi-tenant technical theory, a plurality of business systems are deployed on the same web service platform in a tenant mode to realize business service isolation, so that cross-domain remote process call can be converted into local call, thereby saving the expenses of network communication, interaction and the like and improving the response efficiency.
The embedded web server is used as a web service platform, and the external business system instance is used as a tenant to be registered to the web service platform, so that the business service isolated multi-tenant system is realized. Specifically, after receiving a tenant registration request of a service system example, first allocating a tenant identifier to the tenant; then, configuration information corresponding to the service system can be obtained according to the tenant identity, so as to analyze a service alias (or a domain name of the tenant, and other tenants can access the tenant through the service alias), a private service interface (i.e., a method only allowed to be called by the tenant itself), a public service interface (a method shared by all tenants), a service alias (i.e., a service alias of another system which the current tenant needs to access), a service interface (which does not distinguish public and private), data source fragmentation information and the like, which are provided by the tenant to the outside; then, obtaining an executable class file of a service system according to a tenant identity and loading the executable class file into a JVM (Java virtual machine), wherein a class loading mechanism based on Java is needed in specific implementation, an executable resource package of the tenant is located at a place where a Java class loader cannot be loaded, so that the tenant needs to be loaded automatically, and a tenant resource file can be further incorporated (a section is connected to other application program types or objects and a notified object is created, such a behavior is called as incorporating) identity in the loading process, namely, a tenant identity tentrid which does not influence program operation is added into a compiled byte code file, so as to realize coding of the tenant; finally, the business system instance is published as a web service and distinguished from other web services by a port. When the configuration information of the business system is analyzed, a lock can be configured for the private service interface, so that the tenant holding the lock can access the private method of the business system instance.
The following describes a deployment method of a web service according to the present invention with reference to the accompanying drawings and specific embodiments.
Fig. 1 is a schematic diagram of main steps of a method for deploying a web service based on a multi-tenant technology according to an embodiment of the present invention. As shown in fig. 1, in order to implement that at least one business system is deployed to a web service platform in a tenant form, the method for deploying a web service based on a multi-tenant technology in the embodiment of the present invention mainly includes the following steps S101 to S103.
Step S101: acquiring a tenant registration request of a service system, wherein the tenant registration request comprises a configuration file and an executable file of the service system;
step S102: analyzing the configuration file, generating an authority verification rule for a private method in the configuration file, and loading an executable file;
step S103: ports are allocated to the business system and published as web services.
In step S102, data isolation may be performed on resource files such as an executable class file of the tenant, and in the loading process, intervention codes are dynamically injected to suspend and wake up the general thread. The method generates the authority verification rule for the private method so as to realize that only the specified user can access the private service interface of the service system, thereby realizing service isolation. After the authority verification rule is generated for the private method, the private method and the authority verification rule are stored in a tenant registration center of the web platform, so that authority verification can be performed when a subsequent user accesses the service system through the web service platform.
According to one embodiment of the invention, if the private method has a dependent method, the permission check rule is added to the annotation of the dependent method. Wherein, a dependent method refers to a method that the private method needs to depend on when executing. If the private method has a dependent method, when the private method is called to be executed, the dependent method needs to be executed, and at this time, the authority of the user can be checked according to the authority checking rule stored in the annotation of the dependent method. The authority verification rule may be flexibly set as required, and for example, the authority verification rule may be a token key pair generated and a token key pair used for authority verification, or a verification code generated and a verification code used for authority verification, and the like.
According to an embodiment of the present invention, after acquiring the tenant registration request of the service system, the method may further include:
marking the declared executable class files of the business system which need to use a coroutine processing method, and updating the executable class files of the business system into marked class files.
And, loading the executable class file includes:
and analyzing the executable class file, and weaving intervention codes into the marked method to realize the pause and the awakening of the general thread.
Through the technical scheme of the embodiment, business processing can be performed in a coroutine mode, and coroutine (coroutine) is also a program component as with a subroutine. Subroutines are portions of code of a main program that perform specific tasks and are relatively independent of other code in the main program, and are more general and flexible than subroutines, but are not as widely used in practice as subroutines. Compared with threads, the coroutines are relatively independent and have own contexts, but the switching is controlled by the system; the multiple coroutines are relatively independent and have own contexts, but the switching is controlled by the coroutines, and the current coroutine is switched to other coroutines and is controlled by the current coroutine. Therefore, the coroutine is more flexible in switching mode compared with the thread, the expense on creating and maintaining the thread can be saved, and the distributed high-concurrency throughput is improved.
The invention carries on the business processing based on the light-weight coroutine of JVM, while carrying on the systematic compilation to the class file according to built-in class loader and JVM agent of the invention, discern and record the class or method with coroutine label, and record the position of the class or method containing coroutine label into a self-defining file- "coroutine file", through cooperating with Java byte code file (. class) and coroutine file of the standard in order to realize the pause (yield method) and awaken (notify method) of the general thread while loading. The concurrent program yield method of the invention can not generate memory occupation on the JVM and suspend the thread, thereby saving the expense of creating and maintaining the thread.
In a distributed deployment environment, the coroutine processing mode of the invention controls the suspension and the continuous execution of the thread by the service system through yield action of coroutine, and the processing of distributed transactions in a concurrent environment can not cause the suspension and the blockage of the thread.
According to another embodiment of the present invention, after acquiring the tenant registration request of the service system, the method may further include:
and storing the executable class files into a database or a disk after serialization and compression processing.
According to the embodiment, after acquiring the tenant registration request of the business system, the configuration file and the executable class file of the business system, the web service platform can also store the executable class file of the business system into a database or a disk corresponding to a working space of the web service platform instead of directly loading the executable class file into the JVM, only when the business system is called, the class file is dynamically loaded and executed, and resources are released after business processing is completed, so that the dynamic loading and unloading of the class are realized, and the effective utilization rate of the JVM is improved.
According to another embodiment, the invention can store the executable class file containing the coroutine file to a disk or a database after serialization and compression processing, and only when the coroutine method is called, dynamic loading and intervention code weaving are carried out according to the coroutine file. If the coroutine method is not needed, the process does not produce redundant stack frames on the JVM. When the web service is called, the class loader reads the coroutine file from the compressed data, so as to obtain the method containing the coroutine identification and the method line needing yield (thread pause), as well as the parameter name and the request type. The class loader loads a target service class according to the parameter name and the request type and organizes an intervention code, when a program is executed to a yield method, the execution is terminated by throwing an exception, an execution result of the execution termination is stored to the stack top of the target service class as an intermediate value, and when the next call to the web service is initiated, the intermediate value is directly loaded from the last suspended position as a variable value and is pressed into an operation stack.
In a large-scale service integration environment, the invention writes the coroutine file into a disk by serializing and deserializing the executable class file, and the memory of the JVM is not consumed by the process.
By serializing and byte (byte) converting the runtime object and then performing the file conversion, the class file can be conveniently stored on storage media such as a disk and a database. The invention provides two dynamic compression modes according to different media to data size definitions. In a windows or linux system, English letters, numbers and English semihorn symbols occupy one byte, and in a relational database such as mysql, the varchar type Chinese and English occupancy are consistent.
In an embodiment of the present invention, if the compression is saved in the database, the compression process includes:
performing byte processing on the serialized executable class file to convert the executable class file into byte codes;
encoding the byte codes based on a Base64 encoding mode;
cutting off the first two bits of the 8-bit binary code corresponding to each byte code, and splicing the binary codes of all the byte codes;
and segmenting the binary code obtained after splicing into a section according to each 8 bits, and converting each segmented binary code into bytes after decimal transformation for compression processing.
Among them, Base64 is one of the most common encoding methods for transmitting 8Bit byte codes on a network, and Base64 is a method for representing binary data based on 64 printable characters.
In a disk medium of a server, a serialized file generated by arranging and combining 64 symbols of capital letters (A-Z), lowercase letters (a-Z), numbers (0-9) and English half-corner symbols (+/-) through Base64 coding processing of byte data is generated, the corresponding relation of 0-63 and 64 symbols is firstly established, then 0-63 is binarized, then the first two bits of the binary code of 8 bits are cut off and spliced with the binary code of the next processing, then each segment of 8 bits is segmented, the binary code after the segmentation processing is subjected to decimal processing, the byte value of the binary code is obtained and output to realize compression processing, and the decompression process is opposite.
In another embodiment of the present invention, if the data is saved to the disk, the compression process includes:
establishing a coordinate axis with a longitudinal axis of 54 and a transverse axis of 20, and representing a Chinese character symbol by the intersection point of each unit transverse axis and each unit longitudinal axis;
performing byte processing on the serialized executable class file to convert the executable class file into byte codes, and encoding the byte codes based on a Base64 encoding mode;
according to the corresponding relation between the preset codes and coordinate values on coordinate axes, acquiring horizontal and vertical coordinate values corresponding to the codes, and taking Chinese character symbols of the corresponding intersection points of the vertical axis and the horizontal axis as compressed files.
Wherein 54 refers to 54 symbols in total consisting of capital letters (A-Z), lowercase letters (a-Z) and English semi-character (+/-), and 20 refers to the number of possible repeated symbols. Specifically, for storage of class files in a relational database, a coordinate axis with a longitudinal axis of 54 and a longitudinal axis of 20 may be established, a position is replaced by a Chinese character symbol at an intersection point of the transverse axis and the longitudinal axis of each unit, Base64 processing is performed on byte codes after byte encoding, shorthand is performed on connected letters, for example, sssss is recorded as a form of an original value plus number s5, and then Chinese character symbols corresponding to s5 (where the first character s corresponds to a longitudinal axis coordinate and the second character 5 corresponds to a transverse axis coordinate) are searched on the coordinate axis and output to realize compression processing, and decompression processes are opposite.
Fig. 2 is a system architecture diagram of an embodiment of the present invention. As shown in fig. 2, the web service platform system of the present invention mainly includes a monitoring management platform, a web server and a database 3. The monitoring management platform is used for monitoring and managing the web service platform system, and a user submits a tenant registration request of the service system, executable resource files (such as: jar, zip, war, tar) of the service system, configuration information and the like through the monitoring management platform; the web server is a container for providing a running environment of each business system deployed on a web service platform, wherein a solid line represents access of public methods and data, and a dotted line represents usage of private methods and data; the database is used for storing application data of each business system.
FIG. 3 is a schematic diagram of a deployment flow of a web service according to an embodiment of the present invention. As shown in fig. 3, taking an example that a business system performs tenant registration through a web service platform, a deployment process of a web service mainly includes the following steps:
step S301: a user uploads an engineering compression package of a service system through a monitoring management platform, wherein the engineering compression package comprises a configuration file, an executable file and the like of the service system;
step S302: the central control dispatching device of the web service platform judges the current node state and distributes the current node state to different processors, wherein if ' f ' is 0 ', namely the business system uploads a project compression packet for the first time, the corresponding project compression packet is transmitted to a coder;
step S303: the code printer analyzes the configuration file in the engineering compression package to acquire information such as a service alias, a private service interface, a public service interface, a service alias and a service interface for calling an external system, a data source fragment id and the like which are externally provided by the service system; furthermore, renaming the declaration in the executable class file in the engineering compression package that needs to use the protocol processing method to realize adding the protocol identifier, where the renaming format is, for example: the original name _ coroutine _ protocol method name and the position of the method added with the protocol identification are recorded; finally, moving the processed file to a working space of a web service platform, and storing the processed file in a disk or a database corresponding to the working space;
step S304: after the coder finishes processing, the central control calling and dialing device of the web service platform judges the current node state again and allocates the current node state to different processors, wherein at the moment, "_ f = 1" indicates that the file is transferred to the working space of the web service platform, and then allocates the task of the current node to the initializer;
step S305: the initializer is used for deploying the service system uploaded to the working space of the web service platform into the JVM, specifically, calling a self-defined class loader through an agent of the JVM to load an executable class file, and analyzing the file containing the coroutine identification to generate a coroutine file; analyzing the configuration file, generating a token key pair for the private method, and pushing the private method and the key to a registration center; then searching whether the private method has a dependent method in the registry, if so, saving the secret key into an annotation file of the dependent method;
step S306: after the processing of the initializer is completed, the central control calling device of the web service platform judges the current node state again, wherein f is 2, which indicates that the file is loaded and analyzed, and returns to the monitoring management platform to upload successfully;
step S307: triggering execution by a user;
step S308: a central control transfer device of the web service platform distributes tasks to separators;
step S309: the splitter obtains an available port from a port pool of the registry and publishes the business system as a web service.
The process of other business systems for tenant registration through the web service platform is the same as the above process. Therefore, a plurality of business systems can be registered to the uniform web service platform in a tenant mode to realize service isolation.
Fig. 4 is a schematic diagram of main modules of a web service deployment apparatus based on multi-tenant technology according to an embodiment of the present invention. As shown in fig. 4, in order to implement that at least one business system is deployed to a web service platform in a tenant form, a deployment apparatus 400 of a web service based on a multi-tenant technology according to an embodiment of the present invention mainly includes a request acquisition module 401, an analysis loading module 402, and a service publishing module 403.
The request obtaining module 401 is configured to obtain a tenant registration request of a service system, where the tenant registration request includes a configuration file and an executable class file of the service system;
the analysis loading module 402 is configured to analyze the configuration file, generate an authority verification rule for a private method therein, and load the executable class file;
the service publishing module 403 is configured to allocate a port to the business system and publish the port as a web service.
According to one embodiment of the invention, if the private method has a dependent method, the permission check rule is added to the annotation of the dependent method.
According to another embodiment of the present invention, the apparatus 400 for deploying a web service based on a multi-tenant technology may further include a marking module (not shown in the figure) for:
after acquiring a tenant registration request of a service system, marking the declared executable class files of the service system which need to be processed by using a coroutine processing method, and updating the executable class files of the service system into marked class files.
According to an embodiment of the present invention, the parsing loading module 402 may be further configured to:
and analyzing the executable class file, and weaving an intervention code into the marked method to realize the pause and the awakening of the general thread.
According to another embodiment of the present invention, the apparatus 400 for deploying a web service based on a multi-tenant technology may further include a file saving module (not shown in the figure) for:
after acquiring a tenant registration request of a service system, storing the executable class file into a database or a disk after serialization and compression processing.
According to an embodiment of the present invention, if the compression is saved in the database, the compression process includes:
performing byte processing on the serialized executable class file to convert the executable class file into byte codes;
encoding the byte codes based on a Base64 encoding mode;
cutting off the first two bits of the 8-bit binary code corresponding to each byte code, and splicing the binary codes of all the byte codes;
and segmenting the binary code obtained after splicing into a section according to each 8 bits, and converting each segmented binary code into bytes after decimal transformation for compression processing.
According to another embodiment of the present invention, if the data is saved to the disk, the compression process includes:
establishing a coordinate axis with a longitudinal axis of 54 and a transverse axis of 20, and representing a Chinese character symbol by the intersection point of each unit transverse axis and each unit longitudinal axis;
performing byte processing on the serialized executable class file to convert the executable class file into byte codes, and encoding the byte codes based on a Base64 encoding mode;
according to the corresponding relation between the preset code and the coordinate values on the coordinate axis, acquiring the horizontal coordinate value and the vertical coordinate value corresponding to the code, and taking the Chinese character symbol of the corresponding intersection point of the vertical axis and the horizontal axis as a compressed file.
According to another aspect of the invention, a method and a device for calling the web service are also provided. Wherein the web service is deployed according to the method in the foregoing embodiment. The calling method of the web service mainly comprises the following steps:
acquiring a request type of a web service calling request initiated by a user;
when the request type is a private request, performing authority verification on the user;
and when the permission check is passed, responding to the web service calling request.
According to an embodiment of the present invention, the performing the authority check on the user includes:
acquiring a private method corresponding to the private request;
and carrying out authority verification on the user according to the authority verification rule of the private method.
According to another embodiment of the present invention, the performing the authority check on the user includes:
acquiring a private method corresponding to the private request;
if the private method has a dependent method, acquiring the authority verification rule from the annotation of the dependent method;
and carrying out authority verification on the user according to the authority verification rule.
FIG. 5 is a schematic diagram of a call flow of a web service according to an embodiment of the present invention. As shown in fig. 5, the call flow of the web service according to an embodiment of the present invention mainly includes the following steps:
step S501: a user initiates a call request of a web service to a web service platform, at this time, the call request does not need to distinguish web service devices, and only needs to add a port number port corresponding to the web service, where the call request is, for example: http:// xxxx: port/x/x;
step S502: after the request reaches the target web service, an IOC (Inversion of Control) controller of the web service platform performs authority verification before service processing, and because the web service has a public method and a private method, the authority verification needs to be performed on a user;
step S503: the IOC controller judges the request type, and when the request type is a private request, the encryption machine performs authority verification;
step S504: the encryption machine firstly obtains a secret key corresponding to a private method of the target web service or a secret key corresponding to a secret key of a dependent method of the private method from a registry; then, the encryption machine checks whether the key is legal (for example, whether the generation rule is satisfied, whether the key is issued by the web service platform, and the like) and whether the key is legal; if yes, the verification is passed, and the secret key or verification success information is sent to the IOC controller;
step S505: the IOC controller sends the secret key to the target web service;
step S506: the target web service requests a dependent service (a service corresponding to a dependent method) to perform business processing according to the secret key;
step S507: after receiving the request of the target web service, the dependent service performs permission verification again by the IOC control system through executing the steps S502-S504, and after the permission verification is passed, the IOC controller sends the secret key to the dependent service;
step S508: the dependence service returns a response result to the target web service;
step S509: the target web service returns a response result.
According to the embodiment of the invention, the calling device of the web service based on the multi-tenant technology mainly comprises:
the type obtaining module is used for obtaining the request type of the web service calling request initiated by the user;
the authority verification module is used for verifying the authority of the user when the request type is a private request;
and the request response module is used for responding to the web service calling request when the permission verification passes.
Wherein, the permission verification module can be further configured to:
acquiring a private method corresponding to the private request;
and carrying out authority verification on the user according to the authority verification rule of the private method.
In addition, the permission verification module may be further configured to:
acquiring a private method corresponding to the private request;
if the private method has a dependent method, acquiring the authority verification rule from the annotation of the dependent method;
and carrying out authority verification on the user according to the authority verification rule.
According to the technical scheme of the embodiment of the invention, the web service deployment method based on the multi-tenant technology is realized by acquiring the tenant registration request of the business system, analyzing the configuration file of the business system to generate the authority verification rule for the private method, and after the executable class file of the business system is loaded, allocating the port for the business system and issuing the web service, and based on the multi-tenant technology theory, deploying a plurality of business systems on the same web service platform in the form of tenants to realize business service isolation, so that cross-domain remote process call can be converted into local call, thereby saving the expenses of network communication, interaction and the like and improving the response efficiency. In addition, the invention can also use the way of coordinating the journey to carry on the business processing, the coordinating journey is relative to thread, its switching mode is more flexible, and can save the establishment of the thread, maintain the expenses, improve the throughput under the distributed high concurrency; meanwhile, the executable class files of the business system can be stored in a database or a disk corresponding to the working space of the web service platform instead of being directly loaded into the JVM, the class files can be dynamically loaded and executed only when the business system is called, and resources are released after business processing is finished, so that the dynamic loading and unloading of the class are realized, and the effective utilization rate of the JVM is improved.
Fig. 6 illustrates an exemplary system architecture 600 of a deployment, invocation method or device of a multi-tenant technology based web service to which embodiments of the present invention may be applied.
As shown in fig. 6, the system architecture 600 may include terminal devices 601, 602, 603, a network 604, and a server 605. The network 604 serves to provide a medium for communication links between the terminal devices 601, 602, 603 and the server 605. Network 604 may include various types of connections, such as wire, wireless communication links, or fiber optic cables, to name a few.
A user may use the terminal devices 601, 602, 603 to interact with the server 605 via the network 604 to receive or send messages or the like. The terminal devices 601, 602, 603 may have installed thereon various communication client applications, such as shopping applications, web browser applications, search applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only).
The terminal devices 601, 602, 603 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 605 may be a server providing various services, such as a background management server (for example only) providing support for shopping websites browsed by users using the terminal devices 601, 602, 603. The backend management server may analyze and perform other processing on the received data such as the product information query request, and feed back a processing result (for example, target push information, product information — just an example) to the terminal device.
It should be noted that the deployment and calling method of the web service based on the multi-tenant technology provided by the embodiment of the present invention is generally executed by the server 605, and accordingly, the deployment and calling device of the web service based on the multi-tenant technology is generally disposed in the server 605.
It should be understood that the number of terminal devices, networks, and servers in fig. 6 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 7, a block diagram of a computer system 700 suitable for use with a terminal device or server implementing an embodiment of the invention is shown. The terminal device or the server shown in fig. 7 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 7, the computer system 700 includes a Central Processing Unit (CPU)701, which can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)702 or a program loaded from a storage section 708 into a Random Access Memory (RAM) 703. In the RAM 703, various programs and data necessary for the operation of the system 700 are also stored. The CPU 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input/output (I/O) interface 705 is also connected to bus 704.
To the I/O interface 705, AN input section 706 including a keyboard, a mouse, and the like, AN output section 707 including a keyboard such as a Cathode Ray Tube (CRT), a liquid crystal display (L CD), and the like, a speaker, and the like, a storage section 708 including a hard disk and the like, and a communication section 709 including a network interface card such as a L AN card, a modem, and the like, the communication section 709 performs communication processing via a network such as the internet, a drive 710 is also connected to the I/O interface 705 as necessary, a removable medium 711 such as a magnetic disk, AN optical disk, a magneto-optical disk, a semiconductor memory, and the like is mounted on the drive 710 as necessary, so that a computer program read out therefrom is mounted into the storage section 708 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program can be downloaded and installed from a network through the communication section 709, and/or installed from the removable medium 711. The computer program performs the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 701.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units or modules described in the embodiments of the present invention may be implemented by software, or may be implemented by hardware. The described units or modules may also be provided in a processor, and may be described as: a processor comprises a request acquisition module, a parsing loading module and a service publishing module. The names of these units or modules do not in some cases constitute a limitation on the units or modules themselves, for example, the request acquisition module may also be described as a "module for acquiring a tenant registration request of a business system".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: acquiring a tenant registration request of a service system, wherein the tenant registration request comprises a configuration file and an executable file of the service system; analyzing the configuration file, generating an authority verification rule for a private method in the configuration file, and loading the executable file; and allocating ports for the business system and publishing the ports as web services.
According to the technical scheme of the embodiment of the invention, the web service deployment method based on the multi-tenant technology is realized by acquiring the tenant registration request of the business system, analyzing the configuration file of the business system to generate the authority verification rule for the private method, and after the executable class file of the business system is loaded, allocating the port for the business system and issuing the web service, and based on the multi-tenant technology theory, deploying a plurality of business systems on the same web service platform in the form of tenants to realize business service isolation, so that cross-domain remote process call can be converted into local call, thereby saving the expenses of network communication, interaction and the like and improving the response efficiency. In addition, the invention can also use the way of coordinating the journey to carry on the business processing, the coordinating journey is relative to thread, its switching mode is more flexible, and can save the establishment of the thread, maintain the expenses, improve the throughput under the distributed high concurrency; meanwhile, the executable class files of the business system can be stored in a database or a disk corresponding to the working space of the web service platform instead of being directly loaded into the JVM, the class files can be dynamically loaded and executed only when the business system is called, and resources are released after business processing is finished, so that the dynamic loading and unloading of the class are realized, and the effective utilization rate of the JVM is improved.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.