org.apache.james.mailrepository
Class MailStoreSpoolRepository

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.james.mailrepository.MailStoreSpoolRepository
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, MailRepository, SpoolRepository

public class MailStoreSpoolRepository
extends org.apache.avalon.framework.logger.AbstractLogEnabled
implements org.apache.avalon.framework.service.Serviceable, org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.configuration.Configurable, SpoolRepository

This is a wrapper for the various implementations of SpoolRepositories. This does select the real spool repository via the select method of the provided Store.

The select method requires a configuration object with the form:
<spoolrepository destinationURL="file://path-to-root-dir-for-repository"
type="SPOOL">
</spoolrepository>

Version:
This is $Revision: 165416 $

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.james.services.SpoolRepository
SpoolRepository.AcceptFilter
 
Field Summary
 
Fields inherited from interface org.apache.james.services.SpoolRepository
ROLE, SPOOL
 
Fields inherited from interface org.apache.james.services.MailRepository
MAIL
 
Constructor Summary
MailStoreSpoolRepository()
           
 
Method Summary
 Mail accept()
          Returns an arbitrarily selected mail deposited in this Repository.
 Mail accept(long delay)
          Returns an arbitrarily select mail deposited in this Repository that is either ready immediately for delivery, or is younger than it's last_updated plus the number of failed attempts times the delay time.
 Mail accept(SpoolRepository.AcceptFilter filter)
          Returns an arbitrarily select mail deposited in this Repository for which the supplied filter's accept method returns true.
 void configure(org.apache.avalon.framework.configuration.Configuration conf)
           
 void initialize()
           
 java.util.Iterator list()
          List string keys of messages in repository.
 boolean lock(java.lang.String key)
          Obtains a lock on a message identified by key
 void remove(java.util.Collection mails)
          Remove an Collection of mails from the repository
 void remove(Mail mail)
          Removes a specified message
 void remove(java.lang.String key)
          Removes a message identified by key.
 Mail retrieve(java.lang.String key)
          Retrieves a message given a key.
 void service(org.apache.avalon.framework.service.ServiceManager serviceManager)
           
 void store(Mail mc)
          Stores a message in this repository.
 boolean unlock(java.lang.String key)
          Releases a lock on a message identified the key
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MailStoreSpoolRepository

public MailStoreSpoolRepository()
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(org.apache.avalon.framework.service.ServiceManager)

configure

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

initialize

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

accept

public Mail accept()
            throws java.lang.InterruptedException
Description copied from interface: SpoolRepository
Returns an arbitrarily selected mail deposited in this Repository. Usage: SpoolManager calls accept() to see if there are any unprocessed mails in the spool repository.

Specified by:
accept in interface SpoolRepository
Returns:
the mail
Throws:
java.lang.InterruptedException
See Also:
SpoolRepository.accept()

accept

public Mail accept(long delay)
            throws java.lang.InterruptedException
Description copied from interface: SpoolRepository
Returns an arbitrarily select mail deposited in this Repository that is either ready immediately for delivery, or is younger than it's last_updated plus the number of failed attempts times the delay time. Usage: RemoteDeliverySpool calls accept() with some delay and should block until an unprocessed mail is available.

Specified by:
accept in interface SpoolRepository
Returns:
the mail
Throws:
java.lang.InterruptedException
See Also:
SpoolRepository.accept(long)

accept

public Mail accept(SpoolRepository.AcceptFilter filter)
            throws java.lang.InterruptedException
Description copied from interface: SpoolRepository
Returns an arbitrarily select mail deposited in this Repository for which the supplied filter's accept method returns true. Usage: RemoteDeliverySpool calls accept(filter) with some a filter which determines based on number of retries if the mail is ready for processing. If no message is ready the method will block until one is, the amount of time to block is determined by calling the filters getWaitTime method.

Specified by:
accept in interface SpoolRepository
Returns:
the mail
Throws:
java.lang.InterruptedException
See Also:
SpoolRepository.accept(org.apache.james.services.SpoolRepository.AcceptFilter)

store

public void store(Mail mc)
           throws javax.mail.MessagingException
Description copied from interface: MailRepository
Stores a message in this repository. Shouldn't this return the key under which it is stored?

Specified by:
store in interface MailRepository
Parameters:
mc - the mail message to store
Throws:
javax.mail.MessagingException
See Also:
org.apache.james.services.MailRepository#store(org.apache.james.core.MailImpl)

list

public java.util.Iterator list()
                        throws javax.mail.MessagingException
Description copied from interface: MailRepository
List string keys of messages in repository.

Specified by:
list in interface MailRepository
Returns:
an Iterator over the list of keys in the repository
Throws:
javax.mail.MessagingException
See Also:
MailRepository.list()

retrieve

public Mail retrieve(java.lang.String key)
              throws javax.mail.MessagingException
Description copied from interface: MailRepository
Retrieves a message given a key. At the moment, keys can be obtained from list() in superinterface Store.Repository

Specified by:
retrieve in interface MailRepository
Parameters:
key - the key of the message to retrieve
Returns:
the mail corresponding to this key, null if none exists
Throws:
javax.mail.MessagingException
See Also:
MailRepository.retrieve(java.lang.String)

remove

public void remove(Mail mail)
            throws javax.mail.MessagingException
Description copied from interface: MailRepository
Removes a specified message

Specified by:
remove in interface MailRepository
Parameters:
mail - the message to be removed from the repository
Throws:
javax.mail.MessagingException
See Also:
org.apache.james.services.MailRepository#remove(org.apache.james.core.MailImpl)

remove

public void remove(java.util.Collection mails)
            throws javax.mail.MessagingException
Description copied from interface: MailRepository
Remove an Collection of mails from the repository

Specified by:
remove in interface MailRepository
Parameters:
mails - The Collection of MailImpl's to delete
Throws:
javax.mail.MessagingException
See Also:
MailRepository.remove(java.util.Collection)

remove

public void remove(java.lang.String key)
            throws javax.mail.MessagingException
Description copied from interface: MailRepository
Removes a message identified by key.

Specified by:
remove in interface MailRepository
Parameters:
key - the key of the message to be removed from the repository
Throws:
javax.mail.MessagingException
See Also:
MailRepository.remove(java.lang.String)

lock

public boolean lock(java.lang.String key)
             throws javax.mail.MessagingException
Description copied from interface: MailRepository
Obtains a lock on a message identified by 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
Throws:
javax.mail.MessagingException
See Also:
MailRepository.lock(java.lang.String)

unlock

public boolean unlock(java.lang.String key)
               throws javax.mail.MessagingException
Description copied from interface: MailRepository
Releases a lock on a message identified the 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
Throws:
javax.mail.MessagingException
See Also:
MailRepository.unlock(java.lang.String)


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