public class ScriptExecution extends Object
ScriptEngineFactory
ies
of installed ScriptEngine
s.
It provides a facade to the installed ScriptEngine
s
that implement javax.script.ScriptEngine
.
The services ContentGraphProvider
, DiscobitsHandler
, and
TcManager
are provided to the ScriptEngine's eval method through
the parameter Bindings
. In a script, they are accessible under the
names contentGraphProvider, contentHandler, and tcManager respectively.ScriptEngineManager
,
ScriptEngine
Constructor and Description |
---|
ScriptExecution() |
Modifier and Type | Method and Description |
---|---|
protected void |
bindScriptEngineFactory(javax.script.ScriptEngineFactory factory)
Binds a ScriptEngineFactory.
|
Object |
execute(NonLiteral scriptResource) |
Object |
execute(NonLiteral scriptResource,
javax.script.Bindings bindings)
Executes the specified
scriptResource . |
Object |
execute(String script,
javax.script.Bindings bindings,
String language,
String languageVersion)
Executes the specified
script with the ScriptEngine
that is registered for language and languageVersion . |
Iterator<ScriptLanguageDescription> |
getInstalledScriptLanguages()
Returns all installed script language descriptions.
|
protected void |
unbindScriptEngineFactory(javax.script.ScriptEngineFactory factory)
Unbinds a ScriptEngineFactory.
|
public Object execute(NonLiteral scriptResource) throws javax.script.ScriptException, NoEngineException
javax.script.ScriptException
NoEngineException
execute(org.apache.clerezza.rdf.core.NonLiteral, javax.script.Bindings)
public Object execute(NonLiteral scriptResource, javax.script.Bindings bindings) throws javax.script.ScriptException, NoEngineException
scriptResource
.
The output is either a GraphNode or a response with
the media type specified by the producedType property
of the associated script.
GraphNodes can be rendered by Renderlets registered for the type
of the GraphNode.scriptResource
- The resource (URI).bindings
- Name/Value pairs of Java Object
s made accessible
to scriptjavax.script.ScriptException
- If an error occurrs in the script.NoEngineException
- If no engine can be foundSCRIPT.Script
,
SCRIPT.producedType
,
Renderlet
public Object execute(String script, javax.script.Bindings bindings, String language, String languageVersion) throws javax.script.ScriptException, NoEngineException
script
with the ScriptEngine
that is registered for language
and languageVersion
.
The default ScriptContext
for the ScriptEngine
is used.
It uses bindings
as the ScriptContext.ENGINE_SCOPE
Bindings of the ScriptEngine during the script execution.
Three new attributes are added to the bindings: contentGraphProvider,
contentHandler, and tcManager.
The Reader, Writer and non-ENGINE_SCOPE Bindings of the default
ScriptContext are used. The ENGINE_SCOPE Bindings of the ScriptEngine
is not changed, and its mappings are unaltered by the script execution.
script
- The script language source to be executed.bindings
- The Bindings of attributes to be used for script execution.language
- The script language.
It is used to determine the ScriptEngine.languageVersion
- The version of the script language.
It is used to determine the ScriptEngine.script
.javax.script.ScriptException
- If an error occurrs in the script.NoEngineException
- If no engine can be found for the specified languageScriptEngine.eval(java.lang.String, javax.script.Bindings)
public Iterator<ScriptLanguageDescription> getInstalledScriptLanguages()
ScriptLanguageDescription
protected void bindScriptEngineFactory(javax.script.ScriptEngineFactory factory)
factory
- the script engine factory to bindprotected void unbindScriptEngineFactory(javax.script.ScriptEngineFactory factory)
factory
- the script engine factory to unbindCopyright © 2014 The Apache Software Foundation. All Rights Reserved.