我可以覆盖已经声明的HTTP出站网关吗?

时间:2019-01-15 22:46:20

标签: spring spring-boot spring-mvc spring-integration-http

spring上下文文件中已经定义了一个出站网关,我必须对其进行覆盖。修改文件本身不是一个选择,因为这是一个只读文件,它是基本代码的一部分,无法修改或从应用程序上下文中删除。我想知道是否有一种机制可以覆盖其声明?

我检查了官方的Spring Http集成文档,但找不到太多。如果这样做可行,我会感到惊讶,但是我借此机会第一次在这个备受喜爱的平台上提出要求。

要重新声明的定义:

<int-http:outbound-gateway id='httpGETOutboundGateway'
 request-channel='httpGETRequestChannel'
 url="{scheme}://{host}:{port}${configurationServiceLocation}"
 http-method='GET'
 expected-response-type='java.lang.String'
 charset='UTF-8'>
        <int-http:uri-variable name="scheme" expression="T(org.springframework.web.context.request.RequestContextHolder).
        requestAttributes.request.getScheme()"/>
        <int-http:uri-variable name="host" expression="T(com.company.app.UriVariablesResolver).resolveHost()" />
        <int-http:uri-variable name="port" expression="T(com.company.app.UriVariablesResolver).resolvePort()" />
     </int-http:outbound-gateway>

为Resolver声明了不同的表达式。

<int-http:outbound-gateway id='httpGETOutboundGateway'
 request-channel='httpGETRequestChannel'
 url="{scheme}://{host}:{port}${configurationServiceLocation}"
 http-method='GET'
 expected-response-type='java.lang.String'
 charset='UTF-8'>
    <int-http:uri-variable name="scheme" expression="T(org.springframework.web.context.request.RequestContextHolder).
        requestAttributes.request.getScheme()"/>
    <int-http:uri-variable name="host" expression="T(com.company.app2.MyResolver).resolveHost()" />
    <int-http:uri-variable name="port" expression="T(com.company.app2.MyResolver).resolvePort()" />
</int-http:outbound-gateway>

0 个答案:

没有答案
相关问题