5

I need to build a dynamic path combining a value defined in properties file with the result of a SpEL expression and can't find the right syntax to achieve that.

my situation is something like:

<bean class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
    <property name="locations">
        <list>
            <value>classpath:myprop.properties</value>
        </list>
    </property>
    <property name="ignoreUnresolvablePlaceholders" value="false"/>
</bean>

<bean id="fileNameToFSTree"
    class="foo.bar.FileNameToFSTree"/>

<int-file:outbound-channel-adapter id="filesOut"
    auto-create-directory="true"
    directory-expression="${outDir} + @fileNameToFSTree.nameToTree(payload)"
    delete-source-files="true"/>

given that myprop.properties file contains a variable outDir, I'd like to prepend that variable in the directory-expression of the file outbound.

apparently it regularly evaluates ${outDir} but I got the following exception:

org.springframework.expression.spel.SpelParseException: Expression [/tmp/output + @fileNameToFSTree.nameToTree(payload)] @0: EL1070E: Problem parsing left operand

I've found no traces of that case in the docs or in the examples.

Any hint?

Gibraltar
  • 409
  • 5
  • 15

1 Answers1

2

find this answer just after posting the question:

How does Spring 3 expression language interact with property placeholders?

basically, the syntax is:

directory-expression="'${outDir}' + @fileNameToFSTree.nameToTree(payload)"

Gibraltar
  • 409
  • 5
  • 15
  • 1
    That's correct. Because property placeholder is resolved first. Then its result becomes a part of an expression syntax. So, if the story is just about string value, we need to wrap property placeholder into the quotes. – Artem Bilan Jan 17 '19 at 14:05