Class BaseHttpInboundEndpoint
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.endpoint.AbstractEndpoint
org.springframework.integration.gateway.MessagingGatewaySupport
org.springframework.integration.http.inbound.BaseHttpInboundEndpoint
- All Implemented Interfaces:
Aware
,BeanFactoryAware
,BeanNameAware
,DisposableBean
,InitializingBean
,ApplicationContextAware
,Lifecycle
,Phased
,SmartLifecycle
,ExpressionCapable
,OrderlyShutdownCapable
,IntegrationPattern
,NamedComponent
,IntegrationInboundManagement
,IntegrationManagement
,ManageableLifecycle
,ManageableSmartLifecycle
,TrackableComponent
- Direct Known Subclasses:
HttpRequestHandlingEndpointSupport
,WebFluxInboundEndpoint
public class BaseHttpInboundEndpoint
extends MessagingGatewaySupport
implements OrderlyShutdownCapable
The
MessagingGatewaySupport
extension for HTTP Inbound endpoints
with basic properties.- Since:
- 5.0
- Author:
- Artem Bilan, Gary Russell, Trung Pham
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.integration.gateway.MessagingGatewaySupport
MessagingGatewaySupport.ConvertingMessagingTemplate
Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement
IntegrationManagement.ManagementOverrides
-
Field Summary
Modifier and TypeFieldDescriptionprotected final AtomicInteger
protected static final boolean
protected static final List<HttpMethod>
protected static final boolean
Fields inherited from class org.springframework.integration.gateway.MessagingGatewaySupport
messagingTemplate
Fields inherited from class org.springframework.integration.endpoint.AbstractEndpoint
lifecycleCondition, lifecycleLock
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, logger
Fields inherited from interface org.springframework.integration.support.management.IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME
Fields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
Called after normal shutdown of schedulers, executors etc, and after the shutdown delay has elapsed, but before any forced shutdown of any remaining active scheduler/executor threads.Can optionally return the number of active messages still in process.int
Called before shutdown begins.protected StandardEvaluationContext
protected HttpStatus
evaluateHttpStatus
(HttpEntity<?> httpEntity) Subclasses may implement this method to provide component type information.protected boolean
protected Map<String,
Expression> protected HeaderMapper<HttpHeaders>
Return a pattern type this component implements.protected Expression
final RequestMapping
protected ResolvableType
protected Expression
protected Validator
protected boolean
protected static boolean
isReadable
(HttpMethod httpMethod) Checks if the request has a readable body (not a GET, HEAD, or OPTIONS request).protected void
onInit()
Subclasses may implement this for initialization logic.protected HttpStatus
void
setCrossOrigin
(CrossOrigin crossOrigin) Set theCrossOrigin
to permit cross origin requests for this endpoint.void
setExtractReplyPayload
(boolean extractReplyPayload) Specify whether only the reply Message's payload should be passed in the response.void
setHeaderExpressions
(Map<String, Expression> headerExpressions) Specifies a Map of SpEL expressions to evaluate in order to generate the Message headers.void
setHeaderMapper
(HeaderMapper<HttpHeaders> headerMapper) Set theHeaderMapper
to use when mapping between HTTP headers and MessageHeaders.void
setPayloadExpression
(Expression payloadExpression) Specifies a SpEL expression to evaluate in order to generate the Message payload.void
setRequestMapping
(RequestMapping requestMapping) Set theRequestMapping
which allows you to specify a flexible RESTFul-mapping for this endpoint.void
setRequestPayloadType
(ResolvableType requestPayloadType) Specify the type of payload to be generated when the inbound HTTP request content is read by the converters/encoders.void
setRequestPayloadTypeClass
(Class<?> requestPayloadType) Specify the type of payload to be generated when the inbound HTTP request content is read by the converters/encoders.void
setStatusCodeExpression
(Expression statusCodeExpression) Specify theExpression
to resolve a status code for Response to override the default '200 OK' or '500 Internal Server Error' for a timeout.void
setStatusCodeExpressionString
(String statusCodeExpression) Specify theExpression
to resolve a status code for Response to override the default '200 OK' or '500 Internal Server Error' for a timeout.void
setValidator
(Validator validator) Specify aValidator
to validate a converted payload from request.protected void
Methods inherited from class org.springframework.integration.gateway.MessagingGatewaySupport
buildErrorMessage, 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, setReceiverObservationConvention, setReplyChannel, setReplyChannelName, setReplyMapper, setReplyTimeout, setRequestChannel, setRequestChannelName, setRequestMapper, setRequestTimeout, setShouldTrack
Methods inherited from class org.springframework.integration.endpoint.AbstractEndpoint
doStop, getPhase, getRole, isActive, isAutoStartup, isRunning, setAutoStartup, setPhase, setRole, start, stop, stop
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.integration.support.management.IntegrationManagement
getThisAs
Methods inherited from interface org.springframework.integration.support.context.NamedComponent
getBeanName, getComponentName
-
Field Details
-
JAXB_PRESENT
protected static final boolean JAXB_PRESENT -
ROME_TOOLS_PRESENT
protected static final boolean ROME_TOOLS_PRESENT -
NON_READABLE_BODY_HTTP_METHODS
-
activeCount
-
-
Constructor Details
-
BaseHttpInboundEndpoint
public BaseHttpInboundEndpoint(boolean expectReply)
-
-
Method Details
-
setPayloadExpression
Specifies a SpEL expression to evaluate in order to generate the Message payload. The EvaluationContext will be populated with an HttpEntity instance as the root object, and it may contain variables:#pathVariables
#requestParams
#requestAttributes
#requestHeaders
#matrixVariables
#cookies
- Parameters:
payloadExpression
- The payload expression.
-
setHeaderExpressions
Specifies a Map of SpEL expressions to evaluate in order to generate the Message headers. The keys in the map will be used as the header names. When evaluating the expression, the EvaluationContext will be populated with an HttpEntity instance as the root object, and it may contain variables:#pathVariables
#requestParams
#requestAttributes
#requestHeaders
#matrixVariables
#cookies
- Parameters:
headerExpressions
- The header expressions.
-
setRequestMapping
Set theRequestMapping
which allows you to specify a flexible RESTFul-mapping for this endpoint.- Parameters:
requestMapping
- The request mapping.
-
getRequestMapping
-
setCrossOrigin
Set theCrossOrigin
to permit cross origin requests for this endpoint.- Parameters:
crossOrigin
- the CrossOrigin config.- Since:
- 4.2
-
getCrossOrigin
-
getPayloadExpression
-
getHeaderExpressions
-
isExpectReply
protected boolean isExpectReply()- Returns:
- Whether to expect a reply.
-
setHeaderMapper
Set theHeaderMapper
to use when mapping between HTTP headers and MessageHeaders.- Parameters:
headerMapper
- The header mapper.
-
getHeaderMapper
-
setRequestPayloadTypeClass
Specify the type of payload to be generated when the inbound HTTP request content is read by the converters/encoders. By default this value is null which means at runtime any "text" Content-Type will result in String while all others default tobyte[].class
.- Parameters:
requestPayloadType
- The payload type.
-
setRequestPayloadType
Specify the type of payload to be generated when the inbound HTTP request content is read by the converters/encoders. By default this value is null which means at runtime any "text" Content-Type will result in String while all others default tobyte[].class
.- Parameters:
requestPayloadType
- The payload type.
-
getRequestPayloadType
-
setExtractReplyPayload
public void setExtractReplyPayload(boolean extractReplyPayload) Specify whether only the reply Message's payload should be passed in the response. If this is set to 'false', the entire Message will be used to generate the response. The default is 'true'.- Parameters:
extractReplyPayload
- true to extract the reply payload.
-
getExtractReplyPayload
protected boolean getExtractReplyPayload() -
setStatusCodeExpressionString
Specify theExpression
to resolve a status code for Response to override the default '200 OK' or '500 Internal Server Error' for a timeout.- Parameters:
statusCodeExpression
- The status code Expression.- Since:
- 5.0
- See Also:
-
setStatusCodeExpression
Specify theExpression
to resolve a status code for Response to override the default '200 OK' or '500 Internal Server Error' for a timeout.The
statusCodeExpression
is applied only for the one-way<http:inbound-channel-adapter/>
or when no reply (timeout) is received for a gateway. The<http:inbound-gateway/>
(or wheneverexpectReply
is true) resolves anHttpStatus
from theHttpHeaders.STATUS_CODE
replyMessage
header.- Parameters:
statusCodeExpression
- The status code Expression.- Since:
- 4.1
- See Also:
-
getStatusCodeExpression
-
setValidator
Specify aValidator
to validate a converted payload from request.- Parameters:
validator
- theValidator
to use.- Since:
- 5.2
-
getValidator
-
onInit
protected void onInit()Description copied from class:IntegrationObjectSupport
Subclasses may implement this for initialization logic.- Overrides:
onInit
in classMessagingGatewaySupport
-
evaluateHttpStatus
-
resolveHttpStatusFromHeaders
-
createEvaluationContext
-
beforeShutdown
public int beforeShutdown()Description copied from interface:OrderlyShutdownCapable
Called before shutdown begins. Implementations should stop accepting new messages. Can optionally return the number of active messages in process.- Specified by:
beforeShutdown
in interfaceOrderlyShutdownCapable
- Returns:
- The number of active messages if available.
-
afterShutdown
public int afterShutdown()Description copied from interface:OrderlyShutdownCapable
Called after normal shutdown of schedulers, executors etc, and after the shutdown delay has elapsed, but before any forced shutdown of any remaining active scheduler/executor threads.Can optionally return the number of active messages still in process.- Specified by:
afterShutdown
in interfaceOrderlyShutdownCapable
- Returns:
- The number of active messages if available.
-
getComponentType
Description copied from class:IntegrationObjectSupport
Subclasses may implement this method to provide component type information.- Specified by:
getComponentType
in interfaceNamedComponent
- Overrides:
getComponentType
in classMessagingGatewaySupport
-
getIntegrationPatternType
Description copied from interface:IntegrationPattern
Return a pattern type this component implements.- Specified by:
getIntegrationPatternType
in interfaceIntegrationPattern
- Overrides:
getIntegrationPatternType
in classMessagingGatewaySupport
- Returns:
- the
IntegrationPatternType
this component implements.
-
validate
-
isReadable
Checks if the request has a readable body (not a GET, HEAD, or OPTIONS request).- Parameters:
httpMethod
- the HTTP method to check- Returns:
- true or false if HTTP request can contain the body
-