org.apache.james.transport.mailets
Class JDBCListserv

java.lang.Object
  extended by org.apache.mailet.GenericMailet
      extended by org.apache.james.transport.mailets.GenericListserv
          extended by org.apache.james.transport.mailets.JDBCListserv
All Implemented Interfaces:
Mailet, MailetConfig

public class JDBCListserv
extends GenericListserv

Rewrites recipient addresses based on a database table. The connection is configured by passing the URL to a conn definition. You need to set the table name to check (or view) along with the source and target columns to use. For example, <mailet match="All" class="JDBCListserv"> <data_source>maildb</datasource> <listserv_id>mylistserv</listserv_id> <listserv_table>source_email_address</listserv_table> <members_table>target_email_address</members_table> </mailet> This mailet will cache the settings available when first initialized. If you wish it to reload for each message, add the init parameter <cache_settings>false</cache_settings>


Field Summary
protected  boolean attachmentsAllowed
           
protected  boolean cacheSettings
           
protected  org.apache.avalon.excalibur.datasource.DataSourceComponent datasource
           
protected  MailAddress listservAddress
           
protected  java.lang.String listservID
           
protected  java.lang.String listservQuery
           
protected  java.lang.String listservTable
           
protected  java.util.Collection members
           
protected  boolean membersOnly
           
protected  java.lang.String membersQuery
           
protected  java.lang.String membersTable
           
protected  boolean replyToList
           
protected  java.lang.String subjectPrefix
           
 
Constructor Summary
JDBCListserv()
           
 
Method Summary
 MailAddress getListservAddress()
          The email address that this listserv processes on.
 java.lang.String getMailetInfo()
          Return a string describing this mailet.
 java.util.Collection getMembers()
          Returns a Collection of MailAddress objects of members to receive this email
 java.lang.String getSubjectPrefix()
          An optional subject prefix which will be surrounded by [].
 void init()
          Initialize the mailet
 boolean isAttachmentsAllowed()
          Returns whether this listserv allow attachments
 boolean isMembersOnly()
          Returns whether this list should restrict to senders only
 boolean isReplyToList()
          Returns whether listserv should add reply-to header
protected  void loadSettings()
          Loads the configuration settings for this mailet from the database.
 
Methods inherited from class org.apache.james.transport.mailets.GenericListserv
isPrefixAutoBracketed, service
 
Methods inherited from class org.apache.mailet.GenericMailet
destroy, getInitParameter, getInitParameter, getInitParameterNames, getMailetConfig, getMailetContext, getMailetName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

datasource

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

listservID

protected java.lang.String listservID

listservTable

protected java.lang.String listservTable

membersTable

protected java.lang.String membersTable

cacheSettings

protected boolean cacheSettings

members

protected java.util.Collection members

membersOnly

protected boolean membersOnly

attachmentsAllowed

protected boolean attachmentsAllowed

replyToList

protected boolean replyToList

listservAddress

protected MailAddress listservAddress

subjectPrefix

protected java.lang.String subjectPrefix

listservQuery

protected java.lang.String listservQuery

membersQuery

protected java.lang.String membersQuery
Constructor Detail

JDBCListserv

public JDBCListserv()
Method Detail

init

public void init()
          throws javax.mail.MessagingException
Initialize the mailet

Overrides:
init in class GenericMailet
Throws:
javax.mail.MessagingException - if an exception occurs that interrupts the mailet's normal operation

getMembers

public java.util.Collection getMembers()
                                throws javax.mail.MessagingException
Returns a Collection of MailAddress objects of members to receive this email

Specified by:
getMembers in class GenericListserv
Throws:
javax.mail.MessagingException

isMembersOnly

public boolean isMembersOnly()
                      throws javax.mail.MessagingException
Returns whether this list should restrict to senders only

Specified by:
isMembersOnly in class GenericListserv
Throws:
javax.mail.MessagingException

isAttachmentsAllowed

public boolean isAttachmentsAllowed()
                             throws javax.mail.MessagingException
Returns whether this listserv allow attachments

Specified by:
isAttachmentsAllowed in class GenericListserv
Throws:
javax.mail.MessagingException

isReplyToList

public boolean isReplyToList()
                      throws javax.mail.MessagingException
Returns whether listserv should add reply-to header

Specified by:
isReplyToList in class GenericListserv
Returns:
whether listserv should add a reply-to header
Throws:
javax.mail.MessagingException

getListservAddress

public MailAddress getListservAddress()
                               throws javax.mail.MessagingException
The email address that this listserv processes on. If returns null, will use the recipient of the message, which hopefully will be the correct email address assuming the matcher was properly specified.

Overrides:
getListservAddress in class GenericListserv
Throws:
javax.mail.MessagingException

getSubjectPrefix

public java.lang.String getSubjectPrefix()
                                  throws javax.mail.MessagingException
An optional subject prefix which will be surrounded by [].

Specified by:
getSubjectPrefix in class GenericListserv
Throws:
javax.mail.MessagingException

loadSettings

protected void loadSettings()
                     throws javax.mail.MessagingException
Loads the configuration settings for this mailet from the database.

Throws:
javax.mail.MessagingException - if a problem occurs while accessing the database or the required parameters are not present

getMailetInfo

public java.lang.String getMailetInfo()
Return a string describing this mailet.

Specified by:
getMailetInfo in interface Mailet
Overrides:
getMailetInfo in class GenericMailet
Returns:
a string describing this mailet


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