public abstract class RhinoBasedProcessor extends ResourceProcessor
| Modifier and Type | Field and Description |
|---|---|
protected static Resource |
commonsScript |
protected static Resource |
cycleScript |
protected static Resource |
envScript |
private org.mozilla.javascript.ScriptableObject |
globalScope |
protected org.slf4j.Logger |
LOG |
protected ResourceFactory |
resourceFactory |
| Constructor and Description |
|---|
RhinoBasedProcessor(ResourceFactory resourceFactory) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addClientSideEnvironment(org.mozilla.javascript.Context context,
org.mozilla.javascript.Scriptable scope) |
protected void |
addCommon(org.mozilla.javascript.Context context,
org.mozilla.javascript.Scriptable scope) |
void |
addJSON(org.mozilla.javascript.Context context,
org.mozilla.javascript.Scriptable scope) |
protected java.lang.String |
buildSimpleRunScript(java.lang.String jsFunction,
java.lang.String content,
java.lang.String... extraArgs) |
protected org.mozilla.javascript.NativeObject |
callModuleFunction(org.mozilla.javascript.Context context,
org.mozilla.javascript.Scriptable scope,
org.mozilla.javascript.Scriptable module,
java.lang.String functionName,
java.lang.String[] args) |
private org.mozilla.javascript.Context |
enterContext() |
protected <T> T |
evaluate(org.mozilla.javascript.Context context,
org.mozilla.javascript.Scriptable scope,
Resource script) |
protected <T> T |
evaluate(org.mozilla.javascript.Context context,
org.mozilla.javascript.Scriptable scope,
java.lang.String script) |
protected <T> T |
evaluate(org.mozilla.javascript.Context context,
org.mozilla.javascript.Scriptable scope,
java.lang.String script,
java.lang.String sourceName) |
protected <T> T |
evaluateFromClasspath(org.mozilla.javascript.Context context,
org.mozilla.javascript.Scriptable scope,
java.lang.String path) |
protected <T> T |
evaluateFromWebjar(org.mozilla.javascript.Context context,
org.mozilla.javascript.Scriptable scope,
java.lang.String path) |
protected abstract void |
initScope(org.mozilla.javascript.Context context,
org.mozilla.javascript.ScriptableObject globalScope) |
protected abstract java.lang.String |
process(org.mozilla.javascript.Context context,
org.mozilla.javascript.Scriptable scope,
Resource resource,
java.lang.String content) |
java.lang.String |
process(Resource resource,
java.lang.String content) |
protected org.mozilla.javascript.Scriptable |
setupModule(org.mozilla.javascript.Context context,
org.mozilla.javascript.Scriptable scope,
Resource moduleResource,
java.lang.String moduleId) |
protected java.lang.String |
toJSMultiLineString(java.lang.String data)
Transforms a java multi-line string into javascript multi-line string.
|
destroyprotected static Resource commonsScript
protected static Resource envScript
protected static Resource cycleScript
protected final org.slf4j.Logger LOG
private org.mozilla.javascript.ScriptableObject globalScope
protected ResourceFactory resourceFactory
public RhinoBasedProcessor(ResourceFactory resourceFactory)
private org.mozilla.javascript.Context enterContext()
protected abstract void initScope(org.mozilla.javascript.Context context,
org.mozilla.javascript.ScriptableObject globalScope)
throws java.io.IOException
java.io.IOExceptionprotected void addCommon(org.mozilla.javascript.Context context,
org.mozilla.javascript.Scriptable scope)
throws java.io.IOException
java.io.IOExceptionprotected void addClientSideEnvironment(org.mozilla.javascript.Context context,
org.mozilla.javascript.Scriptable scope)
throws java.io.IOException
java.io.IOExceptionpublic void addJSON(org.mozilla.javascript.Context context,
org.mozilla.javascript.Scriptable scope)
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String process(Resource resource, java.lang.String content) throws java.lang.Exception
process in class ResourceProcessorjava.lang.Exceptionprotected abstract java.lang.String process(org.mozilla.javascript.Context context,
org.mozilla.javascript.Scriptable scope,
Resource resource,
java.lang.String content)
throws java.lang.Exception
java.lang.Exceptionprotected <T> T evaluate(org.mozilla.javascript.Context context,
org.mozilla.javascript.Scriptable scope,
java.lang.String script,
java.lang.String sourceName)
protected <T> T evaluate(org.mozilla.javascript.Context context,
org.mozilla.javascript.Scriptable scope,
java.lang.String script)
protected <T> T evaluate(org.mozilla.javascript.Context context,
org.mozilla.javascript.Scriptable scope,
Resource script)
throws java.io.IOException
java.io.IOExceptionprotected <T> T evaluateFromClasspath(org.mozilla.javascript.Context context,
org.mozilla.javascript.Scriptable scope,
java.lang.String path)
throws java.io.IOException
java.io.IOExceptionprotected <T> T evaluateFromWebjar(org.mozilla.javascript.Context context,
org.mozilla.javascript.Scriptable scope,
java.lang.String path)
throws java.io.IOException
java.io.IOExceptionprotected org.mozilla.javascript.Scriptable setupModule(org.mozilla.javascript.Context context,
org.mozilla.javascript.Scriptable scope,
Resource moduleResource,
java.lang.String moduleId)
protected org.mozilla.javascript.NativeObject callModuleFunction(org.mozilla.javascript.Context context,
org.mozilla.javascript.Scriptable scope,
org.mozilla.javascript.Scriptable module,
java.lang.String functionName,
java.lang.String[] args)
protected java.lang.String buildSimpleRunScript(java.lang.String jsFunction,
java.lang.String content,
java.lang.String... extraArgs)
protected java.lang.String toJSMultiLineString(java.lang.String data)
http://stackoverflow.com/questions/805107/multiline-strings-in-javascript/data - a string containing new lines.