public abstract class AbstractMailReceiver extends org.springframework.integration.context.IntegrationObjectSupport implements MailReceiver, org.springframework.beans.factory.DisposableBean
MailReceiver implementations.| Modifier and Type | Field and Description | 
|---|---|
static java.lang.String | 
DEFAULT_SI_USER_FLAG
Default user flag for marking messages as seen by this receiver:
 "spring-integration-mail-adapter". 
 | 
| Constructor and Description | 
|---|
AbstractMailReceiver()  | 
AbstractMailReceiver(java.lang.String url)  | 
AbstractMailReceiver(javax.mail.URLName urlName)  | 
| Modifier and Type | Method and Description | 
|---|---|
protected void | 
closeFolder()  | 
protected void | 
deleteMessages(javax.mail.Message[] messages)
Deletes the given messages from this receiver's folder. 
 | 
void | 
destroy()  | 
protected void | 
fetchMessages(javax.mail.Message[] messages)
Fetches the specified messages from this receiver's folder. 
 | 
protected javax.mail.Folder | 
getFolder()  | 
protected int | 
getFolderOpenMode()  | 
protected java.util.Properties | 
getJavaMailProperties()  | 
protected java.lang.String | 
getUserFlag()  | 
protected void | 
onInit()  | 
protected void | 
openFolder()  | 
java.lang.Object[] | 
receive()  | 
protected abstract javax.mail.Message[] | 
searchForNewMessages()
Subclasses must implement this method to return new mail messages. 
 | 
protected void | 
setAdditionalFlags(javax.mail.Message message)
Optional method allowing you to set additional flags. 
 | 
void | 
setAutoCloseFolder(boolean autoCloseFolder)
Configure a  
boolean flag to close the folder automatically after a fetch (default) or
 populate an additional IntegrationMessageHeaderAccessor.CLOSEABLE_RESOURCE message header instead. | 
void | 
setEmbeddedPartsAsBytes(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. | 
void | 
setHeaderMapper(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. | 
void | 
setJavaMailAuthenticator(javax.mail.Authenticator javaMailAuthenticator)
Optional, sets the Authenticator to be used to obtain a session. 
 | 
void | 
setJavaMailProperties(java.util.Properties javaMailProperties)
A new  
Session will be created with these properties (and the JavaMailAuthenticator if provided). | 
void | 
setMaxFetchSize(int maxFetchSize)
Specify the maximum number of Messages to fetch per call to  
receive(). | 
void | 
setProtocol(java.lang.String protocol)  | 
void | 
setSelectorExpression(org.springframework.expression.Expression selectorExpression)  | 
void | 
setSession(javax.mail.Session session)
Set the  
Session. | 
void | 
setShouldDeleteMessages(boolean shouldDeleteMessages)
Specify whether mail messages should be deleted after retrieval. 
 | 
void | 
setSimpleContent(boolean simpleContent)
MimeMessage.getContent() returns just the email body. | 
void | 
setUserFlag(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". 
 | 
protected boolean | 
shouldDeleteMessages()
Indicates whether the mail messages should be deleted after being received. 
 | 
java.lang.String | 
toString()  | 
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getComponentType, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskSchedulerpublic static final java.lang.String DEFAULT_SI_USER_FLAG
public AbstractMailReceiver()
public AbstractMailReceiver(javax.mail.URLName urlName)
public AbstractMailReceiver(java.lang.String url)
public void setSelectorExpression(org.springframework.expression.Expression selectorExpression)
public void setProtocol(java.lang.String protocol)
public void setSession(javax.mail.Session session)
Session. Otherwise, the Session will be created by invocation of
 Session.getInstance(Properties) or Session.getInstance(Properties, Authenticator).session - The session.setJavaMailProperties(Properties), 
setJavaMailAuthenticator(Authenticator)public void setJavaMailProperties(java.util.Properties javaMailProperties)
Session will be created with these properties (and the JavaMailAuthenticator if provided).
 Use either this method or setSession(javax.mail.Session), but not both.javaMailProperties - The javamail properties.setJavaMailAuthenticator(Authenticator), 
setSession(Session)protected java.util.Properties getJavaMailProperties()
public void setJavaMailAuthenticator(javax.mail.Authenticator javaMailAuthenticator)
setSession(javax.mail.Session) has been used to configure the Session directly.javaMailAuthenticator - The javamail authenticator.setSession(Session)public void setMaxFetchSize(int maxFetchSize)
receive().maxFetchSize - The max fetch size.public void setShouldDeleteMessages(boolean shouldDeleteMessages)
shouldDeleteMessages - true to delete messages.protected boolean shouldDeleteMessages()
protected java.lang.String getUserFlag()
public void setUserFlag(java.lang.String userFlag)
userFlag - the flag.public void setHeaderMapper(org.springframework.integration.mapping.HeaderMapper<javax.mail.internet.MimeMessage> headerMapper)
MimeMessage, when provided, the headers are mapped and the payload is
 the MimeMessage content.headerMapper - the header mapper.setEmbeddedPartsAsBytes(boolean)public void setEmbeddedPartsAsBytes(boolean embeddedPartsAsBytes)
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.
embeddedPartsAsBytes - the embeddedPartsAsBytes to set.setHeaderMapper(HeaderMapper)public void setSimpleContent(boolean simpleContent)
MimeMessage.getContent() returns just the email body.
 fooSome subclasses, such as
IMAPMessage return some headers with the body.
 To: foo@bar From: bar@baz Subject: Test Email fooStarting with version 5.0, messages emitted by mail receivers will render the content in the same way as the
MimeMessage implementation returned by
 javamail. In versions 2.2 through 4.3, the content was always just the body,
 regardless of the underlying message type (unless a header mapper was provided,
 in which case the payload was rendered by the underlying MimeMessage.
 To revert to the previous behavior, set this flag to true. In addition, even if a header mapper is provided, the payload will just be the email body.
simpleContent - true to render simple content.public void setAutoCloseFolder(boolean autoCloseFolder)
boolean flag to close the folder automatically after a fetch (default) or
 populate an additional IntegrationMessageHeaderAccessor.CLOSEABLE_RESOURCE message header instead.
 It is the downstream flow's responsibility to obtain this header and call its close() whenever
 it is necessary.
 Keeping the folder open is useful in cases where communication with the server is needed when parsing multipart content of the email with attachments.
 The setSimpleContent(boolean) and setHeaderMapper(HeaderMapper) options are not
 affected by this flag.
autoCloseFolder - false do not close the folder automatically after a fetch.protected javax.mail.Folder getFolder()
protected int getFolderOpenMode()
protected abstract javax.mail.Message[] searchForNewMessages()
                                                      throws javax.mail.MessagingException
javax.mail.MessagingException - Any MessagingException.protected void openFolder()
                   throws javax.mail.MessagingException
javax.mail.MessagingExceptionpublic java.lang.Object[] receive()
                           throws javax.mail.MessagingException
receive in interface MailReceiverjavax.mail.MessagingExceptionprotected void closeFolder()
protected void fetchMessages(javax.mail.Message[] messages)
                      throws javax.mail.MessagingException
fetches
 every FetchProfile.Item.messages - the messages to fetchjavax.mail.MessagingException - in case of JavaMail errorsprotected void deleteMessages(javax.mail.Message[] messages)
                       throws javax.mail.MessagingException
messages - the messages to deletejavax.mail.MessagingException - in case of JavaMail errorsprotected void setAdditionalFlags(javax.mail.Message message)
                           throws javax.mail.MessagingException
message - The message.javax.mail.MessagingException - A MessagingException.public void destroy()
destroy in interface org.springframework.beans.factory.DisposableBeanprotected void onInit()
onInit in class org.springframework.integration.context.IntegrationObjectSupportpublic java.lang.String toString()
toString in class org.springframework.integration.context.IntegrationObjectSupport