|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.mailet.GenericMailet
org.apache.james.transport.mailets.CommandListservManager
CommandListservManager is the default implementation of ICommandListservManager
.
It loads all the configured IListServCommand
s and delegates to them at runtime.
It isn't responsible for procesing messages sent to the main mailing list, but is responsible for
individual commands sent by users, such as: info, subscribe, etc...
Requests sent to the CommandListservManager take the form of:
<listName>-<commandName>@domainIf the command isn't recognized an error will be sent using
onError(org.apache.mailet.Mail, java.lang.String, java.lang.String)
.
<mailet match="CommandListservMatcher=announce@localhost" class="CommandListservManager"> <listName>announce</listName> <displayName>Announce mailing list</displayName> <listOwner>owner@localhost</listOwner> <repositoryName>list-announce</repositoryName> <listDomain>localhost</listDomain> <commandpackages> <commandpackage>org.apache.james.transport.mailets.listservcommands</commandpackage> </commandpackages> <commands> <command name="subscribe" class="Subscribe"/> <command name="subscribe-confirm" class="SubscribeConfirm"/> <command name="unsubscribe" class="UnSubscribe"/> <command name="unsubscribe-confirm" class="UnSubscribeConfirm"/> <command name="error" class="ErrorCommand"/> <command name="owner" class="Owner"/> <command name="info" class="Info"/> </commands> </mailet>
<listName>-<commandName>-<optCommandParam>@domain
Field Summary | |
protected Map |
commandMap
|
protected List |
commandPackages
|
protected String |
displayName
|
protected String |
listDomain
|
protected String |
listName
|
protected String |
listOwner
|
protected UsersRepository |
usersRepository
|
protected XMLResources |
xmlResources
|
Fields inherited from interface org.apache.james.transport.mailets.ICommandListservManager |
ID |
Constructor Summary | |
CommandListservManager()
|
Method Summary | |
IListServCommand |
getCommand(String name)
Get a specific command specified by the 'commands' configuration block. |
protected String |
getCommandName(MailAddress mailAddress)
Get the name of the command |
Map |
getCommands()
Get all the available commands |
IListServCommand |
getCommandTarget(MailAddress mailAddress)
Based on the to address get a valid or command or null |
protected static Object |
getField(Object instance,
String name)
Retrieves a data field, potentially defined by a super class. |
String |
getListDomain()
Get the domain of the list specified by the config param: 'listDomain'. |
String |
getListName(boolean displayFormat)
Get the name of this list specified by the config param: 'listName'. |
String |
getListOwner()
Gets the owner of this list specified by the config param: 'listOwner'. |
String |
getResourcesFile()
|
Properties |
getStandardProperties()
Use this to get standard properties for future calls to XMLResources |
UsersRepository |
getUsersRepository()
Get the current user repository for this list serv |
void |
init()
A convenience method which can be overridden so that there's no need to call super.init(config). |
protected void |
initializeResources()
initialize the resources |
protected void |
initUsersRepository()
Fetch the repository of users |
XMLResources[] |
initXMLResources(String[] names)
Initializes an array of resources |
protected void |
loadCommand(String commandName,
String className,
org.apache.avalon.framework.configuration.Configuration configuration)
Loads and initializes a single command |
protected void |
loadCommandPackages(org.apache.avalon.framework.configuration.Configuration configuration)
loads all of the packages for the commands |
protected void |
loadCommands(org.apache.avalon.framework.configuration.Configuration configuration)
Load an initialize all of the available commands |
void |
onError(Mail mail,
String subject,
String errorMessage)
An error occurred, send some sort of message |
void |
service(Mail mail)
Called by the mailet container to allow the mailet to process a message. |
Methods inherited from class org.apache.mailet.GenericMailet |
destroy, getInitParameter, getInitParameter, getInitParameterNames, getMailetConfig, getMailetContext, getMailetInfo, getMailetName, init, log, log |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.apache.mailet.Mailet |
destroy, getMailetConfig, getMailetInfo, init |
Field Detail |
protected Map commandMap
protected List commandPackages
protected UsersRepository usersRepository
protected String listName
protected String displayName
protected String listOwner
protected String listDomain
protected XMLResources xmlResources
Constructor Detail |
public CommandListservManager()
Method Detail |
public String getListName(boolean displayFormat)
<listName>announce</listName>
getListName
in interface ICommandListservManager
displayFormat
- is whether you want a display version of this or not
public String getListOwner()
<listOwner>owner@localhost</listOwner>
getListOwner
in interface ICommandListservManager
public String getListDomain()
<listDomain>localhost</listDomain>
getListDomain
in interface ICommandListservManager
public IListServCommand getCommand(String name)
<commands> <command name="subscribe" class="Subscribe"/> <command name="subscribe-confirm" class="SubscribeConfirm"/> <command name="unsubscribe" class="UnSubscribe"/> <command name="unsubscribe-confirm" class="UnSubscribeConfirm"/> <command name="error" class="ErrorCommand"/> <command name="owner" class="Owner"/> <command name="info" class="Info"/> </commands>
getCommand
in interface ICommandListservManager
name
- case in-sensitive
IListServCommand
if found, null otherwisepublic Map getCommands()
getCommands
in interface ICommandListservManager
IListServCommand
getCommand(java.lang.String)
public UsersRepository getUsersRepository()
getUsersRepository
in interface ICommandListservManager
UsersRepository
that is used for the member list of the list servpublic void onError(Mail mail, String subject, String errorMessage) throws MessagingException
onError
in interface ICommandListservManager
subject
- the subject of the message to sendmail
- errorMessage
-
MessagingException
public String getResourcesFile()
getResourcesFile
in interface ICommandListservManager
public Properties getStandardProperties()
XMLResources
getStandardProperties
in interface ICommandListservManager
public XMLResources[] initXMLResources(String[] names) throws org.apache.avalon.framework.configuration.ConfigurationException
initXMLResources
in interface ICommandListservManager
names
- such as 'header, footer' etc...
org.apache.avalon.framework.configuration.ConfigurationException
public void init() throws MessagingException
GenericMailet
A convenience method which can be overridden so that there's no need to call super.init(config).
Instead of overriding init(MailetConfig), simply override this method and it will be called by GenericMailet.init(MailetConfig config). The MailetConfig object can still be retrieved via getMailetConfig().
init
in class GenericMailet
MessagingException
- if an exception occurs that interrupts the mailet's normal operationpublic IListServCommand getCommandTarget(MailAddress mailAddress)
getCommandTarget
in interface ICommandListservManager
mailAddress
-
public void service(Mail mail) throws MessagingException
Called by the mailet container to allow the mailet to process a message.
This method is declared abstract so subclasses must override it.
service
in interface Mailet
service
in class GenericMailet
mail
- - the Mail object that contains the MimeMessage and
routing information
MessagingException
- - if an exception occurs that interferes with the mailet's normal operation
occurredprotected String getCommandName(MailAddress mailAddress)
mailAddress
-
protected void initializeResources() throws Exception
Exception
protected void initUsersRepository()
protected void loadCommands(org.apache.avalon.framework.configuration.Configuration configuration) throws Exception
configuration
-
org.apache.avalon.framework.configuration.ConfigurationException
Exception
protected void loadCommand(String commandName, String className, org.apache.avalon.framework.configuration.Configuration configuration) throws org.apache.avalon.framework.configuration.ConfigurationException, ClassNotFoundException, IllegalAccessException, InstantiationException
commandName
- className
- configuration
-
org.apache.avalon.framework.configuration.ConfigurationException
ClassNotFoundException
IllegalAccessException
InstantiationException
protected void loadCommandPackages(org.apache.avalon.framework.configuration.Configuration configuration) throws org.apache.avalon.framework.configuration.ConfigurationException
configuration
-
org.apache.avalon.framework.configuration.ConfigurationException
protected static Object getField(Object instance, String name) throws IllegalAccessException
IllegalAccessException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |