This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch CAMEL-16593 in repository https://gitbox.apache.org/repos/asf/camel.git
commit a825d4fe8473c44572923f5bf0dbceb0f66e058c Author: Claus Ibsen <[email protected]> AuthorDate: Sat May 8 13:08:03 2021 +0200 CAMEL-16593: Kamelets local bean - Allow to use expression language to supply the bean WIP --- .../model/RouteTemplateBeanFactoryDefinition.java | 69 +++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/RouteTemplateBeanFactoryDefinition.java b/core/camel-core-model/src/main/java/org/apache/camel/model/RouteTemplateBeanFactoryDefinition.java index c3ee3b8..22235e1 100644 --- a/core/camel-core-model/src/main/java/org/apache/camel/model/RouteTemplateBeanFactoryDefinition.java +++ b/core/camel-core-model/src/main/java/org/apache/camel/model/RouteTemplateBeanFactoryDefinition.java @@ -36,7 +36,7 @@ public class RouteTemplateBeanFactoryDefinition { private RouteTemplateDefinition parent; // it only makes sense to use the languages that are general purpose scripting languages @XmlAttribute(required = true) - @Metadata(enums = "bean,groovy,joor,mvel,ognl,spel") + @Metadata(enums = "bean,groovy,joor,language,mvel,ognl,spel") private String language; @XmlValue private String script; @@ -76,10 +76,21 @@ public class RouteTemplateBeanFactoryDefinition { // fluent builders // ---------------------------------------------------- + /** + * Calls a method on a bean for creating the local template bean + * + * @param type the bean class to call + */ public RouteTemplateDefinition bean(Class<?> type) { return bean(type, null); } + /** + * Calls a method on a bean for creating the local template bean + * + * @param type the bean class to call + * @param method the name of the method to call + */ public RouteTemplateDefinition bean(Class<?> type, String method) { setLanguage("bean"); if (method != null) { @@ -90,30 +101,86 @@ public class RouteTemplateBeanFactoryDefinition { return parent; } + /** + * Calls a groovy script for creating the local template bean + * + * If the script use the prefix <tt>resource:</tt> such as <tt>resource:classpath:com/foo/myscript.groovy</tt>, + * <tt>resource:file:/var/myscript.groovy</tt>, then its loaded from the external resource. + * + * @param script the script + */ public RouteTemplateDefinition groovy(String script) { setLanguage("groovy"); setScript(script); return parent; } + /** + * Calls joor script (Java source that is runtime compiled to Java bytecode) + * for creating the local template bean + * + * If the script use the prefix <tt>resource:</tt> such as <tt>resource:classpath:com/foo/myscript.groovy</tt>, + * <tt>resource:file:/var/myscript.groovy</tt>, then its loaded from the external resource. + * + * @param script the script + */ public RouteTemplateDefinition joor(String script) { setLanguage("joor"); setScript(script); return parent; } + /** + * Calls a custom language for creating the local template bean + * + * If the script use the prefix <tt>resource:</tt> such as <tt>resource:classpath:com/foo/myscript.groovy</tt>, + * <tt>resource:file:/var/myscript.groovy</tt>, then its loaded from the external resource. + * + * @param language the custom language (a language not provided out of the box from Camel) + * @param script the script + */ + public RouteTemplateDefinition language(String language, String script) { + setLanguage(language); + setScript(script); + return parent; + } + + /** + * Calls a MvEL script for creating the local template bean + * + * If the script use the prefix <tt>resource:</tt> such as <tt>resource:classpath:com/foo/myscript.groovy</tt>, + * <tt>resource:file:/var/myscript.groovy</tt>, then its loaded from the external resource. + * + * @param script the script + */ public RouteTemplateDefinition mvel(String script) { setLanguage("mvel"); setScript(script); return parent; } + /** + * Calls a OGNL script for creating the local template bean + * + * If the script use the prefix <tt>resource:</tt> such as <tt>resource:classpath:com/foo/myscript.groovy</tt>, + * <tt>resource:file:/var/myscript.groovy</tt>, then its loaded from the external resource. + * + * @param script the script + */ public RouteTemplateDefinition ognl(String script) { setLanguage("ognl"); setScript(script); return parent; } + /** + * Calls a SpEL script (Spring Expression Language) for creating the local template bean + * + * If the script use the prefix <tt>resource:</tt> such as <tt>resource:classpath:com/foo/myscript.groovy</tt>, + * <tt>resource:file:/var/myscript.groovy</tt>, then its loaded from the external resource. + * + * @param script the script + */ public RouteTemplateDefinition spel(String script) { setLanguage("spel"); setScript(script);
