|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.camel.builder.script.ScriptBuilder<E>
public class ScriptBuilder<E extends org.apache.camel.Exchange>
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,
E 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(E exchange)
|
protected Object |
evaluateScript(org.apache.camel.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 |
static ScriptBuilder |
groovy(org.springframework.core.io.Resource scriptResource)
Creates a script builder for the groovy script |
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 |
static ScriptBuilder |
javaScript(File scriptFile)
Creates a script builder for the JavaScript/ECMAScript script |
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 |
boolean |
matches(E exchange)
|
protected boolean |
matches(E exchange,
Object scriptValue)
|
static ScriptBuilder |
php(File scriptFile)
Creates a script builder for the PHP script |
static ScriptBuilder |
php(org.springframework.core.io.Resource scriptResource)
Creates a script builder for the PHP script |
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 |
protected void |
populateBindings(javax.script.ScriptEngine engine,
org.apache.camel.Exchange exchange)
|
void |
process(org.apache.camel.Exchange exchange)
|
static ScriptBuilder |
python(File scriptFile)
Creates a script builder for the Python script |
static ScriptBuilder |
python(org.springframework.core.io.Resource scriptResource)
Creates a script builder for the Python script |
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 |
static ScriptBuilder |
ruby(File scriptFile)
Creates a script builder for the Ruby/JRuby script |
static ScriptBuilder |
ruby(org.springframework.core.io.Resource scriptResource)
Creates a script builder for the Ruby/JRuby script |
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 |
protected Object |
runScript()
|
static ScriptBuilder |
script(String language,
File scriptFile)
Creates a script builder for the named language and script |
static ScriptBuilder |
script(String language,
org.springframework.core.io.Resource scriptResource)
Creates a script builder for the named language and script |
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 |
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(E exchange)
evaluate
in interface org.apache.camel.Expression<E extends org.apache.camel.Exchange>
public boolean matches(E exchange)
matches
in interface org.apache.camel.Predicate<E extends org.apache.camel.Exchange>
public void assertMatches(String text, E exchange) throws AssertionError
assertMatches
in interface org.apache.camel.Predicate<E extends org.apache.camel.Exchange>
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 evaluted
public static ScriptBuilder script(String language, org.springframework.core.io.Resource scriptResource)
language
- the language to use for the scriptscriptResource
- the resource used to load the script
public static ScriptBuilder script(String language, File scriptFile)
language
- the language to use for the scriptscriptFile
- the file used to load the script
public static ScriptBuilder script(String language, URL scriptURL)
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 evaluted
public static ScriptBuilder groovy(org.springframework.core.io.Resource scriptResource)
scriptResource
- the resource used to load the script
public static ScriptBuilder groovy(File scriptFile)
scriptFile
- the file used to load the script
public static ScriptBuilder groovy(URL scriptURL)
scriptURL
- the URL used to load the script
public static ScriptBuilder javaScript(String scriptText)
scriptText
- the script text to be evaluted
public static ScriptBuilder javaScript(org.springframework.core.io.Resource scriptResource)
scriptResource
- the resource used to load the script
public static ScriptBuilder javaScript(File scriptFile)
scriptFile
- the file used to load the script
public static ScriptBuilder javaScript(URL scriptURL)
scriptURL
- the URL used to load the script
public static ScriptBuilder php(String scriptText)
scriptText
- the script text to be evaluted
public static ScriptBuilder php(org.springframework.core.io.Resource scriptResource)
scriptResource
- the resource used to load the script
public static ScriptBuilder php(File scriptFile)
scriptFile
- the file used to load the script
public static ScriptBuilder php(URL scriptURL)
scriptURL
- the URL used to load the script
public static ScriptBuilder python(String scriptText)
scriptText
- the script text to be evaluted
public static ScriptBuilder python(org.springframework.core.io.Resource scriptResource)
scriptResource
- the resource used to load the script
public static ScriptBuilder python(File scriptFile)
scriptFile
- the file used to load the script
public static ScriptBuilder python(URL scriptURL)
scriptURL
- the URL used to load the script
public static ScriptBuilder ruby(String scriptText)
scriptText
- the script text to be evaluted
public static ScriptBuilder ruby(org.springframework.core.io.Resource scriptResource)
scriptResource
- the resource used to load the script
public static ScriptBuilder ruby(File scriptFile)
scriptFile
- the file used to load the script
public static ScriptBuilder ruby(URL scriptURL)
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(E exchange, Object scriptValue)
protected javax.script.ScriptEngine createScriptEngine()
protected void compileScript(javax.script.Compilable compilable)
protected Object evaluateScript(org.apache.camel.Exchange exchange)
protected Object runScript() throws javax.script.ScriptException, IOException
javax.script.ScriptException
IOException
protected void populateBindings(javax.script.ScriptEngine engine, org.apache.camel.Exchange exchange)
protected InputStreamReader createScriptReader() throws IOException
IOException
protected ScriptEvaluationException createScriptCompileException(Exception e)
protected ScriptEvaluationException createScriptEvaluationException(Throwable e)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |