Description of the Script API running on JVM, jvmscriptapi description

Source: Internet
Author: User

Description of the Script API running on JVM, jvmscriptapi description
Basic API description

Other languages can be executed on jvm. A script engine is required to execute other languages. JDK provides related APIs.

This API is suitable for any language that can run on the JVM.

 

 

 

· ScriptEngine is a script execution engine used to execute specified scripts. Based on several eval rewriting forms, you can know that it can be used to execute a script in the string form, or read the script from the file stream and then execute it.

· Bindings is actually an implementation class of java. util. Map. In the Script API, bindings is used to store data that can be used for Script execution.

· ScriptContext: The execution Context of the script. From the class diagram above, we can see that the Context is divided into two types: globalScope and engin.pdf. Some data is used when the script is executed using ScriptEngine, the data may be stored in globalScope or enginscope. The data in globalScope can be used by all ScriptEngine running on the JVM, and enginelist applies to a certain ScriptEngine.

· ScriptEngineFactory is a ScriptEngine factory used to create a ScriptEngine object. Generally, we do not directly use it, but use ScriptEngineManager.

 

· ScriptEngineManager manages all Script APIs. You can use it to create a ScriptEngine object in three ways ). GlobalScope is also maintained.

 

 

 

Function call APIInvocable Interface

 

 

The interface provides four methods,

InvokeFunction is used to call the methods below the global object.

InvokedMethod is used to call a method of an object in the Script.

 

The following example calls the Javascript global function:

The following example shows how to call a custom object in JavaScript:

 

For java interfaces, we can also use the Script language to write the implementation classes of Java interfaces.

This is rarely used.


What does JVM mean by APIs in Java?

JVM is a virtual machine. You can understand SUN as an independent machine that can execute JAVA programs without programmers thinking about the specific hardware.

Application Programming Interface (AP) is a number of predefined functions to provide applications and developers with the ability to access a group of routines based on a software or hardware, without accessing the source code or understanding the details of the internal working mechanism. Specifically, APIs are some programs and instructions developed by SUN. Generally, Apis only refer to reference documents in a narrow sense.

Where is the Java Script API?

Sent

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.