public abstract class AbstractMailReceiver extends IntegrationObjectSupport implements MailReceiver, org.springframework.beans.factory.DisposableBean
MailReceiver implementations.| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_SI_USER_FLAG
Default user flag for marking messages as seen by this receiver:
"spring-integration-mail-adapter".
|
protected int |
folderOpenMode |
protected boolean |
initialized |
protected org.apache.commons.logging.Log |
logger |
EXPRESSION_PARSER| Constructor and Description |
|---|
AbstractMailReceiver() |
AbstractMailReceiver(String url) |
AbstractMailReceiver(URLName urlName) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
deleteMessages(Message[] messages)
Deletes the given messages from this receiver's folder.
|
void |
destroy() |
protected void |
fetchMessages(Message[] messages)
Fetches the specified messages from this receiver's folder.
|
protected Folder |
getFolder() |
protected Properties |
getJavaMailProperties() |
protected String |
getUserFlag() |
protected void |
onInit()
Subclasses may implement this for initialization logic.
|
protected void |
openFolder() |
Object[] |
receive() |
protected abstract Message[] |
searchForNewMessages()
Subclasses must implement this method to return new mail messages.
|
protected void |
setAdditionalFlags(Message message)
Optional method allowing you to set additional flags.
|
void |
setEmbeddedPartsAsBytes(boolean embeddedPartsAsBytes)
|
void |
setHeaderMapper(HeaderMapper<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(Authenticator javaMailAuthenticator)
Optional, sets the Authenticator to be used to obtain a session.
|
void |
setJavaMailProperties(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(String protocol) |
void |
setSelectorExpression(org.springframework.expression.Expression selectorExpression) |
void |
setSession(Session session)
Set the
Session. |
void |
setShouldDeleteMessages(boolean shouldDeleteMessages)
Specify whether mail messages should be deleted after retrieval.
|
void |
setUserFlag(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.
|
String |
toString() |
afterPropertiesSet, extractTypeIfPossible, getApplicationContext, getApplicationContextId, getBeanFactory, getChannelResolver, getComponentName, getComponentType, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskSchedulerpublic static final String DEFAULT_SI_USER_FLAG
protected final org.apache.commons.logging.Log logger
protected volatile int folderOpenMode
protected volatile boolean initialized
public AbstractMailReceiver()
public AbstractMailReceiver(URLName urlName)
public AbstractMailReceiver(String url)
public void setSelectorExpression(org.springframework.expression.Expression selectorExpression)
public void setProtocol(String protocol)
public void setSession(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(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 Properties getJavaMailProperties()
public void setJavaMailAuthenticator(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 String getUserFlag()
public void setUserFlag(String userFlag)
userFlag - the flag.public void setHeaderMapper(HeaderMapper<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)protected Folder getFolder()
protected abstract Message[] searchForNewMessages() throws MessagingException
MessagingException - Any MessagingException.protected void openFolder()
throws MessagingException
MessagingExceptionpublic Object[] receive() throws MessagingException
receive in interface MailReceiverMessagingExceptionprotected void fetchMessages(Message[] messages) throws MessagingException
fetches
every FetchProfile.Item.messages - the messages to fetchMessagingException - in case of JavaMail errorsprotected void deleteMessages(Message[] messages) throws MessagingException
messages - the messages to deleteMessagingException - in case of JavaMail errorsprotected void setAdditionalFlags(Message message) throws MessagingException
message - The message.MessagingException - A MessagingException.public void destroy()
throws Exception
destroy in interface org.springframework.beans.factory.DisposableBeanExceptionprotected void onInit()
throws Exception
IntegrationObjectSupportonInit in class IntegrationObjectSupportException - Any exception.public String toString()
toString in class IntegrationObjectSupport