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,ComponentSourceAware,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, Ngoc Nhan
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.integration.gateway.MessagingGatewaySupport
MessagingGatewaySupport.ConvertingMessagingTemplateNested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement
IntegrationManagement.ManagementOverrides -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AtomicIntegerprotected static final booleanprotected static final List<HttpMethod> protected static final booleanFields inherited from class org.springframework.integration.gateway.MessagingGatewaySupport
messagingTemplateFields inherited from class org.springframework.integration.endpoint.AbstractEndpoint
lifecycleLockFields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, loggerFields inherited from interface org.springframework.integration.support.management.IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAMEFields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintCalled 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.intCalled before shutdown begins.protected StandardEvaluationContextprotected @Nullable HttpStatusevaluateHttpStatus(HttpEntity<?> httpEntity) @Nullable CrossOriginprotected booleanprotected @Nullable Map<String, Expression> protected HeaderMapper<HttpHeaders> Return a pattern type this component implements.protected @Nullable Expressionfinal RequestMappingprotected @Nullable ResolvableTypeprotected @Nullable Expressionprotected @Nullable Validatorprotected booleanprotected static booleanisReadable(@Nullable HttpMethod httpMethod) Checks if the request has a readable body (not a GET, HEAD, or OPTIONS request).protected voidonInit()Subclasses may implement this for initialization logic.protected @Nullable HttpStatusvoidsetCrossOrigin(CrossOrigin crossOrigin) Set theCrossOriginto permit cross-origin requests for this endpoint.voidsetExtractReplyPayload(boolean extractReplyPayload) Specify whether only the reply Message's payload should be passed in the response.voidsetHeaderExpressions(Map<String, Expression> headerExpressions) Specifies a Map of SpEL expressions to evaluate in order to generate the Message headers.voidsetHeaderMapper(HeaderMapper<HttpHeaders> headerMapper) Set theHeaderMapperto use when mapping between HTTP headers and MessageHeaders.voidsetPayloadExpression(Expression payloadExpression) Specifies a SpEL expression to evaluate in order to generate the Message payload.voidsetRequestMapping(RequestMapping requestMapping) Set theRequestMappingwhich allows you to specify a flexible RESTFul-mapping for this endpoint.voidsetRequestPayloadType(ResolvableType requestPayloadType) Specify the type of payload to be generated when the inbound HTTP request content is read by the converters/encoders.voidsetRequestPayloadTypeClass(Class<?> requestPayloadType) Specify the type of payload to be generated when the inbound HTTP request content is read by the converters/encoders.voidsetStatusCodeExpression(Expression statusCodeExpression) Specify theExpressionto resolve a status code for Response to override the default '200 OK' or '500 Internal Server Error' for a timeout.voidsetStatusCodeExpressionString(String statusCodeExpression) Specify theExpressionto resolve a status code for Response to override the default '200 OK' or '500 Internal Server Error' for a timeout.voidsetValidator(Validator validator) Specify aValidatorto validate a converted payload from request.protected voidMethods 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, setShouldTrackMethods inherited from class org.springframework.integration.endpoint.AbstractEndpoint
doStop, getPhase, getRole, isActive, isAutoStartup, isRunning, setAutoStartup, setPhase, setRole, start, stop, stopMethods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentDescription, getComponentName, getComponentSource, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentDescription, setComponentName, setComponentSource, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.integration.support.management.IntegrationManagement
getThisAsMethods inherited from interface org.springframework.integration.support.context.NamedComponent
getBeanName, getComponentNameMethods inherited from interface org.springframework.context.SmartLifecycle
isPauseable
-
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 theRequestMappingwhich allows you to specify a flexible RESTFul-mapping for this endpoint.- Parameters:
requestMapping- The request mapping.
-
getRequestMapping
-
setCrossOrigin
Set theCrossOriginto 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 theHeaderMapperto 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 theExpressionto 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 theExpressionto resolve a status code for Response to override the default '200 OK' or '500 Internal Server Error' for a timeout.The
statusCodeExpressionis 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 wheneverexpectReplyis true) resolves anHttpStatusfrom theHttpHeaders.STATUS_CODEreplyMessageheader.- Parameters:
statusCodeExpression- The status code Expression.- Since:
- 4.1
- See Also:
-
getStatusCodeExpression
-
setValidator
-
getValidator
-
onInit
protected void onInit()Description copied from class:IntegrationObjectSupportSubclasses may implement this for initialization logic.- Overrides:
onInitin classMessagingGatewaySupport
-
evaluateHttpStatus
-
resolveHttpStatusFromHeaders
-
createEvaluationContext
-
beforeShutdown
public int beforeShutdown()Description copied from interface:OrderlyShutdownCapableCalled before shutdown begins. Implementations should stop accepting new messages. Can optionally return the number of active messages in process.- Specified by:
beforeShutdownin interfaceOrderlyShutdownCapable- Returns:
- The number of active messages if available.
-
afterShutdown
public int afterShutdown()Description copied from interface:OrderlyShutdownCapableCalled 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:
afterShutdownin interfaceOrderlyShutdownCapable- Returns:
- The number of active messages if available.
-
getComponentType
- Specified by:
getComponentTypein interfaceNamedComponent- Overrides:
getComponentTypein classMessagingGatewaySupport
-
getIntegrationPatternType
Description copied from interface:IntegrationPatternReturn a pattern type this component implements.- Specified by:
getIntegrationPatternTypein interfaceIntegrationPattern- Overrides:
getIntegrationPatternTypein classMessagingGatewaySupport- Returns:
- the
IntegrationPatternTypethis 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
-