Class 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
  • 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 List<HttpMethod> NON_READABLE_BODY_HTTP_METHODS
    • activeCount

      protected final AtomicInteger activeCount
  • Constructor Details

    • BaseHttpInboundEndpoint

      public BaseHttpInboundEndpoint(boolean expectReply)
  • Method Details

    • setPayloadExpression

      public void setPayloadExpression(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(Map<String,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 Expression getPayloadExpression()
    • getHeaderExpressions

      protected Map<String,Expression> getHeaderExpressions()
    • isExpectReply

      protected boolean isExpectReply()
      Returns:
      Whether to expect a reply.
    • setHeaderMapper

      public void setHeaderMapper(HeaderMapper<HttpHeaders> headerMapper)
      Set the HeaderMapper to use when mapping between HTTP headers and MessageHeaders.
      Parameters:
      headerMapper - The header mapper.
    • getHeaderMapper

      protected HeaderMapper<HttpHeaders> getHeaderMapper()
    • setRequestPayloadTypeClass

      public void setRequestPayloadTypeClass(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(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 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(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

      public void setStatusCodeExpression(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:
    • getStatusCodeExpression

      protected Expression getStatusCodeExpression()
    • setValidator

      public void setValidator(Validator validator)
      Specify a Validator to validate a converted payload from request.
      Parameters:
      validator - the Validator to use.
      Since:
      5.2
    • getValidator

      protected Validator getValidator()
    • onInit

      protected void onInit()
      Description copied from class: IntegrationObjectSupport
      Subclasses may implement this for initialization logic.
      Overrides:
      onInit in class MessagingGatewaySupport
    • evaluateHttpStatus

      protected HttpStatus evaluateHttpStatus(HttpEntity<?> httpEntity)
    • resolveHttpStatusFromHeaders

      protected HttpStatus resolveHttpStatusFromHeaders(MessageHeaders headers)
    • createEvaluationContext

      protected StandardEvaluationContext 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 interface OrderlyShutdownCapable
      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 interface OrderlyShutdownCapable
      Returns:
      The number of active messages if available.
    • getComponentType

      public String getComponentType()
      Description copied from class: IntegrationObjectSupport
      Subclasses may implement this method to provide component type information.
      Specified by:
      getComponentType in interface NamedComponent
      Overrides:
      getComponentType in class MessagingGatewaySupport
    • getIntegrationPatternType

      public IntegrationPatternType getIntegrationPatternType()
      Description copied from interface: IntegrationPattern
      Return a pattern type this component implements.
      Specified by:
      getIntegrationPatternType in interface IntegrationPattern
      Overrides:
      getIntegrationPatternType in class MessagingGatewaySupport
      Returns:
      the IntegrationPatternType this component implements.
    • validate

      protected void validate(Object value)
    • isReadable

      protected static boolean isReadable(@Nullable 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