org.apache.james.mailrepository
Class JDBCMailRepository

java.lang.Object
  |
  +--org.apache.avalon.framework.logger.AbstractLoggable
        |
        +--org.apache.james.mailrepository.JDBCMailRepository
All Implemented Interfaces:
org.apache.avalon.framework.component.Component, org.apache.avalon.framework.component.Composable, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.context.Contextualizable, org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.logger.Loggable, MailRepository
Direct Known Subclasses:
JDBCSpoolRepository

public class JDBCMailRepository
extends org.apache.avalon.framework.logger.AbstractLoggable
implements MailRepository, org.apache.avalon.framework.component.Component, org.apache.avalon.framework.context.Contextualizable, org.apache.avalon.framework.component.Composable, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.activity.Initializable

Implementation of a MailRepository on a database.

Requires a configuration element in the .conf.xml file of the form:
type="MAIL"
model="SYNCHRONOUS"/>

destinationURL specifies..(Serge??)
Type can be SPOOL or MAIL
Model is currently not used and may be dropped

Requires a logger called MailRepository.

Version:
1.0.0, 24/04/1999
Author:
Serge Knystautas , Darrell DeBoer

Field Summary
protected  org.apache.avalon.framework.context.Context context
           
protected  org.apache.avalon.excalibur.datasource.DataSourceComponent datasource
           
protected  java.lang.String datasourceName
           
protected  org.apache.avalon.cornerstone.services.datasource.DataSourceSelector datasources
           
protected  java.lang.String destination
           
protected  java.lang.String filestore
           
protected  java.lang.String repositoryName
           
protected  java.lang.String sqlFileName
           
protected  SqlResources sqlQueries
           
protected  java.lang.String tableName
           
 
Fields inherited from interface org.apache.james.services.MailRepository
MAIL
 
Constructor Summary
JDBCMailRepository()
           
 
Method Summary
 void compose(org.apache.avalon.framework.component.ComponentManager componentManager)
           
 void configure(org.apache.avalon.framework.configuration.Configuration conf)
           
 void contextualize(org.apache.avalon.framework.context.Context context)
           
 boolean equals(java.lang.Object obj)
           
protected  java.sql.Connection getConnection()
           
 void initialize()
          Initialises the JDBC repository.
 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(MailImpl mail)
          Removes a specified message
 void remove(java.lang.String key)
          Removes a message identified by key.
 MailImpl retrieve(java.lang.String key)
          Retrieves a message given a key.
 void store(MailImpl 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.AbstractLoggable
getLogger, setLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

context

protected org.apache.avalon.framework.context.Context context

destination

protected java.lang.String destination

tableName

protected java.lang.String tableName

repositoryName

protected java.lang.String repositoryName

filestore

protected java.lang.String filestore

sqlFileName

protected java.lang.String sqlFileName

datasources

protected org.apache.avalon.cornerstone.services.datasource.DataSourceSelector datasources

datasource

protected org.apache.avalon.excalibur.datasource.DataSourceComponent datasource

datasourceName

protected java.lang.String datasourceName

sqlQueries

protected SqlResources sqlQueries
Constructor Detail

JDBCMailRepository

public JDBCMailRepository()
Method Detail

contextualize

public void contextualize(org.apache.avalon.framework.context.Context context)
                   throws org.apache.avalon.framework.context.ContextException
Specified by:
contextualize in interface org.apache.avalon.framework.context.Contextualizable

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

compose

public void compose(org.apache.avalon.framework.component.ComponentManager componentManager)
             throws org.apache.avalon.framework.component.ComponentException
Specified by:
compose in interface org.apache.avalon.framework.component.Composable

initialize

public void initialize()
                throws java.lang.Exception
Initialises the JDBC repository. 1) Tests the connection to the database. 2) Loads SQL strings from the SQL definition file, choosing the appropriate SQL for this connection, and performing paramter substitution, 3) Initialises the database with the required tables, if necessary.
Specified by:
initialize in interface org.apache.avalon.framework.activity.Initializable

unlock

public boolean unlock(java.lang.String key)
Description copied from interface: MailRepository
Releases a lock on a message identified the key
Specified by:
unlock in interface MailRepository

lock

public boolean lock(java.lang.String key)
Description copied from interface: MailRepository
Obtains a lock on a message identified by key
Specified by:
lock in interface MailRepository

store

public void store(MailImpl mc)
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

retrieve

public MailImpl retrieve(java.lang.String key)
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

remove

public void remove(MailImpl mail)
Description copied from interface: MailRepository
Removes a specified message
Specified by:
remove in interface MailRepository

remove

public void remove(java.lang.String key)
Description copied from interface: MailRepository
Removes a message identified by key.
Specified by:
remove in interface MailRepository

list

public java.util.Iterator list()
Description copied from interface: MailRepository
List string keys of messages in repository.
Specified by:
list in interface MailRepository

getConnection

protected java.sql.Connection getConnection()
                                     throws java.sql.SQLException

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object


"Copyright © 2001 Apache Jakarta Project. All Rights Reserved."