Method and device for integrating js and java based on ioc

CN118626067APending Publication Date: 2024-09-10CHINA TELECOM CLOUD TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410838603.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-26
Publication Date
2024-09-10

AI Technical Summary

Technical Problem

[0004]结合以上两点,第一、需要使用js,第二、js功能暂时不能满足,因此,需要结合js以及一种成熟的,“功能丰富”,可复用的“工具”相结合

Benefits of technology

[0049] The present invention ensures perfect functions and the communication mode between js and java remains unchanged. The sandbox is replaced by nashorn to graalvm, and the callable java methods are expanded from static methods to all methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118626067A
    Figure CN118626067A
Patent Text Reader

Abstract

The invention relates to a method and device for integrating js and java based on ioc, and belongs to the technical field of computers. Js preset functions are written in a java environment, and the js preset functions are injected into a spring container; a java function configuration class is defined, a container object is obtained from the spring container according to the java function configuration class, and a handle of the java function configuration class is reserved; configuring a java object which can be accessed by the js, taking out a corresponding object from the spring container, and keeping the corresponding object in a configuration file; configuring a global js object according to the corresponding object, and setting the attribute of the global js object as reference of java; and adopting the global js object to splice the js code, and calling a graalvm sandbox interface to execute the corresponding java object. According to the method, by combining the efficient execution characteristic of the explanatory language of the js, the safety of the graalvm and the inversion characteristic of spring control, an efficient, safe and reusable channel is formed for communication between the java and the js.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of computer technology, and in particular to a method and device for integrating js and java based on ioc. Background Art

[0002] With the rapid iteration of products and the emergence of various development models such as "waterfall", "spiral" and "rapid iteration", the market urgently needs a solution or platform that can quickly build applications and put them into use. Therefore, the "low-code platform" came into being.

[0003] As a "low" code, it is inevitable to write code in some complex functions. js, this interpreted language is the best choice in this scenario. However, the original js has relatively simple functions, and many functions need to be implemented manually or copied. Although the emergence of es6 and common-js solves this problem. However, it contains specific objects, such as "window", and some functions need to be run in a specific environment, such as a browser. Therefore, it has certain limitations.

[0004] Combining the above two points, first, js is needed, and second, js functions cannot meet the needs for the time being. Therefore, it is necessary to combine js with a mature, "feature-rich" and reusable "tool". Summary of the invention

[0005] In view of the above shortcomings of the prior art, the purpose of the invention is to provide a method and device for integrating js and java based on ioc, based on the graalvm multi-language environment, combined with the spring ioc characteristics, to integrate js and java, so that the mutual calling between java and js is more convenient, flexible and efficient.

[0006] The first aspect of the present invention provides a method for integrating js and java based on ioc, comprising:

[0007] S1, write js preset functions in the java environment, and inject the js preset functions into the spring container;

[0008] S2, defining a java function configuration class, obtaining a container object from the spring container according to the java function configuration class, and retaining a handle to the java function configuration class;

[0009] S3, configure the Java object accessible to js, ​​take out the corresponding object from the spring container, and keep it in the configuration file;

[0010] S4, configuring a global js object according to the corresponding object, and setting the attribute of the global js object to a java reference;

[0011] S5, use the global js object to splice the js code, and call the graalvm sandbox interface to execute the corresponding java object.

[0012] Furthermore, in the S1, writing a js preset function in a java environment and injecting the js preset function into a spring container further comprises:

[0013] The preset function of js written in the java environment in S1 is a function whose difficulty in implementation in js is greater than the preset value;

[0014] The js preset functions at least include:

[0015] Distributed lock, redis cache, local cache, multi-threaded processing, table data reading and writing.

[0016] Furthermore, the S2 defines a java function configuration class, obtains a container object from the spring container according to the java function configuration class, and retains a handle to the java function configuration class, and also includes:

[0017] Define a java function configuration class, which obtains the java method or accessible java class that you want to provide to the js code to call from the spring container through automatic injection and object acquisition, and retains the class handle;

[0018] The handle is agreed upon with the client js caller, and the calling method is executed using the global js object.

[0019] Furthermore, configuring the Java object accessible to JS in the S3, taking the corresponding object from the spring container, and retaining it in the configuration file also includes:

[0020] Parse the defined java function configuration class and obtain the objects and classes that need to be injected into the js engine from the spring container.

[0021] Furthermore, the S5 uses the global js object to splice the js code, calls the graalvm sandbox interface to execute the corresponding java object, and also includes:

[0022] Obtain all objects or static classes in the Java function configuration class, define the calling mapping relationship between the Java object and the JS code according to the agreed calling method, and obtain the JS object corresponding to the Java object;

[0023] The js object is nested at the start position of the custom code written by the user, in which the user presets the object method or attribute through the agreed calling method;

[0024] Send the assembled js code to the graalvm sandbox for execution. Before execution, set the java access whitelist.

[0025] During the execution process, if a preset type statement is encountered, the relevant Java object is searched from the JS preset object. After the relevant Java object is found, the corresponding Java method is called;

[0026] After the call is completed, continue to execute other js codes to complete the execution of the entire custom code.

[0027] According to a second aspect of the present invention, the present invention claims a device for integrating JS and Java based on IOC, comprising:

[0028] Injection module, write js preset functions in java environment, and inject the js preset functions into spring container;

[0029] A function configuration module defines a java function configuration class, obtains a container object from the spring container according to the java function configuration class, and retains a handle to the java function configuration class;

[0030] The object configuration module configures the Java objects accessible by JS, takes out the corresponding objects from the spring container, and keeps them in the configuration file;

[0031] A reference configuration module, which configures a global js object according to the corresponding object and sets the attribute of the global js object as a java reference;

[0032] The object execution module uses the global js object to splice the js code and calls the graalvm sandbox interface to execute the corresponding java object.

[0033] Furthermore, the injection module further includes:

[0034] The preset functions of js written in java environment are functions that are more difficult to implement in js than the preset values;

[0035] The js preset functions at least include:

[0036] Distributed lock, redis cache, local cache, multi-threaded processing, table data reading and writing.

[0037] Furthermore, the function configuration module further includes:

[0038] Define a java function configuration class, which obtains the java method or accessible java class that you want to provide to the js code to call from the spring container through automatic injection and object acquisition, and retains the class handle;

[0039] The handle is agreed upon with the client js caller, and the calling method is executed using the global js object.

[0040] Furthermore, the object configuration module further includes:

[0041] Parse the defined java function configuration class and obtain the objects and classes that need to be injected into the js engine from the spring container.

[0042] Furthermore, the object execution module further includes:

[0043] Obtain all objects or static classes in the Java function configuration class, define the calling mapping relationship between the Java object and the JS code according to the agreed calling method, and obtain the JS object corresponding to the Java object;

[0044] The js object is nested at the start position of the custom code written by the user, in which the user presets the object method or attribute through the agreed calling method;

[0045] Send the assembled js code to the graalvm sandbox for execution. Before execution, set the java access whitelist.

[0046] During the execution process, if a preset type statement is encountered, the relevant Java object is searched from the JS preset object. After the relevant Java object is found, the corresponding Java method is called;

[0047] After the call is completed, continue to execute other js codes to complete the execution of the entire custom code.

[0048] The beneficial effects of the present invention are as follows:

[0049] In the present invention, the communication mode between js and java remains unchanged while ensuring the perfect function. The sandbox is replaced by graalvm from nashorn, and the callable java methods are extended from static methods to all methods.

[0050] In terms of functionality, this solution extends from the original static method to all methods. The functionality is greatly extended, and through integration with spring ioc, resource reuse is achieved.

[0051] In terms of performance, this solution uses GraalVM as the JS engine. Mainstream JS engines also include J2V8, Nashorn, and V8. J2V8 is a Java-encapsulated version of the V8 engine. Therefore, GraalVM, J2V8, and Nashorn are the best solutions for implementing communication between JS and Java. After simple JS, complex JS, and multiple concurrent tests, it was found that GraalVM has the best performance among the three. Therefore, in terms of performance, compared with other solutions that use Nashorn or J2V8 engines, GraalVM is the best solution. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] The accompanying drawings are only used to illustrate specific embodiments and are not considered to limit the present invention. In the entire drawings, the same reference symbols represent the same components. Obviously, the drawings described below are only some embodiments recorded in the embodiments of the present invention. For those of ordinary skill in the art, other drawings can also be obtained based on these drawings.

[0053] Figure 1 This is a workflow diagram of a method for integrating JS and Java based on IOC according to an embodiment of the present invention;

[0054] Figure 2 This is a data flow diagram of a method for integrating js and java based on ioc according to an embodiment of the present invention;

[0055] Figure 3 This is a module structure diagram of a device integrating JS and Java based on IOC according to an embodiment of the present invention. DETAILED DESCRIPTION

[0056] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present invention, the technical solutions of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. It should be understood that these descriptions are only exemplary and are not intended to limit the scope of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in the field without making creative work should fall within the scope of protection of the present invention.

[0057] Furthermore, in the following description, descriptions of well-known structures and technologies are omitted to avoid unnecessarily obscuring the concepts disclosed in the present invention.

[0058] In the description of the present invention, it should be noted that, unless otherwise clearly specified and limited, the orientation or position relationship indicated by the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inside", "outside", etc. is based on the orientation or position relationship shown in the drawings, which is only for the convenience of describing the present invention and simplifying the description, and does not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation of the present invention. In addition, the terms "first", "second", and "third" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. The terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be a connection between the two elements. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0059] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Instead, they are merely examples of methods and systems consistent with some aspects of the present invention as detailed in the appended claims.

[0060] In low-code applications, users need to reserve a place to write code (hereinafter referred to as "custom code") to implement some custom functions, such as: secondary processing of returned data, unified packaging of request headers for requested data, and packaging of returned data into a format that can be recognized by front-end components. Or call some functions provided by the system through custom code, such as: the current user's login information, use the cache technology provided by the system, call other custom codes, implement the reuse of custom codes, implement distributed locks through js, asynchronous loading, multi-threading (js is single-threaded, so multi-threading cannot be achieved simply through js), and other functions. These functions cannot be configured on the page by "dragging, pulling, and dropping".

[0061] There are many ways for js to communicate with java, such as http requests and websockets, but these methods all require establishing links and require network overhead or other overhead during communication. Therefore, it is best to directly call the methods or properties of java objects in js and reference them by address to make communication efficient, direct and simple.

[0062] Graalvm solves this problem very well. It provides a multi-language environment, which can execute js code in java code and reference java objects in js. The multi-language environment provided by Graalvm provides a basis for mutual calls between js and java. However, the official and market-available integration solutions all call java static methods through js to access java implementations. This method requires that the global objects in the method must also be static objects, which has great limitations. It cannot be well integrated with the mainstream java framework spring.

[0063] There are solutions for communication between js and java in the industry, but they all stay at the static methods of js and java. On this basis, the present invention opens up the communication between js and objects managed by spring container. No relevant patents have been found so far. Although they are all js and java communication. Compared with other solutions in the industry, this solution has two obvious improvements. First, the graalvm method is used to realize the communication between js and java. This is a more advanced solution. Compared with nashorn and j2v8, the performance is significantly improved. And the system using nashorn can be smoothly replaced with graalvm. Second, the communication between js and spring container objects is opened. The functionality is greatly expanded, and theoretically, the opening of the container means the reuse of resources. In theory, the performance will be improved again.

[0064] In order to solve the above problems, the purpose of the present invention is to integrate js and java based on the graalvm multi-language environment and combine the spring ioc characteristics, so that the mutual calling between java and js is more convenient, flexible and efficient.

[0065] The first embodiment of the present invention proposes a method for integrating js and java based on ioc, referring to Figure 1 ,include:

[0066] S1, write js preset functions in the java environment, and inject the js preset functions into the spring container;

[0067] S2, defining a java function configuration class, obtaining a container object from the spring container according to the java function configuration class, and retaining a handle to the java function configuration class;

[0068] S3, configure the Java object accessible to js, ​​take out the corresponding object from the spring container, and keep it in the configuration file;

[0069] S4, configuring a global js object according to the corresponding object, and setting the attribute of the global js object to a java reference;

[0070] S5, use the global js object to splice the js code, and call the graalvm sandbox interface to execute the corresponding java object.

[0071] Furthermore, in the S1, writing a js preset function in a java environment and injecting the js preset function into a spring container further comprises:

[0072] The preset function of js written in the java environment in S1 is a function whose difficulty in implementation in js is greater than the preset value;

[0073] The js preset functions at least include:

[0074] Distributed lock, redis cache, local cache, multi-threaded processing, table data reading and writing.

[0075] Furthermore, the S2 defines a java function configuration class, obtains a container object from the spring container according to the java function configuration class, and retains a handle to the java function configuration class, and also includes:

[0076] Define a java function configuration class, which obtains the java method or accessible java class that you want to provide to the js code to call from the spring container through automatic injection and object acquisition, and retains the class handle;

[0077] The handle is agreed upon with the client js caller, and the calling method is executed using the global js object.

[0078] In this embodiment, a java function configuration class is defined. The main function of this class is to obtain the java method or accessible java class that you want to provide to the js code to call from the spring container through automatic injection, object acquisition, etc., and retain the class handle. The handle is agreed with the client (i.e., the js caller) and is called through A.model.method(), where A is the js global object, model is the corresponding functional module, and method is the specific method. When writing custom code, the functions written in the java language are called through the agreed modules and module specific methods. And in the subsequent code running, the java object is obtained through the handle. Thus, the java method is executed. In the form of configuration class, the security of js execution is guaranteed through modular configuration to prevent js from illegally accessing other java classes, such as: System class that may cause system interruption.

[0079] Furthermore, configuring the Java object accessible to JS in the S3, taking the corresponding object from the spring container, and retaining it in the configuration file also includes:

[0080] Parse the defined java function configuration class and obtain the objects and classes that need to be injected into the js engine from the spring container.

[0081] Furthermore, the S5 uses the global js object to splice the js code, calls the graalvm sandbox interface to execute the corresponding java object, and also includes:

[0082] Obtain all objects or static classes in the Java function configuration class, define the calling mapping relationship between the Java object and the JS code according to the agreed calling method, and obtain the JS object corresponding to the Java object;

[0083] The js object is nested at the start position of the custom code written by the user, in which the user presets the object method or attribute through the agreed calling method;

[0084] Send the assembled js code to the graalvm sandbox for execution. Before execution, set the java access whitelist.

[0085] During the execution process, if a preset type statement is encountered, the relevant Java object is searched from the JS preset object. After the relevant Java object is found, the corresponding Java method is called;

[0086] After the call is completed, continue to execute other js codes to complete the execution of the entire custom code.

[0087] In this embodiment, reference is made to Figure 2 In this embodiment, the graalvm sandbox factory class is configured to limit the CPU usage time and memory usage. The sandbox is generated by the factory class, and the js code is executed in the sandbox to ensure the security of server resources and prevent unsafe js code from causing system downtime.

[0088] Write custom code to implement the desired function, and call the Java method (which can be mixed with JS code) through the previously agreed handle to implement the function.

[0089] Parse the java configuration class defined previously and obtain the objects and classes that need to be injected into the js engine from the spring container.

[0090] Use reflection technology to obtain the handles of all objects saved in the configuration class, use Java reflection technology to obtain class information, call the GraalVM sandbox interface, and put the class into the execution whitelist to ensure that it will not be intercepted when js calls this class function.

[0091] Get all objects in the java configuration class, or static classes, according to the A.model.method() method agreed upon earlier. Define a global object as A, use the handle as the model, define each functional module, and assign it to A.model. You can get an application that contains A.model1 = java object 1, A.model2 = java object 2, and the A.model before "=" is the js code, and the java object after "=" is the java object.

[0092] The A object generated in the previous step is nested at the front of the custom code written by the user. In the custom code, the user calls the preset object method or attribute through the agreed A.model.method().

[0093] The assembled js code is sent to the graalvm sandbox for execution. Before execution, a java access whitelist is set. During execution, if a statement similar to A.model.method() is encountered, the relevant model will be searched from the js preset object. After finding the relevant java object, the java method will be called through .method(). After the call is completed, other js codes will be executed to complete the execution of the entire custom code.

[0094] According to the second embodiment of the present invention, the present invention claims a device based on ioc integrating js and java, referring to Figure 3 ,include:

[0095] Injection module, write js preset functions in java environment, and inject the js preset functions into spring container;

[0096] A function configuration module defines a java function configuration class, obtains a container object from the spring container according to the java function configuration class, and retains a handle to the java function configuration class;

[0097] The object configuration module configures the Java objects accessible by JS, takes out the corresponding objects from the spring container, and keeps them in the configuration file;

[0098] A reference configuration module, which configures a global js object according to the corresponding object and sets the attribute of the global js object as a java reference;

[0099] The object execution module uses the global js object to splice the js code and calls the graalvm sandbox interface to execute the corresponding java object.

[0100] Furthermore, the injection module further includes:

[0101] The preset functions of js written in java environment are functions that are more difficult to implement in js than the preset values;

[0102] The js preset functions at least include:

[0103] Distributed lock, redis cache, local cache, multi-threaded processing, table data reading and writing.

[0104] Furthermore, the function configuration module further includes:

[0105] Define a java function configuration class, which obtains the java method or accessible java class that you want to provide to the js code to call from the spring container through automatic injection and object acquisition, and retains the class handle;

[0106] The handle is agreed upon with the client js caller, and the calling method is executed using the global js object.

[0107] Furthermore, the object configuration module further includes:

[0108] Parse the defined java function configuration class and obtain the objects and classes that need to be injected into the js engine from the spring container.

[0109] Furthermore, the object execution module further includes:

[0110] Obtain all objects or static classes in the Java function configuration class, define the calling mapping relationship between the Java object and the JS code according to the agreed calling method, and obtain the JS object corresponding to the Java object;

[0111] The js object is nested at the start position of the custom code written by the user, in which the user presets the object method or attribute through the agreed calling method;

[0112] Send the assembled js code to the graalvm sandbox for execution. Before execution, set the java access whitelist.

[0113] During the execution process, if a preset type statement is encountered, the relevant Java object is searched from the JS preset object. After the relevant Java object is found, the corresponding Java method is called;

[0114] After the call is completed, continue to execute other js codes to complete the execution of the entire custom code.

[0115] For the embodiment of the present invention, the communication mode between js and java remains unchanged to ensure the completeness of functions. The sandbox is replaced by graalvm from nashorn, and the callable java methods are extended from static methods to all methods.

[0116] In terms of functionality, this solution extends from the original static method to all methods. The functionality is greatly extended, and through integration with spring ioc, resource reuse is achieved.

[0117] In terms of performance, this solution uses GraalVM as the JS engine. Mainstream JS engines also include J2V8, Nashorn, and V8. J2V8 is a Java-encapsulated version of the V8 engine. Therefore, GraalVM, J2V8, and Nashorn are the best solutions for implementing communication between JS and Java. After simple JS, complex JS, and multiple concurrent tests, it was found that GraalVM has the best performance among the three. Therefore, in terms of performance, compared with other solutions that use Nashorn or J2V8 engines, GraalVM is the best solution.

[0118] The applicant of the present invention has made a detailed explanation and description of the implementation examples of the present invention in conjunction with the drawings in the specification. However, those skilled in the art should understand that the above implementation examples are only preferred implementation schemes of the present invention, and the detailed description is only to help readers better understand the spirit of the present invention, but not to limit the scope of protection of the present invention. On the contrary, any improvements or modifications based on the inventive spirit of the present invention should fall within the scope of protection of the present invention.

[0119] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the embodiments of the present invention, rather than to limit them. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions recorded in the above embodiments, or replace some of the technical features therein by equivalents; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention. Any changes or replacements that can be easily thought of by those skilled in the art within the technical scope disclosed in the present invention should be covered within the protection scope of the present invention.

Claims

1. A method of integrating js and java based on ioc, It is characterized in that include: S1, write js preset functions in the java environment, and inject the js preset functions into the spring container; S2, defining a java function configuration class, obtaining a container object from the spring container according to the java function configuration class, and retaining a handle to the java function configuration class; S3, configure the Java object accessible by js, take out the corresponding object from the spring container, and keep it in the configuration file; S4, configuring a global js object according to the corresponding object, and setting the attribute of the global js object to a java reference; S5, using the global js object to splice the js code, calling the graalvm sandbox interface to execute the corresponding java object.

2. According to the method of claim 1, It is characterized in that In the S1, the js preset function is written in the java environment, and the js preset function is injected into the spring container, which also includes: The preset function of js written in the java environment in S1 is a function whose difficulty in implementation in js is greater than the preset value; The js preset functions at least include: Distributed lock, redis cache, local cache, multi-threaded processing, table data reading and writing.

3. According to the method of claim 2, integrating js and java based on ioc, It is characterized in that The S2 defines a java function configuration class, obtains a container object from the spring container according to the java function configuration class, and retains a handle to the java function configuration class, and also includes: Define a java function configuration class, which obtains the java method or accessible java class that you want to provide to the js code to call from the spring container through automatic injection and object acquisition, and retains the class handle; The handle is agreed upon with the client js caller, and the calling method is executed using the global js object.

4. According to the method of claim 3, integrating js and java based on ioc, It is characterized in that The S3 configures the Java object accessible by JS, takes the corresponding object from the spring container, and retains it in the configuration file, and also includes: Parse the defined java function configuration class and obtain the objects and classes that need to be injected into the js engine from the spring container.

5. According to the method of claim 3, integrating js and java based on ioc, It is characterized in that In S5, the global js object is used to splice the js code, and the graalvm sandbox interface is called to execute the corresponding java object, which also includes: Obtain all objects or static classes in the Java function configuration class, define the calling mapping relationship between the Java object and the JS code according to the agreed calling method, and obtain the JS object corresponding to the Java object; The js object is nested at the start position of the custom code written by the user, in which the user presets the object method or attribute through the agreed calling method; Send the assembled js code to the graalvm sandbox for execution. Before execution, set the java access whitelist. During the execution process, if a preset type statement is encountered, the relevant Java object is searched from the JS preset object. After the relevant Java object is found, the corresponding Java method is called; After the call is completed, continue to execute other js codes to complete the execution of the entire custom code.

6. A device based on IOC integrating JS and Java, It is characterized in that include: Injection module, write js preset functions in java environment, and inject the js preset functions into spring container; A function configuration module defines a java function configuration class, obtains a container object from the spring container according to the java function configuration class, and retains a handle to the java function configuration class; The object configuration module configures the Java objects accessible by JS, takes out the corresponding objects from the spring container, and keeps them in the configuration file; A reference configuration module, which configures a global js object according to the corresponding object and sets the properties of the global js object as a java reference; The object execution module uses the global js object to splice the js code and calls the graalvm sandbox interface to execute the corresponding java object.

7. The device according to claim 6 that integrates js and java based on ioc, It is characterized in that The injection module further includes: The preset functions of js written in java environment are functions that are more difficult to implement in js than the preset values; The js preset functions at least include: Distributed lock, redis cache, local cache, multi-threaded processing, table data reading and writing.

8. The device according to claim 7, which integrates js and java based on ioc, It is characterized in that The function configuration module further includes: Define a java function configuration class, which obtains the java method or accessible java class that you want to provide to the js code to call from the spring container through automatic injection and object acquisition, and retains the class handle; The handle is agreed upon with the client js caller, and the calling method is executed using the global js object.

9. The device according to claim 8 that integrates js and java based on ioc, It is characterized in that The object configuration module further includes: Parse the defined java function configuration class and obtain the objects and classes that need to be injected into the js engine from the spring container.

10. The device according to claim 9 that integrates js and java based on ioc, It is characterized in that The object execution module further includes: Obtain all objects or static classes in the Java function configuration class, define the calling mapping relationship between the Java object and the JS code according to the agreed calling method, and obtain the JS object corresponding to the Java object; The js object is nested at the start position of the custom code written by the user, in which the user presets the object method or attribute through the agreed calling method; Send the assembled js code to the graalvm sandbox for execution. Before execution, set the java access whitelist. During the execution process, if a preset type statement is encountered, the relevant Java object is searched from the JS preset object. After the relevant Java object is found, the corresponding Java method is called; After the call is completed, continue to execute other js codes to complete the execution of the entire custom code.