P - the type of macro parameters bean.public abstract class AbstractJSR223ScriptMacro<P extends JSR223ScriptMacroParameters> extends AbstractScriptMacro<P> implements PrivilegedScriptMacro
| Modifier and Type | Field and Description |
|---|---|
protected ScriptEngineManager |
scriptEngineManager
The JSR223 Script Engine Manager we use to evaluate JSR223 scripts.
|
CONTENT_DESCRIPTION, documentAccessBridge, execution| Constructor and Description |
|---|
AbstractJSR223ScriptMacro(String macroName) |
AbstractJSR223ScriptMacro(String macroName,
String macroDescription) |
AbstractJSR223ScriptMacro(String macroName,
String macroDescription,
Class<? extends JSR223ScriptMacroParameters> parametersBeanClass) |
AbstractJSR223ScriptMacro(String macroName,
String macroDescription,
org.xwiki.rendering.macro.descriptor.ContentDescriptor contentDescriptor) |
AbstractJSR223ScriptMacro(String macroName,
String macroDescription,
org.xwiki.rendering.macro.descriptor.ContentDescriptor contentDescriptor,
Class<? extends JSR223ScriptMacroParameters> parametersBeanClass) |
| Modifier and Type | Method and Description |
|---|---|
protected Object |
eval(String content,
ScriptEngine engine,
ScriptContext scriptContext)
Execute the script.
|
protected List<org.xwiki.rendering.block.Block> |
evaluateBlock(P parameters,
String content,
org.xwiki.rendering.transformation.MacroTransformationContext context)
Execute provided script and return
Block based result. |
protected List<org.xwiki.rendering.block.Block> |
evaluateBlock(ScriptEngine engine,
P parameters,
String content,
org.xwiki.rendering.transformation.MacroTransformationContext context)
Execute provided script and return
Block based result. |
protected CompiledScript |
getCompiledScript(String content,
Compilable engine)
Return a compiled version of the provided script.
|
protected ScriptContext |
getScriptContext()
Get the current ScriptContext and refresh it.
|
protected String |
getScriptEngineName(P parameters,
org.xwiki.rendering.transformation.MacroTransformationContext context)
Method to overwrite to indicate the script engine name.
|
void |
initialize() |
boolean |
supportsInlineMode() |
evaluate, evaluateString, execute, getComponentManager, parseScriptResult, parseSourceSyntaxprotected ScriptEngineManager scriptEngineManager
public AbstractJSR223ScriptMacro(String macroName)
macroName - the name of the macro (eg "groovy")public AbstractJSR223ScriptMacro(String macroName, String macroDescription)
macroName - the name of the macro (eg "groovy")macroDescription - the text description of the macro.public AbstractJSR223ScriptMacro(String macroName, String macroDescription, org.xwiki.rendering.macro.descriptor.ContentDescriptor contentDescriptor)
macroName - the name of the macro (eg "groovy")macroDescription - the text description of the macro.contentDescriptor - the description of the macro content.public AbstractJSR223ScriptMacro(String macroName, String macroDescription, Class<? extends JSR223ScriptMacroParameters> parametersBeanClass)
macroName - the name of the macro (eg "groovy")macroDescription - the text description of the macro.parametersBeanClass - class of the parameters bean for this macro.public AbstractJSR223ScriptMacro(String macroName, String macroDescription, org.xwiki.rendering.macro.descriptor.ContentDescriptor contentDescriptor, Class<? extends JSR223ScriptMacroParameters> parametersBeanClass)
macroName - the name of the macro (eg "groovy")macroDescription - the text description of the macro.contentDescriptor - the description of the macro content.parametersBeanClass - class of the parameters bean for this macro.public void initialize()
throws org.xwiki.component.phase.InitializationException
initialize in interface org.xwiki.component.phase.Initializableinitialize in class org.xwiki.rendering.macro.AbstractMacro<P extends JSR223ScriptMacroParameters>org.xwiki.component.phase.InitializationExceptionpublic boolean supportsInlineMode()
supportsInlineMode in interface org.xwiki.rendering.macro.Macro<P extends JSR223ScriptMacroParameters>protected String getScriptEngineName(P parameters, org.xwiki.rendering.transformation.MacroTransformationContext context)
parameters - the macro parameters.context - the context of the macro transformation.protected ScriptContext getScriptContext()
protected List<org.xwiki.rendering.block.Block> evaluateBlock(P parameters, String content, org.xwiki.rendering.transformation.MacroTransformationContext context) throws org.xwiki.rendering.macro.MacroExecutionException
AbstractScriptMacroBlock based result.evaluateBlock in class AbstractScriptMacro<P extends JSR223ScriptMacroParameters>parameters - the macro parameters.content - the script to execute.context - the context of the macro transformation.org.xwiki.rendering.macro.MacroExecutionException - failed to evaluate provided content.protected List<org.xwiki.rendering.block.Block> evaluateBlock(ScriptEngine engine, P parameters, String content, org.xwiki.rendering.transformation.MacroTransformationContext context) throws ScriptException, org.xwiki.rendering.macro.MacroExecutionException
Block based result.engine - the script engine to use to evaluate the script.parameters - the macro parameters.content - the script to execute.context - the context of the macro transformation.ScriptException - failed to evaluate scriptorg.xwiki.rendering.macro.MacroExecutionException - failed to evaluate provided content.protected Object eval(String content, ScriptEngine engine, ScriptContext scriptContext) throws ScriptException
content - the script to be executed by the script engineengine - the script enginescriptContext - the script contextScriptException - if an error occurrs in script. ScriptEngines should create and throw
ScriptException wrappers for checked Exceptions thrown by underlying scripting
implementations.protected CompiledScript getCompiledScript(String content, Compilable engine) throws ScriptException
content - the script to compile.engine - the script engine.ScriptException - failed to compile the script.Copyright © 2004–2014 XWiki. All rights reserved.