|
|||||||||
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.
Constructor Summary | |
---|---|
ScriptBuilder(String scriptEngineName)
|
|
ScriptBuilder(String scriptEngineName,
org.springframework.core.io.Resource scriptResource)
|
|
ScriptBuilder(String scriptEngineName,
String scriptText)
|
Method Summary | ||
---|---|---|
void |
assertMatches(String text,
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()
|
|
protected void |
compileScript(javax.script.Compilable compilable)
|
|
protected ScriptEvaluationException |
createScriptCompileException(Exception e)
|
|
protected javax.script.ScriptEngine |
createScriptEngine()
|
|
protected ScriptEvaluationException |
createScriptEvaluationException(Throwable e)
|
|
protected InputStreamReader |
createScriptReader()
|
|
Object |
evaluate(Exchange exchange)
|
|
|
evaluate(Exchange exchange,
Class<T> type)
|
|
protected Object |
evaluateScript(Exchange exchange)
|
|
javax.script.CompiledScript |
getCompiledScript()
|
|
javax.script.ScriptEngine |
getEngine()
|
|
javax.script.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()
|
|
org.springframework.core.io.Resource |
getScriptResource()
|
|
String |
getScriptText()
|
|
static ScriptBuilder |
groovy(File scriptFile)
Creates a script builder for the groovy script File |
|
static ScriptBuilder |
groovy(org.springframework.core.io.Resource scriptResource)
Creates a script builder for the groovy script Resource |
|
static ScriptBuilder |
groovy(String scriptText)
Creates a script builder for the groovy script contents |
|
static ScriptBuilder |
groovy(URL scriptURL)
Creates a script builder for the groovy script URL |
|
protected boolean |
isPython()
|
|
static ScriptBuilder |
javaScript(File scriptFile)
Creates a script builder for the JavaScript/ECMAScript script File |
|
static ScriptBuilder |
javaScript(org.springframework.core.io.Resource scriptResource)
Creates a script builder for the JavaScript/ECMAScript script |
|
static ScriptBuilder |
javaScript(String scriptText)
Creates a script builder for the JavaScript/ECMAScript script contents |
|
static ScriptBuilder |
javaScript(URL scriptURL)
Creates a script builder for the JavaScript/ECMAScript script URL |
|
boolean |
matches(Exchange exchange)
|
|
protected boolean |
matches(Exchange exchange,
Object scriptValue)
|
|
static ScriptBuilder |
php(File scriptFile)
Creates a script builder for the PHP script File |
|
static ScriptBuilder |
php(org.springframework.core.io.Resource scriptResource)
Creates a script builder for the PHP script Resource |
|
static ScriptBuilder |
php(String scriptText)
Creates a script builder for the PHP script contents |
|
static ScriptBuilder |
php(URL scriptURL)
Creates a script builder for the PHP script URL |
|
protected void |
populateBindings(javax.script.ScriptEngine engine,
Exchange exchange)
|
|
void |
process(Exchange exchange)
|
|
static ScriptBuilder |
python(File scriptFile)
Creates a script builder for the Python script File |
|
static ScriptBuilder |
python(org.springframework.core.io.Resource scriptResource)
Creates a script builder for the Python script Resource |
|
static ScriptBuilder |
python(String scriptText)
Creates a script builder for the Python script contents |
|
static ScriptBuilder |
python(URL scriptURL)
Creates a script builder for the Python script URL |
|
static ScriptBuilder |
ruby(File scriptFile)
Creates a script builder for the Ruby/JRuby script File |
|
static ScriptBuilder |
ruby(org.springframework.core.io.Resource scriptResource)
Creates a script builder for the Ruby/JRuby script Resource |
|
static ScriptBuilder |
ruby(String scriptText)
Creates a script builder for the Ruby/JRuby script contents |
|
static ScriptBuilder |
ruby(URL scriptURL)
Creates a script builder for the Ruby/JRuby script URL |
|
protected Object |
runScript()
|
|
static ScriptBuilder |
script(String language,
File scriptFile)
Creates a script builder for the named language and script File |
|
static ScriptBuilder |
script(String language,
org.springframework.core.io.Resource scriptResource)
Creates a script builder for the named language and script Resource |
|
static ScriptBuilder |
script(String language,
String scriptText)
Creates a script builder for the named language and script contents |
|
static ScriptBuilder |
script(String language,
URL scriptURL)
Creates a script builder for the named language and script URL |
|
void |
setScriptContext(javax.script.ScriptContext scriptContext)
Sets the context to use by the script |
|
void |
setScriptResource(org.springframework.core.io.Resource scriptResource)
|
|
void |
setScriptText(String scriptText)
|
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ScriptBuilder(String scriptEngineName)
public ScriptBuilder(String scriptEngineName, String scriptText)
public ScriptBuilder(String scriptEngineName, org.springframework.core.io.Resource scriptResource)
Method Detail |
---|
public String toString()
toString
in class Object
public Object evaluate(Exchange exchange)
public <T> T evaluate(Exchange exchange, Class<T> type)
evaluate
in interface Expression
public boolean matches(Exchange exchange)
matches
in interface Predicate
public void assertMatches(String text, Exchange exchange) throws AssertionError
AssertionError
public void process(Exchange exchange)
process
in interface 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
public static ScriptBuilder script(String language, org.springframework.core.io.Resource scriptResource)
Resource
language
- the language to use for the scriptscriptResource
- the resource used to load the script
public static ScriptBuilder script(String language, File scriptFile)
File
language
- the language to use for the scriptscriptFile
- the file used to load the script
public static ScriptBuilder script(String language, URL scriptURL)
URL
language
- the language to use for the scriptscriptURL
- the URL used to load the script
public static ScriptBuilder groovy(String scriptText)
scriptText
- the script text to be evaluated
public static ScriptBuilder groovy(org.springframework.core.io.Resource scriptResource)
Resource
scriptResource
- the resource used to load the script
public static ScriptBuilder groovy(File scriptFile)
File
scriptFile
- the file used to load the script
public static ScriptBuilder groovy(URL scriptURL)
URL
scriptURL
- the URL used to load the script
public static ScriptBuilder javaScript(String scriptText)
scriptText
- the script text to be evaluated
public static ScriptBuilder javaScript(org.springframework.core.io.Resource scriptResource)
scriptResource
- the resource used to load the script
public static ScriptBuilder javaScript(File scriptFile)
File
scriptFile
- the file used to load the script
public static ScriptBuilder javaScript(URL scriptURL)
URL
scriptURL
- the URL used to load the script
public static ScriptBuilder php(String scriptText)
scriptText
- the script text to be evaluated
public static ScriptBuilder php(org.springframework.core.io.Resource scriptResource)
Resource
scriptResource
- the resource used to load the script
public static ScriptBuilder php(File scriptFile)
File
scriptFile
- the file used to load the script
public static ScriptBuilder php(URL scriptURL)
URL
scriptURL
- the URL used to load the script
public static ScriptBuilder python(String scriptText)
scriptText
- the script text to be evaluated
public static ScriptBuilder python(org.springframework.core.io.Resource scriptResource)
Resource
scriptResource
- the resource used to load the script
public static ScriptBuilder python(File scriptFile)
File
scriptFile
- the file used to load the script
public static ScriptBuilder python(URL scriptURL)
URL
scriptURL
- the URL used to load the script
public static ScriptBuilder ruby(String scriptText)
scriptText
- the script text to be evaluated
public static ScriptBuilder ruby(org.springframework.core.io.Resource scriptResource)
Resource
scriptResource
- the resource used to load the script
public static ScriptBuilder ruby(File scriptFile)
File
scriptFile
- the file used to load the script
public static ScriptBuilder ruby(URL scriptURL)
URL
scriptURL
- the URL used to load the script
public javax.script.ScriptEngine getEngine()
public javax.script.CompiledScript getCompiledScript()
public String getScriptText()
public void setScriptText(String scriptText)
public String getScriptEngineName()
public String getScriptDescription()
public javax.script.ScriptContext getScriptContext()
public void setScriptContext(javax.script.ScriptContext scriptContext)
public org.springframework.core.io.Resource getScriptResource()
public void setScriptResource(org.springframework.core.io.Resource scriptResource)
protected void checkInitialised()
protected boolean matches(Exchange exchange, Object scriptValue)
protected javax.script.ScriptEngine createScriptEngine()
protected void compileScript(javax.script.Compilable compilable)
protected Object evaluateScript(Exchange exchange)
protected Object runScript() throws javax.script.ScriptException, IOException
javax.script.ScriptException
IOException
protected void populateBindings(javax.script.ScriptEngine engine, Exchange exchange)
protected InputStreamReader createScriptReader() throws IOException
IOException
protected ScriptEvaluationException createScriptCompileException(Exception e)
protected ScriptEvaluationException createScriptEvaluationException(Throwable e)
protected boolean isPython()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |