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:
org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanFactoryAware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.DisposableBean,org.springframework.beans.factory.InitializingBean,org.springframework.context.ApplicationContextAware,org.springframework.context.Lifecycle,org.springframework.context.Phased,org.springframework.context.SmartLifecycle,org.springframework.integration.context.ExpressionCapable,org.springframework.integration.context.OrderlyShutdownCapable,org.springframework.integration.IntegrationPattern,org.springframework.integration.support.context.NamedComponent,org.springframework.integration.support.management.IntegrationInboundManagement,org.springframework.integration.support.management.IntegrationManagement,org.springframework.integration.support.management.ManageableLifecycle,org.springframework.integration.support.management.ManageableSmartLifecycle,org.springframework.integration.support.management.TrackableComponent
- Direct Known Subclasses:
HttpRequestHandlingEndpointSupport
public class BaseHttpInboundEndpoint
extends org.springframework.integration.gateway.MessagingGatewaySupport
implements org.springframework.integration.context.OrderlyShutdownCapable
The
MessagingGatewaySupport extension for HTTP Inbound endpoints
with basic properties.- Since:
- 5.0
-
Nested Class Summary
-
Field Summary
Fields Modifier and Type Field Description protected java.util.concurrent.atomic.AtomicIntegeractiveCountprotected static booleanJAXB_PRESENTprotected static java.util.List<org.springframework.http.HttpMethod>NON_READABLE_BODY_HTTP_METHODSprotected static booleanROME_TOOLS_PRESENTFields inherited from class org.springframework.integration.gateway.MessagingGatewaySupport
messagingTemplateFields inherited from class org.springframework.integration.endpoint.AbstractEndpoint
lifecycleCondition, lifecycleLockFields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, logger -
Constructor Summary
Constructors Constructor Description BaseHttpInboundEndpoint(boolean expectReply) -
Method Summary
Modifier and Type Method Description intafterShutdown()intbeforeShutdown()protected org.springframework.expression.spel.support.StandardEvaluationContextcreateEvaluationContext()protected org.springframework.http.HttpStatusevaluateHttpStatus(org.springframework.http.HttpEntity<?> httpEntity)java.lang.StringgetComponentType()CrossOrigingetCrossOrigin()protected booleangetExtractReplyPayload()protected java.util.Map<java.lang.String,org.springframework.expression.Expression>getHeaderExpressions()protected org.springframework.integration.mapping.HeaderMapper<org.springframework.http.HttpHeaders>getHeaderMapper()org.springframework.integration.IntegrationPatternTypegetIntegrationPatternType()protected org.springframework.expression.ExpressiongetPayloadExpression()RequestMappinggetRequestMapping()protected org.springframework.core.ResolvableTypegetRequestPayloadType()protected org.springframework.expression.ExpressiongetStatusCodeExpression()protected org.springframework.validation.ValidatorgetValidator()protected booleanisExpectReply()protected static booleanisReadable(org.springframework.http.HttpMethod httpMethod)Checks if the request has a readable body (not a GET, HEAD, or OPTIONS request).protected voidonInit()protected org.springframework.http.HttpStatusresolveHttpStatusFromHeaders(org.springframework.messaging.MessageHeaders headers)voidsetCrossOrigin(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(java.util.Map<java.lang.String,org.springframework.expression.Expression> headerExpressions)Specifies a Map of SpEL expressions to evaluate in order to generate the Message headers.voidsetHeaderMapper(org.springframework.integration.mapping.HeaderMapper<org.springframework.http.HttpHeaders> headerMapper)Set theHeaderMapperto use when mapping between HTTP headers and MessageHeaders.voidsetPayloadExpression(org.springframework.expression.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(org.springframework.core.ResolvableType requestPayloadType)Specify the type of payload to be generated when the inbound HTTP request content is read by the converters/encoders.voidsetRequestPayloadTypeClass(java.lang.Class<?> requestPayloadType)Specify the type of payload to be generated when the inbound HTTP request content is read by the converters/encoders.voidsetStatusCodeExpression(org.springframework.expression.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(java.lang.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(org.springframework.validation.Validator validator)Specify aValidatorto validate a converted payload from request.protected voidvalidate(java.lang.Object value)Methods inherited from class org.springframework.integration.gateway.MessagingGatewaySupport
buildErrorMessage, buildSendTimer, destroy, doStart, doStop, getErrorChannel, getErrorMessageAttributes, getManagedName, getManagedType, getOverrides, getReplyChannel, getRequestChannel, isLoggingEnabled, receive, receive, receiveMessage, receiveMessage, registerMetricsCaptor, registerReplyMessageCorrelatorIfNecessary, send, sendAndReceive, sendAndReceiveMessage, sendAndReceiveMessageReactive, sendTimer, setErrorChannel, setErrorChannelName, setErrorMessageStrategy, setErrorOnTimeout, setLoggingEnabled, setManagedName, setManagedType, 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, getComponentName, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
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
protected static final java.util.List<org.springframework.http.HttpMethod> NON_READABLE_BODY_HTTP_METHODS -
activeCount
protected final java.util.concurrent.atomic.AtomicInteger activeCount
-
-
Constructor Details
-
BaseHttpInboundEndpoint
public BaseHttpInboundEndpoint(boolean expectReply)
-
-
Method Details
-
setPayloadExpression
public void setPayloadExpression(org.springframework.expression.Expression payloadExpression)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
public void setHeaderExpressions(java.util.Map<java.lang.String,org.springframework.expression.Expression> headerExpressions)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
protected org.springframework.expression.Expression getPayloadExpression() -
getHeaderExpressions
protected java.util.Map<java.lang.String,org.springframework.expression.Expression> getHeaderExpressions() -
isExpectReply
protected boolean isExpectReply()- Returns:
- Whether to expect a reply.
-
setHeaderMapper
public void setHeaderMapper(org.springframework.integration.mapping.HeaderMapper<org.springframework.http.HttpHeaders> headerMapper)Set theHeaderMapperto use when mapping between HTTP headers and MessageHeaders.- Parameters:
headerMapper- The header mapper.
-
getHeaderMapper
protected org.springframework.integration.mapping.HeaderMapper<org.springframework.http.HttpHeaders> getHeaderMapper() -
setRequestPayloadTypeClass
public void setRequestPayloadTypeClass(java.lang.Class<?> requestPayloadType)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
public void setRequestPayloadType(org.springframework.core.ResolvableType requestPayloadType)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
protected org.springframework.core.ResolvableType 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
public void setStatusCodeExpressionString(java.lang.String statusCodeExpression)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(Expression)
-
setStatusCodeExpression
public void setStatusCodeExpression(org.springframework.expression.Expression statusCodeExpression)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:
MessagingGatewaySupport.setReplyTimeout(long),HttpRequestHandlingEndpointSupport(boolean)
-
getStatusCodeExpression
protected org.springframework.expression.Expression getStatusCodeExpression() -
setValidator
public void setValidator(org.springframework.validation.Validator validator)Specify aValidatorto validate a converted payload from request.- Parameters:
validator- theValidatorto use.- Since:
- 5.2
-
getValidator
protected org.springframework.validation.Validator getValidator() -
onInit
protected void onInit()- Overrides:
onInitin classorg.springframework.integration.gateway.MessagingGatewaySupport
-
evaluateHttpStatus
protected org.springframework.http.HttpStatus evaluateHttpStatus(org.springframework.http.HttpEntity<?> httpEntity) -
resolveHttpStatusFromHeaders
protected org.springframework.http.HttpStatus resolveHttpStatusFromHeaders(org.springframework.messaging.MessageHeaders headers) -
createEvaluationContext
protected org.springframework.expression.spel.support.StandardEvaluationContext createEvaluationContext() -
beforeShutdown
public int beforeShutdown()- Specified by:
beforeShutdownin interfaceorg.springframework.integration.context.OrderlyShutdownCapable
-
afterShutdown
public int afterShutdown()- Specified by:
afterShutdownin interfaceorg.springframework.integration.context.OrderlyShutdownCapable
-
getComponentType
public java.lang.String getComponentType()- Specified by:
getComponentTypein interfaceorg.springframework.integration.support.context.NamedComponent- Overrides:
getComponentTypein classorg.springframework.integration.gateway.MessagingGatewaySupport
-
getIntegrationPatternType
public org.springframework.integration.IntegrationPatternType getIntegrationPatternType()- Specified by:
getIntegrationPatternTypein interfaceorg.springframework.integration.IntegrationPattern- Overrides:
getIntegrationPatternTypein classorg.springframework.integration.gateway.MessagingGatewaySupport
-
validate
protected void validate(java.lang.Object value) -
isReadable
protected static boolean isReadable(@Nullable org.springframework.http.HttpMethod httpMethod)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
-