org.apache.james.mailrepository
Class JDBCSpoolRepository
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.james.mailrepository.JDBCMailRepository
org.apache.james.mailrepository.JDBCSpoolRepository
- All Implemented Interfaces:
- org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.context.Contextualizable, org.apache.avalon.framework.logger.LogEnabled, org.apache.avalon.framework.service.Serviceable, MailRepository, SpoolRepository
public class JDBCSpoolRepository
- extends JDBCMailRepository
- implements SpoolRepository
Implementation of a SpoolRepository on a database.
Requires a configuration element in the .conf.xml file of the form:
<repository destinationURL="town://path"
type="MAIL"
model="SYNCHRONOUS"/>
<driver>sun.jdbc.odbc.JdbcOdbcDriver</conn>
<conn>jdbc:odbc:LocalDB</conn>
<table>Message</table>
</repository>
destinationURL specifies..(Serge??)
Type can be SPOOL or MAIL
Model is currently not used and may be dropped
conn is the location of the ...(Serge)
table is the name of the table in the Database to be used
Requires a logger called MailRepository.
Approach for spool manager:
PendingMessage inner class
accept() is called....
checks whether needs to load PendingMessages()
tries to get a message()
if none, wait 60
accept(long) is called
checks whether needs to load PendingMessages
tries to get a message(long)
if none, wait accordingly
sync checkswhetherneedstoloadPendingMessages()
if pending messages has messages in immediate process, return immediately
if run query in last WAIT_LIMIT time, return immediately
query and build 2 vectors of Pending messages.
Ones that need immediate processing
Ones that are delayed. put them in time order
return
get_a_message()
loop through immediate messages.
- remove top message
- try to lock. if successful, return. otherwise loop.
if nothing, return null
get_a_message(long)
try get_a_message()
check top message in pending. if ready, then remove, try to lock, return if lock.
return null.
- Version:
- 1.0.0, 24/04/1999
Method Summary |
Mail |
accept()
Return a message to process. |
Mail |
accept(long delay)
Return a message that's ready to process. |
Mail |
accept(SpoolRepository.AcceptFilter filter)
Returns an arbitrarily selected 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 |
store(Mail mc)
Needs to override this method and reset the time to load to zero. |
Methods inherited from class org.apache.james.mailrepository.JDBCMailRepository |
checkJdbcAttributesSupport, contextualize, equals, getConnection, hashCode, initialize, list, lock, remove, remove, remove, retrieve, service, unlock |
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled |
enableLogging, getLogger, setupLogger, setupLogger, setupLogger |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
JDBCSpoolRepository
public JDBCSpoolRepository()
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
- Overrides:
configure
in class JDBCMailRepository
- Throws:
org.apache.avalon.framework.configuration.ConfigurationException
- See Also:
Configurable.configure(Configuration)
accept
public Mail accept()
throws java.lang.InterruptedException
- Return a message to process. This is a message in the spool that is not locked.
- Specified by:
accept
in interface SpoolRepository
- Returns:
- the mail
- Throws:
java.lang.InterruptedException
accept
public Mail accept(long delay)
throws java.lang.InterruptedException
- Return a message that's ready to process. If a message is of type "error"
then check the last updated time, and don't try it until the long 'delay' parameter
milliseconds has passed.
- Specified by:
accept
in interface SpoolRepository
- Returns:
- the mail
- Throws:
java.lang.InterruptedException
accept
public Mail accept(SpoolRepository.AcceptFilter filter)
throws java.lang.InterruptedException
- Returns an arbitrarily selected 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
store
public void store(Mail mc)
throws javax.mail.MessagingException
- Needs to override this method and reset the time to load to zero.
This will force a reload of the pending messages queue once that
is empty... a message that gets added will sit here until that queue
time has passed and the list is then reloaded.
- Specified by:
store
in interface MailRepository
- Overrides:
store
in class JDBCMailRepository
- Parameters:
mc
- the mail message to store
- Throws:
javax.mail.MessagingException
Copyright © 2002-2007 The Apache Software Foundation. All Rights Reserved.