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

java.lang.Object
org.springframework.beans.factory.config.AbstractFactoryBean<T>
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.Aware, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.BeanFactoryAware, 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 boolean externalReceiver  
    protected R receiver  

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

    PARSER, target

    Fields inherited from class org.springframework.beans.factory.config.AbstractFactoryBean

    logger

    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 MailInboundChannelAdapterSpec​(R receiver)  
    protected MailInboundChannelAdapterSpec​(R receiver, boolean externalReceiver)  
  • Method Summary

    Modifier and Type Method Description
    protected void assertReceiver()  
    S autoCloseFolder​(boolean autoCloseFolder)
    When configured to false, the folder is not closed automatically after a fetch.
    MailReceivingMessageSource doGet()  
    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.
    java.util.Map<java.lang.Object,​java.lang.String> getComponentsToRegister()  
    S headerMapper​(org.springframework.integration.mapping.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.
    S javaMailAuthenticator​(javax.mail.Authenticator javaMailAuthenticator)
    The Java Mail Authenticator.
    S javaMailProperties​(java.util.function.Consumer<org.springframework.integration.support.PropertiesBuilder> configurer)
    Configure the javaMailProperties by invoking a Consumer callback which is invoked with a PropertiesBuilder.
    S javaMailProperties​(java.util.Properties javaMailProperties)
    The Java Mail properties.
    S maxFetchSize​(int maxFetchSize)
    The maximum for fetch size.
    S selector​(java.util.function.Function<javax.mail.internet.MimeMessage,​java.lang.Boolean> selectorFunction)
    Configure a Function to select messages.
    S selectorExpression​(java.lang.String selectorExpression)
    Configure a SpEL expression to select messages.
    S selectorExpression​(org.springframework.expression.Expression selectorExpression)
    Configure a SpEL expression to select messages.
    S session​(javax.mail.Session session)
    Provide the Java Mail Session to use.
    S shouldDeleteMessages​(boolean shouldDeleteMessages)
    A flag to specify if messages should be deleted after receive.
    S simpleContent​(boolean simpleContent)
    Determine how the content is rendered.
    S userFlag​(java.lang.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, createInstance, destroyInstance, get, getId, getObjectType, getPhase, id, isAutoStartup, isRunning, start, stop, stop

    Methods inherited from class org.springframework.beans.factory.config.AbstractFactoryBean

    afterPropertiesSet, destroy, getBeanFactory, getBeanTypeConverter, getEarlySingletonInterfaces, getObject, isSingleton, setBeanClassLoader, setBeanFactory, setSingleton

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • selectorExpression

      public S selectorExpression​(java.lang.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​(java.util.function.Function<javax.mail.internet.MimeMessage,​java.lang.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​(javax.mail.Session session)
      Provide the Java Mail Session to use.
      Parameters:
      session - the session.
      Returns:
      the spec.
      See Also:
      AbstractMailReceiver.setSession(Session)
    • javaMailProperties

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

      public S javaMailProperties​(java.util.function.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:
      AbstractMailReceiver.setJavaMailProperties(Properties)
    • javaMailAuthenticator

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

      public S maxFetchSize​(int maxFetchSize)
      The maximum for fetch size.
      Parameters:
      maxFetchSize - the maxFetchSize.
      Returns:
      the spec.
      See Also:
      AbstractMailReceiver.setMaxFetchSize(int)
    • 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:
      AbstractMailReceiver.setShouldDeleteMessages(boolean)
    • userFlag

      public S userFlag​(java.lang.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:
      AbstractMailReceiver.setUserFlag(String)
    • headerMapper

      public S headerMapper​(org.springframework.integration.mapping.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:
      AbstractMailReceiver.setUserFlag(String), embeddedPartsAsBytes(boolean)
    • 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:
      headerMapper(HeaderMapper)
    • simpleContent

      public S simpleContent​(boolean simpleContent)
      Determine how the content is rendered.
      Parameters:
      simpleContent - true for simple content.
      Returns:
      the spec.
      See Also:
      AbstractMailReceiver.setSimpleContent(boolean)
    • 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:
      AbstractMailReceiver.setAutoCloseFolder(boolean)
    • getComponentsToRegister

      public java.util.Map<java.lang.Object,​java.lang.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>