org.apache.james.mailrepository.file
Class MBoxMailRepository

java.lang.Object
  extended by org.apache.james.mailrepository.file.MBoxMailRepository
All Implemented Interfaces:
Configurable, LogEnabled, MailRepository

public class MBoxMailRepository
extends java.lang.Object
implements MailRepository, LogEnabled, Configurable

Implementation of a MailRepository using UNIX mbox files.

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)

Version:
CVS $Revision: 1025872 $

Nested Class Summary
static interface MBoxMailRepository.MessageAction
          A callback used when a message is read from the mbox file
 
Constructor Summary
MBoxMailRepository()
           
 
Method Summary
 void configure(org.apache.commons.configuration.HierarchicalConfiguration configuration)
           
protected  org.apache.commons.logging.Log getLogger()
           
 java.util.Iterator<java.lang.String> list()
           
 boolean lock(java.lang.String key)
           
 void remove(java.util.Collection<org.apache.mailet.Mail> mails)
           
 void remove(org.apache.mailet.Mail mail)
           
 void remove(java.lang.String key)
           
 org.apache.mailet.Mail retrieve(java.lang.String key)
           
 void setLog(org.apache.commons.logging.Log logger)
           
 void store(org.apache.mailet.Mail mc)
           
 boolean unlock(java.lang.String key)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MBoxMailRepository

public MBoxMailRepository()
Method Detail

setLog

public void setLog(org.apache.commons.logging.Log logger)
Specified by:
setLog in interface LogEnabled

configure

public void configure(org.apache.commons.configuration.HierarchicalConfiguration configuration)
               throws org.apache.commons.configuration.ConfigurationException
Specified by:
configure in interface Configurable
Throws:
org.apache.commons.configuration.ConfigurationException

getLogger

protected org.apache.commons.logging.Log getLogger()

store

public void store(org.apache.mailet.Mail mc)
Specified by:
store in interface MailRepository
See Also:
MailRepository.store(Mail)

list

public java.util.Iterator<java.lang.String> list()
Specified by:
list in interface MailRepository
See Also:
MailRepository.list()

retrieve

public org.apache.mailet.Mail retrieve(java.lang.String key)
Specified by:
retrieve in interface MailRepository
See Also:
MailRepository.retrieve(String)

remove

public void remove(org.apache.mailet.Mail mail)
Specified by:
remove in interface MailRepository
See Also:
MailRepository.remove(Mail)

remove

public void remove(java.util.Collection<org.apache.mailet.Mail> mails)
Specified by:
remove in interface MailRepository
See Also:
MailRepository.remove(Collection)

remove

public void remove(java.lang.String key)
Specified by:
remove in interface MailRepository
See Also:
MailRepository.remove(String)

lock

public boolean lock(java.lang.String key)
Specified by:
lock in interface MailRepository
See Also:
MailRepository.lock(String)

unlock

public boolean unlock(java.lang.String key)
Specified by:
unlock in interface MailRepository
See Also:
MailRepository.unlock(String)


Copyright © 2002-2010 The Apache Software Foundation. All Rights Reserved.