Class HttpRequestHandlingEndpointSupport
- All Implemented Interfaces:
- Aware,- BeanFactoryAware,- BeanNameAware,- DisposableBean,- InitializingBean,- ApplicationContextAware,- Lifecycle,- Phased,- SmartLifecycle,- ExpressionCapable,- OrderlyShutdownCapable,- IntegrationPattern,- NamedComponent,- IntegrationInboundManagement,- IntegrationManagement,- ManageableLifecycle,- ManageableSmartLifecycle,- TrackableComponent
- Direct Known Subclasses:
- HttpRequestHandlingController,- HttpRequestHandlingMessagingGateway
 By default GET and POST requests are accepted via a supplied default instance
 of RequestMapping.
 A GET request will generate a payload containing its 'parameterMap' while a POST
 request will be converted to a Message payload according to the registered
 HttpMessageConverters.
 Several are registered by default, but the list can be explicitly set via
 setMessageConverters(List).
 
 To customize the mapping of request headers to the MessageHeaders, provide a
 reference to a org.springframework.integration.mapping.HeaderMapper<HttpHeaders> implementation
 to the BaseHttpInboundEndpoint.setHeaderMapper(org.springframework.integration.mapping.HeaderMapper) method.
 
 The behavior is "request/reply" by default. Pass false to the constructor
 to force send-only as opposed to sendAndReceive. Send-only means that as soon as
 the Message is created and passed to the
 request channel,
 a response will be generated. Subclasses determine how that response is generated
 (e.g. simple status response or rendering a View).
 
 In a request-reply scenario, the reply Message's payload will be extracted prior
 to generating a response by default.
 To have the entire serialized Message available for the response, switch the
 extractReplyPayload value to false.
- Since:
- 2.0
- Author:
- Mark Fisher, Oleg Zhurakousky, Gary Russell, Artem Bilan, Biju Kunjummen, Trung Pham
- 
Nested Class SummaryNested classes/interfaces inherited from class org.springframework.integration.gateway.MessagingGatewaySupportMessagingGatewaySupport.ConvertingMessagingTemplateNested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagementIntegrationManagement.ManagementOverrides
- 
Field SummaryFields inherited from class org.springframework.integration.http.inbound.BaseHttpInboundEndpointactiveCount, JAXB_PRESENT, NON_READABLE_BODY_HTTP_METHODS, ROME_TOOLS_PRESENTFields inherited from class org.springframework.integration.gateway.MessagingGatewaySupportmessagingTemplateFields inherited from class org.springframework.integration.endpoint.AbstractEndpointlifecycleCondition, lifecycleLockFields inherited from class org.springframework.integration.context.IntegrationObjectSupportEXPRESSION_PARSER, loggerFields inherited from interface org.springframework.integration.support.management.IntegrationManagementMETER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAMEFields inherited from interface org.springframework.context.SmartLifecycleDEFAULT_PHASE
- 
Constructor SummaryConstructorsConstructorDescriptionConstruct a gateway that will wait for thereplyTimeoutfor a reply; if the timeout is exceeded a '500 Internal Server Error' status code is returned.HttpRequestHandlingEndpointSupport(boolean expectReply) Construct a gateway.
- 
Method SummaryModifier and TypeMethodDescriptionprotected final Message<?>doHandleRequest(HttpServletRequest servletRequest, RequestEntity<?> httpEntity) Handles the HTTP request by generating a Message and sending it to the request channel.protected Objectprotected List<HttpMessageConverter<?>>protected voidonInit()Locates theMultipartResolverbean based on the default name defined by theDispatcherServlet.MULTIPART_RESOLVER_BEAN_NAMEconstant if available.protected ServletServerHttpRequestprepareRequest(HttpServletRequest servletRequest) Prepares an instance ofServletServerHttpRequestfrom the rawHttpServletRequest.protected RequestEntity<Object>voidsetMergeWithDefaultConverters(boolean mergeWithDefaultConverters) Flag which determines if the default converters should be available after custom converters.voidsetMessageConverters(List<HttpMessageConverter<?>> messageConverters) Set the message body converters to use.voidsetMultipartResolver(MultipartResolver multipartResolver) Specify theMultipartResolverto use when checking requests.protected voidsetStatusCodeIfNeeded(ServerHttpResponse response, HttpEntity<?> httpEntity) protected final ObjectsetupResponseAndConvertReply(ServletServerHttpResponse response, Message<?> replyMessage) Converts the reply message to the appropriate HTTP reply object and sets up theServletServerHttpResponse.Methods inherited from class org.springframework.integration.http.inbound.BaseHttpInboundEndpointafterShutdown, beforeShutdown, createEvaluationContext, evaluateHttpStatus, getComponentType, getCrossOrigin, getExtractReplyPayload, getHeaderExpressions, getHeaderMapper, getIntegrationPatternType, getPayloadExpression, getRequestMapping, getRequestPayloadType, getStatusCodeExpression, getValidator, isExpectReply, isReadable, resolveHttpStatusFromHeaders, setCrossOrigin, setExtractReplyPayload, setHeaderExpressions, setHeaderMapper, setPayloadExpression, setRequestMapping, setRequestPayloadType, setRequestPayloadTypeClass, setStatusCodeExpression, setStatusCodeExpressionString, setValidator, validateMethods inherited from class org.springframework.integration.gateway.MessagingGatewaySupportbuildErrorMessage, buildSendTimer, destroy, doStart, doStop, getErrorChannel, getErrorMessageAttributes, getErrorMessageStrategy, getManagedName, getManagedType, getOverrides, getReplyChannel, getRequestChannel, isLoggingEnabled, isObserved, receive, receive, receiveMessage, receiveMessage, registerMetricsCaptor, registerObservationRegistry, registerReplyMessageCorrelatorIfNecessary, send, sendAndReceive, sendAndReceiveMessage, sendAndReceiveMessageReactive, sendTimer, setErrorChannel, setErrorChannelName, setErrorMessageStrategy, setErrorOnTimeout, setLoggingEnabled, setManagedName, setManagedType, setObservationConvention, setReplyChannel, setReplyChannelName, setReplyMapper, setReplyTimeout, setRequestChannel, setRequestChannelName, setRequestMapper, setRequestTimeout, setShouldTrackMethods inherited from class org.springframework.integration.endpoint.AbstractEndpointdoStop, getPhase, getRole, isActive, isAutoStartup, isRunning, setAutoStartup, setPhase, setRole, start, stop, stopMethods inherited from class org.springframework.integration.context.IntegrationObjectSupportafterPropertiesSet, 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, toStringMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.integration.support.management.IntegrationManagementgetThisAsMethods inherited from interface org.springframework.integration.support.context.NamedComponentgetBeanName, getComponentName
- 
Constructor Details- 
HttpRequestHandlingEndpointSupportpublic HttpRequestHandlingEndpointSupport()Construct a gateway that will wait for thereplyTimeoutfor a reply; if the timeout is exceeded a '500 Internal Server Error' status code is returned. This can be modified using thestatusCodeExpression.
- 
HttpRequestHandlingEndpointSupportpublic HttpRequestHandlingEndpointSupport(boolean expectReply) Construct a gateway. If 'expectReply' is true it will wait for thereplyTimeoutfor a reply; if the timeout is exceeded a '500 Internal Server Error' status code is returned. This can be modified using thestatusCodeExpression. If 'false', a 200 OK status will be returned; this can also be modified usingstatusCodeExpression.- Parameters:
- expectReply- true if a reply is expected from the downstream flow.
- See Also:
 
 
- 
- 
Method Details- 
setMessageConvertersSet the message body converters to use. These converters are used to convert from and to HTTP requests and responses.- Parameters:
- messageConverters- The message converters.
 
- 
getMessageConverters
- 
setMergeWithDefaultConverterspublic void setMergeWithDefaultConverters(boolean mergeWithDefaultConverters) Flag which determines if the default converters should be available after custom converters.- Parameters:
- mergeWithDefaultConverters- true to merge, false to replace.
 
- 
setMultipartResolverSpecify theMultipartResolverto use when checking requests. If no resolver is provided, the "multipartResolver" bean in the context will be used as a fallback. If that is not available either, this endpoint will not support multipart requests.- Parameters:
- multipartResolver- The multipart resolver.
 
- 
onInitprotected void onInit()Locates theMultipartResolverbean based on the default name defined by theDispatcherServlet.MULTIPART_RESOLVER_BEAN_NAMEconstant if available. Sets up default converters if no converters set, orsetMergeWithDefaultConverters(boolean)was called with true after the converters were set.- Overrides:
- onInitin class- BaseHttpInboundEndpoint
 
- 
doHandleRequestprotected final Message<?> doHandleRequest(HttpServletRequest servletRequest, RequestEntity<?> httpEntity) Handles the HTTP request by generating a Message and sending it to the request channel. If this gateway's 'expectReply' property is true, it will also generate a response from the reply Message once received.- Parameters:
- servletRequest- The servlet request.
- httpEntity- the request entity to use.
- Returns:
- The response Message.
 
- 
setupResponseAndConvertReplyprotected final Object setupResponseAndConvertReply(ServletServerHttpResponse response, Message<?> replyMessage) Converts the reply message to the appropriate HTTP reply object and sets up theServletServerHttpResponse.- Parameters:
- response- The ServletServerHttpResponse.
- replyMessage- The reply message.
- Returns:
- The message payload (if extractReplyPayload) otherwise the message.
 
- 
setStatusCodeIfNeeded
- 
prepareRequestPrepares an instance ofServletServerHttpRequestfrom the rawHttpServletRequest. Also converts the request into a multipart request to make multiparts available if necessary. If no multipart resolver is set, simply returns the existing request.- Parameters:
- servletRequest- current HTTP request
- Returns:
- the processed request (multipart wrapper if necessary)
- See Also:
 
- 
prepareRequestEntityprotected RequestEntity<Object> prepareRequestEntity(ServletServerHttpRequest request) throws IOException - Throws:
- IOException
 
- 
extractRequestBody- Throws:
- IOException
 
 
-