package.html revision 2362
903N/A<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
903N/A<html>
903N/A<head>
903N/A<!--
903N/ACopyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
903N/ADO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
903N/A
903N/AThis code is free software; you can redistribute it and/or modify it
903N/Aunder the terms of the GNU General Public License version 2 only, as
903N/Apublished by the Free Software Foundation. Oracle designates this
903N/Aparticular file as subject to the "Classpath" exception as provided
903N/Aby Oracle in the LICENSE file that accompanied this code.
903N/A
903N/AThis code is distributed in the hope that it will be useful, but WITHOUT
903N/AANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
903N/AFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
903N/Aversion 2 for more details (a copy is included in the LICENSE file that
903N/Aaccompanied this code).
903N/A
903N/AYou should have received a copy of the GNU General Public License version
903N/A2 along with this work; if not, write to the Free Software Foundation,
903N/AInc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
903N/A
903N/APlease contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
903N/ACA 95054 USA or visit www.sun.com if you need additional information or
903N/Ahave any questions.
1480N/A-->
903N/A
903N/A</head>
903N/A<body bgcolor="white">
903N/A<p>The scripting API consists of interfaces and classes that define
903N/AJava <font size=1><sup>TM</sup></font> Scripting Engines and provides
903N/Aa framework for their use in Java applications. This API is intended
903N/Afor use by application programmers who wish to execute programs
903N/Awritten in scripting languages in their Java applications. The
903N/Ascripting language programs are usually provided by the end-users of
903N/Athe applications.
903N/A</p>
903N/A<p>The main areas of functionality of <code>javax.script</code>
903N/Apackage include
903N/A</p>
903N/A<ol>
903N/A <li><p><b>Script execution</b>: Scripts
903N/A are streams of characters used as sources for programs executed by
903N/A script engines. Script execution uses
903N/A {@link javax.script.ScriptEngine#eval eval} methods of
903N/A {@link javax.script.ScriptEngine ScriptEngine} and methods of the
903N/A {@link javax.script.Invocable Invocable} interface.
903N/A </p>
903N/A <li><p><b>Binding</b>: This facility
903N/A allows Java objects to be exposed to script programs as named
903N/A variables. {@link javax.script.Bindings Bindings} and
903N/A {@link javax.script.ScriptContext ScriptContext}
903N/A classes are used for this purpose.
903N/A </p>
903N/A <li><p><b>Compilation</b>: This
903N/A functionality allows the intermediate code generated by the
903N/A front-end of a script engine to be stored and executed repeatedly.
903N/A This benefits applications that execute the same script multiple
903N/A times. These applications can gain efficiency since the engines'
903N/A front-ends only need to execute once per script rather than once per
903N/A script execution. Note that this functionality is optional and
903N/A script engines may choose not to implement it. Callers need to check
903N/A for availability of the {@link javax.script.Compilable Compilable}
903N/A interface using an <I>instanceof</I> check.
</p>
<li><p><b>Invocation</b>: This
functionality allows the reuse of intermediate code generated by a
script engine's front-end. Whereas Compilation allows entire scripts
represented by intermediate code to be re-executed, Invocation
functionality allows individual procedures/methods in the scripts to
be re-executed. As in the case with compilation, not all script
engines are required to provide this facility. Caller has to check
for {@link javax.script.Invocable Invocable} availability.
</p>
<li><p><b>Script engine discovery and Metadata</b>: Applications
written to the Scripting API might have specific requirements on
script engines. Some may require a specific scripting language
and/or version while others may require a specific implementation
engine and/or version. Script engines are packaged in a specified
way so that engines can be discovered at runtime and queried for
attributes. The Engine discovery mechanism is based on the Service
discovery mechanism described in the <b>Jar File Specification</b>.
Script engine implementing classes are packaged in jar files that
include a text resource named
<b>META-INF/services/javax.script.ScriptEngineFactory</b>. This
resource must include a line for each
{@link javax.script.ScriptEngineFactory ScriptEngineFactory}
that is packaged in the jar file.
{@link javax.script.ScriptEngineManager ScriptEngineManager}
includes
{@link javax.script.ScriptEngineManager#getEngineFactories getEngineFactories} method to get all
{@link javax.script.ScriptEngineFactory ScriptEngineFactory} instances
discovered using this mechanism. <code>ScriptEngineFactory</code> has
methods to query attributes about script engine.
</p>
</ol>
@since 1.6
</body>
</html>