|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.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(org.apache.camel.CamelContext camelContext,
String scriptLanguage,
String scriptText)
Constructor. |
|
ScriptBuilder(org.apache.camel.CamelContext camelContext,
String scriptLanguage,
String scriptText,
ScriptEngineFactory scriptEngineFactory)
Constructor. |
|
ScriptBuilder(String scriptLanguage,
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 static ScriptEngine |
createScriptEngine(String language)
|
|
protected ScriptEvaluationException |
createScriptEvaluationException(Throwable e)
|
|
protected static InputStreamReader |
createScriptReader(org.apache.camel.spi.ClassResolver classResolver,
String resource)
|
|
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()
|
|
String |
getScriptDescription()
Returns a description of the script |
|
String |
getScriptLanguage()
|
|
static ScriptBuilder |
groovy(String scriptText)
Creates a script builder for the groovy script contents |
|
static ScriptBuilder |
javaScript(String scriptText)
Creates a script builder for the JavaScript/ECMAScript script contents |
|
protected static ScriptEngineFactory |
lookupScriptEngineFactory(String language)
|
|
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 ScriptContext |
populateBindings(ScriptEngine engine,
org.apache.camel.Exchange exchange,
Map<String,Object> attributes)
|
|
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(ScriptEngine engine,
org.apache.camel.Exchange exchange,
ScriptContext context)
|
|
static ScriptBuilder |
script(String language,
String scriptText)
Creates a script builder for the named language and script contents |
|
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 scriptLanguage, String scriptText)
scriptLanguage
- the name of the scripting languagescriptText
- the script text to be evaluated, or a reference to a script resourcepublic ScriptBuilder(org.apache.camel.CamelContext camelContext, String scriptLanguage, String scriptText)
scriptLanguage
- the name of the scripting languagescriptText
- the script text to be evaluated, or a reference to a script resourcepublic ScriptBuilder(org.apache.camel.CamelContext camelContext, String scriptLanguage, String scriptText, ScriptEngineFactory scriptEngineFactory)
scriptLanguage
- the name of the scripting languagescriptText
- the script text to be evaluated, or a reference to a script resourcescriptEngineFactory
- the script engine factoryMethod 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 CompiledScript getCompiledScript()
public String getScriptLanguage()
public String getScriptDescription()
protected boolean matches(org.apache.camel.Exchange exchange, Object scriptValue)
protected static ScriptEngineFactory lookupScriptEngineFactory(String language)
protected static ScriptEngine createScriptEngine(String language)
protected Object evaluateScript(org.apache.camel.Exchange exchange)
protected Object runScript(ScriptEngine engine, org.apache.camel.Exchange exchange, ScriptContext context) throws ScriptException, IOException
ScriptException
IOException
protected ScriptContext populateBindings(ScriptEngine engine, org.apache.camel.Exchange exchange, Map<String,Object> attributes)
protected void addScriptEngineArguments(ScriptEngine engine, org.apache.camel.Exchange exchange)
protected static InputStreamReader createScriptReader(org.apache.camel.spi.ClassResolver classResolver, String resource) throws IOException
IOException
protected ScriptEvaluationException createScriptEvaluationException(Throwable e)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |