public class MBoxMailRepository extends Object implements MailRepository, LogEnabled, Configurable
Requires a configuration element in the .conf.xml file of the form:
<repository destinationURL="mbox://<directory>" type="MAIL"/><directory> is where the individual mbox files are read from/written to.
Type can ONLY be MAIL (SPOOL is NOT supported)
Requires a logger called MailRepository.
Implementation notes:
This class keeps an internal store of the mbox file When the internal mbox file is updated (added/deleted) then the file will be re-read from disk and then written back. This is a bit inefficent but means that the file on disk should be correct.
The mbox store is mainly meant to be used as a one-way street. Storing new emails is very fast (append to file) whereas reading them (via POP3) is slower (read from disk and parse). Therefore this implementation is best suited to people who wish to use the mbox format for taking data out of James and into something else (IMAP server or mail list displayer)
Modifier and Type | Class and Description |
---|---|
static interface |
MBoxMailRepository.MessageAction
A callback used when a message is read from the mbox file
|
Constructor and Description |
---|
MBoxMailRepository() |
Modifier and Type | Method and Description |
---|---|
void |
configure(org.apache.commons.configuration.HierarchicalConfiguration configuration)
Configure the object.
|
protected org.slf4j.Logger |
getLogger() |
Iterator<String> |
list()
List string keys of messages in repository.
|
boolean |
lock(String key)
Obtains a lock on a message identified by key
|
void |
remove(Collection<org.apache.mailet.Mail> mails)
Remove an Collection of mails from the repository
|
void |
remove(org.apache.mailet.Mail mail)
Removes a specified message
|
void |
remove(String key)
Removes a message identified by key.
|
org.apache.mailet.Mail |
retrieve(String key)
Retrieves a message given a key.
|
void |
setLog(org.slf4j.Logger logger)
Sets the service log.
|
void |
store(org.apache.mailet.Mail mc)
Stores a message in this repository.
|
boolean |
unlock(String key)
Releases a lock on a message identified the key
|
public void setLog(org.slf4j.Logger logger)
LogEnabled
setLog
in interface LogEnabled
logger
- not nullpublic void configure(org.apache.commons.configuration.HierarchicalConfiguration configuration) throws org.apache.commons.configuration.ConfigurationException
Configurable
configure
in interface Configurable
org.apache.commons.configuration.ConfigurationException
protected org.slf4j.Logger getLogger()
public void store(org.apache.mailet.Mail mc)
MailRepository
store
in interface MailRepository
mc
- the mail message to storeMailRepository.store(Mail)
public Iterator<String> list()
MailRepository
list
in interface MailRepository
Iterator
over the list of keys in the repositoryMailRepository.list()
public org.apache.mailet.Mail retrieve(String key)
MailRepository
retrieve
in interface MailRepository
key
- the key of the message to retrieveMailRepository.retrieve(String)
public void remove(org.apache.mailet.Mail mail)
MailRepository
remove
in interface MailRepository
mail
- the message to be removed from the repositoryMailRepository.remove(Mail)
public void remove(Collection<org.apache.mailet.Mail> mails)
MailRepository
remove
in interface MailRepository
mails
- The Collection of MailImpl
's to deleteMailRepository.remove(Collection)
public void remove(String key)
MailRepository
remove
in interface MailRepository
key
- the key of the message to be removed from the repositoryMailRepository.remove(String)
public boolean lock(String key)
MailRepository
lock
in interface MailRepository
key
- the key of the message to be lockedMailRepository.lock(String)
public boolean unlock(String key)
MailRepository
unlock
in interface MailRepository
key
- the key of the message to be unlockedMailRepository.unlock(String)
Copyright © 2002-2012 The Apache Software Foundation. All Rights Reserved.