I've defined these util constants in my context.
<util:constant id="foo1" static-field="com.marvel.avengers.hulc.util.MyExampleConstants.FOO1"/>
<util:constant id="foo2" static-field="com.marvel.avengers.hulc.util.MyExampleConstants.FOO2"/>
<util:constant id="foo3" static-field="com.marvel.avengers.hulc.util.MyExampleConstants.FOO3"/>
I've tried using foo1 constant in my router expression, but it looks like #{foo1} is a bean id and not its value.
<int:router input-channel="channelABC" expression=" !payload.avengersVO.powType.equals(#{foo1})
and !payload.avengersVO.powType.equals(#{foo2})
and !payload.avengersVO.powType.equals(#{foo3}) ? 'flowEndpoint' : 'civilWarsChan'"/>
On the other hand I could use this in an expression but want to see if I could make use of the constants that I've defined in the router expression:
<int:router input-channel="channelABC" expression=" !payload.avengersVO.powType.equals(T(com.marvel.avengers.hulc.util.MyExampleConstants).FOO1)
and !payload.avengersVO.powType.equals(T(com.marvel.avengers.hulc.util.MyExampleConstants).FOO2)
and !payload.avengersVO.powType.equals(T(com.marvel.avengers.hulc.util.MyExampleConstants).FOO3) ? 'flowEndpoint' : 'civilWarsChan'"/>
Can someone help me to know, how to get value from this bean in router expression. Thanks in advance.
This should work:
!payload.avengersVO.powType.equals(@foo2)
Although, your case looks for me fine, too:
<util:constant id="foo" static-field="org.springframework.integration.router.config.RouterParserTests.FOO"/>
<router input-channel="constantExpressionRouter" expression="'#{foo}'"/>
However, pay attention that I wrap the Bean Definition expression into the literal quotes to avoid an attempt to evaluate it as a property at runtime on each message.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.