[
https://issues.apache.org/jira/browse/CAMEL-4988?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13208373#comment-13208373
]
Diego commented on CAMEL-4988:
------------------------------
It seems that if you have a bean of java.lang.String type, it uses it to
autowire the start and end token of the SimpleLanguage. If you have a bean of
this type you have to define a bean to configure SimpleLanguage to keep routes
work as usual. For example this file works:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:camel="http://camel.apache.org/schema/spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean id="string" class="java.lang.String" >
<constructor-arg value="Some text"/>
</bean>
<bean id="simple" class="org.apache.camel.language.simple.SimpleLanguage">
<constructor-arg name="functionStartToken" value="${"/>
<constructor-arg name="functionEndToken" value="}"/>
</bean>
<camelContext xmlns="http://camel.apache.org/schema/spring"
useMDCLogging="true">
<route>
<from uri="quartz://grupo/timer01?cron=*/10+*+*+*+*+?"/>
<transform><constant>Text</constant></transform>
<transform><simple>[${body}]</simple></transform>
<to uri="stream:out"/>
</route>
</camelContext>
</beans>
But this one doesn't work (it prints "[${body}]" instead of "[Text]")
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:camel="http://camel.apache.org/schema/spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean id="string" class="java.lang.String" >
<constructor-arg value="Some text"/>
</bean>
<camelContext xmlns="http://camel.apache.org/schema/spring"
useMDCLogging="true">
<route>
<from uri="quartz://grupo/timer01?cron=*/10+*+*+*+*+?"/>
<transform><constant>Text</constant></transform>
<transform><simple>[${body}]</simple></transform>
<to uri="stream:out"/>
</route>
</camelContext>
</beans>
> Problems with Simple language
> -----------------------------
>
> Key: CAMEL-4988
> URL: https://issues.apache.org/jira/browse/CAMEL-4988
> Project: Camel
> Issue Type: Bug
> Components: camel-core
> Affects Versions: 2.9.0
> Environment: Standalone application with Spring context and routes
> defined in XML.
> Reporter: Diego
>
> If you don't use a simple expresion that falls back to the
> SimpleBackwardsCompatibleParser, the simple language doesn't seem to work. If
> I override the start and end token with an explicit definition of the
> simplelanguage everything works well.
> <bean id="simple" class="org.apache.camel.language.simple.SimpleLanguage">
> <constructor-arg name="functionStartToken" value="${"/>
> <constructor-arg name="functionEndToken" value="}"/>
> </bean>
> It seems that
> org.apache.camel.language.simple.SimpleExpressionParser.SimpleExpressionParser(String)
> fails to create an expression because startToken and endToken are
> "automagically" changed for strange Strings. It seems that when
> exchange.getContext().resolveLanguage("simple") tries to resolve the languaje
> it doesn't use the default construtor and injects a strange start and end
> token in the constructor SimpleLanguage(String functionStartToken, String
> functionEndToken).
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira