public abstract class AbstractHttpRequestExecutingMessageHandler extends AbstractReplyProducingMessageHandler
AbstractReplyProducingMessageHandler.RequestHandler
IntegrationManagement.ManagementOverrides
Modifier and Type | Field and Description |
---|---|
protected DefaultUriBuilderFactory |
uriFactory |
messagingTemplate
EXPRESSION_PARSER, logger
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME
Constructor and Description |
---|
AbstractHttpRequestExecutingMessageHandler(Expression uriExpression) |
Modifier and Type | Method and Description |
---|---|
protected void |
doInit() |
protected Object |
evaluateTypeFromExpression(Message<?> requestMessage,
Expression expression,
String property) |
protected abstract Object |
exchange(Object uri,
HttpMethod httpMethod,
HttpEntity<?> httpRequest,
Object expectedResponseType,
Message<?> requestMessage,
Map<String,?> uriVariables) |
IntegrationPatternType |
getIntegrationPatternType()
Return a pattern type this component implements.
|
protected Object |
getReply(ResponseEntity<?> httpResponse) |
protected Object |
handleRequestMessage(Message<?> requestMessage)
Subclasses must implement this method to handle the request Message.
|
boolean |
isExpectReply() |
protected HttpHeaders |
mapHeaders(Message<?> message) |
void |
setCharset(String charset)
Specify the charset name to use for converting String-typed payloads to bytes.
|
void |
setEncodeUri(boolean encodeUri)
Deprecated.
since 5.3 in favor of
setEncodingMode(org.springframework.web.util.DefaultUriBuilderFactory.EncodingMode) |
void |
setEncodingMode(DefaultUriBuilderFactory.EncodingMode encodingMode)
Set the encoding mode to use.
|
void |
setExpectedResponseType(Class<?> expectedResponseType)
Specify the expected response type for the REST request
otherwise the default response type is
ResponseEntity and will
be returned as a payload of the reply Message. |
void |
setExpectedResponseTypeExpression(Expression expectedResponseTypeExpression)
Specify the
Expression to determine the type for the expected response
The returned value of the expression could be an instance of Class or
String representing a fully qualified class name. |
void |
setExpectReply(boolean expectReply)
Specify whether a reply Message is expected.
|
void |
setExtractPayload(boolean extractPayload)
Specify whether the outbound message's payload should be extracted
when preparing the request body.
|
void |
setHeaderMapper(HeaderMapper<HttpHeaders> headerMapper)
Set the
HeaderMapper to use when mapping between HTTP headers and MessageHeaders. |
void |
setHttpMethod(HttpMethod httpMethod)
Specify the
HttpMethod for requests. |
void |
setHttpMethodExpression(Expression httpMethodExpression)
Specify the SpEL
Expression to determine HttpMethod at runtime. |
void |
setTransferCookies(boolean transferCookies)
Set to true if you wish 'Set-Cookie' headers in responses to be
transferred as 'Cookie' headers in subsequent interactions for
a message.
|
void |
setTrustedSpel(boolean trustedSpel)
Set to true if you trust the source of SpEL expressions used to evaluate URI
variables.
|
void |
setUriVariableExpressions(Map<String,Expression> uriVariableExpressions)
Set the Map of URI variable expressions to evaluate against the outbound message
when replacing the variable placeholders in a URI template.
|
void |
setUriVariablesExpression(Expression uriVariablesExpression)
Set the
Expression to evaluate against the outbound message; the expression
must evaluate to a Map of URI variable expressions to evaluate against the outbound message
when replacing the variable placeholders in a URI template. |
doInvokeAdvisedRequestHandler, getBeanClassLoader, getRequiresReply, handleMessageInternal, hasAdviceChain, onInit, setAdviceChain, setBeanClassLoader, setRequiresReply
addNotPropagatedHeaders, createOutputMessage, getNotPropagatedHeaders, getOutputChannel, isAsync, messageBuilderForReply, produceOutput, resolveErrorChannel, sendErrorMessage, sendOutput, sendOutputs, setAsync, setNotPropagatedHeaders, setOutputChannel, setOutputChannelName, setSendTimeout, shouldCopyRequestHeaders, shouldSplitOutput, updateNotPropagatedHeaders
handleMessage, onComplete, onError, onNext, onSubscribe
buildSendTimer, destroy, getComponentType, getManagedName, getManagedType, getMetricsCaptor, getOrder, getOverrides, isLoggingEnabled, registerMetricsCaptor, sendTimer, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, shouldTrack
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getThisAs
getBeanName, getComponentName
protected final DefaultUriBuilderFactory uriFactory
public AbstractHttpRequestExecutingMessageHandler(Expression uriExpression)
@Deprecated public void setEncodeUri(boolean encodeUri)
setEncodingMode(org.springframework.web.util.DefaultUriBuilderFactory.EncodingMode)
uriVariables
expanding and before send request via
RestTemplate
. The default value is
true
.encodeUri
- true if the URI should be encoded.UriComponentsBuilder
public void setEncodingMode(DefaultUriBuilderFactory.EncodingMode encodingMode)
DefaultUriBuilderFactory.EncodingMode#TEMPLATE_AND_VALUES
.
For more complicated scenarios consider to configure an UriTemplateHandler
on an externally provided RestTemplate
.encodingMode
- the mode to use for uri encodingpublic void setHttpMethodExpression(Expression httpMethodExpression)
Expression
to determine HttpMethod
at runtime.httpMethodExpression
- The method expression.public void setHttpMethod(HttpMethod httpMethod)
HttpMethod
for requests.
The default method is POST
.httpMethod
- The method.public void setExtractPayload(boolean extractPayload)
true
.extractPayload
- true if the payload should be extracted.public void setCharset(String charset)
UTF-8
.charset
- The charset.public boolean isExpectReply()
setExpectReply(boolean)
public void setExpectReply(boolean expectReply)
expectReply
- true if a reply is expected.public void setExpectedResponseType(Class<?> expectedResponseType)
ResponseEntity
and will
be returned as a payload of the reply Message.
To take advantage of the HttpMessageConverters
registered on this adapter, provide a different type).expectedResponseType
- The expected type.
Also see setExpectedResponseTypeExpression(Expression)
public void setExpectedResponseTypeExpression(Expression expectedResponseTypeExpression)
Expression
to determine the type for the expected response
The returned value of the expression could be an instance of Class
or
String
representing a fully qualified class name.expectedResponseTypeExpression
- The expected response type expression.
Also see setExpectedResponseType(java.lang.Class<?>)
public void setHeaderMapper(HeaderMapper<HttpHeaders> headerMapper)
HeaderMapper
to use when mapping between HTTP headers and MessageHeaders.headerMapper
- The header mapper.public void setUriVariableExpressions(Map<String,Expression> uriVariableExpressions)
uriVariableExpressions
- The URI variable expressions.public void setUriVariablesExpression(Expression uriVariablesExpression)
Expression
to evaluate against the outbound message; the expression
must evaluate to a Map of URI variable expressions to evaluate against the outbound message
when replacing the variable placeholders in a URI template.uriVariablesExpression
- The URI variables expression.public void setTransferCookies(boolean transferCookies)
transferCookies
- the transferCookies to set.public void setTrustedSpel(boolean trustedSpel)
SimpleEvaluationContext
is used
for evaluating such expressions, which restricts the use of some SpEL capabilities.trustedSpel
- true to trust.public IntegrationPatternType getIntegrationPatternType()
IntegrationPattern
getIntegrationPatternType
in interface IntegrationPattern
getIntegrationPatternType
in class AbstractReplyProducingMessageHandler
IntegrationPatternType
this component implements.protected void doInit()
doInit
in class AbstractReplyProducingMessageHandler
@Nullable protected Object handleRequestMessage(Message<?> requestMessage)
AbstractReplyProducingMessageHandler
handleRequestMessage
in class AbstractReplyProducingMessageHandler
requestMessage
- The request message.null
.@Nullable protected abstract Object exchange(Object uri, HttpMethod httpMethod, HttpEntity<?> httpRequest, Object expectedResponseType, Message<?> requestMessage, Map<String,?> uriVariables)
protected Object getReply(ResponseEntity<?> httpResponse)
protected HttpHeaders mapHeaders(Message<?> message)