public class RhinoAdapter extends LanguageAdapterBase
LanguageAdapter
that supports the JavaScript language as
implemented by Rhino.Modifier and Type | Field and Description |
---|---|
protected ClassCompiler |
classCompiler
Rhino class compiler.
|
static int |
DEFAULT_OPTIMIZATION_LEVEL
The Rhino default optimization level.
|
protected GeneratedClassLoader |
generatedClassLoader
Rhino class loader.
|
static String |
JAVASCRIPT_CACHE_DIR
The default base directory for cached executables.
|
static int |
LANGUAGE_VERSION
JavaScript language version.
|
static String |
RHINO_CONTEXT
The Rhino context attribute.
|
static String |
RHINO_OPTIMIZATION_LEVEL
The Rhino optimization level language manager attribute.
|
static String |
RHINO_SCOPE
The Rhino scope attribute.
|
DEFAULT_EXTENSION, DEFAULT_TAG, EXTENSIONS, LANGUAGE_NAME, NAME, TAGS, VERSION
Constructor and Description |
---|
RhinoAdapter()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static ExecutionException |
createExecutionException(Executable executable,
Exception x)
Creates an execution exception with a full stack.
|
Program |
createProgram(String sourceCode,
boolean isScriptlet,
int position,
int startLineNumber,
int startColumnNumber,
Executable executable)
Turns source code into a program.
|
Object |
enter(String entryPointName,
Executable executable,
ExecutionContext executionContext,
Object... arguments)
Enters the executable at a stored, named location.
|
Context |
enterContext(ExecutionContext executionContext)
Enters a Rhino context stored in the execution context, creating it if it
doesn't exist.
|
File |
getCacheDir()
The base directory for cached executables.
|
ScriptableObject |
getScope(Executable executable,
ExecutionContext executionContext,
Context context,
int startLineNumber)
Gets the Rhino scope associated with the Rhino context of the execution
context, creating it if it doesn't exist.
|
String |
getSourceCodeForExpressionInclude(String expression,
Executable executable)
Creates source code for including the output of a text-with-scriptlets
document.
|
String |
getSourceCodeForExpressionOutput(String expression,
Executable executable)
Creates source code for outputting a source code expression to standard
output.
|
String |
getSourceCodeForLiteralOutput(String literal,
Executable executable)
Creates source code for outputting literal text to standard output.
|
getAttributes, getLock, getManager, isEphemeral, isThreadSafe, releaseContext, setManager
public static final String RHINO_CONTEXT
public static final String RHINO_SCOPE
public static final String RHINO_OPTIMIZATION_LEVEL
public static final String JAVASCRIPT_CACHE_DIR
public static final int LANGUAGE_VERSION
public static int DEFAULT_OPTIMIZATION_LEVEL
protected final ClassCompiler classCompiler
protected final GeneratedClassLoader generatedClassLoader
public RhinoAdapter() throws LanguageAdapterException
LanguageAdapterException
- In case of an initialization errorpublic static ExecutionException createExecutionException(Executable executable, Exception x)
executable
- The executablex
- The exceptionpublic ScriptableObject getScope(Executable executable, ExecutionContext executionContext, Context context, int startLineNumber)
executable
- The executableexecutionContext
- The execution contextcontext
- The Rhino contextstartLineNumber
- The start line number of the scriptletenterContext(ExecutionContext)
public File getCacheDir()
public Context enterContext(ExecutionContext executionContext)
executionContext
- The execution contextpublic String getSourceCodeForLiteralOutput(String literal, Executable executable) throws ParsingException
LanguageAdapter
getSourceCodeForLiteralOutput
in interface LanguageAdapter
getSourceCodeForLiteralOutput
in class LanguageAdapterBase
literal
- The literal textexecutable
- The executableParsingException
- In case of a parsing errorpublic String getSourceCodeForExpressionOutput(String expression, Executable executable) throws ParsingException
LanguageAdapter
getSourceCodeForExpressionOutput
in interface LanguageAdapter
getSourceCodeForExpressionOutput
in class LanguageAdapterBase
expression
- The source code expressionexecutable
- The executableParsingException
- In case of a parsing errorpublic String getSourceCodeForExpressionInclude(String expression, Executable executable) throws ParsingException
LanguageAdapter
For this to work, the executable must have been created with a container
that supports an inclusion command named according to the language
manager attribute
LanguageManager.CONTAINER_INCLUDE_COMMAND_ATTRIBUTE
.
getSourceCodeForExpressionInclude
in interface LanguageAdapter
getSourceCodeForExpressionInclude
in class LanguageAdapterBase
expression
- The source code expressionexecutable
- The executableParsingException
- In case of a parsing errorLanguageManager.getAttributes()
public Program createProgram(String sourceCode, boolean isScriptlet, int position, int startLineNumber, int startColumnNumber, Executable executable) throws ParsingException
LanguageAdapter
Program.prepare()
on the program.sourceCode
- The source codeisScriptlet
- Whether the source code is a scriptletposition
- The program's position in the executablestartLineNumber
- The line number in the document for where the program's source
code beginsstartColumnNumber
- The column number in the document for where the program's source
code beginsexecutable
- The executableParsingException
- In case of a parsing errorpublic Object enter(String entryPointName, Executable executable, ExecutionContext executionContext, Object... arguments) throws NoSuchMethodException, ParsingException, ExecutionException
LanguageAdapter
enter
in interface LanguageAdapter
enter
in class LanguageAdapterBase
entryPointName
- The entry point nameexecutable
- The executableexecutionContext
- The executable contextarguments
- Optional state to pass to the entry pointNoSuchMethodException
- In case the entry point does not existParsingException
- In case of a parsing errorExecutionException
- In case of an execution errorCopyright © 2009-2015 Three Crickets LLC.