org.apache.james.transport.mailets.listservcommands
Class BaseCommand

java.lang.Object
  extended by org.apache.james.transport.mailets.listservcommands.BaseCommand
All Implemented Interfaces:
IListServCommand
Direct Known Subclasses:
ErrorCommand, Info, Owner, Subscribe, SubscribeConfirm, UnSubscribe, UnSubscribeConfirm

public abstract class BaseCommand
extends java.lang.Object
implements IListServCommand

BaseCommand is a convience base class for any class that wishes to implement IListServCommand. It provides some functions like:



Since:
2.2.0
Version:
CVS $Revision: 494012 $ $Date: 2007-01-08 10:23:58 +0000 (Mon, 08 Jan 2007) $
See Also:
CommandListservManager

Field Summary
protected  ICommandListservManager commandListservManager
           
protected  java.lang.String commandName
           
protected  org.apache.avalon.framework.configuration.Configuration configuration
           
protected  MailetContext mailetContext
           
 
Constructor Summary
BaseCommand()
           
 
Method Summary
protected  javax.mail.internet.MimeMessage generateMail(java.lang.String destEmailAddr, java.lang.String destDisplayName, java.lang.String fromEmailAddr, java.lang.String fromDisplayName, java.lang.String emailSubject, java.lang.String emailPlainText)
          Send mail
protected  ICommandListservManager getCommandListservManager()
          The list serv manager
 java.lang.String getCommandName()
          The name of this command
protected  org.apache.avalon.framework.configuration.Configuration getConfiguration()
           
protected  MailetContext getMailetContext()
          The current mailet context
protected  java.util.Properties getStandardProperties()
          Use this to get standard properties for future calls to XMLResources
protected  UsersRepository getUsersRepository()
           
 void init(ICommandListservManager commandListservManager, org.apache.avalon.framework.configuration.Configuration configuration)
          Perform any required initialization
protected  XMLResources[] initXMLResources(java.lang.String[] names)
           
protected  void log(java.lang.String message)
          Writes the specified message to a mailet log file, prepended by the mailet's name.
protected  void log(java.lang.String message, java.lang.Throwable t)
          Writes an explanatory message and a stack trace for a given Throwable exception to the mailet log file, prepended by the mailet's name.
protected  void sendStandardReply(Mail origMail, java.lang.String subject, java.lang.String message, java.lang.String replyAddress)
          Produces a standard response replyAddress to the sender
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.james.transport.mailets.listservcommands.IListServCommand
onCommand
 

Field Detail

configuration

protected org.apache.avalon.framework.configuration.Configuration configuration

commandListservManager

protected ICommandListservManager commandListservManager

commandName

protected java.lang.String commandName

mailetContext

protected MailetContext mailetContext
Constructor Detail

BaseCommand

public BaseCommand()
Method Detail

init

public void init(ICommandListservManager commandListservManager,
                 org.apache.avalon.framework.configuration.Configuration configuration)
          throws org.apache.avalon.framework.configuration.ConfigurationException
Perform any required initialization

Specified by:
init in interface IListServCommand
Parameters:
configuration -
Throws:
org.apache.avalon.framework.configuration.ConfigurationException

getCommandName

public java.lang.String getCommandName()
The name of this command

Specified by:
getCommandName in interface IListServCommand
Returns:
the name of this command
See Also:
IListServCommand.getCommandName()

getConfiguration

protected org.apache.avalon.framework.configuration.Configuration getConfiguration()
See Also:
Configuration

getCommandListservManager

protected ICommandListservManager getCommandListservManager()
The list serv manager

Returns:
ICommandListservManager

getMailetContext

protected MailetContext getMailetContext()
The current mailet context

Returns:
MailetContext

getUsersRepository

protected UsersRepository getUsersRepository()
See Also:
ICommandListservManager.getUsersRepository()

log

protected void log(java.lang.String message)
Writes the specified message to a mailet log file, prepended by the mailet's name.

Parameters:
message - - a String specifying the message to be written to the log file

log

protected void log(java.lang.String message,
                   java.lang.Throwable t)
Writes an explanatory message and a stack trace for a given Throwable exception to the mailet log file, prepended by the mailet's name.

Parameters:
message - - a String that describes the error or exception
t - - the java.lang.Throwable error or exception

sendStandardReply

protected void sendStandardReply(Mail origMail,
                                 java.lang.String subject,
                                 java.lang.String message,
                                 java.lang.String replyAddress)
                          throws javax.mail.MessagingException
Produces a standard response replyAddress to the sender

Parameters:
origMail -
subject -
message -
replyAddress - an optional custom replyAddress address
Throws:
javax.mail.MessagingException
See Also:
generateMail(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String), MailetContext.sendMail(javax.mail.internet.MimeMessage)

getStandardProperties

protected java.util.Properties getStandardProperties()
Use this to get standard properties for future calls to XMLResources

Returns:
properties with the "LIST_NAME" and the "DOMAIN_NAME" properties

generateMail

protected javax.mail.internet.MimeMessage generateMail(java.lang.String destEmailAddr,
                                                       java.lang.String destDisplayName,
                                                       java.lang.String fromEmailAddr,
                                                       java.lang.String fromDisplayName,
                                                       java.lang.String emailSubject,
                                                       java.lang.String emailPlainText)
                                                throws java.lang.Exception
Send mail

Parameters:
destEmailAddr - the destination email addr: user@server.com
destDisplayName - the display name
fromEmailAddr -
fromDisplayName -
emailSubject -
emailPlainText -
Throws:
java.lang.Exception

initXMLResources

protected XMLResources[] initXMLResources(java.lang.String[] names)
                                   throws org.apache.avalon.framework.configuration.ConfigurationException
Throws:
org.apache.avalon.framework.configuration.ConfigurationException


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