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

Type Parameters:
S - the target MailInboundChannelAdapterSpec implementation type.
R - the target AbstractMailReceiver implementation type.
All Implemented Interfaces:
Aware, BeanClassLoaderAware, BeanFactoryAware, DisposableBean, FactoryBean<MailReceivingMessageSource>, InitializingBean, Lifecycle, Phased, SmartLifecycle, ComponentsRegistration
Direct Known Subclasses:
ImapMailInboundChannelAdapterSpec, Pop3MailInboundChannelAdapterSpec

public abstract class MailInboundChannelAdapterSpec<S extends MailInboundChannelAdapterSpec<S,R>,R extends AbstractMailReceiver> extends MessageSourceSpec<S,MailReceivingMessageSource> implements ComponentsRegistration
Since:
5.0
Author:
Gary Russell, Artem Bilan
  • 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(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<javax.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:
    • session

      public S session(javax.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<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(javax.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(HeaderMapper<javax.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 ComponentsRegistration
    • doGet

      Overrides:
      doGet in class IntegrationComponentSpec<S extends MailInboundChannelAdapterSpec<S,R>,MailReceivingMessageSource>