package ats.emvo.routing;
public class routingpath {
public String RoutingPathToXml() {
String requestLogPath ="file:///d:/in"; //(String) AtsBundleActivator.atsEmvoRoutingProperties.get("requestlogpath");
return requestLogPath;
}
}
我想把这个返回字符串作为路径路径在jboss fuse中获取bean 到目前为止我在camel cxml中调用了它,但是我没有在这里获得返回值。
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<camelContext id="cbr-example-context" xmlns="http://camel.apache.org/schema/blueprint">
<route id="_route1">
<from id="_from1" uri="bean:routingInInterceptor"/>
<to id="_to2" uri="file:///d:/out"/>
</route>
</camelContext>
<bean class="ats.emvo.routing.routingpath" id="routingInInterceptor"/>
</blueprint>
答案 0 :(得分:0)
如果你想跟随,我会提出另一种方法。
根据Camel,“bean:component将bean绑定到Camel消息交换”。因此,如果您在bean调用之后打印Exchange消息体,您将看到来自bean的内容。
...
<uri="bean:routingInInterceptor"/>
<log message=Contents of bean: ${body}/> <!-- "file:///d:/in" -->
...
所以信息放在Exchange中。
在您的情况下,您希望“从”而不是从硬编码的端点URI开始路由。
方法1 因此,您可以在端点URI中使用属性占位符。因此,在设置属性占位符后,您可以使用类似
的内容<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0">
<!-- add file your-configuration-file.cfg with your properties under etc/ -->
<cm:property-placeholder persistent-id="your-configuration-file">
<cm:default-properties>
<cm:property name="your.property" value="file:///d:/in"/>
</cm:default-properties>
</cm:property-placeholder>
<camelContext id="cbr-example-context" xmlns="http://camel.apache.org/schema/blueprint">
<route id="_route1">
<from id="_from1" uri="{{your.property}}"/>
<to id="_to2" uri="file:///d:/out"/>
</route>
</camelContext>
<!-- Actually bean is not needed since you will get the endpoint from properties file -->
<bean class="ats.emvo.routing.routingpath" id="routingInInterceptor"/>
</blueprint>
有关属性组件http://camel.apache.org/properties.html的更多详细信息。
方法2 另一个方法是使用带有 toD 标记的动态端点来评估运行时的端点。所以,你可以有像
这样的东西<route id="_route1">
<from id="_from1" uri="${header.dynamicUri}}"/>
<to id="_to2" uri="file:///d:/out"/>
</route>
动态到部分的http://camel.apache.org/message-endpoint.html中有更多详细信息。