org.apache.james.mailrepository.javamail
Class AbstractJavamailStoreMailRepository

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.james.mailrepository.javamail.AbstractJavamailStoreMailRepository
All Implemented Interfaces:
org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.logger.LogEnabled, org.apache.avalon.framework.service.Serviceable, FolderAdapterFactory, StoreGateKeeperAware, MailRepository
Direct Known Subclasses:
HashJavamailStoreMailRepository, UIDPlusFolderMailRepository

public abstract class AbstractJavamailStoreMailRepository
extends org.apache.avalon.framework.logger.AbstractLogEnabled
implements MailRepository, StoreGateKeeperAware, FolderAdapterFactory, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.service.Serviceable

MailRepository implementation to store mail in a Javamail store This implementation should be considered as EXPERIMENTAL.

TODO examine for thread-safety


Field Summary
protected  boolean cacheMessages
          this has not been tested yet, so it is not configurable.
protected static boolean DEEP_DEBUG
          Whether 'deep debugging' is turned on.
protected  org.apache.avalon.framework.logger.Logger log
           
 
Fields inherited from interface org.apache.james.services.MailRepository
MAIL, ROLE
 
Constructor Summary
AbstractJavamailStoreMailRepository()
           
 
Method Summary
 void configure(org.apache.avalon.framework.configuration.Configuration conf)
          builds destination from attributes destinationURL and postfix.
 void enableLogging(org.apache.avalon.framework.logger.Logger log)
          Set the Logger to use
protected  FolderGateKeeper getFolderGateKeeper()
          Lazy-load FolderGateKeeper with inbox folder.
protected  LockInterface getLock()
          gets the Lock and creates it, if not present.
protected static java.util.Random getRandom()
          lazy-loads random
 StoreGateKeeper getStore()
          offers the underlaying Store for external use
 void initialize()
          Does nothing
 boolean lock(java.lang.String key)
          Obtains a lock on a message identified by a key
 void remove(java.util.Collection mails)
          Remove a list of messages from disk The collection is simply a list of mails to delete
 void remove(org.apache.mailet.Mail mail)
          Removes a specified message
 void service(org.apache.avalon.framework.service.ServiceManager serviceManager)
           
 boolean unlock(java.lang.String key)
          Releases a lock on a message identified by a key
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.james.services.MailRepository
list, remove, retrieve, store
 
Methods inherited from interface org.apache.james.mailrepository.javamail.FolderAdapterFactory
createAdapter
 

Field Detail

DEEP_DEBUG

protected static final boolean DEEP_DEBUG
Whether 'deep debugging' is turned on.

See Also:
Constant Field Values

log

protected org.apache.avalon.framework.logger.Logger log

cacheMessages

protected boolean cacheMessages
this has not been tested yet, so it is not configurable. But it is likely that there would be memory leaks

Constructor Detail

AbstractJavamailStoreMailRepository

public AbstractJavamailStoreMailRepository()
Method Detail

service

public void service(org.apache.avalon.framework.service.ServiceManager serviceManager)
             throws org.apache.avalon.framework.service.ServiceException
Specified by:
service in interface org.apache.avalon.framework.service.Serviceable
Throws:
org.apache.avalon.framework.service.ServiceException
See Also:
Serviceable.service(ServiceManager)

configure

public void configure(org.apache.avalon.framework.configuration.Configuration conf)
               throws org.apache.avalon.framework.configuration.ConfigurationException
builds destination from attributes destinationURL and postfix. at the moment james does not hand over additional parameters like postfix.

Specified by:
configure in interface org.apache.avalon.framework.configuration.Configurable
Throws:
org.apache.avalon.framework.configuration.ConfigurationException
See Also:
Configurable.configure(Configuration)

initialize

public void initialize()
                throws java.lang.Exception
Does nothing

Specified by:
initialize in interface org.apache.avalon.framework.activity.Initializable
Throws:
java.lang.Exception
See Also:
Initializable.initialize()

getLock

protected LockInterface getLock()
gets the Lock and creates it, if not present. LockInterface offers functionality of org.apache.james.util.Lock

Returns:
lock the LockInterface

lock

public boolean lock(java.lang.String key)
Obtains a lock on a message identified by a key

Specified by:
lock in interface MailRepository
Parameters:
key - the key of the message to be locked
Returns:
true if successfully obtained the lock, false otherwise

unlock

public boolean unlock(java.lang.String key)
Releases a lock on a message identified by a key

Specified by:
unlock in interface MailRepository
Parameters:
key - the key of the message to be unlocked
Returns:
true if successfully released the lock, false otherwise

remove

public void remove(org.apache.mailet.Mail mail)
            throws javax.mail.MessagingException
Removes a specified message

Specified by:
remove in interface MailRepository
Parameters:
mail - the message to be removed from the repository
Throws:
javax.mail.MessagingException

remove

public void remove(java.util.Collection mails)
            throws javax.mail.MessagingException
Remove a list of messages from disk The collection is simply a list of mails to delete

Specified by:
remove in interface MailRepository
Parameters:
mails -
Throws:
javax.mail.MessagingException

getStore

public StoreGateKeeper getStore()
offers the underlaying Store for external use

Specified by:
getStore in interface StoreGateKeeperAware
Returns:
the Store

getRandom

protected static java.util.Random getRandom()
lazy-loads random

Returns:
random an instance of random

enableLogging

public void enableLogging(org.apache.avalon.framework.logger.Logger log)
Set the Logger to use

Specified by:
enableLogging in interface org.apache.avalon.framework.logger.LogEnabled
Overrides:
enableLogging in class org.apache.avalon.framework.logger.AbstractLogEnabled
See Also:
AbstractLogEnabled.enableLogging(Logger)

getFolderGateKeeper

protected FolderGateKeeper getFolderGateKeeper()
Lazy-load FolderGateKeeper with inbox folder. Inbox folder is created if not present

Returns:
FolderGateKeeper offering inbox folder for this mail repository


Copyright ? 2002-2009 The Apache Software Foundation. All Rights Reserved.