简体   繁体   English

将Spring bean注入Camel DSL

[英]Injecting Spring bean into Camel DSL

Trying to add Spring bean to Camel body property. 试图将春豆添加到骆驼的身体属性。 Something like: 就像是:

MVEL: exchange.in.body.limit = uiLimit
<transform>
    <mvel>
        exchange.in.body.limit = uiLimit;
        exchange.in.body;
    </mvel>
</transform>
Spel: request.body.limit = uiLimit

Or even putting in header first: 甚至甚至放在标头中:

<setHeader headerName="limit">
  <simple>ref:uiLimit</simple>
</setHeader>

Where uiLimit is: uiLimit在哪里:

<bean id="uiLimit" class="java.math.BigInteger">
  <constructor-arg value="${UI_LIMIT} />
</bean>

And still getting null in header and property. 并且仍然在标头和属性中获取null。

Any ideas why bean lookup in Registry doesn't work for OSGI? 有什么想法为什么在Registry中无法在OSGI中进行bean查找? (all beans/routes inside single bundle) (单个捆绑包中的所有bean /路由)

PS: this works fine in Route: PS:这在Route中工作正常:

<bean ref="uiLimit" method="toString"/>

The transform is only for transforming the message body. transform仅用于转换消息正文。 Not to mutate headers. 不改变标题。

If you want to change a header, use setHeader 如果要更改标题,请使用setHeader

The reason of such behaviour is that Exchange created in another bundle and came via exposed service: 出现这种情况的原因是,Exchange在另一个捆绑软件中创建并通过公开的服务而来:

<osgi:service ref="someHandler" interface="org.apache.camel.Component"/>

Exchange contains Registry/Context from another bundle where this bean is not declared. Exchange包含未声明此bean的另一个捆绑软件中的Registry / Context。 All expression languages are working with Registry/Context attached to Exchange and not with Registry of current budle 所有表达语言都与附加到Exchange的注册表/上下文一起使用,而不与当前好友的注册表一起使用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM