View Javadoc

1   /************************************************************************
2    * Copyright (c) 2000-2006 The Apache Software Foundation.             *
3    * All rights reserved.                                                *
4    * ------------------------------------------------------------------- *
5    * Licensed under the Apache License, Version 2.0 (the "License"); you *
6    * may not use this file except in compliance with the License. You    *
7    * may obtain a copy of the License at:                                *
8    *                                                                     *
9    *     http://www.apache.org/licenses/LICENSE-2.0                      *
10   *                                                                     *
11   * Unless required by applicable law or agreed to in writing, software *
12   * distributed under the License is distributed on an "AS IS" BASIS,   *
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or     *
14   * implied.  See the License for the specific language governing       *
15   * permissions and limitations under the License.                      *
16   ***********************************************************************/
17  
18  package org.apache.james.transport.mailets.listservcommands;
19  
20  import org.apache.avalon.framework.configuration.Configuration;
21  import org.apache.avalon.framework.configuration.ConfigurationException;
22  import org.apache.james.transport.mailets.ICommandListservManager;
23  import org.apache.mailet.Mail;
24  
25  import javax.mail.MessagingException;
26  
27  /***
28   * IListServCommand is the interface that all pluggable list serv commands must implement.
29   * The lifecycle of a IListServCommand will be controlled by the {@link ICommandListservManager}
30   *
31   * <br />
32   * <br />
33   * Requests sent to the CommandListservManager take the form of:
34   * <pre>
35   * &lt;listName&gt;-&lt;commandName&gt;@domain
36   * </pre>
37   * and if the commandName matches the command's name, then the {@link #onCommand} will be invoked.
38   *
39   * <br />
40   * <br />
41   * A typical command is configured:
42   * <pre>
43   * &lt;command name="subscribe" class="Subscribe"/&gt;
44   * </pre>
45   *
46   * <br />
47   * <br />
48   * Typically, IListServCommands will format some text to reply with based off of resource files
49   * and calls to {@link org.apache.james.util.XMLResources#getString}
50   *
51   * This allows you to customize the messages sent by these commands by editing text files and not editing the javacode.
52   *
53   * @version CVS $Revision: 365582 $ $Date: 2006-01-03 08:51:21 +0000 (mar, 03 gen 2006) $
54   * @since 2.2.0
55   * @see ICommandListservManager
56   */
57  public interface IListServCommand {
58  
59      /***
60       * The name of this command
61       * specified by the 'name' parameter.
62       * eg:
63       * <pre>
64       * &lt;command name="subscribe" class="Subscribe"/&gt;
65       * </pre>
66       * @return the name of this command
67       */
68      public String getCommandName();
69  
70      /***
71       * Perform any required initialization
72       * @param configuration
73       * @throws ConfigurationException
74       */
75      public void init(ICommandListservManager commandListservManager, Configuration configuration) throws ConfigurationException;
76  
77      /***
78       * Process this command to your hearts content
79       * @param mail
80       * @throws MessagingException
81       */
82      public void onCommand(Mail mail) throws MessagingException;
83  }