这是用户在 2024-3-28 21:37 为 https://camel.apache.org/manual/expression.html#_expression 保存的双语快照页面,由 沉浸式翻译 提供双语支持。了解如何保存?

 表达


然后,表达式和谓词可用于在 DSL 中创建各种企业集成模式,如收件人列表 EIP。


为支持动态规则,Camel 支持使用各种不同语言的可插拔表达策略。

 表达式 API


如果您在 DSL 之外,想要创建自己的表达式,您可以实现 Expression 接口,重用其他构建器,或者尝试使用 ExpressionBuilder 类。

 表达


如图所示,Camel Expression 的 API 定义在 org.apache.camel.Expression 接口中:

public interface Expression {

    /**
     * Returns the value of the expression on the given exchange
     *
     * @param exchange the message exchange on which to evaluate the expression
     * @param type the expected type of the evaluation result
     * @return the value of the expression
     */
    <T> T evaluate(Exchange exchange, Class<T> type);
}