public abstract class MailboxConnection extends Object
Constructor and Description |
---|
MailboxConnection() |
Modifier and Type | Method and Description |
---|---|
void |
disconnect()
Closes the connection to the mail server.
|
abstract boolean |
expungeMessages()
Expunge messages with the deleted flag.
|
protected long |
getFetchTimeout() |
protected abstract javax.mail.Folder |
getFolder()
Returns the mailbox folder or null if not initialized or available.
|
protected javax.mail.Store |
getMessageStore() |
abstract String |
getProtocolName()
Returns the name of the protocol used by this connection (e.g.
|
abstract String |
getUniqueMessageId(javax.mail.Message message)
Returns a unique id for an email message.
|
boolean |
initialize()
Initializes the connection from configuration properties using the
ConfigurationManager . |
protected boolean |
isShouldStop() |
protected abstract void |
prepareFetching(String mailbox)
Subclasses should use this method for protocol specific initialization.
|
protected abstract void |
processUndeletedMessages(MailMessageWorker worker)
Processes all undeleted messages in a mailbox.
|
protected abstract void |
startCheckMessages()
Starts checking for messages and blocks until another thread calls the
disconnect()
method or an error or exception (e.g. |
void |
startListening(MailMessageWorker worker)
First tries to open the connection to the mail server.
|
protected abstract void |
stopCheckMessages()
Interrupt the check messages loop that was started in
startCheckMessages() . |
public void disconnect()
public abstract boolean expungeMessages()
protected long getFetchTimeout()
protected abstract javax.mail.Folder getFolder()
protected javax.mail.Store getMessageStore()
public abstract String getProtocolName()
public abstract String getUniqueMessageId(javax.mail.Message message)
message
- the messagepublic boolean initialize()
ConfigurationManager
. This does not include opening the connection to the mail
server.protected boolean isShouldStop()
protected abstract void prepareFetching(String mailbox) throws MailboxConnectionException
mailbox
- the mailbox to use. Subclasses should ignore this parameter if they only support a
specific mailboxMailboxConnectionException
- if the connection to the mailbox (folder) failed or was lostprotected abstract void processUndeletedMessages(MailMessageWorker worker)
worker
- the worker processing the messagesprotected abstract void startCheckMessages() throws MailboxConnectionException
disconnect()
method or an error or exception (e.g. connection closed, server unreachable) occurs.MailboxConnectionException
- in case the message check loop was interrupted by an error or exceptionpublic void startListening(MailMessageWorker worker) throws MailboxConnectionException
disconnect()
.worker
- the worker that will be invoked to process messagesMailboxConnectionException
- if an error or exception occurs while connecting or listeningprotected abstract void stopCheckMessages()
startCheckMessages()
. This
method should only be run from another thread than the one that called
startCheckMessages()
.Copyright © 2019 Communote team. All rights reserved.