CN117111904B - Method and system for automatically converting Web applications into serverless functions - Google Patents

Method and system for automatically converting Web applications into serverless functions Download PDF

Info

Publication number
CN117111904B
CN117111904B CN202310458183.0A CN202310458183A CN117111904B CN 117111904 B CN117111904 B CN 117111904B CN 202310458183 A CN202310458183 A CN 202310458183A CN 117111904 B CN117111904 B CN 117111904B
Authority
CN
China
Prior art keywords
request processing
function
class
controller
processing method
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202310458183.0A
Other languages
Chinese (zh)
Other versions
CN117111904A (en
Inventor
杨帆
金杰
韩松江
魏永恋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Lingyue Digital Information Technology Co ltd
Original Assignee
Lingyue Digital Information Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Lingyue Digital Information Technology Co ltd filed Critical Lingyue Digital Information Technology Co ltd
Priority to CN202310458183.0A priority Critical patent/CN117111904B/en
Publication of CN117111904A publication Critical patent/CN117111904A/en
Application granted granted Critical
Publication of CN117111904B publication Critical patent/CN117111904B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Computer Security & Cryptography (AREA)
  • Stored Programmes (AREA)

Abstract

The present disclosure relates to methods and systems for automatically converting Web applications into serverless functions. There is provided a method for automatically converting a Web application into a serverless function, comprising: responsive to loading of a JAR package associated with a Web application of a user, scanning the JAR package to obtain a set of controller classes in the JAR package; determining a request processing method in the method of each controller class in the set of controller classes, and storing information associated with the determined request processing method in a specific data structure; modifying the JAR package so that the class contained in the JAR package accords with the specification of the function computing platform and uploading the modified JAR package and the specific data structure to the function computing platform; determining a first request processing method to be called in an entry function of a function computing platform based on input parameters of the entry function and the specific data structure; and executing a first request processing method using the input parameters of the entry function and by reflecting the call.

Description

Method and system for automatically converting Web applications into serverless functions
Technical Field
The present disclosure relates to the field of automatic transcoding, and more particularly, to a method, computer system, and storage medium for automatically converting Web applications into serverless functions.
Background
Spring Boot is a widely used open source Java-based framework. It provides a fast and efficient way of establishing a robust product-level application. Spring Boot builds on top of the popular Spring framework and provides several features and capabilities that make it easier to develop and deploy enterprise applications. Spring Boot has various built-in features that can simplify the development process. For example, it provides automatic configuration that automatically configures the various components of an application based on dependencies. It also provides various launch templates that allow developers to quickly create new applications for different use cases. In addition, spring Boot also supports a wide range of technologies and protocols, including HTTP, JDBC, mongoDB, redis and so on.
The serverless function (SERVERLESS FUNCTION) is a function designed to run on a cloud computing platform without the need for a dedicated server or infrastructure. This means that the cloud provider manages the infrastructure and resources required to run the functions, while the developer only needs to provide the code for the functions. Serverless functions are typically used in event driven architectures, where the function is triggered by a specific event (such as a new file being uploaded to a cloud storage service, or a new message being received in a message queue, etc.). When an event occurs, the function is automatically invoked and it processes the event and returns a response.
One of the benefits of a serverless function is that it can help reduce infrastructure costs because the developer only has to pay for the amount of resources used when the function is running. This can help businesses or organizations save money, especially when processing may not always require variable workload of a dedicated server. Another benefit of the serverless function is that it can be easily scaled to meet changing demands without manual intervention. This makes it particularly useful for applications with unpredictable or bursty workloads. Popular server-free function platforms provided by cloud providers include, for example, amazon Web Service (AWS) Lambda services, alicloud functions, microsoft Azure functions, and the like.
Disclosure of Invention
The present disclosure is directed to a method, computer system, and medium for automatically converting Web applications into serverless functions.
According to some embodiments of the present disclosure, there is provided a method for automatically converting a Web application into a serverless function, comprising: responsive to loading of a JAR package associated with a user's Web application, scanning the JAR package to obtain a set of controller classes in the JAR package; determining a request processing method of the methods of each controller class in the set of controller classes and storing information associated with the determined request processing method in a specific data structure; modifying the JAR package so that the class it contains conforms to the specification of a function computing platform and uploading the modified JAR package and the specific data structure to the function computing platform; determining a first request processing method to be called in an entry function of the function computing platform based on input parameters of the entry function and the specific data structure; and executing a first request processing method using the input parameters of the entry function and by reflecting the call.
According to some embodiments of the present disclosure, the Web application is a Web application under a Spring Boot framework.
According to some embodiments of the present disclosure, scanning the JAR packet to obtain a set of controller classes in the JAR packet includes: obtaining a list of classes in the JAR package by scanning the JAR package; scanning each class included in the list of classes and determining the class as a controller class in response to the class containing a particular annotation; and adding the determined controller class to the set of controller classes.
According to some embodiments of the disclosure, the specific annotation comprises at least one of: (i) org. And (ii) org.
According to some embodiments of the present disclosure, a method of request processing in a method of determining each controller class in a set of controller classes includes: for each controller class in the set of controller classes, a method of scanning the controller class; and responsive to the method containing a particular annotation, determining the method as a request processing method.
According to some embodiments of the disclosure, the specific annotation comprises one of: requestMapping, getMapping, postMapping, deleteMapping, putMapping, or PATCHMAPPING.
According to some embodiments of the present disclosure, the information associated with the determined request processing method includes at least: the method comprises a method name, a class name of a class to which the method belongs, a type of an HTTP method corresponding to the method, a URL path corresponding to the method and a parameter list of the method.
According to some embodiments of the disclosure, the list of parameters of the method includes a name and a type of each of the at least one parameter.
According to some embodiments of the present disclosure, modifying the JAR package to include a class that conforms to the specifications of a function computing platform includes: creating a processing class conforming to the specification of the function computing platform; dynamically modifying each controller class in the set of controller classes to inherit the processing class; and generating a new JAR packet to replace the JAR packet.
According to some embodiments of the present disclosure, dynamically modifying each controller class in the set of controller classes to inherit the processing class is performed using a method provided by Javassist.
According to some embodiments of the present disclosure, determining, in an entry function of the function computing platform, a first request processing method to be invoked based on input parameters of the entry function and the specific data structure includes: obtaining a URL path and an HTTP method of a user request received by the function computing platform from input parameters of the entry function; and matching a corresponding method name in the specific data structure based on the URL path and the HTTP method, thereby determining a request processing method corresponding to the method name as a first request processing method.
According to some embodiments of the disclosure, the input parameters utilizing the entry function further include: the input parameters of the entry function are converted into parameter types suitable for the first request processing method based on the list of parameters of the first request processing method in the specific data structure.
According to some embodiments of the present disclosure, invoking the first request processing method by reflecting the call includes: the first request processing method is invoked using an instance of a class of the first request processing method and the converted parameters as method parameters using a reflection invocation mechanism provided by Java.
According to some embodiments of the disclosure, the function computing platform includes at least two function computing platforms, and the input parameters utilizing the entry function further include: in response to the function computing platform being a first function computing platform, performing a first conversion of input parameters of an entry function of the first function computing platform into parameter types suitable for a first request processing method; and in response to the function computing platform being a second function computing platform, performing a second transformation of input parameters of an entry function of the second function computing platform into a parameter type suitable for the first request processing method, wherein the first transformation is different from the second transformation.
According to some embodiments of the present disclosure, there is provided a computer system comprising: one or more processors, and a memory coupled with the one or more processors, the memory storing computer-readable program instructions that, when executed by the one or more processors, perform the method as described above.
According to some embodiments of the present disclosure, a computer readable storage medium is provided, on which computer readable program instructions are stored, which instructions, when executed by the processor, perform a method as described above.
According to some embodiments of the present disclosure, there is provided an apparatus for automatically converting a Web application into a serverless function, comprising means for implementing the steps of the method as described above.
Drawings
The foregoing and other objects, features and advantages of the disclosure will be apparent from the following more particular descriptions of exemplary embodiments of the disclosure as illustrated in the accompanying drawings wherein like reference numbers generally represent like parts throughout exemplary embodiments of the disclosure.
FIG. 1 illustrates a block diagram of an exemplary computer system/server 12 suitable for use in implementing embodiments of the present invention.
Fig. 2 illustrates a flow chart of a method for automatically converting a Web application into a serverless function according to one embodiment of the present disclosure.
FIG. 3 illustrates an example of obtaining a list of classes by scanning JAR package according to one embodiment of the present invention.
Fig. 4 illustrates an example of a list of methods determined to be a request processing method according to one embodiment of the invention.
Detailed Description
Preferred embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While the preferred embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
FIG. 1 illustrates a block diagram of an exemplary computer system/server 12 suitable for use in implementing embodiments of the present invention. The computer system/server 12 shown in FIG. 1 is intended to be exemplary only and should not be taken to limit the functionality or scope of use of embodiments of the present invention.
As shown in FIG. 1, computer system/server 12 is in the form of a general purpose computing device. Components of computer system/server 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, a bus 18 that connects the various system components, including the system memory 28 and the processing units 16.
The system memory 28 may include computer system readable media in the form of volatile memory, such as Random Access Memory (RAM) 30 and/or cache memory 32. The computer system/server 12 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, storage system 34 may be used to read from or write to non-removable, nonvolatile magnetic media. Although not shown in fig. 1, a magnetic disk drive as well as an optical disk drive may also be provided. In such cases, each drive may be coupled to bus 18 through one or more data medium interfaces. Memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to carry out the functions of embodiments of the invention.
A program/utility 40 having a set (at least one) of program modules 42 may be stored in, for example, memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each or some combination of which may include an implementation of a network environment. Program modules 42 generally perform the functions and/or methods of the embodiments described herein.
The computer system/server 12 may also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), one or more devices that enable a user to interact with the computer system/server 12, and/or any devices (e.g., network card, modem, etc.) that enable the computer system/server 12 to communicate with one or more other computing devices. Such communication may occur through an input/output (I/O) interface 22. Also, the computer system/server 12 can communicate with one or more networks such as a Local Area Network (LAN), a Wide Area Network (WAN) and/or a public network, such as the Internet, through a network adapter 20. As shown, network adapter 20 communicates with other modules of computer system/server 12 via bus 18. It should be appreciated that although not shown, other hardware and/or software modules may be used in connection with computer system/server 12, including, but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, data backup storage systems, and the like.
As described above, spring Boot and serverless functions are two different frameworks. Typically, a developer needs to develop applications for the two frameworks separately. In the case where a developer has developed a Web application under the Spring Boot framework, when a service of the Web application needs to be applied to a server-less function platform, a code of the server-less function needs to be rewritten for a specific server-less function platform to reflect service logic of the Web application. The inventors of the present invention found that this was a cumbersome and labor intensive task.
In order to realize automatic conversion of Web applications based on Spring frameworks into functions on a function computing platform, the inventor of the invention proposes a method and a system for automatically converting Web applications into server-free functions.
Referring now to fig. 2, fig. 2 illustrates a flow chart of a method 200 for automatically converting a Web application into a serverless function in accordance with one embodiment of the present disclosure. The method 200 is performed, for example, by the computer system/server 12 described in fig. 1. The method 200 includes a controller class search step 210, a request processing method search and store step 220, a JAR package modification step 230, a call method determination step 240, and a request processing method execution step 250.
The method 200 begins with a controller class search step 210. In a controller class search step 210, a JAR package associated with a user's Web application is scanned to obtain a set of controller classes in the JAR package in response to loading of the JAR package. The JAR package is a Java Archive file. The JAR file format is based on the popular ZIP file format. Unlike ZIP files, JAR files are used not only for compression and publishing, but also for deploying and packaging libraries, components and plug-ins, and can be used directly by tools like compilers and JVM. Web applications under Spring framework and server-less function platforms using Java language support the use of JAR packages. According to an embodiment of the present disclosure, the Web application may be a Web application under a Spring Boot framework. According to another embodiment of the present disclosure, the Web application may also be a Web application under a framework similar to the Spring Boot framework, which is present or proposed in the future.
According to one embodiment of the present disclosure, scanning a JAR packet to obtain a set of controller classes in the JAR packet (i.e., step 210) may include obtaining a list of classes in the JAR packet by scanning the JAR packet. In one example, files in the loaded JAR may be traversed, looking for files ending with ". Class" and recording the file name of such files as class names. By so doing, class names of all classes included in the JAR packet may be obtained to form a list of classes.
For ease of illustration, this disclosure provides one example. This example is merely illustrative and the invention should not be limited by this example. FIG. 3 illustrates an example of obtaining a list of classes by scanning JAR package according to one embodiment of the present invention.
According to one embodiment of the present disclosure, step 210 may further include: scanning each class included in the list of classes and determining the class as a controller class in response to the class containing a particular annotation; and adding the determined controller class to the set of controller classes. Annotation (Annoation), also called metadata, is a description at the code level. It is a feature introduced by JDK1.5 and later versions, at the same level as class, interface, enumeration. It may be declared in front of packages, classes, fields, methods, local variables, method parameters, etc. to illustrate, annotate these elements. According to the invention, it is determined whether a class is a controller class by determining whether the class contains a specific annotation.
According to one embodiment of the present disclosure, such specific annotations may include at least one of: (i) org. And (ii) org. Examples of specific annotations are given herein only and not as an enumeration, and other annotations may be considered by those skilled in the art as a basis for determining the class of controllers.
In the example of fig. 3, the 6 th class (com.dts. Online. Controller. Pagebrowse controller) and the 7 th class (com.dts. Online. Controller. Logincontroller) are determined to be controller classes and form a collection of controller classes, since they contain the annotation "@ RestController". The other classes in fig. 3 (i.e., class1 through 5) are not selected to be added to the set of controller classes because they do not contain specific annotations.
Referring back to fig. 2, in a request processing method searching and storing step 220, a request processing method of the methods of each controller class in the set of controller classes is determined, and information associated with the determined request processing method is stored in a specific data structure.
According to one embodiment of the present disclosure, a request processing method in a method of determining each controller class in a set of controller classes may include: for each controller class in the set of controller classes, a method of scanning the controller class; and responsive to the method containing a particular annotation, determining the method as a request processing method. Here, similarly to the determination of the controller class, it is also determined whether the Method is a request processing Method (i.e., handler Method) depending on the specific annotation of the Method.
According to one embodiment of the present disclosure, such specific annotations may include one of the following: requestMapping, getMapping, postMapping, deleteMapping, putMapping, or PATCHMAPPING. Examples of specific annotations are given herein only and not as an enumeration, and other annotations may be considered as a basis for determining the request processing method by those skilled in the art.
Continuing with the above example, FIG. 4 shows an example of a list of methods determined to be request processing methods according to one embodiment of the invention. In fig. 4, three methods (i.e., getBrowseCount, getCourseStatus, recordTrainUser) of the Controller class com.dts.online.controller.pagebrowse Controller are determined as request processing methods, and two methods (i.e., loginByDid, logout) of the Controller class com.dts.online.controller.logic Controller are also determined as request processing methods. For example, getBrowseCount methods have notes @ PostMapping, getCourseStatus have notes @ GETMAPPING, and the other three methods also have specific notes.
According to one embodiment of the present disclosure, the information associated with the determined request processing method may include, for example: the method comprises a method name, a class name of a class to which the method belongs, a type of an HTTP method corresponding to the method, a URL path corresponding to the method and a parameter list of the method. In one example, information of the request processing method is saved in an object, and storing information associated with the determined request processing method in a particular data structure includes storing the information in a JavaScript object notation (JSON) file by serialization. The following gives the content of serializing the information of the recordTrainUser method listed in fig. 4 in a JSON file.
Here, only an example of the record information of recordTrainUser methods is given, and other request processing methods may be stored in similar data structures according to the same rule. The record information for each method forms an entry in the JSON file (beginning with "{" and ending with "}). In the above data structure, methodName field indicates a method name, className field indicates a class name of a class to which the method belongs, httpMethod field indicates an HTTP method corresponding to the method, urlPath field indicates a URL path corresponding to the method, and methodArgsList field indicates a parameter list of the method. In the above example of the recordTrainUser method, the parameter list contains two parameter requests and httpServletRequest. According to an embodiment of the invention, the list of parameters of the method may comprise a name and a type of each of the at least one parameter. For example, in the above example, the type of parameter request is cn.hutool.jsson.jsonob object, and the type of parameter httpServletRequest is java.servlet.http.httpservletrequest. According to another embodiment of the invention, the list of parameters may include notes and/or sources of each parameter, among other names and types.
Referring back to FIG. 2, in JAR package modification step 230, the JAR package is modified such that the class it contains conforms to the specifications of the function computing platform and the modified JAR package and the particular data structure are uploaded to the function computing platform.
According to one embodiment of the present disclosure, modifying the JAR package so that it contains classes that conform to the specifications of the function computing platform may include: creating a processing class conforming to the specification of the function computing platform; dynamically modifying each controller class in the set of controller classes to inherit the processing class; and generating a new JAR packet to replace the JAR packet. Function computing platforms generally require processing classes to implement some of the required specific methods, while classes of Web applications from Spring frameworks often do not implement such methods. The inventors propose to create a parent class, and implement these methods by the parent class to meet the specifications of the function computing platform. And dynamically inherits the parent class in the conversion process, so that the class of the Web application also accords with the specification of the function computing platform. To achieve this, dynamically modifying each controller class in the set of controller classes to inherit the processing class may be performed using the method provided by Javassist. For example, inheritance of a parent class may be achieved by:
here NepheleRequestHandler is the name of the created processing class (i.e., parent class). The processing class is only one example, and different classes may be created.
According to another embodiment of the present invention, modifying the JAR package may further comprise dynamically modifying each controller class in the set of controller classes to implement a specific interface that pre-implements a method conforming to the specifications of the function computing platform.
Referring back to fig. 2, in a calling method determining step 240, a first request processing method to be called is determined in an entry function of the function computing platform based on input parameters of the entry function and the specific data structure. When the JAR package and the JSON file are uploaded to the function computing platform, the resources are utilized in the entry function of the function computing platform. The standard function definition of the function computing platform is function (event), event is an event object, context is a context object, and the function returns a response object. The event object contains information about an event, and function () is triggered to execute in response to the occurrence of the event.
According to one embodiment of the present disclosure, determining a first request processing method to be invoked in an entry function of a function computing platform based on input parameters of the entry function and the specific data structure may include: obtaining a URL path and an HTTP method of a user request received by the function computing platform from input parameters of the entry function; and matching a corresponding method name in the specific data structure based on the URL path and the HTTP method, thereby determining a request processing method corresponding to the method name as a first request processing method.
The above recordTrainUser example is used for illustration. Those skilled in the art know that the information requested by the user may be included in the input parameters event of the entry function, for example. For example, when the user request is an HTTP request, it may include URL paths and HTTP methods. For example, a URL for a user request is "/browse/recordTrainUser" (which is a relative path) and its HTTP method is POST. That is, matching entries can be found in the JSON file according to the above example of the present invention using the two conditions of "urlPath" = "/browse/recordTrainUser" and "httpMethod" = "POST". Thus, recordTrainUser methods of the PageBrowseController class (i.e., "methodName" = "recordTrainUser" entries) can be uniquely matched in JSON files according to these two conditions in the above example. Thus, a particular request processing method in the original Web application to be invoked can be determined based on the input parameters of the entry function of the function computing platform.
Referring back to fig. 2, in a request processing method execution step 250, a first request processing method is executed using the input parameters of the entry function and by reflecting the call. When the request processing method to be invoked is determined, some preparation for execution of the request processing method is required. According to one embodiment of the present disclosure, utilizing the input parameters of the entry function may further include converting the input parameters of the entry function into parameter types suitable for the first request processing method based on the parameter list of the first request processing method in the specific data structure. Since the JSON file according to the present invention includes a parameter list of a request processing method to be invoked and the parameter list includes the name and type of each parameter, information contained in input parameters (e.g., event) of an entry function of a function computing platform can be converted into the parameter list according to information of the JSON record.
In one example, for example, when the input parameter includes a key value pair user: tom, age:34, gender: male, and the parameter list of the method to be called includes user (String type), age (Int type), the "Tom" is converted into String type and assigned to the parameter user and the "34" is converted into integer type and assigned to the parameter age, thereby forming a parameter list suitable for the method to be called. In this example, the key-value pair gener is not utilized. The simple examples are given here only for ease of illustration, and in practice the conversion may be more complex, but with the names and types of the parameters of the parameter lists known, conversion from the input parameters of the function computing platform to the parameter list of the request processing method to be invoked may be effected.
According to one embodiment of the present disclosure, invoking the first request processing method by reflection calling may include invoking the first request processing method using a Java-provided reflection calling mechanism using an instance of a class of the first request processing method and the converted parameter as method parameters. In one embodiment, the reflection call for the request processing method is made, for example, by the following code.
Class<?>clazz=invokeObj.getClass();
Method method=clazz.getDeclaredMethod(methodName,paramType);
Object result=method.invoke(invokeObj,args);
The above is merely an example of a reflection call given for illustrative purposes and the method of the present invention is not limited thereto. In the above code, invokeObj is an instantiation object of a class to which the method to be invoked belongs, methodName is a name of the first request processing method determined in step 240, PARAMTYPE is a type of parameter of the method to be invoked (when there are a plurality of parameters, the parameter is an array), args is a list of parameters of the converted method to be invoked.
By utilizing reflection calling, it is achieved that a request handling method matching a user request is dynamically called at run-time, which is not known at the encoding stage.
According to one embodiment of the present disclosure, the method 200 may further include converting the result returned from invoking the first request processing method to be suitable for the function computing platform. The first request processing method can be adapted to the response output of the function computing platform by converting the result returned by the execution of the first request processing method. For example, an integer type variable is converted into a string type variable.
According to one embodiment of the present disclosure, the function computing platform may include at least two function computing platforms, and the method 200 may further include automatically performing different processes in steps 240 and 250 based on different types of function computing platforms. For example, the method 200 may include: in response to the function computing platform being a first function computing platform, performing a first conversion of input parameters of an entry function of the first function computing platform into parameter types suitable for a first request processing method; and in response to the function computing platform being a second function computing platform, performing a second transformation of input parameters of an entry function of the second function computing platform into a parameter type suitable for the first request processing method, wherein the first transformation is different from the second transformation.
By adopting the method and the device, the Web application program based on SpringBoot frames can be automatically converted into the function running on the function computing platform, so that a developer does not need to manually modify codes, and the development efficiency is improved. By automatically scanning the JAR package, determining the controller class and the request processing method, the workload of a developer is reduced, and the risk of human errors is also reduced. In addition, the method according to the invention can identify and process the request processing method in SPRING MVC framework, has good adaptability, and can be applied to various Web application programs.
The present invention may be a system, method, and/or computer program product. The computer program product may include a computer readable storage medium having computer readable program instructions embodied thereon for causing a processor to implement aspects of the present invention.
According to one embodiment of the present invention, a computer system is provided that includes one or more processors and a memory coupled to the one or more processors. The memory stores computer-readable program instructions that, when executed by the one or more processors, perform: responsive to loading of a JAR package associated with a user's Web application, scanning the JAR package to obtain a set of controller classes in the JAR package; determining a request processing method of the methods of each controller class in the set of controller classes and storing information associated with the determined request processing method in a specific data structure; modifying the JAR package so that the class it contains conforms to the specification of a function computing platform and uploading the modified JAR package and the specific data structure to the function computing platform; determining a first request processing method to be called in an entry function of the function computing platform based on input parameters of the entry function and the specific data structure; and executing a first request processing method using the input parameters of the entry function and by reflecting the call.
According to another embodiment of the present invention, there is provided a computer readable storage medium having stored thereon computer readable program instructions which, when executed by a processor, perform: responsive to loading of a JAR package associated with a user's Web application, scanning the JAR package to obtain a set of controller classes in the JAR package; determining a request processing method of the methods of each controller class in the set of controller classes and storing information associated with the determined request processing method in a specific data structure; modifying the JAR package so that the class it contains conforms to the specification of a function computing platform and uploading the modified JAR package and the specific data structure to the function computing platform; determining a first request processing method to be called in an entry function of the function computing platform based on input parameters of the entry function and the specific data structure; and executing a first request processing method using the input parameters of the entry function and by reflecting the call.
According to another embodiment of the present invention, there is provided an apparatus for scheduling timed tasks, including: means for scanning a JAR package associated with a user's Web application to obtain a set of controller classes in the JAR package in response to loading of the JAR package; means for determining a request processing method of the methods of each controller class of the set of controller classes and storing information associated with the determined request processing method in a specific data structure; means for modifying the JAR package such that it contains classes that conform to the specifications of a function computing platform and uploading the modified JAR package and the specific data structure to the function computing platform; means for determining a first request processing method to be invoked in an entry function of the function computing platform based on input parameters of the entry function and the specific data structure; and means for executing the first request processing method using the input parameters of the entry function and by reflecting the call.
The computer readable storage medium may be a tangible device that can hold and store instructions for use by an instruction execution device. The computer readable storage medium may be, for example, but not limited to, an electronic storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of the computer-readable storage medium would include the following: portable computer disks, hard disks, random Access Memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static Random Access Memory (SRAM), portable compact disk read-only memory (CD-ROM), digital Versatile Disks (DVD), memory sticks, floppy disks, mechanical coding devices, punch cards or in-groove structures such as punch cards or grooves having instructions stored thereon, and any suitable combination of the foregoing. Computer-readable storage media, as used herein, are not to be construed as transitory signals per se, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through waveguides or other transmission media (e.g., optical pulses through fiber optic cables), or electrical signals transmitted through wires.
The computer readable program instructions described herein may be downloaded from a computer readable storage medium to a respective computing/processing device or to an external computer or external storage device over a network, such as the internet, a local area network, a wide area network, and/or a wireless network. The network may include copper transmission cables, fiber optic transmissions, wireless transmissions, routers, firewalls, switches, gateway computers and/or edge servers. The network interface card or network interface in each computing/processing device receives computer readable program instructions from the network and forwards the computer readable program instructions for storage in a computer readable storage medium in the respective computing/processing device.
Computer program instructions for carrying out operations of the present invention may be assembly instructions, instruction Set Architecture (ISA) instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source or object code written in any combination of one or more programming languages, including an object oriented programming language such as SMALLTALK, C ++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The computer readable program instructions may be executed entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider). In some embodiments, aspects of the present invention are implemented by personalizing electronic circuitry, such as programmable logic circuitry, field Programmable Gate Arrays (FPGAs), or Programmable Logic Arrays (PLAs), with state information for computer readable program instructions, which can execute the computer readable program instructions.
Various aspects of the present invention are described herein with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and/or block diagrams, and combinations of blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer-readable program instructions.
These computer readable program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks. These computer readable program instructions may also be stored in a computer readable storage medium that can direct a computer, programmable data processing apparatus, and/or other devices to function in a particular manner, such that the computer readable medium having the instructions stored therein includes an article of manufacture including instructions which implement the function/act specified in the flowchart and/or block diagram block or blocks.
The computer readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other devices to cause a series of operational steps to be performed on the computer, other programmable apparatus or other devices to produce a computer implemented process such that the instructions which execute on the computer, other programmable apparatus or other devices implement the functions/acts specified in the flowchart and/or block diagram block or blocks.
The flowcharts 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 instructions, which comprises one or more executable instructions for implementing the specified logical function(s). 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 and/or flowchart illustration, and combinations of blocks in the block diagrams and/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 foregoing description of embodiments of the invention has been presented for purposes of illustration and description, and is not intended to be exhaustive or limited to the embodiments disclosed. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the various embodiments described. The terminology used herein was chosen in order to best explain the principles of the embodiments, the practical application, or the technical improvement of the technology in the marketplace, or to enable others of ordinary skill in the art to understand the embodiments disclosed herein.

Claims (16)

1. A method for automatically converting a Web application into a serverless function, comprising:
Responsive to loading of a JAR package associated with a user's Web application, scanning the JAR package to obtain a set of controller classes in the JAR package;
determining a request processing method of the methods of each controller class in the set of controller classes and storing information associated with the determined request processing method in a specific data structure;
Modifying the JAR package such that it contains classes that conform to the specifications of the function computing platform and uploading the modified JAR package and the particular data structure to the function computing platform, wherein modifying the JAR package such that it contains classes that conform to the specifications of the function computing platform comprises:
Creating a processing class conforming to the specification of the function computing platform;
Dynamically modifying each controller class in the set of controller classes to inherit the processing class; and
Generating a new JAR packet to replace the JAR packet;
determining a first request processing method to be called in an entry function of the function computing platform based on input parameters of the entry function and the specific data structure; and
A first request processing method is performed using input parameters of the entry function and by reflecting the call.
2. The method of claim 1, wherein the Web application is a Web application under a Spring Boot framework.
3. The method of claim 1, wherein scanning the JAR packet to obtain a set of controller classes in the JAR packet comprises:
obtaining a list of classes in the JAR package by scanning the JAR package;
scanning each class included in the list of classes and determining the class as a controller class in response to the class containing a particular annotation; and
The determined controller class is added to the set of controller classes.
4. A method according to claim 3, wherein the specific annotation comprises at least one of:
(i) org. And
(ii)org.springframework.stereotype.Controller。
5. The method of claim 1, wherein the request processing method in the method of determining each controller class in the set of controller classes comprises:
for each controller class in the set of controller classes, a method of scanning the controller class; and
In response to the method containing a particular annotation, the method is determined to be a request processing method.
6. The method of claim 5, wherein the particular annotation comprises one of:
RequestMapping, getMapping, postMapping, deleteMapping, putMapping, or PATCHMAPPING.
7. The method of claim 1, wherein the information associated with the determined request processing method includes at least:
The method comprises a method name, a class name of a class to which the method belongs, a type of an HTTP method corresponding to the method, a URL path corresponding to the method and a parameter list of the method.
8. The method of claim 7, wherein the list of parameters of a method includes a name and a type of each of at least one parameter.
9. The method of claim 1, wherein dynamically modifying each controller class in the set of controller classes to inherit the processing class is performed using a method provided by Javassist.
10. The method of claim 1, wherein determining, in an entry function of the function computing platform, a first request processing method to call based on input parameters of the entry function and the particular data structure comprises:
Obtaining a URL path and an HTTP method of a user request received by the function computing platform from input parameters of the entry function; and
And matching corresponding method names in the specific data structure based on the URL path and the HTTP method, so that a request processing method corresponding to the method names is determined as a first request processing method.
11. The method of claim 10, wherein utilizing the input parameters of the entry function further comprises:
The input parameters of the entry function are converted into parameter types suitable for the first request processing method based on the list of parameters of the first request processing method in the specific data structure.
12. The method of claim 10, wherein invoking the first request processing method by reflection invoking comprises:
The first request processing method is invoked using an instance of a class of the first request processing method and the converted parameters as method parameters using a reflection invocation mechanism provided by Java.
13. The method of claim 1, wherein the function computing platform comprises at least two function computing platforms, and wherein utilizing input parameters of the entry function further comprises:
in response to the function computing platform being a first function computing platform, performing a first conversion of input parameters of an entry function of the first function computing platform into parameter types suitable for a first request processing method; and
In response to the function computing platform being a second function computing platform, performing a second transformation of input parameters of an entry function of the second function computing platform into a parameter type suitable for the first request processing method, wherein the first transformation is different from the second transformation.
14. A computer system, comprising:
One or more processors; and
A memory coupled to the one or more processors, the memory storing computer-readable program instructions that, when executed by the one or more processors, perform the method of any of claims 1-13.
15. A computer readable storage medium having stored thereon computer readable program instructions which, when executed by a processor, perform the method of any of claims 1-13.
16. An apparatus for automatically converting a Web application into a serverless function, comprising means for implementing the steps of the method of any of claims 1-13.
CN202310458183.0A 2023-04-26 2023-04-26 Method and system for automatically converting Web applications into serverless functions Active CN117111904B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310458183.0A CN117111904B (en) 2023-04-26 2023-04-26 Method and system for automatically converting Web applications into serverless functions

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310458183.0A CN117111904B (en) 2023-04-26 2023-04-26 Method and system for automatically converting Web applications into serverless functions

Publications (2)

Publication Number Publication Date
CN117111904A CN117111904A (en) 2023-11-24
CN117111904B true CN117111904B (en) 2024-05-28

Family

ID=88807998

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310458183.0A Active CN117111904B (en) 2023-04-26 2023-04-26 Method and system for automatically converting Web applications into serverless functions

Country Status (1)

Country Link
CN (1) CN117111904B (en)

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108628635A (en) * 2018-05-07 2018-10-09 广州视源电子科技股份有限公司 Method, apparatus, equipment and the storage medium of the name that gets parms and local variable name
CN112929195A (en) * 2019-12-05 2021-06-08 北京沃东天骏信息技术有限公司 Service system, method executed by service system, processing apparatus, and storage medium
CN112955869A (en) * 2018-11-08 2021-06-11 英特尔公司 Function As A Service (FAAS) system enhancements
CN113614697A (en) * 2018-12-21 2021-11-05 华为技术有限公司 Mechanism to reduce server-less function startup latency
CN113946454A (en) * 2021-09-29 2022-01-18 南京信息职业技术学院 Webpage data processing method, system, equipment and storage medium
CN114090193A (en) * 2021-12-03 2022-02-25 深圳前海微众银行股份有限公司 Request processing method and device
CN114586011A (en) * 2019-09-27 2022-06-03 亚马逊技术有限公司 Insertion of owner-specified data processing pipelines into input/output paths of object storage services
CN115086189A (en) * 2022-05-20 2022-09-20 中国科学院软件研究所 Server-free computing oriented service resource elastic expansion method and system
CN115357298A (en) * 2022-07-26 2022-11-18 中联智慧农业股份有限公司 Calling method of third-party interface, processor and storage medium
CN115495086A (en) * 2022-08-31 2022-12-20 蚂蚁区块链科技(上海)有限公司 Compiling method, compiler and Wasm virtual machine

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20220210034A1 (en) * 2020-12-31 2022-06-30 Centurylink Intellectual Property Llc Systems and methods for edge site selection and metrics capture

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108628635A (en) * 2018-05-07 2018-10-09 广州视源电子科技股份有限公司 Method, apparatus, equipment and the storage medium of the name that gets parms and local variable name
CN112955869A (en) * 2018-11-08 2021-06-11 英特尔公司 Function As A Service (FAAS) system enhancements
CN113614697A (en) * 2018-12-21 2021-11-05 华为技术有限公司 Mechanism to reduce server-less function startup latency
CN114586011A (en) * 2019-09-27 2022-06-03 亚马逊技术有限公司 Insertion of owner-specified data processing pipelines into input/output paths of object storage services
CN112929195A (en) * 2019-12-05 2021-06-08 北京沃东天骏信息技术有限公司 Service system, method executed by service system, processing apparatus, and storage medium
CN113946454A (en) * 2021-09-29 2022-01-18 南京信息职业技术学院 Webpage data processing method, system, equipment and storage medium
CN114090193A (en) * 2021-12-03 2022-02-25 深圳前海微众银行股份有限公司 Request processing method and device
CN115086189A (en) * 2022-05-20 2022-09-20 中国科学院软件研究所 Server-free computing oriented service resource elastic expansion method and system
CN115357298A (en) * 2022-07-26 2022-11-18 中联智慧农业股份有限公司 Calling method of third-party interface, processor and storage medium
CN115495086A (en) * 2022-08-31 2022-12-20 蚂蚁区块链科技(上海)有限公司 Compiling method, compiler and Wasm virtual machine

Also Published As

Publication number Publication date
CN117111904A (en) 2023-11-24

Similar Documents

Publication Publication Date Title
US10162624B1 (en) Web shell for dynamically generated cross-platform applications
US11178207B2 (en) Software version control without affecting a deployed container
US8904368B2 (en) Instantiating a composite application for different target platforms
US8621439B2 (en) Modern application tracing
US8738589B2 (en) Classloading technique for an application server that provides dependency enforcement
US9645838B2 (en) Automatic discovery of a JavaScript API
US11042387B2 (en) Deploying cross-platform applications on mobile devices with native and web components
US8327341B2 (en) Integrating aspect oriented programming into the application server
US20200409665A1 (en) Systems and Methods for Seamlessly Integrating Multiple Products by Using a Common Visual Modeler
US20080301637A1 (en) Profile service based deployment configuration
US20200004530A1 (en) Melding of mediation flow service component architecture (sca) components
US8640146B2 (en) Providing extensive ability for describing a management interface
US9009667B2 (en) Application server that supports multiple component models
US11100233B2 (en) Optimizing operating system vulnerability analysis
CN115982491A (en) Page updating method and device, electronic equipment and computer readable storage medium
US9009699B2 (en) Providing a POJO-based microcontainer for an application server
KR20210144045A (en) System and method for executing application based on microservice architecture and computer program for the same
CN117111904B (en) Method and system for automatically converting Web applications into serverless functions
CN117337429A (en) Deploying a machine learning model
CN114115830A (en) Webpage control generating method, device, equipment and storage medium
CN117118962B (en) Method and system for deploying user methods across multiple cloud platforms
Zahraei A GIPSY Runtime System with a Kubernetes Underlay for the OpenTDIP Forensic Computing Backend
CN116991380B (en) Application program construction method and device, electronic equipment and storage medium
CN116701017A (en) Method, device, equipment and medium for calling non-public API in android system
CN117785511A (en) Method and device for processing functional data, storage medium and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant