将 Java Class 返回的值存储在 Class Mediator 中
Store Value returned from Java Class in Class Mediator
在我的 WSO2 ESB 中,我创建了一个 Java class,它生成一个字符串值作为输出。现在我用 "Class Mediator" 调用我的 Java class。我如何将从我的 Java class 返回的值存储在我的 WSO2 ESB 中并将其显示为日志调解器中的日志?
您可以将 属性 中的值保存在 class 中介中,如下所示,
public boolean mediate(MessageContext context) {
context.setProperty("testKey","Value in class mediator");
return true;
}
并按如下方式访问存储的值,
<log>
<property name="test log" expression="$ctx:testKey"/>
</log>
您需要在 java class 中设置 属性 例如 context.setProperty("propertyName","PropertyValue")
现在,由于 属性 已在 java class 中设置,因此您可以通过使用表达式 $ctx:propertyName
或尝试使用 get-property(propertyName)
两者都会获取值,但 $ctx
与 get-property
相比性能更快
在我的 WSO2 ESB 中,我创建了一个 Java class,它生成一个字符串值作为输出。现在我用 "Class Mediator" 调用我的 Java class。我如何将从我的 Java class 返回的值存储在我的 WSO2 ESB 中并将其显示为日志调解器中的日志?
您可以将 属性 中的值保存在 class 中介中,如下所示,
public boolean mediate(MessageContext context) {
context.setProperty("testKey","Value in class mediator");
return true;
}
并按如下方式访问存储的值,
<log>
<property name="test log" expression="$ctx:testKey"/>
</log>
您需要在 java class 中设置 属性 例如 context.setProperty("propertyName","PropertyValue")
现在,由于 属性 已在 java class 中设置,因此您可以通过使用表达式 $ctx:propertyName
或尝试使用 get-property(propertyName)
两者都会获取值,但 $ctx
与 get-property