Class MailInboundChannelAdapterSpec<S extends MailInboundChannelAdapterSpec<S,R>,R extends AbstractMailReceiver>

java.lang.Object
org.springframework.integration.dsl.IntegrationComponentSpec<S,H>
org.springframework.integration.dsl.MessageSourceSpec<S,MailReceivingMessageSource>
org.springframework.integration.mail.dsl.MailInboundChannelAdapterSpec<S,R>
Type Parameters:
S - the target MailInboundChannelAdapterSpec implementation type.
R - the target AbstractMailReceiver implementation type.
All Implemented Interfaces:
org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.FactoryBean<MailReceivingMessageSource>, org.springframework.beans.factory.InitializingBean, org.springframework.context.Lifecycle, org.springframework.context.Phased, org.springframework.context.SmartLifecycle, org.springframework.integration.dsl.ComponentsRegistration
Direct Known Subclasses:
ImapMailInboundChannelAdapterSpec, Pop3MailInboundChannelAdapterSpec

public abstract class MailInboundChannelAdapterSpec<S extends MailInboundChannelAdapterSpec<S,R>,R extends AbstractMailReceiver> extends org.springframework.integration.dsl.MessageSourceSpec<S,MailReceivingMessageSource> implements org.springframework.integration.dsl.ComponentsRegistration
A MessageSourceSpec for a MailReceivingMessageSource.
Since:
5.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final boolean
     
    protected final R
     

    Fields inherited from class org.springframework.integration.dsl.IntegrationComponentSpec

    logger, PARSER, target

    Fields inherited from interface org.springframework.beans.factory.FactoryBean

    OBJECT_TYPE_ATTRIBUTE

    Fields inherited from interface org.springframework.context.SmartLifecycle

    DEFAULT_PHASE
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
    protected
    MailInboundChannelAdapterSpec(R receiver, boolean externalReceiver)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
     
    autoCloseFolder(boolean autoCloseFolder)
    When configured to false, the folder is not closed automatically after a fetch.
     
    embeddedPartsAsBytes(boolean embeddedPartsAsBytes)
    When a header mapper is provided determine whether an embedded Part (e.g Message or Multipart content is rendered as a byte[] in the payload.
     
    headerMapper(org.springframework.integration.mapping.HeaderMapper<jakarta.mail.internet.MimeMessage> headerMapper)
    Set the header mapper; if a header mapper is not provided, the message payload is a MimeMessage, when provided, the headers are mapped and the payload is the MimeMessage content.
    javaMailAuthenticator(jakarta.mail.Authenticator javaMailAuthenticator)
    The Java Mail Authenticator.
    javaMailProperties(Consumer<org.springframework.integration.support.PropertiesBuilder> configurer)
    Configure the javaMailProperties by invoking a Consumer callback which is invoked with a PropertiesBuilder.
    javaMailProperties(Properties javaMailProperties)
    The Java Mail properties.
    maxFetchSize(int maxFetchSize)
    The maximum for fetch size.
    selector(Function<jakarta.mail.internet.MimeMessage,Boolean> selectorFunction)
    Configure a Function to select messages.
    selectorExpression(String selectorExpression)
    Configure a SpEL expression to select messages.
    selectorExpression(org.springframework.expression.Expression selectorExpression)
    Configure a SpEL expression to select messages.
    session(jakarta.mail.Session session)
    Provide the Java Mail Session to use.
    shouldDeleteMessages(boolean shouldDeleteMessages)
    A flag to specify if messages should be deleted after receive.
    simpleContent(boolean simpleContent)
    Determine how the content is rendered.
    userFlag(String userFlag)
    Set the name of the flag to use to flag messages when the server does not support \Recent but supports user flags; default "spring-integration-mail-adapter".

    Methods inherited from class org.springframework.integration.dsl.MessageSourceSpec

    messageHeaders

    Methods inherited from class org.springframework.integration.dsl.IntegrationComponentSpec

    _this, afterPropertiesSet, destroy, get, getId, getObject, getObjectType, getPhase, id, isAutoStartup, isRunning, start, stop, stop

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.beans.factory.FactoryBean

    isSingleton
  • Field Details

    • receiver

      protected final R extends AbstractMailReceiver receiver
    • externalReceiver

      protected final boolean externalReceiver
  • Constructor Details

    • MailInboundChannelAdapterSpec

      protected MailInboundChannelAdapterSpec(R receiver)
    • MailInboundChannelAdapterSpec

      protected MailInboundChannelAdapterSpec(R receiver, boolean externalReceiver)
  • Method Details

    • selectorExpression

      public S selectorExpression(String selectorExpression)
      Configure a SpEL expression to select messages. The root object for the expression evaluation is a MimeMessage which should return a boolean result (true means select the message).
      Parameters:
      selectorExpression - the selectorExpression.
      Returns:
      the spec.
    • assertReceiver

      protected void assertReceiver()
    • selectorExpression

      public S selectorExpression(org.springframework.expression.Expression selectorExpression)
      Configure a SpEL expression to select messages. The root object for the expression evaluation is a MimeMessage which should return a boolean result (true means select the message).
      Parameters:
      selectorExpression - the selectorExpression.
      Returns:
      the spec.
    • selector

      public S selector(Function<jakarta.mail.internet.MimeMessage,Boolean> selectorFunction)
      Configure a Function to select messages. The argument for the function is a MimeMessage; apply returns a boolean result (true means select the message).
      Parameters:
      selectorFunction - the selectorFunction.
      Returns:
      the spec.
      See Also:
      • FunctionExpression
    • session

      public S session(jakarta.mail.Session session)
      Provide the Java Mail Session to use.
      Parameters:
      session - the session.
      Returns:
      the spec.
      See Also:
    • javaMailProperties

      public S javaMailProperties(Properties javaMailProperties)
      The Java Mail properties.
      Parameters:
      javaMailProperties - the javaMailProperties.
      Returns:
      the spec.
      See Also:
    • javaMailProperties

      public S javaMailProperties(Consumer<org.springframework.integration.support.PropertiesBuilder> configurer)
      Configure the javaMailProperties by invoking a Consumer callback which is invoked with a PropertiesBuilder.
      Parameters:
      configurer - the configurer.
      Returns:
      the spec.
      See Also:
    • javaMailAuthenticator

      public S javaMailAuthenticator(jakarta.mail.Authenticator javaMailAuthenticator)
      The Java Mail Authenticator.
      Parameters:
      javaMailAuthenticator - the javaMailAuthenticator.
      Returns:
      the spec.
      See Also:
    • maxFetchSize

      public S maxFetchSize(int maxFetchSize)
      The maximum for fetch size.
      Parameters:
      maxFetchSize - the maxFetchSize.
      Returns:
      the spec.
      See Also:
    • shouldDeleteMessages

      public S shouldDeleteMessages(boolean shouldDeleteMessages)
      A flag to specify if messages should be deleted after receive.
      Parameters:
      shouldDeleteMessages - the shouldDeleteMessages.
      Returns:
      the spec.
      See Also:
    • userFlag

      public S userFlag(String userFlag)
      Set the name of the flag to use to flag messages when the server does not support \Recent but supports user flags; default "spring-integration-mail-adapter".
      Parameters:
      userFlag - the flag.
      Returns:
      the spec.
      See Also:
    • headerMapper

      public S headerMapper(org.springframework.integration.mapping.HeaderMapper<jakarta.mail.internet.MimeMessage> headerMapper)
      Set the header mapper; if a header mapper is not provided, the message payload is a MimeMessage, when provided, the headers are mapped and the payload is the MimeMessage content.
      Parameters:
      headerMapper - the header mapper.
      Returns:
      the spec.
      See Also:
    • embeddedPartsAsBytes

      public S embeddedPartsAsBytes(boolean embeddedPartsAsBytes)
      When a header mapper is provided determine whether an embedded Part (e.g Message or Multipart content is rendered as a byte[] in the payload. Otherwise, leave as a Part. These objects are not suitable for downstream serialization. Default: true.

      This has no effect if there is no header mapper, in that case the payload is the MimeMessage.

      Parameters:
      embeddedPartsAsBytes - the embeddedPartsAsBytes to set.
      Returns:
      the spec.
      See Also:
    • simpleContent

      public S simpleContent(boolean simpleContent)
      Determine how the content is rendered.
      Parameters:
      simpleContent - true for simple content.
      Returns:
      the spec.
      See Also:
    • autoCloseFolder

      public S autoCloseFolder(boolean autoCloseFolder)
      When configured to false, the folder is not closed automatically after a fetch. It is the target application's responsibility to close it using the IntegrationMessageHeaderAccessor.CLOSEABLE_RESOURCE header from the message produced by this channel adapter.
      Parameters:
      autoCloseFolder - set to false to keep folder opened.
      Returns:
      the spec.
      Since:
      5.2
      See Also:
    • getComponentsToRegister

      public Map<Object,String> getComponentsToRegister()
      Specified by:
      getComponentsToRegister in interface org.springframework.integration.dsl.ComponentsRegistration
    • doGet

      Overrides:
      doGet in class org.springframework.integration.dsl.IntegrationComponentSpec<S extends MailInboundChannelAdapterSpec<S,R>,MailReceivingMessageSource>