我正在尝试使用Spring Integration的现有项目,并且要求是根据有效负载中的“type”字符串值动态调用各种服务激活器,并且有效负载数据必须在其中一个服务激活器中进行类型转换。
我以为我可以在
这样的表达式中做到这一点< service-activator input-channel =“TEST_CHANNEL”expression =“new TestProcessor()。test(**(mypackage.TestData)** payload.data)”>
但是这会在部署时给出表达式解析器错误 'EL1043E :(位置156):意外的令牌。预期'rparen())'但是'标识符'“
以下是包含更多详细信息和代码的测试用例。
Object data = requestItem.getData(); String type = requestType.getTypeName();
gatewayservice.processRequest(data,type)
<channel id="COMMON_REQUEST_PROCESSOR_CHANNEL"/>
<recipient-list-router id="routerGateway" input-channel="COMMON_REQUEST_PROCESSOR_CHANNEL">
<recipient selector-expression="payload.type.equals('A')" channel="A_CHANNEL"/>
<recipient selector-expression="payload.type.equals('B')" channel="B_CHANNEL"/>
<recipient selector-expression="payload.type.equals('C')" channel="C_CHANNEL"/>
</recipient-list-router>
<channel id="A_CHANNEL"/>
<service-activator input-channel="A_CHANNEL"
expression="new ClassA().process(payload.data)'">
</service-activator>
<channel id="B_CHANNEL"/>
<service-activator input-channel="B_CHANNEL"
expression="new ClassB().process(payload.data)'">
</service-activator>
<channel id="C_CHANNEL"/>
<service-activator input-channel="C_CHANNEL"
expression="new ClassC().process((**specific class cast required here**)payload.data)'">
</service-activator>