public abstract class AbstractMailReceiver extends IntegrationObjectSupport implements MailReceiver, org.springframework.beans.factory.DisposableBean
MailReceiver
implementations.MailReceiver.MailReceiverContext
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_SI_USER_FLAG |
protected int |
folderOpenMode |
protected boolean |
initialized |
protected org.apache.commons.logging.Log |
logger |
static java.lang.String |
SI_USER_FLAG
Deprecated.
- this constant will be removed in 4.3; see
setUserFlag(String) and DEFAULT_SI_USER_FLAG |
Constructor and Description |
---|
AbstractMailReceiver() |
AbstractMailReceiver(java.lang.String url) |
AbstractMailReceiver(javax.mail.URLName urlName) |
Modifier and Type | Method and Description |
---|---|
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 java.util.Properties |
getJavaMailProperties() |
protected java.lang.String |
getUserFlag() |
protected void |
onInit()
Subclasses may implement this for initialization logic.
|
protected void |
openFolder() |
javax.mail.Message[] |
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 |
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 |
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, getApplicationContext, getApplicationContextId, getBeanFactory, getChannelResolver, getComponentName, getComponentType, getConversionService, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setTaskScheduler
public static final java.lang.String DEFAULT_SI_USER_FLAG
@Deprecated public static final java.lang.String SI_USER_FLAG
setUserFlag(String)
and DEFAULT_SI_USER_FLAG
protected final org.apache.commons.logging.Log logger
protected volatile int folderOpenMode
protected volatile boolean initialized
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.protected javax.mail.Folder getFolder()
protected abstract javax.mail.Message[] searchForNewMessages() throws javax.mail.MessagingException
javax.mail.MessagingException
- Any MessagingException.protected void openFolder() throws javax.mail.MessagingException
javax.mail.MessagingException
public javax.mail.Message[] receive() throws javax.mail.MessagingException
receive
in interface MailReceiver
javax.mail.MessagingException
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() throws java.lang.Exception
destroy
in interface org.springframework.beans.factory.DisposableBean
java.lang.Exception
protected void onInit() throws java.lang.Exception
IntegrationObjectSupport
onInit
in class IntegrationObjectSupport
java.lang.Exception
- Any exception.public java.lang.String toString()
toString
in class IntegrationObjectSupport