org.apache.james.test.mock.james
Class InMemorySpoolRepository

java.lang.Object
  extended by org.apache.james.test.mock.james.InMemorySpoolRepository
All Implemented Interfaces:
org.apache.avalon.framework.activity.Disposable

public class InMemorySpoolRepository
extends java.lang.Object
implements org.apache.avalon.framework.activity.Disposable

Implementation of a MailRepository on a FileSystem. Requires a configuration element in the .conf.xml file of the form: <repository destinationURL="file://path-to-root-dir-for-repository" type="MAIL" model="SYNCHRONOUS"/> Requires a logger called MailRepository.

Version:
1.0.0, 24/04/1999

Field Summary
protected static boolean DEEP_DEBUG
          Whether 'deep debugging' is turned on.
 
Constructor Summary
InMemorySpoolRepository()
           
 
Method Summary
 Mail accept()
          Returns an arbitrarily selected mail deposited in this Repository.
 Mail accept(long delay)
          Returns an arbitrarily selected 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.
 void clear()
           
 void dispose()
           
 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 a key
 void remove(Mail mail)
          Removes a specified message
 Mail retrieve(java.lang.String key)
          Retrieves a message given a key.
 int size()
           
 void store(Mail mc)
          Stores a message in this repository.
 java.lang.String toString()
           
 boolean unlock(java.lang.String key)
          Releases a lock on a message identified by a key
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEEP_DEBUG

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

See Also:
Constant Field Values
Constructor Detail

InMemorySpoolRepository

public InMemorySpoolRepository()
Method Detail

unlock

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

Parameters:
key - the key of the message to be unlocked
Returns:
true if successfully released the lock, false otherwise

lock

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

Parameters:
key - the key of the message to be locked
Returns:
true if successfully obtained the lock, false otherwise

store

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

Parameters:
mc - the mail message to store
Throws:
javax.mail.MessagingException

retrieve

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

Parameters:
key - the key of the message to retrieve
Returns:
the mail corresponding to this key, null if none exists
Throws:
javax.mail.MessagingException

remove

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

Parameters:
mail - the message to be removed from the repository
Throws:
javax.mail.MessagingException

list

public java.util.Iterator list()
List string keys of messages in repository.

Returns:
an Iterator over the list of keys in the repository

accept

public Mail accept()
            throws java.lang.InterruptedException

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.

Synchronized to ensure thread safe access to the underlying spool.

Returns:
the mail
Throws:
java.lang.InterruptedException

accept

public Mail accept(long delay)
            throws java.lang.InterruptedException

Returns an arbitrarily selected 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.

Synchronized to ensure thread safe access to the underlying spool.

Returns:
the mail
Throws:
java.lang.InterruptedException

size

public int size()

clear

public void clear()

dispose

public void dispose()
Specified by:
dispose in interface org.apache.avalon.framework.activity.Disposable

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


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