1 /* 2 * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 /** 27 28 <p>The scripting API consists of interfaces and classes that define 29 Java™ Scripting Engines and provides 30 a framework for their use in Java applications. This API is intended 31 for use by application programmers who wish to execute programs 32 written in scripting languages in their Java applications. The 33 scripting language programs are usually provided by the end-users of 34 the applications. 35 </p> 36 <p>The main areas of functionality of <code>javax.script</code> 37 package include 38 </p> 39 <ol> 40 <li><p><b>Script execution</b>: Scripts 41 are streams of characters used as sources for programs executed by 42 script engines. Script execution uses 43 {@link javax.script.ScriptEngine#eval eval} methods of 44 {@link javax.script.ScriptEngine ScriptEngine} and methods of the 45 {@link javax.script.Invocable Invocable} interface. 46 </p> 47 <li><p><b>Binding</b>: This facility 48 allows Java objects to be exposed to script programs as named 49 variables. {@link javax.script.Bindings Bindings} and 50 {@link javax.script.ScriptContext ScriptContext} 51 classes are used for this purpose. 52 </p> 53 <li><p><b>Compilation</b>: This 54 functionality allows the intermediate code generated by the 55 front-end of a script engine to be stored and executed repeatedly. 56 This benefits applications that execute the same script multiple 57 times. These applications can gain efficiency since the engines' 58 front-ends only need to execute once per script rather than once per 59 script execution. Note that this functionality is optional and 60 script engines may choose not to implement it. Callers need to check 61 for availability of the {@link javax.script.Compilable Compilable} 62 interface using an <I>instanceof</I> check. 63 </p> 64 <li><p><b>Invocation</b>: This 65 functionality allows the reuse of intermediate code generated by a 66 script engine's front-end. Whereas Compilation allows entire scripts 67 represented by intermediate code to be re-executed, Invocation 68 functionality allows individual procedures/methods in the scripts to 69 be re-executed. As in the case with compilation, not all script 70 engines are required to provide this facility. Caller has to check 71 for {@link javax.script.Invocable Invocable} availability. 72 </p> 73 <li><p><b>Script engine discovery</b>: Applications 74 written to the Scripting API might have specific requirements on 75 script engines. Some may require a specific scripting language 76 and/or version while others may require a specific implementation 77 engine and/or version. Script engines are packaged in a specified 78 way so that engines can be discovered at runtime and queried for 79 attributes. The Engine discovery mechanism is based on the service-provider 80 loading facility described in the {@link java.util.ServiceLoader} class. 81 {@link javax.script.ScriptEngineManager ScriptEngineManager} 82 includes 83 {@link javax.script.ScriptEngineManager#getEngineFactories getEngineFactories} method to get all 84 {@link javax.script.ScriptEngineFactory ScriptEngineFactory} instances 85 discovered using this mechanism. <code>ScriptEngineFactory</code> has 86 methods to query attributes about script engine. 87 </p> 88 </ol> 89 90 @since 1.6 91 */ 92 93 package javax.script; 94