Groovy 如何在Apache Camel路由中更改属性值?

Groovy 如何在Apache Camel路由中更改属性值?,groovy,apache-camel,spring-camel,spring-dsl,Groovy,Apache Camel,Spring Camel,Spring Dsl,在属性文件中定义了变量测试: test=旧值 在接下来的Spring DSL定义中,定义了驼峰路由。属性通过PropertiesComponent加载 <bean id="properties" class="org.apache.camel.component.properties.PropertiesComponent"> <property name="cache" value="false"/> <property name="locat

在属性文件中定义了变量测试:

test=旧值

在接下来的Spring DSL定义中,定义了驼峰路由。属性通过PropertiesComponent加载

  <bean id="properties" class="org.apache.camel.component.properties.PropertiesComponent">
    <property name="cache" value="false"/>
    <property name="location" value="classpath:res.properties"/>
  </bean>


  <camelContext id="ctx" xmlns="http://camel.apache.org/schema/spring">
    <route id="toParamRoute">    
      <from uri="servlet:myParam"/>
            HERE I WOULD LIKE TO SET THE 
            VARIABLE TEST WITH A NEW VALUE, 
            SUCH THAT THE FOLLOWING LOG MESSAGE 
            WILL PRINT THE NEW VALUE, 
            E.G: test=NEW_VALUE
      <log message="{{test}}"/>                   
    </route>    
 </camelContext>

我想在这里设置
使用新值进行变量测试,
这样,下面的日志消息
将打印新值,
例如:测试=新的_值
我使用groovy、语言脚本表达式和外部Springbean尝试了不同的方法,但没有成功。有没有办法设置和更改启动时加载的变量的值? 最好的方法是什么


有人能帮我吗?我在stackoverflow上没有发现任何类似的问题!我面临的问题和我正在寻找的解决方案是一个基本的构建块,用于构建一个WEB UI管理控制台,以动态更改路由的某些行为。为了简化流程,我可以说,在propertyPlaceholder加载了一个属性文件之后,通过UI网页可以更改路由的默认参数,并且只有在路由启动之后

使用语法
{{property}}
计算的属性在上下文初始化期间仅解析一次。如果需要反映运行时更改,请使用

示例:

<bean id="myProperties" class="java.util.Properties"/>

<bean id="properties" class="org.apache.camel.component.properties.PropertiesComponent">
    <property name="cache" value="false"/>
    <property name="location" value="classpath:res.properties"/>
    <property name="overrideProperties" ref="myProperties" />
</bean>


<camelContext id="ctx" xmlns="http://camel.apache.org/schema/spring">
    <route id="toParamRoute">
        <from uri="timer://foo"/>
        <log message="About to change property test from value ${properties:test} to value ${exchangeProperty.CamelTimerCounter}. Initial value was {{test}}"/>
        <bean ref="myProperties" method="setProperty(test, ${exchangeProperty.CamelTimerCounter})" />
        <log message="New value is ${properties:test}"/>
    </route>
</camelContext>