Package org.apache.camel.support
Class ScriptHelper
java.lang.Object
org.apache.camel.support.ScriptHelper
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
hasExternalScript
(String external) Whether the expression/predicate refers to an external script on the file/classpath etc.static String
resolveOptionalExternalScript
(org.apache.camel.CamelContext camelContext, String expression) Resolves the expression/predicate whether it refers to an external script on the file/classpath etc.static String
resolveOptionalExternalScript
(org.apache.camel.CamelContext camelContext, org.apache.camel.Exchange exchange, String expression) Resolves the expression/predicate whether it refers to an external script on the file/classpath etc.
-
Method Details
-
resolveOptionalExternalScript
public static String resolveOptionalExternalScript(org.apache.camel.CamelContext camelContext, String expression) Resolves the expression/predicate whether it refers to an external script on the file/classpath etc. This requires to use the prefix resource: such as resource:classpath:com/foo/myscript.groovy, resource:file:/var/myscript.groovy. If not then the returned value is returned as-is. The resource is regarded as mandatory and an exception is thrown if the resource cannot be loaded. Adding ?optional=true as suffix will mark the resource as optional and null is returned if the resource could not be loaded. -
resolveOptionalExternalScript
public static String resolveOptionalExternalScript(org.apache.camel.CamelContext camelContext, org.apache.camel.Exchange exchange, String expression) Resolves the expression/predicate whether it refers to an external script on the file/classpath etc. This requires to use the prefix resource: such as resource:classpath:com/foo/myscript.groovy, resource:file:/var/myscript.groovy. If not then the returned value is returned as-is. If the exchange is provided (not null), then the external script can be referred via simple language for dynamic values, etc. resource:classpath:${header.myFileName} The resource is regarded as mandatory and an exception is thrown if the resource cannot be loaded. Adding ?optional=true as suffix will mark the resource as optional and null is returned if the resource could not be loaded. -
hasExternalScript
Whether the expression/predicate refers to an external script on the file/classpath etc. This requires to use the prefix resource: such as resource:classpath:com/foo/myscript.groovy, resource:ref:myResource, resource:file:/var/myscript.groovy.
-