|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.camel.builder.script.ScriptBuilder
public class ScriptBuilder
A builder class for creating Processor
, Expression
and
Predicate
objects using the JSR 223 scripting engine.
Field Summary | |
---|---|
static String |
ARGUMENTS
Additional arguments to ScriptEngine provided as a header on the IN Message
using the key ARGUMENTS |
Constructor Summary | |
---|---|
ScriptBuilder(String scriptEngineName)
Constructor. |
|
ScriptBuilder(String scriptEngineName,
String scriptText)
Constructor. |
Method Summary | ||
---|---|---|
protected void |
addScriptEngineArguments(ScriptEngine engine,
org.apache.camel.Exchange exchange)
|
|
void |
assertMatches(String text,
org.apache.camel.Exchange exchange)
|
|
ScriptBuilder |
attribute(String name,
Object value)
Sets the attribute on the context so that it is available to the script as a variable in the ScriptContext.ENGINE_SCOPE |
|
protected void |
checkInitialised(org.apache.camel.Exchange exchange)
|
|
protected void |
compileScript(Compilable compilable,
org.apache.camel.Exchange exchange)
|
|
protected ScriptEvaluationException |
createScriptCompileException(Exception e)
|
|
protected ScriptEngine |
createScriptEngine()
|
|
protected ScriptEvaluationException |
createScriptEvaluationException(Throwable e)
|
|
protected InputStreamReader |
createScriptReader(org.apache.camel.Exchange exchange)
|
|
Object |
evaluate(org.apache.camel.Exchange exchange)
|
|
|
evaluate(org.apache.camel.Exchange exchange,
Class<T> type)
|
|
protected Object |
evaluateScript(org.apache.camel.Exchange exchange)
|
|
CompiledScript |
getCompiledScript()
|
|
ScriptEngine |
getEngine()
|
|
ScriptContext |
getScriptContext()
Access the script context so that it can be configured such as adding attributes |
|
String |
getScriptDescription()
Returns a description of the script |
|
String |
getScriptEngineName()
|
|
String |
getScriptText()
|
|
static ScriptBuilder |
groovy(String scriptText)
Creates a script builder for the groovy script contents |
|
protected boolean |
isBeanShell()
|
|
protected boolean |
isPython()
|
|
static ScriptBuilder |
javaScript(String scriptText)
Creates a script builder for the JavaScript/ECMAScript script contents |
|
boolean |
matches(org.apache.camel.Exchange exchange)
|
|
protected boolean |
matches(org.apache.camel.Exchange exchange,
Object scriptValue)
|
|
static ScriptBuilder |
php(String scriptText)
Creates a script builder for the PHP script contents |
|
protected void |
populateBindings(ScriptEngine engine,
org.apache.camel.Exchange exchange)
|
|
void |
process(org.apache.camel.Exchange exchange)
|
|
static ScriptBuilder |
python(String scriptText)
Creates a script builder for the Python script contents |
|
static ScriptBuilder |
ruby(String scriptText)
Creates a script builder for the Ruby/JRuby script contents |
|
protected Object |
runScript(org.apache.camel.Exchange exchange)
|
|
static ScriptBuilder |
script(String language,
String scriptText)
Creates a script builder for the named language and script contents |
|
void |
setScriptContext(ScriptContext scriptContext)
Sets the context to use by the script |
|
void |
setScriptText(String scriptText)
|
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String ARGUMENTS
ScriptEngine
provided as a header on the IN Message
using the key ARGUMENTS
Constructor Detail |
---|
public ScriptBuilder(String scriptEngineName)
scriptEngineName
- the name of the scripting languagepublic ScriptBuilder(String scriptEngineName, String scriptText)
scriptEngineName
- the name of the scripting languagescriptText
- the script text to be evaluated, or a reference to a script resourceMethod Detail |
---|
public String toString()
toString
in class Object
public Object evaluate(org.apache.camel.Exchange exchange)
public <T> T evaluate(org.apache.camel.Exchange exchange, Class<T> type)
evaluate
in interface org.apache.camel.Expression
public boolean matches(org.apache.camel.Exchange exchange)
matches
in interface org.apache.camel.Predicate
public void assertMatches(String text, org.apache.camel.Exchange exchange) throws AssertionError
AssertionError
public void process(org.apache.camel.Exchange exchange)
process
in interface org.apache.camel.Processor
public ScriptBuilder attribute(String name, Object value)
ScriptContext.ENGINE_SCOPE
name
- the name of the attributevalue
- the attribute value
public static ScriptBuilder script(String language, String scriptText)
language
- the language to use for the scriptscriptText
- the script text to be evaluated, or a reference to a script resource
public static ScriptBuilder groovy(String scriptText)
scriptText
- the script text to be evaluated, or a reference to a script resource
public static ScriptBuilder javaScript(String scriptText)
scriptText
- the script text to be evaluated, or a reference to a script resource
public static ScriptBuilder php(String scriptText)
scriptText
- the script text to be evaluated, or a reference to a script resource
public static ScriptBuilder python(String scriptText)
scriptText
- the script text to be evaluated, or a reference to a script resource
public static ScriptBuilder ruby(String scriptText)
scriptText
- the script text to be evaluated, or a reference to a script resource
public ScriptEngine getEngine()
public CompiledScript getCompiledScript()
public String getScriptText()
public void setScriptText(String scriptText)
public String getScriptEngineName()
public String getScriptDescription()
public ScriptContext getScriptContext()
public void setScriptContext(ScriptContext scriptContext)
protected void checkInitialised(org.apache.camel.Exchange exchange)
protected boolean matches(org.apache.camel.Exchange exchange, Object scriptValue)
protected ScriptEngine createScriptEngine()
protected void compileScript(Compilable compilable, org.apache.camel.Exchange exchange)
protected Object evaluateScript(org.apache.camel.Exchange exchange)
protected Object runScript(org.apache.camel.Exchange exchange) throws ScriptException, IOException
ScriptException
IOException
protected void populateBindings(ScriptEngine engine, org.apache.camel.Exchange exchange)
protected void addScriptEngineArguments(ScriptEngine engine, org.apache.camel.Exchange exchange)
protected InputStreamReader createScriptReader(org.apache.camel.Exchange exchange) throws IOException
IOException
protected ScriptEvaluationException createScriptCompileException(Exception e)
protected ScriptEvaluationException createScriptEvaluationException(Throwable e)
protected boolean isPython()
protected boolean isBeanShell()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |