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

    Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement

    org.springframework.integration.support.management.IntegrationManagement.ManagementOverrides
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected java.util.concurrent.atomic.AtomicInteger activeCount  
    protected static boolean JAXB_PRESENT  
    protected static java.util.List<org.springframework.http.HttpMethod> NON_READABLE_BODY_HTTP_METHODS  
    protected static boolean ROME_TOOLS_PRESENT  

    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

    Constructors 
    Constructor Description
    BaseHttpInboundEndpoint​(boolean expectReply)  
  • Method Summary

    Modifier and Type Method Description
    int afterShutdown()  
    int beforeShutdown()  
    protected org.springframework.expression.spel.support.StandardEvaluationContext createEvaluationContext()  
    protected org.springframework.http.HttpStatus evaluateHttpStatus​(org.springframework.http.HttpEntity<?> httpEntity)  
    java.lang.String getComponentType()  
    CrossOrigin getCrossOrigin()  
    protected boolean getExtractReplyPayload()  
    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.IntegrationPatternType getIntegrationPatternType()  
    protected org.springframework.expression.Expression getPayloadExpression()  
    RequestMapping getRequestMapping()  
    protected org.springframework.core.ResolvableType getRequestPayloadType()  
    protected org.springframework.expression.Expression getStatusCodeExpression()  
    protected org.springframework.validation.Validator getValidator()  
    protected boolean isExpectReply()  
    protected static boolean isReadable​(org.springframework.http.HttpMethod httpMethod)
    Checks if the request has a readable body (not a GET, HEAD, or OPTIONS request).
    protected void onInit()  
    protected org.springframework.http.HttpStatus resolveHttpStatusFromHeaders​(org.springframework.messaging.MessageHeaders headers)  
    void setCrossOrigin​(CrossOrigin crossOrigin)
    Set the CrossOrigin 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​(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.
    void setHeaderMapper​(org.springframework.integration.mapping.HeaderMapper<org.springframework.http.HttpHeaders> headerMapper)
    Set the HeaderMapper to use when mapping between HTTP headers and MessageHeaders.
    void setPayloadExpression​(org.springframework.expression.Expression payloadExpression)
    Specifies a SpEL expression to evaluate in order to generate the Message payload.
    void setRequestMapping​(RequestMapping requestMapping)
    Set the RequestMapping which allows you to specify a flexible RESTFul-mapping for this endpoint.
    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.
    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.
    void setStatusCodeExpression​(org.springframework.expression.Expression statusCodeExpression)
    Specify the Expression to resolve a status code for Response to override the default '200 OK' or '500 Internal Server Error' for a timeout.
    void setStatusCodeExpressionString​(java.lang.String statusCodeExpression)
    Specify the Expression to resolve a status code for Response to override the default '200 OK' or '500 Internal Server Error' for a timeout.
    void setValidator​(org.springframework.validation.Validator validator)
    Specify a Validator to validate a converted payload from request.
    protected void validate​(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, 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, getIntegrationProperty, 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

  • Constructor Details

  • 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

      public void setRequestMapping​(RequestMapping requestMapping)
      Set the RequestMapping which allows you to specify a flexible RESTFul-mapping for this endpoint.
      Parameters:
      requestMapping - The request mapping.
    • getRequestMapping

      public final RequestMapping getRequestMapping()
    • setCrossOrigin

      public void setCrossOrigin​(CrossOrigin crossOrigin)
      Set the CrossOrigin to permit cross origin requests for this endpoint.
      Parameters:
      crossOrigin - the CrossOrigin config.
      Since:
      4.2
    • getCrossOrigin

      public CrossOrigin 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 the HeaderMapper to 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 to byte[].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 to byte[].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 the Expression 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(Expression)
    • setStatusCodeExpression

      public void setStatusCodeExpression​(org.springframework.expression.Expression statusCodeExpression)
      Specify the Expression 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 whenever expectReply is true) resolves an HttpStatus from the HttpHeaders.STATUS_CODE reply Message header.

      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 a Validator to validate a converted payload from request.
      Parameters:
      validator - the Validator to use.
      Since:
      5.2
    • getValidator

      protected org.springframework.validation.Validator getValidator()
    • onInit

      protected void onInit()
      Overrides:
      onInit in class org.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:
      beforeShutdown in interface org.springframework.integration.context.OrderlyShutdownCapable
    • afterShutdown

      public int afterShutdown()
      Specified by:
      afterShutdown in interface org.springframework.integration.context.OrderlyShutdownCapable
    • getComponentType

      public java.lang.String getComponentType()
      Specified by:
      getComponentType in interface org.springframework.integration.support.context.NamedComponent
      Overrides:
      getComponentType in class org.springframework.integration.gateway.MessagingGatewaySupport
    • getIntegrationPatternType

      public org.springframework.integration.IntegrationPatternType getIntegrationPatternType()
      Specified by:
      getIntegrationPatternType in interface org.springframework.integration.IntegrationPattern
      Overrides:
      getIntegrationPatternType in class org.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