org.apache.james.mailrepository
Class JDBCSpoolRepository
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.james.mailrepository.AbstractMailRepository
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.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 |
org.apache.mailet.Mail |
accept()
Returns an arbitrarily selected mail deposited in this Repository. |
org.apache.mailet.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. |
org.apache.mailet.Mail |
accept(SpoolRepository.AcceptFilter filter)
/** |
void |
configure(org.apache.avalon.framework.configuration.Configuration conf)
|
void |
store(org.apache.mailet.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, equals, getConnection, hashCode, initialize, internalRemove, internalStore, list, retrieve, service, setDatasources |
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 org.apache.mailet.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 org.apache.mailet.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 org.apache.mailet.Mail accept(SpoolRepository.AcceptFilter filter)
throws java.lang.InterruptedException
- /**
- 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(org.apache.mailet.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 AbstractMailRepository
- Parameters:
mc
- the mail message to store
- Throws:
javax.mail.MessagingException
- See Also:
AbstractMailRepository.store(Mail)
Copyright ? 2002-2009 The Apache Software Foundation. All Rights Reserved.